Skip to content

Commit 72ebc02

Browse files
committed
Switching from NULL to nullptr in src/rustllvm.
1 parent c72d859 commit 72ebc02

File tree

3 files changed

+23
-23
lines changed

3 files changed

+23
-23
lines changed

src/rustllvm/ArchiveWrapper.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ struct RustArchiveMember {
2222
Archive::Child child;
2323

2424
RustArchiveMember()
25-
: filename(NULL), name(NULL),
25+
: filename(nullptr), name(nullptr),
2626
#if LLVM_VERSION_GE(3, 8)
27-
child(NULL, NULL, NULL)
27+
child(nullptr, nullptr, nullptr)
2828
#else
29-
child(NULL, NULL)
29+
child(nullptr, nullptr)
3030
#endif
3131
{
3232
}
@@ -118,7 +118,7 @@ LLVMRustArchiveIteratorNew(LLVMRustArchiveRef ra) {
118118
if (rai->err) {
119119
LLVMRustSetLastError(toString(std::move(rai->err)).c_str());
120120
delete rai;
121-
return NULL;
121+
return nullptr;
122122
}
123123
#endif
124124
rai->end = ar->child_end();
@@ -183,12 +183,12 @@ LLVMRustArchiveChildName(LLVMRustArchiveChildConstRef child, size_t *size) {
183183
// in the future, and in the mean time this tells LLVM that the error was
184184
// not ignored and that it shouldn't abort the process.
185185
LLVMRustSetLastError(toString(name_or_err.takeError()).c_str());
186-
return NULL;
186+
return nullptr;
187187
}
188188
#else
189189
ErrorOr<StringRef> name_or_err = child->getName();
190190
if (name_or_err.getError())
191-
return NULL;
191+
return nullptr;
192192
#endif
193193
StringRef name = name_or_err.get();
194194
*size = name.size();
@@ -202,13 +202,13 @@ extern "C" const char *LLVMRustArchiveChildData(LLVMRustArchiveChildRef child,
202202
Expected<StringRef> buf_or_err = child->getBuffer();
203203
if (!buf_or_err) {
204204
LLVMRustSetLastError(toString(buf_or_err.takeError()).c_str());
205-
return NULL;
205+
return nullptr;
206206
}
207207
#else
208208
ErrorOr<StringRef> buf_or_err = child->getBuffer();
209209
if (buf_or_err.getError()) {
210210
LLVMRustSetLastError(buf_or_err.getError().message().c_str());
211-
return NULL;
211+
return nullptr;
212212
}
213213
#endif
214214
buf = buf_or_err.get();

src/rustllvm/PassWrapper.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ extern "C" LLVMPassRef LLVMRustFindAndCreatePass(const char *PassName) {
8383
if (PI) {
8484
return wrap(PI->createPass());
8585
}
86-
return NULL;
86+
return nullptr;
8787
}
8888

8989
extern "C" LLVMRustPassKind LLVMRustPassKind(LLVMPassRef rust_pass) {
@@ -317,9 +317,9 @@ extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine(
317317
Triple Trip(Triple::normalize(triple));
318318
const llvm::Target *TheTarget =
319319
TargetRegistry::lookupTarget(Trip.getTriple(), Error);
320-
if (TheTarget == NULL) {
320+
if (TheTarget == nullptr) {
321321
LLVMRustSetLastError(Error.c_str());
322-
return NULL;
322+
return nullptr;
323323
}
324324

325325
StringRef real_cpu = cpu;
@@ -549,7 +549,7 @@ extern "C" void LLVMRustMarkAllFunctionsNounwind(LLVMModuleRef M) {
549549
++GV) {
550550
GV->setDoesNotThrow();
551551
Function *F = dyn_cast<Function>(GV);
552-
if (F == NULL)
552+
if (F == nullptr)
553553
continue;
554554

555555
for (Function::iterator B = F->begin(), BE = F->end(); B != BE; ++B) {

src/rustllvm/RustWrapper.cpp

+11-11
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ LLVMRustCreateMemoryBufferWithContentsOfFile(const char *Path) {
6666

6767
extern "C" char *LLVMRustGetLastError(void) {
6868
char *ret = LastError;
69-
LastError = NULL;
69+
LastError = nullptr;
7070
return ret;
7171
}
7272

@@ -319,7 +319,7 @@ inline Metadata **unwrap(LLVMRustMetadataRef *Vals) {
319319
}
320320

321321
template <typename DIT> DIT *unwrapDIptr(LLVMRustMetadataRef ref) {
322-
return (DIT *)(ref ? unwrap<MDNode>(ref) : NULL);
322+
return (DIT *)(ref ? unwrap<MDNode>(ref) : nullptr);
323323
}
324324

325325
#define DIDescriptor DIScope
@@ -574,7 +574,7 @@ extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreateStaticVariable(
574574
LLVMRustDIBuilderRef Builder, LLVMRustMetadataRef Context, const char *Name,
575575
const char *LinkageName, LLVMRustMetadataRef File, unsigned LineNo,
576576
LLVMRustMetadataRef Ty, bool isLocalToUnit, LLVMValueRef Val,
577-
LLVMRustMetadataRef Decl = NULL, uint64_t AlignInBits = 0) {
577+
LLVMRustMetadataRef Decl = nullptr, uint64_t AlignInBits = 0) {
578578
Constant *InitVal = cast<Constant>(unwrap(Val));
579579

580580
#if LLVM_VERSION_GE(4, 0)
@@ -1012,14 +1012,14 @@ extern "C" LLVMValueRef LLVMRustBuildCleanupPad(LLVMBuilderRef Builder,
10121012
const char *Name) {
10131013
#if LLVM_VERSION_GE(3, 8)
10141014
Value **Args = unwrap(LLArgs);
1015-
if (ParentPad == NULL) {
1015+
if (ParentPad == nullptr) {
10161016
Type *Ty = Type::getTokenTy(unwrap(Builder)->getContext());
10171017
ParentPad = wrap(Constant::getNullValue(Ty));
10181018
}
10191019
return wrap(unwrap(Builder)->CreateCleanupPad(
10201020
unwrap(ParentPad), ArrayRef<Value *>(Args, ArgCnt), Name));
10211021
#else
1022-
return NULL;
1022+
return nullptr;
10231023
#endif
10241024
}
10251025

@@ -1030,7 +1030,7 @@ extern "C" LLVMValueRef LLVMRustBuildCleanupRet(LLVMBuilderRef Builder,
10301030
CleanupPadInst *Inst = cast<CleanupPadInst>(unwrap(CleanupPad));
10311031
return wrap(unwrap(Builder)->CreateCleanupRet(Inst, unwrap(UnwindBB)));
10321032
#else
1033-
return NULL;
1033+
return nullptr;
10341034
#endif
10351035
}
10361036

@@ -1042,7 +1042,7 @@ LLVMRustBuildCatchPad(LLVMBuilderRef Builder, LLVMValueRef ParentPad,
10421042
return wrap(unwrap(Builder)->CreateCatchPad(
10431043
unwrap(ParentPad), ArrayRef<Value *>(Args, ArgCnt), Name));
10441044
#else
1045-
return NULL;
1045+
return nullptr;
10461046
#endif
10471047
}
10481048

@@ -1053,7 +1053,7 @@ extern "C" LLVMValueRef LLVMRustBuildCatchRet(LLVMBuilderRef Builder,
10531053
return wrap(unwrap(Builder)->CreateCatchRet(cast<CatchPadInst>(unwrap(Pad)),
10541054
unwrap(BB)));
10551055
#else
1056-
return NULL;
1056+
return nullptr;
10571057
#endif
10581058
}
10591059

@@ -1063,14 +1063,14 @@ extern "C" LLVMValueRef LLVMRustBuildCatchSwitch(LLVMBuilderRef Builder,
10631063
unsigned NumHandlers,
10641064
const char *Name) {
10651065
#if LLVM_VERSION_GE(3, 8)
1066-
if (ParentPad == NULL) {
1066+
if (ParentPad == nullptr) {
10671067
Type *Ty = Type::getTokenTy(unwrap(Builder)->getContext());
10681068
ParentPad = wrap(Constant::getNullValue(Ty));
10691069
}
10701070
return wrap(unwrap(Builder)->CreateCatchSwitch(unwrap(ParentPad), unwrap(BB),
10711071
NumHandlers, Name));
10721072
#else
1073-
return NULL;
1073+
return nullptr;
10741074
#endif
10751075
}
10761076

@@ -1126,7 +1126,7 @@ LLVMRustBuildInvoke(LLVMBuilderRef B, LLVMValueRef Fn, LLVMValueRef *Args,
11261126
extern "C" void *LLVMRustBuildOperandBundleDef(const char *Name,
11271127
LLVMValueRef *Inputs,
11281128
unsigned NumInputs) {
1129-
return NULL;
1129+
return nullptr;
11301130
}
11311131

11321132
extern "C" void LLVMRustFreeOperandBundleDef(void *Bundle) {}

0 commit comments

Comments
 (0)