aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Wailes <chriswailes@google.com>2014-08-12 15:58:29 -0700
committerStephen Hines <srhines@google.com>2014-08-20 18:30:52 -0700
commit5abbe0e9ca2508260b627ffef2bf01e2554e8357 (patch)
treeda74b15f300a17c6e24d5737b32d77458127f5ac
parentc916badea65dab0f37d5099bafb0e84a7758f96a (diff)
downloadandroid_frameworks_compile_slang-5abbe0e9ca2508260b627ffef2bf01e2554e8357.tar.gz
android_frameworks_compile_slang-5abbe0e9ca2508260b627ffef2bf01e2554e8357.tar.bz2
android_frameworks_compile_slang-5abbe0e9ca2508260b627ffef2bf01e2554e8357.zip
Replace the NULL macro with nullptr literal.
Change-Id: I33609969cd0d7aa55eaa83fb2c65f5faa6d55fa0
-rw-r--r--Android.mk3
-rw-r--r--slang.cpp24
-rw-r--r--slang_backend.cpp14
-rw-r--r--slang_rs.cpp4
-rw-r--r--slang_rs_ast_replace.h10
-rw-r--r--slang_rs_backend.cpp29
-rw-r--r--slang_rs_check_ast.cpp2
-rw-r--r--slang_rs_context.cpp24
-rw-r--r--slang_rs_context.h2
-rw-r--r--slang_rs_export_element.cpp16
-rw-r--r--slang_rs_export_foreach.cpp36
-rw-r--r--slang_rs_export_foreach.h14
-rw-r--r--slang_rs_export_func.cpp16
-rw-r--r--slang_rs_export_func.h8
-rw-r--r--slang_rs_export_type.cpp225
-rw-r--r--slang_rs_export_type.h20
-rw-r--r--slang_rs_export_var.cpp2
-rw-r--r--slang_rs_exportable.cpp4
-rw-r--r--slang_rs_exportable.h2
-rw-r--r--slang_rs_object_ref_count.cpp90
-rw-r--r--slang_rs_object_ref_count.h4
-rw-r--r--slang_rs_reflect_utils.cpp6
-rw-r--r--slang_rs_reflect_utils.h2
-rw-r--r--slang_rs_reflection.cpp32
-rw-r--r--slang_rs_reflection.h2
-rw-r--r--slang_rs_reflection_cpp.cpp12
26 files changed, 303 insertions, 300 deletions
diff --git a/Android.mk b/Android.mk
index 8502647..d7aa1c6 100644
--- a/Android.mk
+++ b/Android.mk
@@ -19,7 +19,8 @@ ifeq ($(TARGET_BUILD_APPS),)
LOCAL_PATH := $(call my-dir)
-local_cflags_for_slang := -Wno-sign-promo -Wall -Wno-unused-parameter -Wno-return-type -Werror
+local_cflags_for_slang := -Wno-sign-promo -Wall -Wno-unused-parameter \
+ -Wno-return-type -Werror -std=c++11
ifeq ($(TARGET_BUILD_VARIANT),eng)
local_cflags_for_slang += -O0
else
diff --git a/slang.cpp b/slang.cpp
index 7810695..c6dfe82 100644
--- a/slang.cpp
+++ b/slang.cpp
@@ -85,8 +85,8 @@ struct ForceSlangLinking {
return;
// llvm-rs-link needs following functions existing in libslang.
- llvm::parseBitcodeFile(NULL, llvm::getGlobalContext());
- llvm::Linker::LinkModules(NULL, NULL, 0, NULL);
+ llvm::parseBitcodeFile(nullptr, llvm::getGlobalContext());
+ llvm::Linker::LinkModules(nullptr, nullptr, 0, nullptr);
// llvm-rs-cc need this.
new clang::TextDiagnosticPrinter(llvm::errs(),
@@ -115,14 +115,14 @@ OpenOutputFile(const char *OutputFile,
llvm::sys::fs::OpenFlags Flags,
std::string* Error,
clang::DiagnosticsEngine *DiagEngine) {
- slangAssert((OutputFile != NULL) && (Error != NULL) &&
- (DiagEngine != NULL) && "Invalid parameter!");
+ slangAssert((OutputFile != nullptr) && (Error != nullptr) &&
+ (DiagEngine != nullptr) && "Invalid parameter!");
if (SlangUtils::CreateDirectoryWithParents(
llvm::sys::path::parent_path(OutputFile), Error)) {
llvm::tool_output_file *F =
new llvm::tool_output_file(OutputFile, *Error, Flags);
- if (F != NULL)
+ if (F != nullptr)
return F;
}
@@ -130,7 +130,7 @@ OpenOutputFile(const char *OutputFile,
DiagEngine->Report(clang::diag::err_fe_error_opening)
<< OutputFile << *Error;
- return NULL;
+ return nullptr;
}
void Slang::GlobalInitialization() {
@@ -213,7 +213,7 @@ void Slang::createPreprocessor() {
*mSourceMgr,
*HeaderInfo,
*this,
- NULL,
+ nullptr,
/* OwnsHeaderSearch = */true));
// Initialize the preprocessor
mPP->Initialize(getTargetInfo());
@@ -258,7 +258,7 @@ Slang::createBackend(const clang::CodeGenOptions& CodeGenOpts,
&mPragmas, OS, OT);
}
-Slang::Slang() : mInitialized(false), mDiagClient(NULL),
+Slang::Slang() : mInitialized(false), mDiagClient(nullptr),
mTargetOpts(new clang::TargetOptions()), mOT(OT_Default) {
GlobalInitialization();
}
@@ -331,7 +331,7 @@ bool Slang::setInputSource(llvm::StringRef InputFile) {
bool Slang::setOutput(const char *OutputFile) {
std::string Error;
- llvm::tool_output_file *OS = NULL;
+ llvm::tool_output_file *OS = nullptr;
switch (mOT) {
case OT_Dependency:
@@ -370,7 +370,7 @@ bool Slang::setDepOutput(const char *OutputFile) {
mDOS.reset(
OpenOutputFile(OutputFile, llvm::sys::fs::F_Text, &Error, mDiagEngine));
- if (!Error.empty() || (mDOS.get() == NULL))
+ if (!Error.empty() || (mDOS.get() == nullptr))
return false;
mDepOutputFileName = OutputFile;
@@ -381,7 +381,7 @@ bool Slang::setDepOutput(const char *OutputFile) {
int Slang::generateDepFile() {
if (mDiagEngine->hasErrorOccurred())
return 1;
- if (mDOS.get() == NULL)
+ if (mDOS.get() == nullptr)
return 1;
// Initialize options for generating dependency file
@@ -428,7 +428,7 @@ int Slang::generateDepFile() {
int Slang::compile() {
if (mDiagEngine->hasErrorOccurred())
return 1;
- if (mOS.get() == NULL)
+ if (mOS.get() == nullptr)
return 1;
// Here is per-compilation needed initialization
diff --git a/slang_backend.cpp b/slang_backend.cpp
index 43d843e..8780a77 100644
--- a/slang_backend.cpp
+++ b/slang_backend.cpp
@@ -117,7 +117,7 @@ bool Backend::CreateCodeGenPasses() {
std::string Error;
const llvm::Target* TargetInfo =
llvm::TargetRegistry::lookupTarget(Triple, Error);
- if (TargetInfo == NULL) {
+ if (TargetInfo == nullptr) {
mDiagEngine.Report(clang::diag::err_fe_unable_to_create_target) << Error;
return false;
}
@@ -209,13 +209,13 @@ Backend::Backend(clang::DiagnosticsEngine *DiagEngine,
Slang::OutputType OT)
: ASTConsumer(),
mTargetOpts(TargetOpts),
- mpModule(NULL),
+ mpModule(nullptr),
mpOS(OS),
mOT(OT),
- mGen(NULL),
- mPerFunctionPasses(NULL),
- mPerModulePasses(NULL),
- mCodeGenPasses(NULL),
+ mGen(nullptr),
+ mPerFunctionPasses(nullptr),
+ mPerModulePasses(nullptr),
+ mCodeGenPasses(nullptr),
mLLVMContext(llvm::getGlobalContext()),
mDiagEngine(*DiagEngine),
mCodeGenOpts(CodeGenOpts),
@@ -268,7 +268,7 @@ void Backend::HandleTranslationUnit(clang::ASTContext &Ctx) {
llvm::Module *M = mGen->ReleaseModule();
if (!M) {
// The module has been released by IR gen on failures, do not double free.
- mpModule = NULL;
+ mpModule = nullptr;
return;
}
diff --git a/slang_rs.cpp b/slang_rs.cpp
index 6bb5798..ec241a8 100644
--- a/slang_rs.cpp
+++ b/slang_rs.cpp
@@ -266,7 +266,7 @@ bool SlangRS::IsLocInRSHeaderFile(const clang::SourceLocation &Loc,
}
SlangRS::SlangRS()
- : Slang(), mRSContext(NULL), mAllowRSPrefix(false), mTargetAPI(0),
+ : Slang(), mRSContext(nullptr), mAllowRSPrefix(false), mTargetAPI(0),
mVerbose(false), mIsFilterscript(false) {
}
@@ -435,7 +435,7 @@ bool SlangRS::compile(
void SlangRS::reset() {
delete mRSContext;
- mRSContext = NULL;
+ mRSContext = nullptr;
mGeneratedFileNames.clear();
Slang::reset();
}
diff --git a/slang_rs_ast_replace.h b/slang_rs_ast_replace.h
index 0507603..f93171d 100644
--- a/slang_rs_ast_replace.h
+++ b/slang_rs_ast_replace.h
@@ -58,11 +58,11 @@ class RSASTReplace : public clang::StmtVisitor<RSASTReplace> {
public:
explicit RSASTReplace(clang::ASTContext &Con)
: C(Con),
- mOuterStmt(NULL),
- mOldStmt(NULL),
- mNewStmt(NULL),
- mOldExpr(NULL),
- mNewExpr(NULL) {
+ mOuterStmt(nullptr),
+ mOldStmt(nullptr),
+ mNewStmt(nullptr),
+ mOldExpr(nullptr),
+ mNewExpr(nullptr) {
}
void VisitStmt(clang::Stmt *S);
diff --git a/slang_rs_backend.cpp b/slang_rs_backend.cpp
index 1e9bb05..565c5a9 100644
--- a/slang_rs_backend.cpp
+++ b/slang_rs_backend.cpp
@@ -61,12 +61,12 @@ RSBackend::RSBackend(RSContext *Context,
mSourceMgr(SourceMgr),
mAllowRSPrefix(AllowRSPrefix),
mIsFilterscript(IsFilterscript),
- mExportVarMetadata(NULL),
- mExportFuncMetadata(NULL),
- mExportForEachNameMetadata(NULL),
- mExportForEachSignatureMetadata(NULL),
- mExportTypeMetadata(NULL),
- mRSObjectSlotsMetadata(NULL),
+ mExportVarMetadata(nullptr),
+ mExportFuncMetadata(nullptr),
+ mExportForEachNameMetadata(nullptr),
+ mExportForEachSignatureMetadata(nullptr),
+ mExportTypeMetadata(nullptr),
+ mRSObjectSlotsMetadata(nullptr),
mRefCount(mContext->getASTContext()),
mASTChecker(Context, Context->getTargetAPI(), IsFilterscript) {
}
@@ -88,7 +88,7 @@ bool RSBackend::HandleTopLevelDecl(clang::DeclGroupRef D) {
for (clang::DeclGroupRef::iterator I = D.begin(), E = D.end();
I != E; I++) {
clang::FunctionDecl *FD = llvm::dyn_cast<clang::FunctionDecl>(*I);
- if (FD == NULL)
+ if (FD == nullptr)
continue;
if (!FD->getName().startswith("rs")) // Check prefix
continue;
@@ -182,7 +182,7 @@ void RSBackend::HandleTranslationUnitPre(clang::ASTContext &C) {
///////////////////////////////////////////////////////////////////////////////
void RSBackend::dumpExportVarInfo(llvm::Module *M) {
int slotCount = 0;
- if (mExportVarMetadata == NULL)
+ if (mExportVarMetadata == nullptr)
mExportVarMetadata = M->getOrInsertNamedMetadata(RS_EXPORT_VAR_MN);
llvm::SmallVector<llvm::Value*, 2> ExportVarInfo;
@@ -251,7 +251,7 @@ void RSBackend::dumpExportVarInfo(llvm::Module *M) {
llvm::MDNode::get(mLLVMContext, ExportVarInfo));
ExportVarInfo.clear();
- if (mRSObjectSlotsMetadata == NULL) {
+ if (mRSObjectSlotsMetadata == nullptr) {
mRSObjectSlotsMetadata =
M->getOrInsertNamedMetadata(RS_OBJECT_SLOTS_MN);
}
@@ -266,7 +266,7 @@ void RSBackend::dumpExportVarInfo(llvm::Module *M) {
}
void RSBackend::dumpExportFunctionInfo(llvm::Module *M) {
- if (mExportFuncMetadata == NULL)
+ if (mExportFuncMetadata == nullptr)
mExportFuncMetadata =
M->getOrInsertNamedMetadata(RS_EXPORT_FUNC_MN);
@@ -292,8 +292,9 @@ void RSBackend::dumpExportFunctionInfo(llvm::Module *M) {
// Create helper function
{
- llvm::StructType *HelperFunctionParameterTy = NULL;
+ llvm::StructType *HelperFunctionParameterTy = nullptr;
std::vector<bool> isStructInput;
+
if (!F->getArgumentList().empty()) {
std::vector<llvm::Type*> HelperFunctionParameterTys;
for (llvm::Function::arg_iterator AI = F->arg_begin(),
@@ -405,11 +406,11 @@ void RSBackend::dumpExportFunctionInfo(llvm::Module *M) {
}
void RSBackend::dumpExportForEachInfo(llvm::Module *M) {
- if (mExportForEachNameMetadata == NULL) {
+ if (mExportForEachNameMetadata == nullptr) {
mExportForEachNameMetadata =
M->getOrInsertNamedMetadata(RS_EXPORT_FOREACH_NAME_MN);
}
- if (mExportForEachSignatureMetadata == NULL) {
+ if (mExportForEachSignatureMetadata == nullptr) {
mExportForEachSignatureMetadata =
M->getOrInsertNamedMetadata(RS_EXPORT_FOREACH_MN);
}
@@ -461,7 +462,7 @@ void RSBackend::dumpExportTypeInfo(llvm::Module *M) {
const RSExportRecordType *ERT =
static_cast<const RSExportRecordType*>(ET);
- if (mExportTypeMetadata == NULL)
+ if (mExportTypeMetadata == nullptr)
mExportTypeMetadata =
M->getOrInsertNamedMetadata(RS_EXPORT_TYPE_MN);
diff --git a/slang_rs_check_ast.cpp b/slang_rs_check_ast.cpp
index b5cb024..848a176 100644
--- a/slang_rs_check_ast.cpp
+++ b/slang_rs_check_ast.cpp
@@ -260,7 +260,7 @@ void RSCheckAST::VisitExpr(clang::Expr *E) {
E = E->IgnoreImpCasts();
if (mIsFilterscript &&
!SlangRS::IsLocInRSHeaderFile(E->getExprLoc(), mSM) &&
- !RSExportType::ValidateType(Context, C, E->getType(), NULL, E->getExprLoc(),
+ !RSExportType::ValidateType(Context, C, E->getType(), nullptr, E->getExprLoc(),
mTargetAPI, mIsFilterscript)) {
mValid = false;
} else {
diff --git a/slang_rs_context.cpp b/slang_rs_context.cpp
index bef4766..608d6cb 100644
--- a/slang_rs_context.cpp
+++ b/slang_rs_context.cpp
@@ -53,9 +53,9 @@ RSContext::RSContext(clang::Preprocessor &PP,
mPragmas(Pragmas),
mTargetAPI(TargetAPI),
mVerbose(Verbose),
- mDataLayout(NULL),
+ mDataLayout(nullptr),
mLLVMContext(llvm::getGlobalContext()),
- mLicenseNote(NULL),
+ mLicenseNote(nullptr),
mRSPackageName("android.renderscript"),
version(0),
mMangleCtx(Ctx.createMangleContext()),
@@ -77,7 +77,7 @@ bool RSContext::processExportVar(const clang::VarDecl *VD) {
return false;
RSExportVar *EV = new RSExportVar(this, VD, ET);
- if (EV == NULL)
+ if (EV == nullptr)
return false;
else
mExportVars.push_back(EV);
@@ -103,7 +103,7 @@ bool RSContext::processExportFunc(const clang::FunctionDecl *FD) {
return RSExportForEach::validateSpecialFuncDecl(mTargetAPI, this, FD);
} else if (RSExportForEach::isRSForEachFunc(mTargetAPI, this, FD)) {
RSExportForEach *EFE = RSExportForEach::Create(this, FD);
- if (EFE == NULL)
+ if (EFE == nullptr)
return false;
else
mExportForEach.push_back(EFE);
@@ -111,7 +111,7 @@ bool RSContext::processExportFunc(const clang::FunctionDecl *FD) {
}
RSExportFunc *EF = RSExportFunc::Create(this, FD);
- if (EF == NULL)
+ if (EF == nullptr)
return false;
else
mExportFuncs.push_back(EF);
@@ -123,23 +123,23 @@ bool RSContext::processExportFunc(const clang::FunctionDecl *FD) {
bool RSContext::processExportType(const llvm::StringRef &Name) {
clang::TranslationUnitDecl *TUDecl = mCtx.getTranslationUnitDecl();
- slangAssert(TUDecl != NULL && "Translation unit declaration (top-level "
- "declaration) is null object");
+ slangAssert(TUDecl != nullptr && "Translation unit declaration (top-level "
+ "declaration) is null object");
const clang::IdentifierInfo *II = mPP.getIdentifierInfo(Name);
- if (II == NULL)
+ if (II == nullptr)
// TODO(zonr): alert identifier @Name mark as an exportable type cannot be
// found
return false;
clang::DeclContext::lookup_const_result R = TUDecl->lookup(II);
- RSExportType *ET = NULL;
+ RSExportType *ET = nullptr;
for (clang::DeclContext::lookup_const_iterator I = R.begin(), E = R.end();
I != E;
I++) {
clang::NamedDecl *const ND = *I;
- const clang::Type *T = NULL;
+ const clang::Type *T = nullptr;
switch (ND->getKind()) {
case clang::Decl::Typedef: {
@@ -157,11 +157,11 @@ bool RSContext::processExportType(const llvm::StringRef &Name) {
}
}
- if (T != NULL)
+ if (T != nullptr)
ET = RSExportType::Create(this, T);
}
- return (ET != NULL);
+ return (ET != nullptr);
}
diff --git a/slang_rs_context.h b/slang_rs_context.h
index c47f4c1..8e9b577 100644
--- a/slang_rs_context.h
+++ b/slang_rs_context.h
@@ -158,7 +158,7 @@ class RSContext {
bool processExport();
inline void newExportable(RSExportable *E) {
- if (E != NULL)
+ if (E != nullptr)
mExportables.push_back(E);
}
typedef ExportableList::iterator exportable_iterator;
diff --git a/slang_rs_export_element.cpp b/slang_rs_export_element.cpp
index 00d5a53..a5985bb 100644
--- a/slang_rs_export_element.cpp
+++ b/slang_rs_export_element.cpp
@@ -74,15 +74,15 @@ RSExportType *RSExportElement::Create(RSContext *Context,
// Create RSExportType corresponded to the @T first and then verify
llvm::StringRef TypeName;
- RSExportType *ET = NULL;
+ RSExportType *ET = nullptr;
if (!Initialized)
Init();
- slangAssert(EI != NULL && "Element info not found");
+ slangAssert(EI != nullptr && "Element info not found");
- if (!RSExportType::NormalizeType(T, TypeName, Context, NULL))
- return NULL;
+ if (!RSExportType::NormalizeType(T, TypeName, Context, nullptr))
+ return nullptr;
switch (T->getTypeClass()) {
case clang::Type::Builtin:
@@ -131,7 +131,7 @@ RSExportType *RSExportElement::CreateFromDecl(RSContext *Context,
const clang::DeclaratorDecl *DD) {
const clang::Type* T = RSExportType::GetTypeOfDecl(DD);
const clang::Type* CT = GetCanonicalType(T);
- const ElementInfo* EI = NULL;
+ const ElementInfo* EI = nullptr;
// Note: RS element like rs_pixel_rgb elements are either in the type of
// primitive or vector.
@@ -149,14 +149,14 @@ RSExportType *RSExportElement::CreateFromDecl(RSContext *Context,
const clang::TypedefType *TT = static_cast<const clang::TypedefType*>(T);
const clang::TypedefNameDecl *TD = TT->getDecl();
EI = GetElementInfo(TD->getName());
- if (EI != NULL)
+ if (EI != nullptr)
break;
T = TD->getUnderlyingType().getTypePtr();
}
}
- if (EI == NULL) {
+ if (EI == nullptr) {
return RSExportType::Create(Context, T);
} else {
return RSExportElement::Create(Context, T, EI);
@@ -170,7 +170,7 @@ RSExportElement::GetElementInfo(const llvm::StringRef &Name) {
ElementInfoMapTy::const_iterator I = ElementInfoMap.find(Name);
if (I == ElementInfoMap.end())
- return NULL;
+ return nullptr;
else
return I->getValue();
}
diff --git a/slang_rs_export_foreach.cpp b/slang_rs_export_foreach.cpp
index 439f9a9..d7ff0b3 100644
--- a/slang_rs_export_foreach.cpp
+++ b/slang_rs_export_foreach.cpp
@@ -108,7 +108,7 @@ bool RSExportForEach::validateAndConstructOldStyleParams(
// The only non-const pointer should be out.
if (!QT->getPointeeType().isConstQualified()) {
- if (mOut == NULL) {
+ if (mOut == nullptr) {
mOut = PVD;
} else {
Context->ReportError(PVD->getLocation(),
@@ -119,9 +119,9 @@ bool RSExportForEach::validateAndConstructOldStyleParams(
valid = false;
}
} else {
- if (mIns.empty() && mOut == NULL) {
+ if (mIns.empty() && mOut == nullptr) {
mIns.push_back(PVD);
- } else if (mUsrData == NULL) {
+ } else if (mUsrData == nullptr) {
mUsrData = PVD;
} else {
Context->ReportError(
@@ -227,8 +227,8 @@ bool RSExportForEach::validateAndConstructKernelParams(
bool RSExportForEach::validateIterationParameters(
RSContext *Context, const clang::FunctionDecl *FD,
size_t *IndexOfFirstIterator) {
- slangAssert(IndexOfFirstIterator != NULL);
- slangAssert(mX == NULL && mY == NULL);
+ slangAssert(IndexOfFirstIterator != nullptr);
+ slangAssert(mX == nullptr && mY == nullptr);
clang::ASTContext &C = Context->getASTContext();
// Find the x and y parameters if present.
@@ -239,9 +239,9 @@ bool RSExportForEach::validateIterationParameters(
const clang::ParmVarDecl *PVD = FD->getParamDecl(i);
llvm::StringRef ParamName = PVD->getName();
if (ParamName.equals("x")) {
- slangAssert(mX == NULL); // We won't be invoked if two 'x' are present.
+ slangAssert(mX == nullptr); // We won't be invoked if two 'x' are present.
mX = PVD;
- if (mY != NULL) {
+ if (mY != nullptr) {
Context->ReportError(PVD->getLocation(),
"In compute kernel %0(), parameter 'x' should "
"be defined before parameter 'y'")
@@ -249,7 +249,7 @@ bool RSExportForEach::validateIterationParameters(
valid = false;
}
} else if (ParamName.equals("y")) {
- slangAssert(mY == NULL); // We won't be invoked if two 'y' are present.
+ slangAssert(mY == nullptr); // We won't be invoked if two 'y' are present.
mY = PVD;
} else {
// It's neither x nor y.
@@ -278,7 +278,7 @@ bool RSExportForEach::validateIterationParameters(
}
}
// Check that x and y have the same type.
- if (mX != NULL and mY != NULL) {
+ if (mX != nullptr and mY != nullptr) {
clang::QualType XType = mX->getType();
clang::QualType YType = mY->getType();
@@ -299,8 +299,8 @@ bool RSExportForEach::setSignatureMetadata(RSContext *Context,
bool valid = true;
if (mIsKernelStyle) {
- slangAssert(mOut == NULL);
- slangAssert(mUsrData == NULL);
+ slangAssert(mOut == nullptr);
+ slangAssert(mUsrData == nullptr);
} else {
slangAssert(!mHasReturnType);
}
@@ -345,7 +345,7 @@ RSExportForEach *RSExportForEach::Create(RSContext *Context,
FE = new RSExportForEach(Context, Name);
if (!FE->validateAndConstructParams(Context, FD)) {
- return NULL;
+ return nullptr;
}
clang::ASTContext &Ctx = Context->getASTContext();
@@ -364,7 +364,7 @@ RSExportForEach *RSExportForEach::Create(RSContext *Context,
C.VoidTy) {
// In the case of using const void*, we can't reflect an appopriate
// Java type, so we fall back to just reflecting the ain/aout parameters
- FE->mUsrData = NULL;
+ FE->mUsrData = nullptr;
} else {
clang::RecordDecl *RD =
clang::RecordDecl::Create(Ctx, clang::TTK_Struct,
@@ -380,8 +380,8 @@ RSExportForEach *RSExportForEach::Create(RSContext *Context,
clang::SourceLocation(),
PVD->getIdentifier(),
QT->getPointeeType(),
- NULL,
- /* BitWidth = */ NULL,
+ nullptr,
+ /* BitWidth = */ nullptr,
/* Mutable = */ false,
/* HasInit = */ clang::ICIS_NoInit);
RD->addDecl(FD);
@@ -393,11 +393,11 @@ RSExportForEach *RSExportForEach::Create(RSContext *Context,
RSExportType *ET = RSExportType::Create(Context, T.getTypePtr());
- if (ET == NULL) {
+ if (ET == nullptr) {
fprintf(stderr, "Failed to export the function %s. There's at least "
"one parameter whose type is not supported by the "
"reflection\n", FE->getName().c_str());
- return NULL;
+ return nullptr;
}
slangAssert((ET->getClass() == RSExportType::ExportClassRecord) &&
@@ -414,7 +414,7 @@ RSExportForEach *RSExportForEach::Create(RSContext *Context,
RSExportType *InExportType = RSExportType::Create(Context, T);
if (FE->mIsKernelStyle) {
- slangAssert(InExportType != NULL);
+ slangAssert(InExportType != nullptr);
}
FE->mInTypes.push_back(InExportType);
diff --git a/slang_rs_export_foreach.h b/slang_rs_export_foreach.h
index f401d19..3bf9a29 100644
--- a/slang_rs_export_foreach.h
+++ b/slang_rs_export_foreach.h
@@ -69,9 +69,9 @@ class RSExportForEach : public RSExportable {
// TODO(all): Add support for LOD/face when we have them
RSExportForEach(RSContext *Context, const llvm::StringRef &Name)
: RSExportable(Context, RSExportable::EX_FOREACH),
- mName(Name.data(), Name.size()), mParamPacketType(NULL),
- mOutType(NULL), numParams(0), mSignatureMetadata(0),
- mOut(NULL), mUsrData(NULL), mX(NULL), mY(NULL),
+ mName(Name.data(), Name.size()), mParamPacketType(nullptr),
+ mOutType(nullptr), numParams(0), mSignatureMetadata(0),
+ mOut(nullptr), mUsrData(nullptr), mX(nullptr), mY(nullptr),
mResultType(clang::QualType()), mHasReturnType(false),
mIsKernelStyle(false), mDummyRoot(false) {
}
@@ -110,11 +110,11 @@ class RSExportForEach : public RSExportable {
}
inline bool hasOut() const {
- return (mOut != NULL);
+ return (mOut != nullptr);
}
inline bool hasUsrData() const {
- return (mUsrData != NULL);
+ return (mUsrData != nullptr);
}
inline bool hasReturn() const {
@@ -148,13 +148,13 @@ class RSExportForEach : public RSExportable {
typedef RSExportRecordType::const_field_iterator const_param_iterator;
inline const_param_iterator params_begin() const {
- slangAssert((mParamPacketType != NULL) &&
+ slangAssert((mParamPacketType != nullptr) &&
"Get parameter from export foreach having no parameter!");
return mParamPacketType->fields_begin();
}
inline const_param_iterator params_end() const {
- slangAssert((mParamPacketType != NULL) &&
+ slangAssert((mParamPacketType != nullptr) &&
"Get parameter from export foreach having no parameter!");
return mParamPacketType->fields_end();
}
diff --git a/slang_rs_export_func.cpp b/slang_rs_export_func.cpp
index 5fc36f1..070270c 100644
--- a/slang_rs_export_func.cpp
+++ b/slang_rs_export_func.cpp
@@ -55,14 +55,14 @@ RSExportFunc *RSExportFunc::Create(RSContext *Context,
slangAssert(!Name.empty() && "Function must have a name");
if (!ValidateFuncDecl(Context, FD)) {
- return NULL;
+ return nullptr;
}
F = new RSExportFunc(Context, Name, FD);
// Initialize mParamPacketType
if (FD->getNumParams() <= 0) {
- F->mParamPacketType = NULL;
+ F->mParamPacketType = nullptr;
} else {
clang::ASTContext &Ctx = Context->getASTContext();
@@ -92,8 +92,8 @@ RSExportFunc *RSExportFunc::Create(RSContext *Context,
clang::SourceLocation(),
PVD->getIdentifier(),
PVD->getOriginalType(),
- NULL,
- /* BitWidth = */ NULL,
+ nullptr,
+ /* BitWidth = */ nullptr,
/* Mutable = */ false,
/* HasInit = */ clang::ICIS_NoInit);
RD->addDecl(FD);
@@ -107,11 +107,11 @@ RSExportFunc *RSExportFunc::Create(RSContext *Context,
RSExportType *ET =
RSExportType::Create(Context, T.getTypePtr());
- if (ET == NULL) {
+ if (ET == nullptr) {
fprintf(stderr, "Failed to export the function %s. There's at least one "
"parameter whose type is not supported by the "
"reflection\n", F->getName().c_str());
- return NULL;
+ return nullptr;
}
slangAssert((ET->getClass() == RSExportType::ExportClassRecord) &&
@@ -125,12 +125,12 @@ RSExportFunc *RSExportFunc::Create(RSContext *Context,
bool
RSExportFunc::checkParameterPacketType(llvm::StructType *ParamTy) const {
- if (ParamTy == NULL)
+ if (ParamTy == nullptr)
return !hasParam();
else if (!hasParam())
return false;
- slangAssert(mParamPacketType != NULL);
+ slangAssert(mParamPacketType != nullptr);
const RSExportRecordType *ERT = mParamPacketType;
// must have same number of elements
diff --git a/slang_rs_export_func.h b/slang_rs_export_func.h
index d680f52..3c0804d 100644
--- a/slang_rs_export_func.h
+++ b/slang_rs_export_func.h
@@ -56,7 +56,7 @@ class RSExportFunc : public RSExportable {
mName(Name.data(), Name.size()),
mMangledName(),
mShouldMangle(false),
- mParamPacketType(NULL) {
+ mParamPacketType(nullptr) {
mShouldMangle = Context->getMangleContext().shouldMangleDeclName(FD);
@@ -74,12 +74,12 @@ class RSExportFunc : public RSExportable {
typedef RSExportRecordType::const_field_iterator const_param_iterator;
inline const_param_iterator params_begin() const {
- slangAssert((mParamPacketType != NULL) &&
+ slangAssert((mParamPacketType != nullptr) &&
"Get parameter from export function having no parameter!");
return mParamPacketType->fields_begin();
}
inline const_param_iterator params_end() const {
- slangAssert((mParamPacketType != NULL) &&
+ slangAssert((mParamPacketType != nullptr) &&
"Get parameter from export function having no parameter!");
return mParamPacketType->fields_end();
}
@@ -98,7 +98,7 @@ class RSExportFunc : public RSExportable {
// Check whether the given ParamsPacket type (in LLVM type) is "size
// equivalent" to the one obtained from getParamPacketType(). If the @Params
- // is NULL, means there must be no any parameters.
+ // is nullptr, means there must be no any parameters.
bool checkParameterPacketType(llvm::StructType *ParamTy) const;
}; // RSExportFunc
diff --git a/slang_rs_export_type.cpp b/slang_rs_export_type.cpp
index d197c4e..b507f9f 100644
--- a/slang_rs_export_type.cpp
+++ b/slang_rs_export_type.cpp
@@ -59,31 +59,31 @@ static RSReflectionType gReflectionTypes[] = {
{PrimitiveDataType, "UNSIGNED_32", "U32", 32, "uint32_t", "long", "UInt", "Long", true},
{PrimitiveDataType, "UNSIGNED_64", "U64", 64, "uint64_t", "long", "ULong", "Long", false},
- {PrimitiveDataType, "BOOLEAN", "BOOLEAN", 8, "bool", "boolean", NULL, NULL, false},
+ {PrimitiveDataType, "BOOLEAN", "BOOLEAN", 8, "bool", "boolean", nullptr, nullptr, false},
- {PrimitiveDataType, "UNSIGNED_5_6_5", NULL, 16, NULL, NULL, NULL, NULL, false},
- {PrimitiveDataType, "UNSIGNED_5_5_5_1", NULL, 16, NULL, NULL, NULL, NULL, false},
- {PrimitiveDataType, "UNSIGNED_4_4_4_4", NULL, 16, NULL, NULL, NULL, NULL, false},
+ {PrimitiveDataType, "UNSIGNED_5_6_5", nullptr, 16, nullptr, nullptr, nullptr, nullptr, false},
+ {PrimitiveDataType, "UNSIGNED_5_5_5_1", nullptr, 16, nullptr, nullptr, nullptr, nullptr, false},
+ {PrimitiveDataType, "UNSIGNED_4_4_4_4", nullptr, 16, nullptr, nullptr, nullptr, nullptr, false},
- {MatrixDataType, "MATRIX_2X2", NULL, 4*32, "rsMatrix_2x2", "Matrix2f", NULL, NULL, false},
- {MatrixDataType, "MATRIX_3X3", NULL, 9*32, "rsMatrix_3x3", "Matrix3f", NULL, NULL, false},
- {MatrixDataType, "MATRIX_4X4", NULL, 16*32, "rsMatrix_4x4", "Matrix4f", NULL, NULL, false},
+ {MatrixDataType, "MATRIX_2X2", nullptr, 4*32, "rsMatrix_2x2", "Matrix2f", nullptr, nullptr, false},
+ {MatrixDataType, "MATRIX_3X3", nullptr, 9*32, "rsMatrix_3x3", "Matrix3f", nullptr, nullptr, false},
+ {MatrixDataType, "MATRIX_4X4", nullptr, 16*32, "rsMatrix_4x4", "Matrix4f", nullptr, nullptr, false},
// RS object types are 32 bits in 32-bit RS, but 256 bits in 64-bit RS.
// This is handled specially by the GetSizeInBits() method.
- {ObjectDataType, "RS_ELEMENT", "ELEMENT", 32, "Element", "Element", NULL, NULL, false},
- {ObjectDataType, "RS_TYPE", "TYPE", 32, "Type", "Type", NULL, NULL, false},
- {ObjectDataType, "RS_ALLOCATION", "ALLOCATION", 32, "Allocation", "Allocation", NULL, NULL, false},
- {ObjectDataType, "RS_SAMPLER", "SAMPLER", 32, "Sampler", "Sampler", NULL, NULL, false},
- {ObjectDataType, "RS_SCRIPT", "SCRIPT", 32, "Script", "Script", NULL, NULL, false},
- {ObjectDataType, "RS_MESH", "MESH", 32, "Mesh", "Mesh", NULL, NULL, false},
- {ObjectDataType, "RS_PATH", "PATH", 32, "Path", "Path", NULL, NULL, false},
-
- {ObjectDataType, "RS_PROGRAM_FRAGMENT", "PROGRAM_FRAGMENT", 32, "ProgramFragment", "ProgramFragment", NULL, NULL, false},
- {ObjectDataType, "RS_PROGRAM_VERTEX", "PROGRAM_VERTEX", 32, "ProgramVertex", "ProgramVertex", NULL, NULL, false},
- {ObjectDataType, "RS_PROGRAM_RASTER", "PROGRAM_RASTER", 32, "ProgramRaster", "ProgramRaster", NULL, NULL, false},
- {ObjectDataType, "RS_PROGRAM_STORE", "PROGRAM_STORE", 32, "ProgramStore", "ProgramStore", NULL, NULL, false},
- {ObjectDataType, "RS_FONT", "FONT", 32, "Font", "Font", NULL, NULL, false}
+ {ObjectDataType, "RS_ELEMENT", "ELEMENT", 32, "Element", "Element", nullptr, nullptr, false},
+ {ObjectDataType, "RS_TYPE", "TYPE", 32, "Type", "Type", nullptr, nullptr, false},
+ {ObjectDataType, "RS_ALLOCATION", "ALLOCATION", 32, "Allocation", "Allocation", nullptr, nullptr, false},
+ {ObjectDataType, "RS_SAMPLER", "SAMPLER", 32, "Sampler", "Sampler", nullptr, nullptr, false},
+ {ObjectDataType, "RS_SCRIPT", "SCRIPT", 32, "Script", "Script", nullptr, nullptr, false},
+ {ObjectDataType, "RS_MESH", "MESH", 32, "Mesh", "Mesh", nullptr, nullptr, false},
+ {ObjectDataType, "RS_PATH", "PATH", 32, "Path", "Path", nullptr, nullptr, false},
+
+ {ObjectDataType, "RS_PROGRAM_FRAGMENT", "PROGRAM_FRAGMENT", 32, "ProgramFragment", "ProgramFragment", nullptr, nullptr, false},
+ {ObjectDataType, "RS_PROGRAM_VERTEX", "PROGRAM_VERTEX", 32, "ProgramVertex", "ProgramVertex", nullptr, nullptr, false},
+ {ObjectDataType, "RS_PROGRAM_RASTER", "PROGRAM_RASTER", 32, "ProgramRaster", "ProgramRaster", nullptr, nullptr, false},
+ {ObjectDataType, "RS_PROGRAM_STORE", "PROGRAM_STORE", 32, "ProgramStore", "ProgramStore", nullptr, nullptr, false},
+ {ObjectDataType, "RS_FONT", "FONT", 32, "Font", "Font", nullptr, nullptr, false}
};
const int kMaxVectorSize = 4;
@@ -201,7 +201,7 @@ static const clang::Type *ConstantArrayTypeExportableHelper(
if (ElementType->isArrayType()) {
ReportTypeError(Context, VD, TopLevelRecord,
"multidimensional arrays cannot be exported: '%0'");
- return NULL;
+ return nullptr;
} else if (ElementType->isExtVectorType()) {
const clang::ExtVectorType *EVT =
static_cast<const clang::ExtVectorType*>(ElementType);
@@ -211,19 +211,19 @@ static const clang::Type *ConstantArrayTypeExportableHelper(
if (!RSExportPrimitiveType::IsPrimitiveType(BaseElementType)) {
ReportTypeError(Context, VD, TopLevelRecord,
"vectors of non-primitive types cannot be exported: '%0'");
- return NULL;
+ return nullptr;
}
if (numElements == 3 && CAT->getSize() != 1) {
ReportTypeError(Context, VD, TopLevelRecord,
"arrays of width 3 vector types cannot be exported: '%0'");
- return NULL;
+ return nullptr;
}
}
if (TypeExportableHelper(ElementType, SPS, Context, VD,
- TopLevelRecord) == NULL) {
- return NULL;
+ TopLevelRecord) == nullptr) {
+ return nullptr;
} else {
return CAT;
}
@@ -235,7 +235,7 @@ BuiltinInfo *FindBuiltinType(clang::BuiltinType::Kind builtinTypeKind) {
return &BuiltinInfoTable[i];
}
}
- return NULL;
+ return nullptr;
}
static const clang::Type *TypeExportableHelper(
@@ -245,8 +245,8 @@ static const clang::Type *TypeExportableHelper(
clang::VarDecl const *VD,
clang::RecordDecl const *TopLevelRecord) {
// Normalize first
- if ((T = GetCanonicalType(T)) == NULL)
- return NULL;
+ if ((T = GetCanonicalType(T)) == nullptr)
+ return nullptr;
if (SPS.count(T))
return T;
@@ -256,7 +256,7 @@ static const clang::Type *TypeExportableHelper(
switch (T->getTypeClass()) {
case clang::Type::Builtin: {
const clang::BuiltinType *BT = static_cast<const clang::BuiltinType*>(CTI);
- return FindBuiltinType(BT->getKind()) == NULL ? NULL : T;
+ return FindBuiltinType(BT->getKind()) == nullptr ? nullptr : T;
}
case clang::Type::Record: {
if (RSExportPrimitiveType::GetRSSpecificType(T) != DataTypeUnknown) {
@@ -267,19 +267,19 @@ static const clang::Type *TypeExportableHelper(
if (T->isUnionType()) {
ReportTypeError(Context, VD, T->getAsUnionType()->getDecl(),
"unions cannot be exported: '%0'");
- return NULL;
+ return nullptr;
} else if (!T->isStructureType()) {
slangAssert(false && "Unknown type cannot be exported");
- return NULL;
+ return nullptr;
}
clang::RecordDecl *RD = T->getAsStructureType()->getDecl();
- if (RD != NULL) {
+ if (RD != nullptr) {
RD = RD->getDefinition();
- if (RD == NULL) {
- ReportTypeError(Context, NULL, T->getAsStructureType()->getDecl(),
+ if (RD == nullptr) {
+ ReportTypeError(Context, nullptr, T->getAsStructureType()->getDecl(),
"struct is not defined in this module");
- return NULL;
+ return nullptr;
}
}
@@ -287,14 +287,14 @@ static const clang::Type *TypeExportableHelper(
TopLevelRecord = RD;
}
if (RD->getName().empty()) {
- ReportTypeError(Context, NULL, RD,
+ ReportTypeError(Context, nullptr, RD,
"anonymous structures cannot be exported");
- return NULL;
+ return nullptr;
}
// Fast check
if (RD->hasFlexibleArrayMember() || RD->hasObjectMember())
- return NULL;
+ return nullptr;
// Insert myself into checking set
SPS.insert(T);
@@ -309,7 +309,7 @@ static const clang::Type *TypeExportableHelper(
FT = GetCanonicalType(FT);
if (!TypeExportableHelper(FT, SPS, Context, VD, TopLevelRecord)) {
- return NULL;
+ return nullptr;
}
// We don't support bit fields yet
@@ -320,7 +320,7 @@ static const clang::Type *TypeExportableHelper(
FD->getLocation(),
"bit fields are not able to be exported: '%0.%1'")
<< RD->getName() << FD->getName();
- return NULL;
+ return nullptr;
}
}
@@ -330,7 +330,7 @@ static const clang::Type *TypeExportableHelper(
if (TopLevelRecord) {
ReportTypeError(Context, VD, TopLevelRecord,
"structures containing pointers cannot be exported: '%0'");
- return NULL;
+ return nullptr;
}
const clang::PointerType *PT = static_cast<const clang::PointerType*>(CTI);
@@ -339,14 +339,14 @@ static const clang::Type *TypeExportableHelper(
if (PointeeType->getTypeClass() == clang::Type::Pointer) {
ReportTypeError(Context, VD, TopLevelRecord,
"multiple levels of pointers cannot be exported: '%0'");
- return NULL;
+ return nullptr;
}
// We don't support pointer with array-type pointee or unsupported pointee
// type
if (PointeeType->isArrayType() ||
(TypeExportableHelper(PointeeType, SPS, Context, VD,
- TopLevelRecord) == NULL))
- return NULL;
+ TopLevelRecord) == nullptr))
+ return nullptr;
else
return T;
}
@@ -355,15 +355,15 @@ static const clang::Type *TypeExportableHelper(
static_cast<const clang::ExtVectorType*>(CTI);
// Only vector with size 2, 3 and 4 are supported.
if (EVT->getNumElements() < 2 || EVT->getNumElements() > 4)
- return NULL;
+ return nullptr;
// Check base element type
const clang::Type *ElementType = GetExtVectorElementType(EVT);
if ((ElementType->getTypeClass() != clang::Type::Builtin) ||
(TypeExportableHelper(ElementType, SPS, Context, VD,
- TopLevelRecord) == NULL))
- return NULL;
+ TopLevelRecord) == nullptr))
+ return nullptr;
else
return T;
}
@@ -381,25 +381,26 @@ static const clang::Type *TypeExportableHelper(
}
default: {
slangAssert(false && "Unknown type cannot be validated");
- return NULL;
+ return nullptr;
}
}
}
// Return the type that can be used to create RSExportType, will always return
-// the canonical type
-// If the Type T is not exportable, this function returns NULL. DiagEngine is
-// used to generate proper Clang diagnostic messages when a
-// non-exportable type is detected. TopLevelRecord is used to capture the
-// highest struct (in the case of a nested hierarchy) for detecting other
-// types that cannot be exported (mostly pointers within a struct).
+// the canonical type.
+//
+// If the Type T is not exportable, this function returns nullptr. DiagEngine is
+// used to generate proper Clang diagnostic messages when a non-exportable type
+// is detected. TopLevelRecord is used to capture the highest struct (in the
+// case of a nested hierarchy) for detecting other types that cannot be exported
+// (mostly pointers within a struct).
static const clang::Type *TypeExportable(const clang::Type *T,
slang::RSContext *Context,
const clang::VarDecl *VD) {
llvm::SmallPtrSet<const clang::Type*, 8> SPS =
llvm::SmallPtrSet<const clang::Type*, 8>();
- return TypeExportableHelper(T, SPS, Context, VD, NULL);
+ return TypeExportableHelper(T, SPS, Context, VD, nullptr);
}
static bool ValidateRSObjectInVarDecl(slang::RSContext *Context,
@@ -414,7 +415,7 @@ static bool ValidateRSObjectInVarDecl(slang::RSContext *Context,
// Only if we are not a pointer to an object.
const clang::Type *T = GetCanonicalType(VD->getType().getTypePtr());
if (T->getTypeClass() != clang::Type::Pointer) {
- ReportTypeError(Context, VD, NULL,
+ ReportTypeError(Context, VD, nullptr,
"arrays/structures containing RS object types "
"cannot be exported in target API < %1: '%0'",
SLANG_JB_TARGET_API);
@@ -452,7 +453,7 @@ static bool ValidateTypeHelper(
clang::RecordDecl *UnionDecl,
unsigned int TargetAPI,
bool IsFilterscript) {
- if ((T = GetCanonicalType(T)) == NULL)
+ if ((T = GetCanonicalType(T)) == nullptr)
return true;
if (SPS.count(T))
@@ -463,7 +464,7 @@ static bool ValidateTypeHelper(
switch (T->getTypeClass()) {
case clang::Type::Record: {
if (RSExportPrimitiveType::IsRSObjectType(T)) {
- clang::VarDecl *VD = (ND ? llvm::dyn_cast<clang::VarDecl>(ND) : NULL);
+ clang::VarDecl *VD = (ND ? llvm::dyn_cast<clang::VarDecl>(ND) : nullptr);
if (VD && !ValidateRSObjectInVarDecl(Context, VD, InCompositeType,
TargetAPI)) {
return false;
@@ -474,13 +475,13 @@ static bool ValidateTypeHelper(
if (!UnionDecl) {
return true;
} else if (RSExportPrimitiveType::IsRSObjectType(T)) {
- ReportTypeError(Context, NULL, UnionDecl,
+ ReportTypeError(Context, nullptr, UnionDecl,
"unions containing RS object types are not allowed");
return false;
}
}
- clang::RecordDecl *RD = NULL;
+ clang::RecordDecl *RD = nullptr;
// Check internal struct
if (T->isUnionType()) {
@@ -493,9 +494,9 @@ static bool ValidateTypeHelper(
return false;
}
- if (RD != NULL) {
+ if (RD != nullptr) {
RD = RD->getDefinition();
- if (RD == NULL) {
+ if (RD == nullptr) {
// FIXME
return true;
}
@@ -583,7 +584,7 @@ static bool ValidateTypeHelper(
EVT->getNumElements() == 3 &&
ND &&
ND->getFormalLinkage() == clang::ExternalLinkage) {
- ReportTypeError(Context, ND, NULL,
+ ReportTypeError(Context, ND, nullptr,
"structs containing vectors of dimension 3 cannot "
"be exported at this API level: '%0'");
return false;
@@ -624,7 +625,7 @@ bool RSExportType::NormalizeType(const clang::Type *&T,
llvm::StringRef &TypeName,
RSContext *Context,
const clang::VarDecl *VD) {
- if ((T = TypeExportable(T, Context, VD)) == NULL) {
+ if ((T = TypeExportable(T, Context, VD)) == nullptr) {
return false;
}
// Get type name
@@ -650,7 +651,7 @@ bool RSExportType::ValidateType(slang::RSContext *Context, clang::ASTContext &C,
llvm::SmallPtrSet<const clang::Type*, 8> SPS =
llvm::SmallPtrSet<const clang::Type*, 8>();
- return ValidateTypeHelper(Context, C, T, ND, Loc, SPS, false, NULL, TargetAPI,
+ return ValidateTypeHelper(Context, C, T, ND, Loc, SPS, false, nullptr, TargetAPI,
IsFilterscript);
return true;
}
@@ -668,16 +669,16 @@ const clang::Type
clang::QualType T = DD->getType();
if (T.isNull())
- return NULL;
+ return nullptr;
else
return T.getTypePtr();
}
- return NULL;
+ return nullptr;
}
llvm::StringRef RSExportType::GetTypeName(const clang::Type* T) {
T = GetCanonicalType(T);
- if (T == NULL)
+ if (T == nullptr)
return llvm::StringRef();
const clang::Type *CTI = T->getCanonicalTypeInternal().getTypePtr();
@@ -686,7 +687,7 @@ llvm::StringRef RSExportType::GetTypeName(const clang::Type* T) {
case clang::Type::Builtin: {
const clang::BuiltinType *BT = static_cast<const clang::BuiltinType*>(CTI);
BuiltinInfo *info = FindBuiltinType(BT->getKind());
- if (info != NULL) {
+ if (info != nullptr) {
return info->cname[0];
}
slangAssert(false && "Unknown data type of the builtin");
@@ -702,7 +703,7 @@ llvm::StringRef RSExportType::GetTypeName(const clang::Type* T) {
llvm::StringRef Name = RD->getName();
if (Name.empty()) {
- if (RD->getTypedefNameForAnonDecl() != NULL) {
+ if (RD->getTypedefNameForAnonDecl() != nullptr) {
Name = RD->getTypedefNameForAnonDecl()->getName();
}
@@ -712,7 +713,7 @@ llvm::StringRef RSExportType::GetTypeName(const clang::Type* T) {
RE = RD->redecls_end();
RI != RE;
RI++) {
- slangAssert(*RI != NULL && "cannot be NULL object");
+ slangAssert(*RI != nullptr && "cannot be NULL object");
Name = (*RI)->getName();
if (!Name.empty())
@@ -727,7 +728,7 @@ llvm::StringRef RSExportType::GetTypeName(const clang::Type* T) {
const clang::PointerType *P = static_cast<const clang::PointerType*>(CTI);
const clang::Type *PT = GetPointeeType(P);
llvm::StringRef PointeeName;
- if (NormalizeType(PT, PointeeName, NULL, NULL)) {
+ if (NormalizeType(PT, PointeeName, nullptr, nullptr)) {
char *Name = new char[ 1 /* * */ + PointeeName.size() + 1 ];
Name[0] = '*';
memcpy(Name + 1, PointeeName.data(), PointeeName.size());
@@ -768,7 +769,7 @@ RSExportType *RSExportType::Create(RSContext *Context,
const clang::Type *CTI = T->getCanonicalTypeInternal().getTypePtr();
- RSExportType *ET = NULL;
+ RSExportType *ET = nullptr;
switch (T->getTypeClass()) {
case clang::Type::Record: {
DataType dt = RSExportPrimitiveType::GetRSSpecificType(TypeName);
@@ -848,10 +849,10 @@ RSExportType *RSExportType::Create(RSContext *Context,
RSExportType *RSExportType::Create(RSContext *Context, const clang::Type *T) {
llvm::StringRef TypeName;
- if (NormalizeType(T, TypeName, Context, NULL)) {
+ if (NormalizeType(T, TypeName, Context, nullptr)) {
return Create(Context, T, TypeName);
} else {
- return NULL;
+ return nullptr;
}
}
@@ -876,7 +877,7 @@ RSExportType::RSExportType(RSContext *Context,
// Make a copy on Name since memory stored @Name is either allocated in
// ASTContext or allocated in GetTypeName which will be destroyed later.
mName(Name.data(), Name.size()),
- mLLVMType(NULL) {
+ mLLVMType(nullptr) {
// Don't cache the type whose name start with '<'. Those type failed to
// get their name since constructing their name in GetTypeName() requiring
// complicated work.
@@ -891,7 +892,7 @@ bool RSExportType::keep() {
if (!RSExportable::keep())
return false;
// Invalidate converted LLVM type.
- mLLVMType = NULL;
+ mLLVMType = nullptr;
return true;
}
@@ -908,7 +909,7 @@ llvm::ManagedStatic<RSExportPrimitiveType::RSSpecificTypeMapTy>
RSExportPrimitiveType::RSSpecificTypeMap;
bool RSExportPrimitiveType::IsPrimitiveType(const clang::Type *T) {
- if ((T != NULL) && (T->getTypeClass() == clang::Type::Builtin))
+ if ((T != nullptr) && (T->getTypeClass() == clang::Type::Builtin))
return true;
else
return false;
@@ -935,7 +936,7 @@ RSExportPrimitiveType::GetRSSpecificType(const llvm::StringRef &TypeName) {
DataType RSExportPrimitiveType::GetRSSpecificType(const clang::Type *T) {
T = GetCanonicalType(T);
- if ((T == NULL) || (T->getTypeClass() != clang::Type::Record))
+ if ((T == nullptr) || (T->getTypeClass() != clang::Type::Record))
return DataTypeUnknown;
return GetRSSpecificType( RSExportType::GetTypeName(T) );
@@ -1029,7 +1030,7 @@ size_t RSExportPrimitiveType::GetSizeInBits(const RSExportPrimitiveType *EPT) {
DataType
RSExportPrimitiveType::GetDataType(RSContext *Context, const clang::Type *T) {
- if (T == NULL)
+ if (T == nullptr)
return DataTypeUnknown;
switch (T->getTypeClass()) {
@@ -1037,7 +1038,7 @@ RSExportPrimitiveType::GetDataType(RSContext *Context, const clang::Type *T) {
const clang::BuiltinType *BT =
static_cast<const clang::BuiltinType*>(T->getCanonicalTypeInternal().getTypePtr());
BuiltinInfo *info = FindBuiltinType(BT->getKind());
- if (info != NULL) {
+ if (info != nullptr) {
return info->type;
}
// The size of type WChar depend on platform so we abandon the support
@@ -1068,7 +1069,7 @@ RSExportPrimitiveType
DataType DT = GetDataType(Context, T);
if ((DT == DataTypeUnknown) || TypeName.empty())
- return NULL;
+ return nullptr;
else
return new RSExportPrimitiveType(Context, ExportClassPrimitive, TypeName,
DT, Normalized);
@@ -1077,11 +1078,11 @@ RSExportPrimitiveType
RSExportPrimitiveType *RSExportPrimitiveType::Create(RSContext *Context,
const clang::Type *T) {
llvm::StringRef TypeName;
- if (RSExportType::NormalizeType(T, TypeName, Context, NULL)
+ if (RSExportType::NormalizeType(T, TypeName, Context, nullptr)
&& IsPrimitiveType(T)) {
return Create(Context, T, TypeName);
} else {
- return NULL;
+ return nullptr;
}
}
@@ -1150,7 +1151,7 @@ llvm::Type *RSExportPrimitiveType::convertToLLVMType() const {
}
}
- return NULL;
+ return nullptr;
}
bool RSExportPrimitiveType::equals(const RSExportable *E) const {
@@ -1162,7 +1163,7 @@ RSReflectionType *RSExportPrimitiveType::getRSReflectionType(DataType DT) {
if (DT > DataTypeUnknown && DT < DataTypeMax) {
return &gReflectionTypes[DT];
} else {
- return NULL;
+ return nullptr;
}
}
@@ -1183,9 +1184,9 @@ RSExportPointerType
Context->getASTContext().IntTy.getTypePtr());
}
- if (PointeeET == NULL) {
+ if (PointeeET == nullptr) {
// Error diagnostic is emitted for corresponding pointee type
- return NULL;
+ return nullptr;
}
return new RSExportPointerType(Context, TypeName, PointeeET);
@@ -1227,7 +1228,7 @@ RSExportVectorType::GetTypeName(const clang::ExtVectorType *EVT) {
return name;
BuiltinInfo *info = FindBuiltinType(BT->getKind());
- if (info != NULL) {
+ if (info != nullptr) {
int I = EVT->getNumElements() - 1;
if (I < kMaxVectorSize) {
name = info->cname[I];
@@ -1242,7 +1243,7 @@ RSExportVectorType *RSExportVectorType::Create(RSContext *Context,
const clang::ExtVectorType *EVT,
const llvm::StringRef &TypeName,
bool Normalized) {
- slangAssert(EVT != NULL && EVT->getTypeClass() == clang::Type::ExtVector);
+ slangAssert(EVT != nullptr && EVT->getTypeClass() == clang::Type::ExtVector);
const clang::Type *ElementType = GetExtVectorElementType(EVT);
DataType DT = RSExportPrimitiveType::GetDataType(Context, ElementType);
@@ -1254,7 +1255,7 @@ RSExportVectorType *RSExportVectorType::Create(RSContext *Context,
Normalized,
EVT->getNumElements());
else
- return NULL;
+ return nullptr;
}
llvm::Type *RSExportVectorType::convertToLLVMType() const {
@@ -1273,37 +1274,37 @@ RSExportMatrixType *RSExportMatrixType::Create(RSContext *Context,
const clang::RecordType *RT,
const llvm::StringRef &TypeName,
unsigned Dim) {
- slangAssert((RT != NULL) && (RT->getTypeClass() == clang::Type::Record));
+ slangAssert((RT != nullptr) && (RT->getTypeClass() == clang::Type::Record));
slangAssert((Dim > 1) && "Invalid dimension of matrix");
// Check whether the struct rs_matrix is in our expected form (but assume it's
// correct if we're not sure whether it's correct or not)
const clang::RecordDecl* RD = RT->getDecl();
RD = RD->getDefinition();
- if (RD != NULL) {
+ if (RD != nullptr) {
// Find definition, perform further examination
if (RD->field_empty()) {
Context->ReportError(
RD->getLocation(),
"invalid matrix struct: must have 1 field for saving values: '%0'")
<< RD->getName();
- return NULL;
+ return nullptr;
}
clang::RecordDecl::field_iterator FIT = RD->field_begin();
const clang::FieldDecl *FD = *FIT;
const clang::Type *FT = RSExportType::GetTypeOfDecl(FD);
- if ((FT == NULL) || (FT->getTypeClass() != clang::Type::ConstantArray)) {
+ if ((FT == nullptr) || (FT->getTypeClass() != clang::Type::ConstantArray)) {
Context->ReportError(RD->getLocation(),
"invalid matrix struct: first field should"
" be an array with constant size: '%0'")
<< RD->getName();
- return NULL;
+ return nullptr;
}
const clang::ConstantArrayType *CAT =
static_cast<const clang::ConstantArrayType *>(FT);
const clang::Type *ElementType = GetConstantArrayElementType(CAT);
- if ((ElementType == NULL) ||
+ if ((ElementType == nullptr) ||
(ElementType->getTypeClass() != clang::Type::Builtin) ||
(static_cast<const clang::BuiltinType *>(ElementType)->getKind() !=
clang::BuiltinType::Float)) {
@@ -1311,7 +1312,7 @@ RSExportMatrixType *RSExportMatrixType::Create(RSContext *Context,
"invalid matrix struct: first field "
"should be a float array: '%0'")
<< RD->getName();
- return NULL;
+ return nullptr;
}
if (CAT->getSize() != Dim * Dim) {
@@ -1319,7 +1320,7 @@ RSExportMatrixType *RSExportMatrixType::Create(RSContext *Context,
"invalid matrix struct: first field "
"should be an array with size %0: '%1'")
<< (Dim * Dim) << (RD->getName());
- return NULL;
+ return nullptr;
}
FIT++;
@@ -1328,7 +1329,7 @@ RSExportMatrixType *RSExportMatrixType::Create(RSContext *Context,
"invalid matrix struct: must have "
"exactly 1 field: '%0'")
<< RD->getName();
- return NULL;
+ return nullptr;
}
}
@@ -1356,7 +1357,7 @@ bool RSExportMatrixType::equals(const RSExportable *E) const {
RSExportConstantArrayType
*RSExportConstantArrayType::Create(RSContext *Context,
const clang::ConstantArrayType *CAT) {
- slangAssert(CAT != NULL && CAT->getTypeClass() == clang::Type::ConstantArray);
+ slangAssert(CAT != nullptr && CAT->getTypeClass() == clang::Type::ConstantArray);
slangAssert((CAT->getSize().getActiveBits() < 32) && "array too large");
@@ -1366,8 +1367,8 @@ RSExportConstantArrayType
const clang::Type *ElementType = GetConstantArrayElementType(CAT);
RSExportType *ElementET = RSExportType::Create(Context, ElementType);
- if (ElementET == NULL) {
- return NULL;
+ if (ElementET == nullptr) {
+ return nullptr;
}
return new RSExportConstantArrayType(Context,
@@ -1399,22 +1400,22 @@ RSExportRecordType *RSExportRecordType::Create(RSContext *Context,
const clang::RecordType *RT,
const llvm::StringRef &TypeName,
bool mIsArtificial) {
- slangAssert(RT != NULL && RT->getTypeClass() == clang::Type::Record);
+ slangAssert(RT != nullptr && RT->getTypeClass() == clang::Type::Record);
const clang::RecordDecl *RD = RT->getDecl();
slangAssert(RD->isStruct());
RD = RD->getDefinition();
- if (RD == NULL) {
+ if (RD == nullptr) {
slangAssert(false && "struct is not defined in this module");
- return NULL;
+ return nullptr;
}
// Struct layout construct by clang. We rely on this for obtaining the
// alloc size of a struct and offset of every field in that struct.
const clang::ASTRecordLayout *RL =
&Context->getASTContext().getASTRecordLayout(RD);
- slangAssert((RL != NULL) &&
+ slangAssert((RL != nullptr) &&
"Failed to retrieve the struct layout from Clang.");
RSExportRecordType *ERT =
@@ -1436,13 +1437,13 @@ RSExportRecordType *RSExportRecordType::Create(RSContext *Context,
clang::FieldDecl *FD = *FI;
if (FD->isBitField()) {
- return NULL;
+ return nullptr;
}
// Type
RSExportType *ET = RSExportElement::CreateFromDecl(Context, FD);
- if (ET != NULL) {
+ if (ET != nullptr) {
ERT->mFields.push_back(
new Field(ET, FD->getName(), ERT,
static_cast<size_t>(RL->getFieldOffset(Index) >> 3)));
@@ -1450,7 +1451,7 @@ RSExportRecordType *RSExportRecordType::Create(RSContext *Context,
Context->ReportError(RD->getLocation(),
"field type cannot be exported: '%0.%1'")
<< RD->getName() << FD->getName();
- return NULL;
+ return nullptr;
}
}
@@ -1475,10 +1476,10 @@ llvm::Type *RSExportRecordType::convertToLLVMType() const {
llvm::StructType *ST = llvm::StructType::get(getRSContext()->getLLVMContext(),
FieldTypes,
mIsPacked);
- if (ST != NULL) {
+ if (ST != nullptr) {
return ST;
} else {
- return NULL;
+ return nullptr;
}
}
diff --git a/slang_rs_export_type.h b/slang_rs_export_type.h
index 841a230..a71f6c8 100644
--- a/slang_rs_export_type.h
+++ b/slang_rs_export_type.h
@@ -35,8 +35,8 @@
inline const clang::Type* GetCanonicalType(const clang::Type* T) {
- if (T == NULL) {
- return NULL;
+ if (T == nullptr) {
+ return nullptr;
}
return T->getCanonicalTypeInternal().getTypePtr();
}
@@ -46,22 +46,22 @@ inline const clang::Type* GetCanonicalType(clang::QualType QT) {
}
inline const clang::Type* GetExtVectorElementType(const clang::ExtVectorType *T) {
- if (T == NULL) {
- return NULL;
+ if (T == nullptr) {
+ return nullptr;
}
return GetCanonicalType(T->getElementType());
}
inline const clang::Type* GetPointeeType(const clang::PointerType *T) {
- if (T == NULL) {
- return NULL;
+ if (T == nullptr) {
+ return nullptr;
}
return GetCanonicalType(T->getPointeeType());
}
inline const clang::Type* GetConstantArrayElementType(const clang::ConstantArrayType *T) {
- if (T == NULL) {
- return NULL;
+ if (T == nullptr) {
+ return nullptr;
}
return GetCanonicalType(T->getElementType());
}
@@ -257,7 +257,7 @@ class RSExportType : public RSExportable {
virtual unsigned getSize() const { return 1; }
inline llvm::Type *getLLVMType() const {
- if (mLLVMType == NULL)
+ if (mLLVMType == nullptr)
mLLVMType = convertToLLVMType();
return mLLVMType;
}
@@ -593,7 +593,7 @@ class RSExportRecordType : public RSExportType {
E = mFields.end();
I != E;
I++)
- if (*I != NULL)
+ if (*I != nullptr)
delete *I;
}
}; // RSExportRecordType
diff --git a/slang_rs_export_var.cpp b/slang_rs_export_var.cpp
index 3df28af..0d9e614 100644
--- a/slang_rs_export_var.cpp
+++ b/slang_rs_export_var.cpp
@@ -38,7 +38,7 @@ RSExportVar::RSExportVar(RSContext *Context,
mNumInits(0) {
// mInit - Evaluate initializer expression
const clang::Expr *Initializer = VD->getAnyInitializer();
- if (Initializer != NULL) {
+ if (Initializer != nullptr) {
switch (ET->getClass()) {
case RSExportType::ExportClassPrimitive:
case RSExportType::ExportClassVector: {
diff --git a/slang_rs_exportable.cpp b/slang_rs_exportable.cpp
index 53c1fbb..4a843ab 100644
--- a/slang_rs_exportable.cpp
+++ b/slang_rs_exportable.cpp
@@ -22,12 +22,12 @@ bool RSExportable::keep() {
if (isKeep())
return false;
// Invalidate associated Context.
- mContext = NULL;
+ mContext = nullptr;
return true;
}
bool RSExportable::equals(const RSExportable *E) const {
- return ((E == NULL) ? false : (mK == E->mK));
+ return ((E == nullptr) ? false : (mK == E->mK));
}
} // namespace slang
diff --git a/slang_rs_exportable.h b/slang_rs_exportable.h
index 8b51182..0871be3 100644
--- a/slang_rs_exportable.h
+++ b/slang_rs_exportable.h
@@ -50,7 +50,7 @@ class RSExportable {
// responsibility is then transferred to the object who invoked this function.
// Return false if the exportable is kept or failed to keep.
virtual bool keep();
- inline bool isKeep() const { return (mContext == NULL); }
+ inline bool isKeep() const { return (mContext == nullptr); }
virtual bool equals(const RSExportable *E) const;
diff --git a/slang_rs_object_ref_count.cpp b/slang_rs_object_ref_count.cpp
index f0ac22d..47db22f 100644
--- a/slang_rs_object_ref_count.cpp
+++ b/slang_rs_object_ref_count.cpp
@@ -42,8 +42,8 @@ RSObjectRefCount::RSClearObjectFD[DataTypeMax];
void RSObjectRefCount::GetRSRefCountingFunctions(clang::ASTContext &C) {
for (unsigned i = 0; i < DataTypeMax; i++) {
- RSSetObjectFD[i] = NULL;
- RSClearObjectFD[i] = NULL;
+ RSSetObjectFD[i] = nullptr;
+ RSClearObjectFD[i] = nullptr;
}
clang::TranslationUnitDecl *TUDecl = C.getTranslationUnitDecl();
@@ -151,7 +151,7 @@ static void AppendAfterStmt(clang::ASTContext &C,
}
slangAssert(Once <= 1);
- // When S is NULL, we are appending to the end of the CompoundStmt.
+ // When S is nullptr, we are appending to the end of the CompoundStmt.
if (!S) {
slangAssert(Once == 0);
std::list<clang::Stmt*>::const_iterator I = StmtList.begin();
@@ -218,7 +218,7 @@ class DestructorVisitor : public clang::StmtVisitor<DestructorVisitor> {
// the replacement. It also finishes up by appending the destructor to the
// current outermost CompoundStmt.
void InsertDestructors() {
- clang::Stmt *S = NULL;
+ clang::Stmt *S = nullptr;
clang::SourceManager &SM = mCtx.getSourceManager();
std::list<clang::Stmt *> StmtList;
StmtList.push_back(mDtorStmt);
@@ -244,7 +244,7 @@ class DestructorVisitor : public clang::StmtVisitor<DestructorVisitor> {
clang::CompoundStmt *CS =
llvm::dyn_cast<clang::CompoundStmt>(mOuterStmt);
slangAssert(CS);
- AppendAfterStmt(mCtx, CS, NULL, StmtList);
+ AppendAfterStmt(mCtx, CS, nullptr, StmtList);
}
void VisitStmt(clang::Stmt *S);
@@ -358,7 +358,7 @@ clang::Expr *ClearSingleRSObject(clang::ASTContext &C,
"Should not be destroying arrays with this function");
clang::FunctionDecl *ClearObjectFD = RSObjectRefCount::GetRSClearObjectFD(T);
- slangAssert((ClearObjectFD != NULL) &&
+ slangAssert((ClearObjectFD != nullptr) &&
"rsClearObject doesn't cover all RS object types");
clang::QualType ClearObjectFDType = ClearObjectFD->getType();
@@ -391,14 +391,14 @@ clang::Expr *ClearSingleRSObject(clang::ASTContext &C,
ClearObjectFD->getLocation(),
ClearObjectFDType,
clang::VK_RValue,
- NULL);
+ nullptr);
clang::Expr *RSClearObjectFP =
clang::ImplicitCastExpr::Create(C,
C.getPointerType(ClearObjectFDType),
clang::CK_FunctionToPointerDecay,
RefRSClearObjectFD,
- NULL,
+ nullptr,
clang::VK_RValue);
llvm::SmallVector<clang::Expr*, 1> ArgList;
@@ -445,11 +445,11 @@ static clang::Stmt *ClearArrayRSObject(
// Actually extract out the base RS object type for use later
BaseType = BaseType->getArrayElementTypeNoTypeQual();
- clang::Stmt *StmtArray[2] = {NULL};
+ clang::Stmt *StmtArray[2] = {nullptr};
int StmtCtr = 0;
if (NumArrayElements <= 0) {
- return NULL;
+ return nullptr;
}
// Example destructor loop for "rs_font fontArr[10];"
@@ -463,7 +463,7 @@ static clang::Stmt *ClearArrayRSObject(
// (BinaryOperator 'int' '<'
// (DeclRefExpr 'int' Var='rsIntIter')
// (IntegerLiteral 'int' 10)
- // NULL << CondVar >>
+ // nullptr << CondVar >>
// (UnaryOperator 'int' postfix '++'
// (DeclRefExpr 'int' Var='rsIntIter'))
// (CallExpr 'void'
@@ -505,7 +505,7 @@ static clang::Stmt *ClearArrayRSObject(
Loc,
C.IntTy,
clang::VK_RValue,
- NULL);
+ nullptr);
clang::Expr *Int0 = clang::IntegerLiteral::Create(C,
llvm::APInt(C.getTypeSize(C.IntTy), 0), C.IntTy, Loc);
@@ -551,7 +551,7 @@ static clang::Stmt *ClearArrayRSObject(
C.getPointerType(BaseType->getCanonicalTypeInternal()),
clang::CK_ArrayToPointerDecay,
RefRSArr,
- NULL,
+ nullptr,
clang::VK_RValue);
clang::Expr *RefRSArrPtrSubscript =
@@ -564,7 +564,7 @@ static clang::Stmt *ClearArrayRSObject(
DataType DT = RSExportPrimitiveType::GetRSSpecificType(BaseType);
- clang::Stmt *RSClearObjectCall = NULL;
+ clang::Stmt *RSClearObjectCall = nullptr;
if (BaseType->isArrayType()) {
RSClearObjectCall =
ClearArrayRSObject(C, DC, RefRSArrPtrSubscript, StartLoc, Loc);
@@ -579,7 +579,7 @@ static clang::Stmt *ClearArrayRSObject(
new(C) clang::ForStmt(C,
Init,
Cond,
- NULL, // no condVar
+ nullptr, // no condVar
Inc,
RSClearObjectCall,
Loc,
@@ -667,7 +667,7 @@ static clang::Stmt *ClearStructRSObject(
unsigned StmtCount = 0;
clang::Stmt **StmtArray = new clang::Stmt*[FieldsToDestroy];
for (unsigned i = 0; i < FieldsToDestroy; i++) {
- StmtArray[i] = NULL;
+ StmtArray[i] = nullptr;
}
// Populate StmtArray by creating a destructor for each RS object field
@@ -700,7 +700,7 @@ static clang::Stmt *ClearStructRSObject(
FD,
FoundDecl,
clang::DeclarationNameInfo(),
- NULL,
+ nullptr,
OrigType->getCanonicalTypeInternal(),
clang::VK_RValue,
clang::OK_Ordinary);
@@ -733,7 +733,7 @@ static clang::Stmt *ClearStructRSObject(
FD,
FoundDecl,
clang::DeclarationNameInfo(),
- NULL,
+ nullptr,
OrigType->getCanonicalTypeInternal(),
clang::VK_RValue,
clang::OK_Ordinary);
@@ -770,7 +770,7 @@ static clang::Stmt *CreateSingleRSSetObject(clang::ASTContext &C,
clang::SourceLocation Loc) {
const clang::Type *T = DstExpr->getType().getTypePtr();
clang::FunctionDecl *SetObjectFD = RSObjectRefCount::GetRSSetObjectFD(T);
- slangAssert((SetObjectFD != NULL) &&
+ slangAssert((SetObjectFD != nullptr) &&
"rsSetObject doesn't cover all RS object types");
clang::QualType SetObjectFDType = SetObjectFD->getType();
@@ -787,14 +787,14 @@ static clang::Stmt *CreateSingleRSSetObject(clang::ASTContext &C,
Loc,
SetObjectFDType,
clang::VK_RValue,
- NULL);
+ nullptr);
clang::Expr *RSSetObjectFP =
clang::ImplicitCastExpr::Create(C,
C.getPointerType(SetObjectFDType),
clang::CK_FunctionToPointerDecay,
RefRSSetObjectFD,
- NULL,
+ nullptr,
clang::VK_RValue);
llvm::SmallVector<clang::Expr*, 2> ArgList;
@@ -828,7 +828,7 @@ static clang::Stmt *CreateStructRSSetObject(clang::ASTContext &C,
clang::Expr *SrcArr,
clang::SourceLocation StartLoc,
clang::SourceLocation Loc) {
- clang::DeclContext *DC = NULL;
+ clang::DeclContext *DC = nullptr;
const clang::Type *BaseType = DstArr->getType().getTypePtr();
slangAssert(BaseType->isArrayType());
@@ -836,11 +836,11 @@ static clang::Stmt *CreateStructRSSetObject(clang::ASTContext &C,
// Actually extract out the base RS object type for use later
BaseType = BaseType->getArrayElementTypeNoTypeQual();
- clang::Stmt *StmtArray[2] = {NULL};
+ clang::Stmt *StmtArray[2] = {nullptr};
int StmtCtr = 0;
if (NumArrayElements <= 0) {
- return NULL;
+ return nullptr;
}
// Create helper variable for iterating through elements
@@ -872,7 +872,7 @@ static clang::Stmt *CreateStructRSSetObject(clang::ASTContext &C,
Loc,
C.IntTy,
clang::VK_RValue,
- NULL);
+ nullptr);
clang::Expr *Int0 = clang::IntegerLiteral::Create(C,
llvm::APInt(C.getTypeSize(C.IntTy), 0), C.IntTy, Loc);
@@ -916,7 +916,7 @@ static clang::Stmt *CreateStructRSSetObject(clang::ASTContext &C,
C.getPointerType(BaseType->getCanonicalTypeInternal()),
clang::CK_ArrayToPointerDecay,
DstArr,
- NULL,
+ nullptr,
clang::VK_RValue);
clang::Expr *DstArrPtrSubscript =
@@ -932,7 +932,7 @@ static clang::Stmt *CreateStructRSSetObject(clang::ASTContext &C,
C.getPointerType(BaseType->getCanonicalTypeInternal()),
clang::CK_ArrayToPointerDecay,
SrcArr,
- NULL,
+ nullptr,
clang::VK_RValue);
clang::Expr *SrcArrPtrSubscript =
@@ -945,7 +945,7 @@ static clang::Stmt *CreateStructRSSetObject(clang::ASTContext &C,
DataType DT = RSExportPrimitiveType::GetRSSpecificType(BaseType);
- clang::Stmt *RSSetObjectCall = NULL;
+ clang::Stmt *RSSetObjectCall = nullptr;
if (BaseType->isArrayType()) {
RSSetObjectCall = CreateArrayRSSetObject(C, DstArrPtrSubscript,
SrcArrPtrSubscript,
@@ -964,7 +964,7 @@ static clang::Stmt *CreateStructRSSetObject(clang::ASTContext &C,
new(C) clang::ForStmt(C,
Init,
Cond,
- NULL, // no condVar
+ nullptr, // no condVar
Inc,
RSSetObjectCall,
Loc,
@@ -996,7 +996,7 @@ static clang::Stmt *CreateStructRSSetObject(clang::ASTContext &C,
unsigned StmtCount = 0;
clang::Stmt **StmtArray = new clang::Stmt*[FieldsToSet];
for (unsigned i = 0; i < FieldsToSet; i++) {
- StmtArray[i] = NULL;
+ StmtArray[i] = nullptr;
}
clang::RecordDecl *RD = T->getAsStructureType()->getDecl();
@@ -1026,7 +1026,7 @@ static clang::Stmt *CreateStructRSSetObject(clang::ASTContext &C,
FD,
FoundDecl,
clang::DeclarationNameInfo(),
- NULL,
+ nullptr,
OrigType->getCanonicalTypeInternal(),
clang::VK_RValue,
clang::OK_Ordinary);
@@ -1040,7 +1040,7 @@ static clang::Stmt *CreateStructRSSetObject(clang::ASTContext &C,
FD,
FoundDecl,
clang::DeclarationNameInfo(),
- NULL,
+ nullptr,
OrigType->getCanonicalTypeInternal(),
clang::VK_RValue,
clang::OK_Ordinary);
@@ -1104,7 +1104,7 @@ void RSObjectRefCount::Scope::ReplaceRSObjectAssignment(
clang::SourceLocation Loc = AS->getExprLoc();
clang::SourceLocation StartLoc = AS->getLHS()->getExprLoc();
- clang::Stmt *UpdatedStmt = NULL;
+ clang::Stmt *UpdatedStmt = nullptr;
if (!RSExportPrimitiveType::IsRSObjectType(QT.getTypePtr())) {
// By definition, this is a struct assignment if we get here
@@ -1148,7 +1148,7 @@ void RSObjectRefCount::Scope::AppendRSObjectInit(
Loc,
T->getCanonicalTypeInternal(),
clang::VK_RValue,
- NULL);
+ nullptr);
clang::Stmt *RSSetObjectOps =
CreateStructRSSetObject(C, RefRSVar, InitExpr, StartLoc, Loc);
@@ -1160,7 +1160,7 @@ void RSObjectRefCount::Scope::AppendRSObjectInit(
}
clang::FunctionDecl *SetObjectFD = RSObjectRefCount::GetRSSetObjectFD(DT);
- slangAssert((SetObjectFD != NULL) &&
+ slangAssert((SetObjectFD != nullptr) &&
"rsSetObject doesn't cover all RS object types");
clang::QualType SetObjectFDType = SetObjectFD->getType();
@@ -1177,14 +1177,14 @@ void RSObjectRefCount::Scope::AppendRSObjectInit(
Loc,
SetObjectFDType,
clang::VK_RValue,
- NULL);
+ nullptr);
clang::Expr *RSSetObjectFP =
clang::ImplicitCastExpr::Create(C,
C.getPointerType(SetObjectFDType),
clang::CK_FunctionToPointerDecay,
RefRSSetObjectFD,
- NULL,
+ nullptr,
clang::VK_RValue);
const clang::Type *T = RSExportType::GetTypeOfDecl(VD);
@@ -1197,7 +1197,7 @@ void RSObjectRefCount::Scope::AppendRSObjectInit(
Loc,
T->getCanonicalTypeInternal(),
clang::VK_RValue,
- NULL);
+ nullptr);
llvm::SmallVector<clang::Expr*, 2> ArgList;
ArgList.push_back(new(C) clang::UnaryOperator(RefRSVar,
@@ -1258,7 +1258,7 @@ clang::Stmt *RSObjectRefCount::Scope::ClearRSObject(
Loc,
T->getCanonicalTypeInternal(),
clang::VK_RValue,
- NULL);
+ nullptr);
if (T->isArrayType()) {
return ClearArrayRSObject(C, DC, RefRSVar, StartLoc, Loc);
@@ -1330,7 +1330,7 @@ clang::Expr *RSObjectRefCount::CreateZeroInitializerForRSSpecificType(
DataType DT,
clang::ASTContext &C,
const clang::SourceLocation &Loc) {
- clang::Expr *Res = NULL;
+ clang::Expr *Res = nullptr;
switch (DT) {
case DataTypeIsStruct:
case DataTypeRSElement:
@@ -1354,7 +1354,7 @@ clang::Expr *RSObjectRefCount::CreateZeroInitializerForRSSpecificType(
C.NullPtrTy,
clang::CK_IntegralToPointer,
Int0,
- NULL,
+ nullptr,
clang::VK_RValue);
llvm::SmallVector<clang::Expr*, 1>InitList;
@@ -1441,7 +1441,7 @@ void RSObjectRefCount::VisitDeclStmt(clang::DeclStmt *DS) {
if (D->getKind() == clang::Decl::Var) {
clang::VarDecl *VD = static_cast<clang::VarDecl*>(D);
DataType DT = DataTypeUnknown;
- clang::Expr *InitExpr = NULL;
+ clang::Expr *InitExpr = nullptr;
if (InitializeRSObject(VD, &DT, &InitExpr)) {
// We need to zero-init all RS object types (including matrices), ...
getCurrentScope()->AppendRSObjectInit(VD, DS, DT, InitExpr);
@@ -1505,7 +1505,7 @@ clang::FunctionDecl *RSObjectRefCount::CreateStaticGlobalDtor() {
clang::FunctionProtoType::ExtProtoInfo EPI;
clang::QualType T = mCtx.getFunctionType(mCtx.VoidTy,
llvm::ArrayRef<clang::QualType>(), EPI);
- clang::FunctionDecl *FD = NULL;
+ clang::FunctionDecl *FD = nullptr;
// Generate rsClearObject() call chains for every global variable
// (whether static or extern).
@@ -1517,7 +1517,7 @@ clang::FunctionDecl *RSObjectRefCount::CreateStaticGlobalDtor() {
if (CountRSObjectTypes(mCtx, VD->getType().getTypePtr(), loc)) {
if (!FD) {
// Only create FD if we are going to use it.
- FD = clang::FunctionDecl::Create(mCtx, DC, loc, loc, N, T, NULL,
+ FD = clang::FunctionDecl::Create(mCtx, DC, loc, loc, N, T, nullptr,
clang::SC_None);
}
// Make sure to create any helpers within the function's DeclContext,
@@ -1530,7 +1530,7 @@ clang::FunctionDecl *RSObjectRefCount::CreateStaticGlobalDtor() {
// Nothing needs to be destroyed, so don't emit a dtor.
if (StmtList.empty()) {
- return NULL;
+ return nullptr;
}
clang::CompoundStmt *CS = BuildCompoundStmt(mCtx, StmtList, loc);
diff --git a/slang_rs_object_ref_count.h b/slang_rs_object_ref_count.h
index ca25891..eb200b8 100644
--- a/slang_rs_object_ref_count.h
+++ b/slang_rs_object_ref_count.h
@@ -118,7 +118,7 @@ class RSObjectRefCount : public clang::StmtVisitor<RSObjectRefCount> {
return RSSetObjectFD[DT];
} else {
slangAssert(false && "incorrect type");
- return NULL;
+ return nullptr;
}
}
@@ -132,7 +132,7 @@ class RSObjectRefCount : public clang::StmtVisitor<RSObjectRefCount> {
return RSClearObjectFD[DT];
} else {
slangAssert(false && "incorrect type");
- return NULL;
+ return nullptr;
}
}
diff --git a/slang_rs_reflect_utils.cpp b/slang_rs_reflect_utils.cpp
index 66facab..cccbdc4 100644
--- a/slang_rs_reflect_utils.cpp
+++ b/slang_rs_reflect_utils.cpp
@@ -169,7 +169,7 @@ static bool GenerateJavaCodeAccessorMethodForBitwidth(
}
FILE *pfin = fopen(filename.c_str(), "rb");
- if (pfin == NULL) {
+ if (pfin == nullptr) {
fprintf(stderr, "Error: could not read file %s\n", filename.c_str());
return false;
}
@@ -262,7 +262,7 @@ bool RSSlangReflectUtils::GenerateJavaBitCodeAccessor(
string output_path =
ComputePackagedPath(context.reflectPath, context.packageName);
if (!SlangUtils::CreateDirectoryWithParents(llvm::StringRef(output_path),
- NULL)) {
+ nullptr)) {
fprintf(stderr, "Error: could not create dir %s\n", output_path.c_str());
return false;
}
@@ -365,7 +365,7 @@ bool GeneratedFile::startFile(const string &outDirectory,
}
// Write the license.
- if (optionalLicense != NULL) {
+ if (optionalLicense != nullptr) {
*this << *optionalLicense;
} else {
*this << gApacheLicenseNote;
diff --git a/slang_rs_reflect_utils.h b/slang_rs_reflect_utils.h
index dc6b50c..1cbc098 100644
--- a/slang_rs_reflect_utils.h
+++ b/slang_rs_reflect_utils.h
@@ -111,7 +111,7 @@ public:
* - opening the stream,
* - writing out the license,
* - writing a message that this file has been auto-generated.
- * If optionalLicense is NULL, a default license is used.
+ * If optionalLicense is nullptr, a default license is used.
*/
bool startFile(const std::string &outPath, const std::string &outFileName,
const std::string &sourceFileName,
diff --git a/slang_rs_reflection.cpp b/slang_rs_reflection.cpp
index 9f5ccd0..be3d7dc 100644
--- a/slang_rs_reflection.cpp
+++ b/slang_rs_reflection.cpp
@@ -115,7 +115,7 @@ static const char *GetMatrixTypeName(const RSExportMatrixType *EMT) {
return MatrixTypeJavaNameMap[EMT->getDim() - 2];
slangAssert(false && "GetMatrixTypeName : Unsupported matrix dimension");
- return NULL;
+ return nullptr;
}
static const char *GetVectorAccessor(unsigned Index) {
@@ -170,7 +170,7 @@ static const char *GetPackerAPIName(const RSExportPrimitiveType *EPT) {
return PrimitiveTypePackerAPINameMap[EPT->getType()];
slangAssert(false && "GetPackerAPIName : Unknown primitive data type");
- return NULL;
+ return nullptr;
}
static std::string GetTypeName(const RSExportType *ET, bool Brackets = true) {
@@ -358,7 +358,7 @@ void RSReflectionJava::genScriptClassConstructor() {
// Generate a simple constructor with only a single parameter (the rest
// can be inferred from information we already have).
mOut.indent() << "// Constructor\n";
- startFunction(AM_Public, false, NULL, getClassName(), 1, "RenderScript",
+ startFunction(AM_Public, false, nullptr, getClassName(), 1, "RenderScript",
"rs");
if (getEmbedBitcodeInJava()) {
@@ -380,7 +380,7 @@ void RSReflectionJava::genScriptClassConstructor() {
endFunction();
// Alternate constructor (legacy) with 3 original parameters.
- startFunction(AM_Public, false, NULL, getClassName(), 3, "RenderScript",
+ startFunction(AM_Public, false, nullptr, getClassName(), 3, "RenderScript",
"rs", "Resources", "resources", "int", "id");
// Call constructor of super class
mOut.indent() << "super(rs, resources, id);\n";
@@ -425,7 +425,7 @@ void RSReflectionJava::genScriptClassConstructor() {
for (RSExportForEach::InTypeIter BI = InTypes.begin(), EI = InTypes.end();
BI != EI; BI++) {
- if (*BI != NULL) {
+ if (*BI != nullptr) {
genTypeInstanceFromPointer(*BI);
}
}
@@ -640,7 +640,7 @@ void RSReflectionJava::genExportFunction(const RSExportFunc *EF) {
std::string FieldPackerName = EF->getName() + "_fp";
if (genCreateFieldPacker(ERT, FieldPackerName.c_str()))
- genPackVarOfType(ERT, NULL, FieldPackerName.c_str());
+ genPackVarOfType(ERT, nullptr, FieldPackerName.c_str());
mOut.indent() << "invoke(" << RS_EXPORT_FUNC_INDEX_PREFIX << EF->getName()
<< ", " << FieldPackerName << ");\n";
@@ -764,7 +764,7 @@ void RSReflectionJava::genExportForEach(const RSExportForEach *EF) {
startFunction(AM_Public, false, "void", "forEach_" + EF->getName(), Args);
if (InTypes.size() == 1) {
- if (InTypes.front() != NULL) {
+ if (InTypes.front() != nullptr) {
genTypeCheck(InTypes.front(), "ain");
}
@@ -773,7 +773,7 @@ void RSReflectionJava::genExportForEach(const RSExportForEach *EF) {
for (RSExportForEach::InTypeIter BI = InTypes.begin(), EI = InTypes.end();
BI != EI; BI++, ++Index) {
- if (*BI != NULL) {
+ if (*BI != nullptr) {
genTypeCheck(*BI, ("ain_" + Ins[Index]->getName()).str().c_str());
}
}
@@ -804,7 +804,7 @@ void RSReflectionJava::genExportForEach(const RSExportForEach *EF) {
std::string FieldPackerName = EF->getName() + "_fp";
if (ERT) {
if (genCreateFieldPacker(ERT, FieldPackerName.c_str())) {
- genPackVarOfType(ERT, NULL, FieldPackerName.c_str());
+ genPackVarOfType(ERT, nullptr, FieldPackerName.c_str());
}
}
mOut.indent() << "forEach(" << RS_EXPORT_FOREACH_INDEX_PREFIX
@@ -1291,7 +1291,7 @@ void RSReflectionJava::genPackVarOfType(const RSExportType *ET,
size_t FieldStoreSize = T->getStoreSize();
size_t FieldAllocSize = T->getAllocSize();
- if (VarName != NULL)
+ if (VarName != nullptr)
FieldName = VarName + ("." + F->getName());
else
FieldName = F->getName();
@@ -1376,7 +1376,7 @@ void RSReflectionJava::genNewItemBufferIfNull(const char *Index) {
mOut.indent() << "if (" << RS_TYPE_ITEM_BUFFER_NAME " == null) ";
mOut << RS_TYPE_ITEM_BUFFER_NAME << " = new " << RS_TYPE_ITEM_CLASS_NAME
<< "[getType().getX() /* count */];\n";
- if (Index != NULL) {
+ if (Index != nullptr) {
mOut.indent() << "if (" << RS_TYPE_ITEM_BUFFER_NAME << "[" << Index
<< "] == null) ";
mOut << RS_TYPE_ITEM_BUFFER_NAME << "[" << Index << "] = new "
@@ -1495,7 +1495,7 @@ void RSReflectionJava::genTypeClassConstructor(const RSExportRecordType *ERT) {
endFunction();
// private with element
- startFunction(AM_Private, false, NULL, getClassName(), 1, "RenderScript",
+ startFunction(AM_Private, false, nullptr, getClassName(), 1, "RenderScript",
RenderScriptVar);
mOut.indent() << RS_TYPE_ITEM_BUFFER_NAME << " = null;\n";
mOut.indent() << RS_TYPE_ITEM_BUFFER_PACKER_NAME << " = null;\n";
@@ -1503,7 +1503,7 @@ void RSReflectionJava::genTypeClassConstructor(const RSExportRecordType *ERT) {
endFunction();
// 1D without usage
- startFunction(AM_Public, false, NULL, getClassName(), 2, "RenderScript",
+ startFunction(AM_Public, false, nullptr, getClassName(), 2, "RenderScript",
RenderScriptVar, "int", "count");
mOut.indent() << RS_TYPE_ITEM_BUFFER_NAME << " = null;\n";
@@ -1514,7 +1514,7 @@ void RSReflectionJava::genTypeClassConstructor(const RSExportRecordType *ERT) {
endFunction();
// 1D with usage
- startFunction(AM_Public, false, NULL, getClassName(), 3, "RenderScript",
+ startFunction(AM_Public, false, nullptr, getClassName(), 3, "RenderScript",
RenderScriptVar, "int", "count", "int", "usages");
mOut.indent() << RS_TYPE_ITEM_BUFFER_NAME << " = null;\n";
@@ -1615,7 +1615,7 @@ void RSReflectionJava::genTypeClassItemSetter(const RSExportRecordType *ERT) {
startFunction(AM_PublicSynchronized, false, "void", "set", 3,
RS_TYPE_ITEM_CLASS_NAME, "i", "int", "index", "boolean",
"copyNow");
- genNewItemBufferIfNull(NULL);
+ genNewItemBufferIfNull(nullptr);
mOut.indent() << RS_TYPE_ITEM_BUFFER_NAME << "[index] = i;\n";
mOut.indent() << "if (copyNow) ";
@@ -2025,7 +2025,7 @@ bool RSReflectionJava::startClass(AccessModifier AM, bool IsStatic,
mOut << AccessModifierStr(AM) << ((IsStatic) ? " static" : "") << " class "
<< ClassName;
- if (SuperClassName != NULL)
+ if (SuperClassName != nullptr)
mOut << " extends " << SuperClassName;
mOut.startBlock();
diff --git a/slang_rs_reflection.h b/slang_rs_reflection.h
index 0c2b773..097a380 100644
--- a/slang_rs_reflection.h
+++ b/slang_rs_reflection.h
@@ -247,7 +247,7 @@ public:
inline const char *getLastError() const {
if (mLastError.empty())
- return NULL;
+ return nullptr;
else
return mLastError.c_str();
}
diff --git a/slang_rs_reflection_cpp.cpp b/slang_rs_reflection_cpp.cpp
index 0840d37..0b08028 100644
--- a/slang_rs_reflection_cpp.cpp
+++ b/slang_rs_reflection_cpp.cpp
@@ -56,7 +56,7 @@ static const char *GetMatrixTypeName(const RSExportMatrixType *EMT) {
return MatrixTypeCNameMap[EMT->getDim() - 2];
slangAssert(false && "GetMatrixTypeName : Unsupported matrix dimension");
- return NULL;
+ return nullptr;
}
static std::string GetTypeName(const RSExportType *ET, bool Brackets = true) {
@@ -304,7 +304,7 @@ void RSReflectionCpp::genExportFunctionDeclarations() {
bool RSReflectionCpp::genEncodedBitCode() {
FILE *pfin = fopen(mBitCodeFilePath.c_str(), "rb");
- if (pfin == NULL) {
+ if (pfin == nullptr) {
fprintf(stderr, "Error: could not read file %s\n",
mBitCodeFilePath.c_str());
return false;
@@ -431,7 +431,7 @@ bool RSReflectionCpp::writeImplementationFile() {
std::string FieldPackerName = ef->getName() + "_fp";
if (ERT) {
if (genCreateFieldPacker(ERT, FieldPackerName.c_str())) {
- genPackVarOfType(ERT, NULL, FieldPackerName.c_str());
+ genPackVarOfType(ERT, nullptr, FieldPackerName.c_str());
}
}
mOut.indent() << "forEach(" << slot << ", ";
@@ -470,7 +470,7 @@ bool RSReflectionCpp::writeImplementationFile() {
if (params) {
param_len = params->getAllocSize();
if (genCreateFieldPacker(params, "__fp")) {
- genPackVarOfType(params, NULL, "__fp");
+ genPackVarOfType(params, nullptr, "__fp");
}
}
@@ -605,7 +605,7 @@ void RSReflectionCpp::genPointerTypeExportVariable(const RSExportVar *EV) {
void RSReflectionCpp::genGetterAndSetter(const RSExportVectorType *EVT,
const RSExportVar *EV) {
- slangAssert(EVT != NULL);
+ slangAssert(EVT != nullptr);
RSReflectionTypeData rtd;
EVT->convertToRTD(&rtd);
@@ -767,7 +767,7 @@ void RSReflectionCpp::genPackVarOfType(const RSExportType *ET,
size_t FieldStoreSize = T->getStoreSize();
size_t FieldAllocSize = T->getAllocSize();
- if (VarName != NULL)
+ if (VarName != nullptr)
FieldName = VarName + ("." + F->getName());
else
FieldName = F->getName();