From 72ebc02f13eeb7328d199d7d5ccaee4e5ff03b3e Mon Sep 17 00:00:00 2001 From: karpinski Date: Fri, 30 Dec 2016 13:21:21 +0100 Subject: [PATCH] Switching from NULL to nullptr in src/rustllvm. --- src/rustllvm/ArchiveWrapper.cpp | 16 ++++++++-------- src/rustllvm/PassWrapper.cpp | 8 ++++---- src/rustllvm/RustWrapper.cpp | 22 +++++++++++----------- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/rustllvm/ArchiveWrapper.cpp b/src/rustllvm/ArchiveWrapper.cpp index 2effb1173fe..6ff06b56bc4 100644 --- a/src/rustllvm/ArchiveWrapper.cpp +++ b/src/rustllvm/ArchiveWrapper.cpp @@ -22,11 +22,11 @@ struct RustArchiveMember { Archive::Child child; RustArchiveMember() - : filename(NULL), name(NULL), + : filename(nullptr), name(nullptr), #if LLVM_VERSION_GE(3, 8) - child(NULL, NULL, NULL) + child(nullptr, nullptr, nullptr) #else - child(NULL, NULL) + child(nullptr, nullptr) #endif { } @@ -118,7 +118,7 @@ LLVMRustArchiveIteratorNew(LLVMRustArchiveRef ra) { if (rai->err) { LLVMRustSetLastError(toString(std::move(rai->err)).c_str()); delete rai; - return NULL; + return nullptr; } #endif rai->end = ar->child_end(); @@ -183,12 +183,12 @@ LLVMRustArchiveChildName(LLVMRustArchiveChildConstRef child, size_t *size) { // in the future, and in the mean time this tells LLVM that the error was // not ignored and that it shouldn't abort the process. LLVMRustSetLastError(toString(name_or_err.takeError()).c_str()); - return NULL; + return nullptr; } #else ErrorOr name_or_err = child->getName(); if (name_or_err.getError()) - return NULL; + return nullptr; #endif StringRef name = name_or_err.get(); *size = name.size(); @@ -202,13 +202,13 @@ extern "C" const char *LLVMRustArchiveChildData(LLVMRustArchiveChildRef child, Expected buf_or_err = child->getBuffer(); if (!buf_or_err) { LLVMRustSetLastError(toString(buf_or_err.takeError()).c_str()); - return NULL; + return nullptr; } #else ErrorOr buf_or_err = child->getBuffer(); if (buf_or_err.getError()) { LLVMRustSetLastError(buf_or_err.getError().message().c_str()); - return NULL; + return nullptr; } #endif buf = buf_or_err.get(); diff --git a/src/rustllvm/PassWrapper.cpp b/src/rustllvm/PassWrapper.cpp index 1fe336ecd4b..f71dac77caf 100644 --- a/src/rustllvm/PassWrapper.cpp +++ b/src/rustllvm/PassWrapper.cpp @@ -83,7 +83,7 @@ extern "C" LLVMPassRef LLVMRustFindAndCreatePass(const char *PassName) { if (PI) { return wrap(PI->createPass()); } - return NULL; + return nullptr; } extern "C" LLVMRustPassKind LLVMRustPassKind(LLVMPassRef rust_pass) { @@ -317,9 +317,9 @@ extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine( Triple Trip(Triple::normalize(triple)); const llvm::Target *TheTarget = TargetRegistry::lookupTarget(Trip.getTriple(), Error); - if (TheTarget == NULL) { + if (TheTarget == nullptr) { LLVMRustSetLastError(Error.c_str()); - return NULL; + return nullptr; } StringRef real_cpu = cpu; @@ -549,7 +549,7 @@ extern "C" void LLVMRustMarkAllFunctionsNounwind(LLVMModuleRef M) { ++GV) { GV->setDoesNotThrow(); Function *F = dyn_cast(GV); - if (F == NULL) + if (F == nullptr) continue; for (Function::iterator B = F->begin(), BE = F->end(); B != BE; ++B) { diff --git a/src/rustllvm/RustWrapper.cpp b/src/rustllvm/RustWrapper.cpp index 89d9d46dfb3..8f635441167 100644 --- a/src/rustllvm/RustWrapper.cpp +++ b/src/rustllvm/RustWrapper.cpp @@ -66,7 +66,7 @@ LLVMRustCreateMemoryBufferWithContentsOfFile(const char *Path) { extern "C" char *LLVMRustGetLastError(void) { char *ret = LastError; - LastError = NULL; + LastError = nullptr; return ret; } @@ -319,7 +319,7 @@ inline Metadata **unwrap(LLVMRustMetadataRef *Vals) { } template DIT *unwrapDIptr(LLVMRustMetadataRef ref) { - return (DIT *)(ref ? unwrap(ref) : NULL); + return (DIT *)(ref ? unwrap(ref) : nullptr); } #define DIDescriptor DIScope @@ -574,7 +574,7 @@ extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreateStaticVariable( LLVMRustDIBuilderRef Builder, LLVMRustMetadataRef Context, const char *Name, const char *LinkageName, LLVMRustMetadataRef File, unsigned LineNo, LLVMRustMetadataRef Ty, bool isLocalToUnit, LLVMValueRef Val, - LLVMRustMetadataRef Decl = NULL, uint64_t AlignInBits = 0) { + LLVMRustMetadataRef Decl = nullptr, uint64_t AlignInBits = 0) { Constant *InitVal = cast(unwrap(Val)); #if LLVM_VERSION_GE(4, 0) @@ -1012,14 +1012,14 @@ extern "C" LLVMValueRef LLVMRustBuildCleanupPad(LLVMBuilderRef Builder, const char *Name) { #if LLVM_VERSION_GE(3, 8) Value **Args = unwrap(LLArgs); - if (ParentPad == NULL) { + if (ParentPad == nullptr) { Type *Ty = Type::getTokenTy(unwrap(Builder)->getContext()); ParentPad = wrap(Constant::getNullValue(Ty)); } return wrap(unwrap(Builder)->CreateCleanupPad( unwrap(ParentPad), ArrayRef(Args, ArgCnt), Name)); #else - return NULL; + return nullptr; #endif } @@ -1030,7 +1030,7 @@ extern "C" LLVMValueRef LLVMRustBuildCleanupRet(LLVMBuilderRef Builder, CleanupPadInst *Inst = cast(unwrap(CleanupPad)); return wrap(unwrap(Builder)->CreateCleanupRet(Inst, unwrap(UnwindBB))); #else - return NULL; + return nullptr; #endif } @@ -1042,7 +1042,7 @@ LLVMRustBuildCatchPad(LLVMBuilderRef Builder, LLVMValueRef ParentPad, return wrap(unwrap(Builder)->CreateCatchPad( unwrap(ParentPad), ArrayRef(Args, ArgCnt), Name)); #else - return NULL; + return nullptr; #endif } @@ -1053,7 +1053,7 @@ extern "C" LLVMValueRef LLVMRustBuildCatchRet(LLVMBuilderRef Builder, return wrap(unwrap(Builder)->CreateCatchRet(cast(unwrap(Pad)), unwrap(BB))); #else - return NULL; + return nullptr; #endif } @@ -1063,14 +1063,14 @@ extern "C" LLVMValueRef LLVMRustBuildCatchSwitch(LLVMBuilderRef Builder, unsigned NumHandlers, const char *Name) { #if LLVM_VERSION_GE(3, 8) - if (ParentPad == NULL) { + if (ParentPad == nullptr) { Type *Ty = Type::getTokenTy(unwrap(Builder)->getContext()); ParentPad = wrap(Constant::getNullValue(Ty)); } return wrap(unwrap(Builder)->CreateCatchSwitch(unwrap(ParentPad), unwrap(BB), NumHandlers, Name)); #else - return NULL; + return nullptr; #endif } @@ -1126,7 +1126,7 @@ LLVMRustBuildInvoke(LLVMBuilderRef B, LLVMValueRef Fn, LLVMValueRef *Args, extern "C" void *LLVMRustBuildOperandBundleDef(const char *Name, LLVMValueRef *Inputs, unsigned NumInputs) { - return NULL; + return nullptr; } extern "C" void LLVMRustFreeOperandBundleDef(void *Bundle) {}