[C++11] More 'nullptr' conversion. In some cases just using a boolean check instead of comparing to nullptr.
llvm-svn: 206252
diff --git a/llvm/lib/LTO/LTOCodeGenerator.cpp b/llvm/lib/LTO/LTOCodeGenerator.cpp
index 2ba90fa..8df4277 100644
--- a/llvm/lib/LTO/LTOCodeGenerator.cpp
+++ b/llvm/lib/LTO/LTOCodeGenerator.cpp
@@ -64,17 +64,17 @@
LTOCodeGenerator::LTOCodeGenerator()
: Context(getGlobalContext()), Linker(new Module("ld-temp.o", Context)),
- TargetMach(NULL), EmitDwarfDebugInfo(false), ScopeRestrictionsDone(false),
- CodeModel(LTO_CODEGEN_PIC_MODEL_DEFAULT), NativeObjectFile(NULL),
- DiagHandler(NULL), DiagContext(NULL) {
+ TargetMach(nullptr), EmitDwarfDebugInfo(false),
+ ScopeRestrictionsDone(false), CodeModel(LTO_CODEGEN_PIC_MODEL_DEFAULT),
+ NativeObjectFile(nullptr), DiagHandler(nullptr), DiagContext(nullptr) {
initializeLTOPasses();
}
LTOCodeGenerator::~LTOCodeGenerator() {
delete TargetMach;
delete NativeObjectFile;
- TargetMach = NULL;
- NativeObjectFile = NULL;
+ TargetMach = nullptr;
+ NativeObjectFile = nullptr;
Linker.deleteModule();
@@ -245,7 +245,7 @@
const char *name;
if (!compile_to_file(&name, disableOpt, disableInline, disableGVNLoadPRE,
errMsg))
- return NULL;
+ return nullptr;
// remove old buffer if compile() called twice
delete NativeObjectFile;
@@ -255,7 +255,7 @@
if (error_code ec = MemoryBuffer::getFile(name, BuffPtr, -1, false)) {
errMsg = ec.message();
sys::fs::remove(NativeObjectPath);
- return NULL;
+ return nullptr;
}
NativeObjectFile = BuffPtr.release();
@@ -263,14 +263,14 @@
sys::fs::remove(NativeObjectPath);
// return buffer, unless error
- if (NativeObjectFile == NULL)
- return NULL;
+ if (!NativeObjectFile)
+ return nullptr;
*length = NativeObjectFile->getBufferSize();
return NativeObjectFile->getBufferStart();
}
bool LTOCodeGenerator::determineTarget(std::string &errMsg) {
- if (TargetMach != NULL)
+ if (TargetMach)
return true;
std::string TripleStr = Linker.getModule()->getTargetTriple();
@@ -280,7 +280,7 @@
// create target machine from info for merged modules
const Target *march = TargetRegistry::lookupTarget(TripleStr, errMsg);
- if (march == NULL)
+ if (!march)
return false;
// The relocation model is actually a static member of TargetMachine and
@@ -355,7 +355,7 @@
static void findUsedValues(GlobalVariable *LLVMUsed,
SmallPtrSet<GlobalValue*, 8> &UsedValues) {
- if (LLVMUsed == 0) return;
+ if (!LLVMUsed) return;
ConstantArray *Inits = cast<ConstantArray>(LLVMUsed->getInitializer());
for (unsigned i = 0, e = Inits->getNumOperands(); i != e; ++i)
@@ -579,7 +579,7 @@
this->DiagHandler = DiagHandler;
this->DiagContext = Ctxt;
if (!DiagHandler)
- return Context.setDiagnosticHandler(NULL, NULL);
+ return Context.setDiagnosticHandler(nullptr, nullptr);
// Register the LTOCodeGenerator stub in the LLVMContext to forward the
// diagnostic to the external DiagHandler.
Context.setDiagnosticHandler(LTOCodeGenerator::DiagnosticHandler, this);
diff --git a/llvm/lib/LTO/LTOModule.cpp b/llvm/lib/LTO/LTOModule.cpp
index 567da04..3527b8b 100644
--- a/llvm/lib/LTO/LTOModule.cpp
+++ b/llvm/lib/LTO/LTOModule.cpp
@@ -100,7 +100,7 @@
std::unique_ptr<MemoryBuffer> buffer;
if (error_code ec = MemoryBuffer::getFile(path, buffer)) {
errMsg = ec.message();
- return NULL;
+ return nullptr;
}
return makeLTOModule(buffer.release(), options, errMsg);
}
@@ -120,7 +120,7 @@
if (error_code ec =
MemoryBuffer::getOpenFileSlice(fd, path, buffer, map_size, offset)) {
errMsg = ec.message();
- return NULL;
+ return nullptr;
}
return makeLTOModule(buffer.release(), options, errMsg);
}
@@ -130,7 +130,7 @@
std::string &errMsg, StringRef path) {
std::unique_ptr<MemoryBuffer> buffer(makeBuffer(mem, length, path));
if (!buffer)
- return NULL;
+ return nullptr;
return makeLTOModule(buffer.release(), options, errMsg);
}
@@ -143,7 +143,7 @@
if (error_code EC = ModuleOrErr.getError()) {
errMsg = EC.message();
delete buffer;
- return NULL;
+ return nullptr;
}
std::unique_ptr<Module> m(ModuleOrErr.get());
@@ -155,7 +155,7 @@
// find machine architecture for this module
const Target *march = TargetRegistry::lookupTarget(TripleStr, errMsg);
if (!march)
- return NULL;
+ return nullptr;
// construct LTOModule, hand over ownership of module and target
SubtargetFeatures Features;
@@ -189,7 +189,7 @@
if (Ret->parseSymbols(errMsg)) {
delete Ret;
- return NULL;
+ return nullptr;
}
Ret->parseMetadata();
@@ -460,7 +460,7 @@
NameAndAttributes &info = _undefines[entry.getKey().data()];
- if (info.symbol == 0) {
+ if (info.symbol == nullptr) {
// FIXME: This is trying to take care of module ASM like this:
//
// module asm ".zerofill __FOO, __foo, _bar_baz_qux, 0"
@@ -474,7 +474,7 @@
info.attributes =
LTO_SYMBOL_PERMISSIONS_DATA | LTO_SYMBOL_DEFINITION_REGULAR | scope;
info.isFunction = false;
- info.symbol = 0;
+ info.symbol = nullptr;
// add to table of symbols
_symbols.push_back(info);
@@ -508,7 +508,7 @@
info.name = entry.getKey().data();
info.attributes = attr;
info.isFunction = false;
- info.symbol = 0;
+ info.symbol = nullptr;
entry.setValue(info);
}