From 0b6cb7104b15504cd41f48cc2babcbcee70775f3 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Tue, 15 Apr 2014 06:32:26 +0000 Subject: [C++11] More 'nullptr' conversion. In some cases just using a boolean check instead of comparing to nullptr. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206252 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/ExecutionEngine/ExecutionEngine.cpp | 62 ++++++++++++------------- lib/ExecutionEngine/ExecutionEngineBindings.cpp | 4 +- lib/ExecutionEngine/TargetSelect.cpp | 8 ++-- 3 files changed, 37 insertions(+), 37 deletions(-) (limited to 'lib/ExecutionEngine') diff --git a/lib/ExecutionEngine/ExecutionEngine.cpp b/lib/ExecutionEngine/ExecutionEngine.cpp index 4768e67a1e..4685d6d13b 100644 --- a/lib/ExecutionEngine/ExecutionEngine.cpp +++ b/lib/ExecutionEngine/ExecutionEngine.cpp @@ -50,19 +50,19 @@ ExecutionEngine *(*ExecutionEngine::JITCtor)( std::string *ErrorStr, JITMemoryManager *JMM, bool GVsWithCode, - TargetMachine *TM) = 0; + TargetMachine *TM) = nullptr; ExecutionEngine *(*ExecutionEngine::MCJITCtor)( Module *M, std::string *ErrorStr, RTDyldMemoryManager *MCJMM, bool GVsWithCode, - TargetMachine *TM) = 0; + TargetMachine *TM) = nullptr; ExecutionEngine *(*ExecutionEngine::InterpCtor)(Module *M, - std::string *ErrorStr) = 0; + std::string *ErrorStr) =nullptr; ExecutionEngine::ExecutionEngine(Module *M) : EEState(*this), - LazyFunctionCreator(0) { + LazyFunctionCreator(nullptr) { CompilingLazily = false; GVCompilationDisabled = false; SymbolSearchingDisabled = false; @@ -129,7 +129,7 @@ Function *ExecutionEngine::FindFunctionNamed(const char *FnName) { if (Function *F = Modules[i]->getFunction(FnName)) return F; } - return 0; + return nullptr; } @@ -141,7 +141,7 @@ void *ExecutionEngineState::RemoveMapping(const MutexGuard &, // FIXME: This is silly, we shouldn't end up with a mapping -> 0 in the // GlobalAddressMap. if (I == GlobalAddressMap.end()) - OldVal = 0; + OldVal = nullptr; else { OldVal = I->second; GlobalAddressMap.erase(I); @@ -157,14 +157,14 @@ void ExecutionEngine::addGlobalMapping(const GlobalValue *GV, void *Addr) { DEBUG(dbgs() << "JIT: Map \'" << GV->getName() << "\' to [" << Addr << "]\n";); void *&CurVal = EEState.getGlobalAddressMap(locked)[GV]; - assert((CurVal == 0 || Addr == 0) && "GlobalMapping already established!"); + assert((!CurVal || !Addr) && "GlobalMapping already established!"); CurVal = Addr; // If we are using the reverse mapping, add it too. if (!EEState.getGlobalAddressReverseMap(locked).empty()) { AssertingVH &V = EEState.getGlobalAddressReverseMap(locked)[Addr]; - assert((V == 0 || GV == 0) && "GlobalMapping already established!"); + assert((!V || !GV) && "GlobalMapping already established!"); V = GV; } } @@ -193,7 +193,7 @@ void *ExecutionEngine::updateGlobalMapping(const GlobalValue *GV, void *Addr) { EEState.getGlobalAddressMap(locked); // Deleting from the mapping? - if (Addr == 0) + if (!Addr) return EEState.RemoveMapping(locked, GV); void *&CurVal = Map[GV]; @@ -207,7 +207,7 @@ void *ExecutionEngine::updateGlobalMapping(const GlobalValue *GV, void *Addr) { if (!EEState.getGlobalAddressReverseMap(locked).empty()) { AssertingVH &V = EEState.getGlobalAddressReverseMap(locked)[Addr]; - assert((V == 0 || GV == 0) && "GlobalMapping already established!"); + assert((!V || !GV) && "GlobalMapping already established!"); V = GV; } return OldVal; @@ -218,7 +218,7 @@ void *ExecutionEngine::getPointerToGlobalIfAvailable(const GlobalValue *GV) { ExecutionEngineState::GlobalAddressMapTy::iterator I = EEState.getGlobalAddressMap(locked).find(GV); - return I != EEState.getGlobalAddressMap(locked).end() ? I->second : 0; + return I != EEState.getGlobalAddressMap(locked).end() ? I->second : nullptr; } const GlobalValue *ExecutionEngine::getGlobalValueAtAddress(void *Addr) { @@ -235,7 +235,7 @@ const GlobalValue *ExecutionEngine::getGlobalValueAtAddress(void *Addr) { std::map >::iterator I = EEState.getGlobalAddressReverseMap(locked).find(Addr); - return I != EEState.getGlobalAddressReverseMap(locked).end() ? I->second : 0; + return I != EEState.getGlobalAddressReverseMap(locked).end() ? I->second : nullptr; } namespace { @@ -243,11 +243,11 @@ class ArgvArray { char *Array; std::vector Values; public: - ArgvArray() : Array(NULL) {} + ArgvArray() : Array(nullptr) {} ~ArgvArray() { clear(); } void clear() { delete[] Array; - Array = NULL; + Array = nullptr; for (size_t I = 0, E = Values.size(); I != E; ++I) { delete[] Values[I]; } @@ -283,7 +283,7 @@ void *ArgvArray::reset(LLVMContext &C, ExecutionEngine *EE, } // Null terminate it - EE->StoreValueToMemory(PTOGV(0), + EE->StoreValueToMemory(PTOGV(nullptr), (GenericValue*)(Array+InputArgv.size()*PtrSize), SBytePtr); return Array; @@ -303,11 +303,11 @@ void ExecutionEngine::runStaticConstructorsDestructors(Module *module, // Should be an array of '{ i32, void ()* }' structs. The first value is // the init priority, which we ignore. ConstantArray *InitList = dyn_cast(GV->getInitializer()); - if (InitList == 0) + if (!InitList) return; for (unsigned i = 0, e = InitList->getNumOperands(); i != e; ++i) { ConstantStruct *CS = dyn_cast(InitList->getOperand(i)); - if (CS == 0) continue; + if (!CS) continue; Constant *FP = CS->getOperand(1); if (FP->isNullValue()) @@ -418,10 +418,10 @@ ExecutionEngine *ExecutionEngine::createJIT(Module *M, bool GVsWithCode, Reloc::Model RM, CodeModel::Model CMM) { - if (ExecutionEngine::JITCtor == 0) { + if (!ExecutionEngine::JITCtor) { if (ErrorStr) *ErrorStr = "JIT has not been linked in."; - return 0; + return nullptr; } // Use the defaults for extra parameters. Users can use EngineBuilder to @@ -437,7 +437,7 @@ ExecutionEngine *ExecutionEngine::createJIT(Module *M, // TODO: permit custom TargetOptions here TargetMachine *TM = EB.selectTarget(); - if (!TM || (ErrorStr && ErrorStr->length() > 0)) return 0; + if (!TM || (ErrorStr && ErrorStr->length() > 0)) return nullptr; return ExecutionEngine::JITCtor(M, ErrorStr, JMM, GVsWithCode, TM); } @@ -447,8 +447,8 @@ ExecutionEngine *EngineBuilder::create(TargetMachine *TM) { // Make sure we can resolve symbols in the program as well. The zero arg // to the function tells DynamicLibrary to load the program, not a library. - if (sys::DynamicLibrary::LoadLibraryPermanently(0, ErrorStr)) - return 0; + if (sys::DynamicLibrary::LoadLibraryPermanently(nullptr, ErrorStr)) + return nullptr; assert(!(JMM && MCJMM)); @@ -461,7 +461,7 @@ ExecutionEngine *EngineBuilder::create(TargetMachine *TM) { else { if (ErrorStr) *ErrorStr = "Cannot create an interpreter with a memory manager."; - return 0; + return nullptr; } } @@ -470,7 +470,7 @@ ExecutionEngine *EngineBuilder::create(TargetMachine *TM) { *ErrorStr = "Cannot create a legacy JIT with a runtime dyld memory " "manager."; - return 0; + return nullptr; } // Unless the interpreter was explicitly selected or the JIT is not linked, @@ -503,16 +503,16 @@ ExecutionEngine *EngineBuilder::create(TargetMachine *TM) { return ExecutionEngine::InterpCtor(M, ErrorStr); if (ErrorStr) *ErrorStr = "Interpreter has not been linked in."; - return 0; + return nullptr; } - if ((WhichEngine & EngineKind::JIT) && ExecutionEngine::JITCtor == 0 && - ExecutionEngine::MCJITCtor == 0) { + if ((WhichEngine & EngineKind::JIT) && !ExecutionEngine::JITCtor && + !ExecutionEngine::MCJITCtor) { if (ErrorStr) *ErrorStr = "JIT has not been linked in."; } - return 0; + return nullptr; } void *ExecutionEngine::getPointerToGlobal(const GlobalValue *GV) { @@ -848,7 +848,7 @@ GenericValue ExecutionEngine::getConstantValue(const Constant *C) { break; case Type::PointerTyID: if (isa(C)) - Result.PointerVal = 0; + Result.PointerVal = nullptr; else if (const Function *F = dyn_cast(C)) Result = PTOGV(getPointerToFunctionOrStub(const_cast(F))); else if (const GlobalVariable *GV = dyn_cast(C)) @@ -1290,12 +1290,12 @@ void ExecutionEngine::emitGlobals() { void ExecutionEngine::EmitGlobalVariable(const GlobalVariable *GV) { void *GA = getPointerToGlobalIfAvailable(GV); - if (GA == 0) { + if (!GA) { // If it's not already specified, allocate memory for the global. GA = getMemoryForGV(GV); // If we failed to allocate memory for this global, return. - if (GA == 0) return; + if (!GA) return; addGlobalMapping(GV, GA); } diff --git a/lib/ExecutionEngine/ExecutionEngineBindings.cpp b/lib/ExecutionEngine/ExecutionEngineBindings.cpp index db3dead05a..de707a09d5 100644 --- a/lib/ExecutionEngine/ExecutionEngineBindings.cpp +++ b/lib/ExecutionEngine/ExecutionEngineBindings.cpp @@ -410,7 +410,7 @@ uint8_t *SimpleBindingMemoryManager::allocateDataSection( } bool SimpleBindingMemoryManager::finalizeMemory(std::string *ErrMsg) { - char *errMsgCString = 0; + char *errMsgCString = nullptr; bool result = Functions.FinalizeMemory(Opaque, &errMsgCString); assert((result || !errMsgCString) && "Did not expect an error message if FinalizeMemory succeeded"); @@ -433,7 +433,7 @@ LLVMMCJITMemoryManagerRef LLVMCreateSimpleMCJITMemoryManager( if (!AllocateCodeSection || !AllocateDataSection || !FinalizeMemory || !Destroy) - return NULL; + return nullptr; SimpleBindingMMFunctions functions; functions.AllocateCodeSection = AllocateCodeSection; diff --git a/lib/ExecutionEngine/TargetSelect.cpp b/lib/ExecutionEngine/TargetSelect.cpp index 9b7d348979..b10d51f648 100644 --- a/lib/ExecutionEngine/TargetSelect.cpp +++ b/lib/ExecutionEngine/TargetSelect.cpp @@ -47,7 +47,7 @@ TargetMachine *EngineBuilder::selectTarget(const Triple &TargetTriple, TheTriple.setTriple(sys::getProcessTriple()); // Adjust the triple to match what the user requested. - const Target *TheTarget = 0; + const Target *TheTarget = nullptr; if (!MArch.empty()) { for (TargetRegistry::iterator it = TargetRegistry::begin(), ie = TargetRegistry::end(); it != ie; ++it) { @@ -61,7 +61,7 @@ TargetMachine *EngineBuilder::selectTarget(const Triple &TargetTriple, if (ErrorStr) *ErrorStr = "No available targets are compatible with this -march, " "see -version for the available targets.\n"; - return 0; + return nullptr; } // Adjust the triple to match (if known), otherwise stick with the @@ -72,10 +72,10 @@ TargetMachine *EngineBuilder::selectTarget(const Triple &TargetTriple, } else { std::string Error; TheTarget = TargetRegistry::lookupTarget(TheTriple.getTriple(), Error); - if (TheTarget == 0) { + if (!TheTarget) { if (ErrorStr) *ErrorStr = Error; - return 0; + return nullptr; } } -- cgit v1.2.3