From 573faecacf5277b338f27c541c93c364ff284304 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Fri, 25 Apr 2014 04:24:47 +0000 Subject: [C++] Use 'nullptr'. Tools edition. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207176 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/bugpoint/BugDriver.cpp | 8 ++--- tools/bugpoint/CrashDebugger.cpp | 8 ++--- tools/bugpoint/ExecutionDriver.cpp | 8 ++--- tools/bugpoint/ExtractFunction.cpp | 22 ++++++------ tools/bugpoint/FindBugs.cpp | 2 +- tools/bugpoint/Miscompilation.cpp | 6 ++-- tools/bugpoint/OptimizerDriver.cpp | 14 ++++---- tools/bugpoint/ToolRunner.cpp | 34 +++++++++--------- tools/bugpoint/bugpoint.cpp | 2 +- tools/llc/llc.cpp | 10 +++--- tools/lli/RemoteMemoryManager.cpp | 10 +++--- tools/lli/RemoteTarget.cpp | 4 +-- tools/lli/lli.cpp | 12 +++---- tools/llvm-ar/llvm-ar.cpp | 4 +-- tools/llvm-as/llvm-as.cpp | 2 +- tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp | 34 +++++++++--------- tools/llvm-diff/DiffLog.cpp | 4 +-- tools/llvm-dis/llvm-dis.cpp | 4 +-- tools/llvm-extract/llvm-extract.cpp | 2 +- tools/llvm-link/llvm-link.cpp | 8 ++--- tools/llvm-lto/llvm-lto.cpp | 4 +-- tools/llvm-mc/Disassembler.cpp | 2 +- tools/llvm-mc/llvm-mc.cpp | 10 +++--- tools/llvm-objdump/MachODump.cpp | 4 +-- tools/llvm-objdump/llvm-objdump.cpp | 4 +-- tools/llvm-profdata/llvm-profdata.cpp | 2 +- tools/llvm-readobj/ARMAttributeParser.cpp | 60 +++++++++++++++---------------- tools/llvm-readobj/COFFDumper.cpp | 13 +++---- tools/llvm-readobj/ELFDumper.cpp | 3 +- tools/llvm-rtdyld/llvm-rtdyld.cpp | 10 +++--- tools/llvm-size/llvm-size.cpp | 2 +- tools/llvm-stress/llvm-stress.cpp | 4 +-- tools/llvm-symbolizer/LLVMSymbolize.cpp | 26 +++++++------- tools/llvm-symbolizer/llvm-symbolizer.cpp | 2 +- tools/opt/PrintSCC.cpp | 4 +-- tools/opt/opt.cpp | 8 ++--- 36 files changed, 179 insertions(+), 177 deletions(-) diff --git a/tools/bugpoint/BugDriver.cpp b/tools/bugpoint/BugDriver.cpp index 2d1b903829..043863a354 100644 --- a/tools/bugpoint/BugDriver.cpp +++ b/tools/bugpoint/BugDriver.cpp @@ -70,8 +70,8 @@ BugDriver::BugDriver(const char *toolname, bool find_bugs, unsigned timeout, unsigned memlimit, bool use_valgrind, LLVMContext& ctxt) : Context(ctxt), ToolName(toolname), ReferenceOutputFile(OutputFile), - Program(0), Interpreter(0), SafeInterpreter(0), gcc(0), - run_find_bugs(find_bugs), Timeout(timeout), + Program(nullptr), Interpreter(nullptr), SafeInterpreter(nullptr), + gcc(nullptr), run_find_bugs(find_bugs), Timeout(timeout), MemoryLimit(memlimit), UseValgrind(use_valgrind) {} BugDriver::~BugDriver() { @@ -117,13 +117,13 @@ bool BugDriver::addSources(const std::vector &Filenames) { // Load the first input file. Program = ParseInputFile(Filenames[0], Context); - if (Program == 0) return true; + if (!Program) return true; outs() << "Read input file : '" << Filenames[0] << "'\n"; for (unsigned i = 1, e = Filenames.size(); i != e; ++i) { std::unique_ptr M(ParseInputFile(Filenames[i], Context)); - if (M.get() == 0) return true; + if (!M.get()) return true; outs() << "Linking in input file: '" << Filenames[i] << "'\n"; std::string ErrorMessage; diff --git a/tools/bugpoint/CrashDebugger.cpp b/tools/bugpoint/CrashDebugger.cpp index c646ff49b1..8bd61b3c09 100644 --- a/tools/bugpoint/CrashDebugger.cpp +++ b/tools/bugpoint/CrashDebugger.cpp @@ -63,7 +63,7 @@ ReducePassList::doTest(std::vector &Prefix, std::vector &Suffix, std::string &Error) { std::string PrefixOutput; - Module *OrigProgram = 0; + Module *OrigProgram = nullptr; if (!Prefix.empty()) { outs() << "Checking to see if these passes crash: " << getPassesString(Prefix) << ": "; @@ -73,7 +73,7 @@ ReducePassList::doTest(std::vector &Prefix, OrigProgram = BD.Program; BD.Program = ParseInputFile(PrefixOutput, BD.getContext()); - if (BD.Program == 0) { + if (BD.Program == nullptr) { errs() << BD.getToolName() << ": Error reading bitcode file '" << PrefixOutput << "'!\n"; exit(1); @@ -149,7 +149,7 @@ ReduceCrashingGlobalVariables::TestGlobalVariables( for (Module::global_iterator I = M->global_begin(), E = M->global_end(); I != E; ++I) if (I->hasInitializer() && !GVSet.count(I)) { - I->setInitializer(0); + I->setInitializer(nullptr); I->setLinkage(GlobalValue::ExternalLinkage); } @@ -447,7 +447,7 @@ static bool DebugACrash(BugDriver &BD, for (Module::global_iterator I = M->global_begin(), E = M->global_end(); I != E; ++I) if (I->hasInitializer()) { - I->setInitializer(0); + I->setInitializer(nullptr); I->setLinkage(GlobalValue::ExternalLinkage); DeletedInit = true; } diff --git a/tools/bugpoint/ExecutionDriver.cpp b/tools/bugpoint/ExecutionDriver.cpp index 609de03db8..5ed7d2cab3 100644 --- a/tools/bugpoint/ExecutionDriver.cpp +++ b/tools/bugpoint/ExecutionDriver.cpp @@ -145,7 +145,7 @@ bool BugDriver::initializeExecutionEnvironment() { // Create an instance of the AbstractInterpreter interface as specified on // the command line - SafeInterpreter = 0; + SafeInterpreter = nullptr; std::string Message; switch (InterpreterSel) { @@ -256,7 +256,7 @@ bool BugDriver::initializeExecutionEnvironment() { if (!gcc) { outs() << Message << "\nExiting.\n"; exit(1); } // If there was an error creating the selected interpreter, quit with error. - return Interpreter == 0; + return Interpreter == nullptr; } /// compileProgram - Try to compile the specified module, returning false and @@ -298,7 +298,7 @@ std::string BugDriver::executeProgram(const Module *Program, const std::string &SharedObj, AbstractInterpreter *AI, std::string *Error) const { - if (AI == 0) AI = Interpreter; + if (!AI) AI = Interpreter; assert(AI && "Interpreter should have been created already!"); bool CreatedBitcode = false; if (BitcodeFile.empty()) { @@ -445,7 +445,7 @@ bool BugDriver::diffProgram(const Module *Program, std::string *ErrMsg) const { // Execute the program, generating an output file... std::string Output( - executeProgram(Program, "", BitcodeFile, SharedObject, 0, ErrMsg)); + executeProgram(Program, "", BitcodeFile, SharedObject, nullptr, ErrMsg)); if (!ErrMsg->empty()) return false; diff --git a/tools/bugpoint/ExtractFunction.cpp b/tools/bugpoint/ExtractFunction.cpp index d1b1aff778..38cdf241ce 100644 --- a/tools/bugpoint/ExtractFunction.cpp +++ b/tools/bugpoint/ExtractFunction.cpp @@ -51,7 +51,7 @@ namespace { Function* globalInitUsesExternalBA(GlobalVariable* GV) { if (!GV->hasInitializer()) - return 0; + return nullptr; Constant *I = GV->getInitializer(); @@ -78,7 +78,7 @@ namespace { Todo.push_back(C); } } - return 0; + return nullptr; } } // end anonymous namespace @@ -150,7 +150,7 @@ Module *BugDriver::performFinalCleanups(Module *M, bool MayModifySemantics) { CleanupPasses.push_back("deadargelim"); Module *New = runPassesOn(M, CleanupPasses); - if (New == 0) { + if (!New) { errs() << "Final cleanups failed. Sorry. :( Please report a bug!\n"; return M; } @@ -167,11 +167,11 @@ Module *BugDriver::ExtractLoop(Module *M) { LoopExtractPasses.push_back("loop-extract-single"); Module *NewM = runPassesOn(M, LoopExtractPasses); - if (NewM == 0) { + if (!NewM) { outs() << "*** Loop extraction failed: "; EmitProgressBitcode(M, "loopextraction", true); outs() << "*** Sorry. :( Please report a bug!\n"; - return 0; + return nullptr; } // Check to see if we created any new functions. If not, no loops were @@ -180,7 +180,7 @@ Module *BugDriver::ExtractLoop(Module *M) { static unsigned NumExtracted = 32; if (M->size() == NewM->size() || --NumExtracted == 0) { delete NewM; - return 0; + return nullptr; } else { assert(M->size() < NewM->size() && "Loop extract removed functions?"); Module::iterator MI = NewM->begin(); @@ -337,10 +337,10 @@ llvm::SplitFunctionsOutOfModule(Module *M, << "' and from test function '" << TestFn->getName() << "'.\n"; exit(1); } - I->setInitializer(0); // Delete the initializer to make it external + I->setInitializer(nullptr); // Delete the initializer to make it external } else { // If we keep it in the safe module, then delete it in the test module - GV->setInitializer(0); + GV->setInitializer(nullptr); } } @@ -372,7 +372,7 @@ Module *BugDriver::ExtractMappedBlocksFromModule(const outs() << "*** Basic Block extraction failed!\n"; errs() << "Error creating temporary file: " << EC.message() << "\n"; EmitProgressBitcode(M, "basicblockextractfail", true); - return 0; + return nullptr; } sys::RemoveFileOnSignal(Filename); @@ -391,7 +391,7 @@ Module *BugDriver::ExtractMappedBlocksFromModule(const errs() << "Error writing list of blocks to not extract\n"; EmitProgressBitcode(M, "basicblockextractfail", true); BlocksToNotExtractFile.os().clear_error(); - return 0; + return nullptr; } BlocksToNotExtractFile.keep(); @@ -405,7 +405,7 @@ Module *BugDriver::ExtractMappedBlocksFromModule(const sys::fs::remove(Filename.c_str()); - if (Ret == 0) { + if (!Ret) { outs() << "*** Basic Block extraction failed, please report a bug!\n"; EmitProgressBitcode(M, "basicblockextractfail", true); } diff --git a/tools/bugpoint/FindBugs.cpp b/tools/bugpoint/FindBugs.cpp index e2941f6f43..a0c859b7f3 100644 --- a/tools/bugpoint/FindBugs.cpp +++ b/tools/bugpoint/FindBugs.cpp @@ -45,7 +45,7 @@ bool BugDriver::runManyPasses(const std::vector &AllPasses, return false; } - srand(time(NULL)); + srand(time(nullptr)); unsigned num = 1; while(1) { diff --git a/tools/bugpoint/Miscompilation.cpp b/tools/bugpoint/Miscompilation.cpp index fecae60c41..f5936ac88e 100644 --- a/tools/bugpoint/Miscompilation.cpp +++ b/tools/bugpoint/Miscompilation.cpp @@ -235,7 +235,7 @@ static Module *TestMergedProgram(const BugDriver &BD, Module *M1, Module *M2, if (!Error.empty()) { // Delete the linked module delete M1; - return NULL; + return nullptr; } return M1; } @@ -592,7 +592,7 @@ static bool ExtractBlocks(BugDriver &BD, MiscompiledFunctions, VMap); Module *Extracted = BD.ExtractMappedBlocksFromModule(Blocks, ToExtract); - if (Extracted == 0) { + if (!Extracted) { // Weird, extraction should have worked. errs() << "Nondeterministic problem extracting blocks??\n"; delete ProgClone; @@ -845,7 +845,7 @@ static void CleanupAndPrepareModules(BugDriver &BD, Module *&Test, Safe->getOrInsertFunction("getPointerToNamedFunction", Type::getInt8PtrTy(Safe->getContext()), Type::getInt8PtrTy(Safe->getContext()), - (Type *)0); + (Type *)nullptr); // Use the function we just added to get addresses of functions we need. for (Module::iterator F = Safe->begin(), E = Safe->end(); F != E; ++F) { diff --git a/tools/bugpoint/OptimizerDriver.cpp b/tools/bugpoint/OptimizerDriver.cpp index eaea9d9ed5..b2722e6d0e 100644 --- a/tools/bugpoint/OptimizerDriver.cpp +++ b/tools/bugpoint/OptimizerDriver.cpp @@ -196,7 +196,7 @@ bool BugDriver::runPasses(Module *Program, Args.push_back(InputFilename.c_str()); for (unsigned i = 0; i < NumExtraArgs; ++i) Args.push_back(*ExtraArgs); - Args.push_back(0); + Args.push_back(nullptr); DEBUG(errs() << "\nAbout to run:\t"; for (unsigned i = 0, e = Args.size()-1; i != e; ++i) @@ -212,12 +212,12 @@ bool BugDriver::runPasses(Module *Program, // Redirect stdout and stderr to nowhere if SilencePasses is given StringRef Nowhere; - const StringRef *Redirects[3] = {0, &Nowhere, &Nowhere}; + const StringRef *Redirects[3] = {nullptr, &Nowhere, &Nowhere}; std::string ErrMsg; - int result = sys::ExecuteAndWait(Prog, Args.data(), 0, - (SilencePasses ? Redirects : 0), Timeout, - MemoryLimit, &ErrMsg); + int result = sys::ExecuteAndWait(Prog, Args.data(), nullptr, + (SilencePasses ? Redirects : nullptr), + Timeout, MemoryLimit, &ErrMsg); // If we are supposed to delete the bitcode file or if the passes crashed, // remove it now. This may fail if the file was never created, but that's ok. @@ -264,11 +264,11 @@ Module *BugDriver::runPassesOn(Module *M, EmitProgressBitcode(M, "pass-error", false); exit(debugOptimizerCrash()); } - return 0; + return nullptr; } Module *Ret = ParseInputFile(BitcodeResult, Context); - if (Ret == 0) { + if (!Ret) { errs() << getToolName() << ": Error reading bitcode file '" << BitcodeResult << "'!\n"; exit(1); diff --git a/tools/bugpoint/ToolRunner.cpp b/tools/bugpoint/ToolRunner.cpp index e1c995f519..c481b03e2b 100644 --- a/tools/bugpoint/ToolRunner.cpp +++ b/tools/bugpoint/ToolRunner.cpp @@ -62,7 +62,7 @@ static int RunProgramWithTimeout(StringRef ProgramPath, StringRef StdErrFile, unsigned NumSeconds = 0, unsigned MemoryLimit = 0, - std::string *ErrMsg = 0) { + std::string *ErrMsg = nullptr) { const StringRef *Redirects[3] = { &StdInFile, &StdOutFile, &StdErrFile }; #if 0 // For debug purposes @@ -74,7 +74,7 @@ static int RunProgramWithTimeout(StringRef ProgramPath, } #endif - return sys::ExecuteAndWait(ProgramPath, Args, 0, Redirects, + return sys::ExecuteAndWait(ProgramPath, Args, nullptr, Redirects, NumSeconds, MemoryLimit, ErrMsg); } @@ -103,7 +103,7 @@ static int RunProgramRemotelyWithTimeout(StringRef RemoteClientPath, #endif // Run the program remotely with the remote client - int ReturnCode = sys::ExecuteAndWait(RemoteClientPath, Args, 0, + int ReturnCode = sys::ExecuteAndWait(RemoteClientPath, Args, nullptr, Redirects, NumSeconds, MemoryLimit); // Has the remote client fail? @@ -219,7 +219,7 @@ int LLI::ExecuteProgram(const std::string &Bitcode, // Add optional parameters to the running program from Argv for (unsigned i=0, e = Args.size(); i != e; ++i) LLIArgs.push_back(Args[i].c_str()); - LLIArgs.push_back(0); + LLIArgs.push_back(nullptr); outs() << ""; outs().flush(); DEBUG(errs() << "\nAbout to run:\t"; @@ -277,7 +277,7 @@ AbstractInterpreter *AbstractInterpreter::createLLI(const char *Argv0, } Message = "Cannot find `lli' in executable directory!\n"; - return 0; + return nullptr; } //===---------------------------------------------------------------------===// @@ -328,7 +328,7 @@ void CustomCompiler::compileProgram(const std::string &Bitcode, for (std::size_t i = 0; i < CompilerArgs.size(); ++i) ProgramArgs.push_back(CompilerArgs.at(i).c_str()); ProgramArgs.push_back(Bitcode.c_str()); - ProgramArgs.push_back(0); + ProgramArgs.push_back(nullptr); // Add optional parameters to the running program from Argv for (unsigned i = 0, e = CompilerArgs.size(); i != e; ++i) @@ -385,7 +385,7 @@ int CustomExecutor::ExecuteProgram(const std::string &Bitcode, for (std::size_t i = 0; i < ExecutorArgs.size(); ++i) ProgramArgs.push_back(ExecutorArgs.at(i).c_str()); ProgramArgs.push_back(Bitcode.c_str()); - ProgramArgs.push_back(0); + ProgramArgs.push_back(nullptr); // Add optional parameters to the running program from Argv for (unsigned i = 0, e = Args.size(); i != e; ++i) @@ -448,7 +448,7 @@ AbstractInterpreter *AbstractInterpreter::createCustomCompiler( std::vector Args; lexCommand(Message, CompileCommandLine, CmdPath, Args); if (CmdPath.empty()) - return 0; + return nullptr; return new CustomCompiler(CmdPath, Args); } @@ -464,7 +464,7 @@ AbstractInterpreter *AbstractInterpreter::createCustomExecutor( std::vector Args; lexCommand(Message, ExecCommandLine, CmdPath, Args); if (CmdPath.empty()) - return 0; + return nullptr; return new CustomExecutor(CmdPath, Args); } @@ -499,7 +499,7 @@ GCC::FileType LLC::OutputCode(const std::string &Bitcode, if (UseIntegratedAssembler) LLCArgs.push_back("-filetype=obj"); - LLCArgs.push_back (0); + LLCArgs.push_back (nullptr); outs() << (UseIntegratedAssembler ? "" : ""); outs().flush(); @@ -559,7 +559,7 @@ LLC *AbstractInterpreter::createLLC(const char *Argv0, PrependMainExecutablePath("llc", Argv0, (void *)(intptr_t) & createLLC); if (LLCPath.empty()) { Message = "Cannot find `llc' in executable directory!\n"; - return 0; + return nullptr; } GCC *gcc = GCC::create(Message, GCCBinary, GCCArgs); @@ -625,7 +625,7 @@ int JIT::ExecuteProgram(const std::string &Bitcode, // Add optional parameters to the running program from Argv for (unsigned i=0, e = Args.size(); i != e; ++i) JITArgs.push_back(Args[i].c_str()); - JITArgs.push_back(0); + JITArgs.push_back(nullptr); outs() << ""; outs().flush(); DEBUG(errs() << "\nAbout to run:\t"; @@ -651,7 +651,7 @@ AbstractInterpreter *AbstractInterpreter::createJIT(const char *Argv0, } Message = "Cannot find `lli' in executable directory!\n"; - return 0; + return nullptr; } //===---------------------------------------------------------------------===// @@ -737,7 +737,7 @@ int GCC::ExecuteProgram(const std::string &ProgramFile, #endif if (TargetTriple.getArch() == Triple::sparc) GCCArgs.push_back("-mcpu=v9"); - GCCArgs.push_back(0); // NULL terminator + GCCArgs.push_back(nullptr); // NULL terminator outs() << ""; outs().flush(); DEBUG(errs() << "\nAbout to run:\t"; @@ -786,7 +786,7 @@ int GCC::ExecuteProgram(const std::string &ProgramFile, // Add optional parameters to the running program from Argv for (unsigned i = 0, e = Args.size(); i != e; ++i) ProgramArgs.push_back(Args[i].c_str()); - ProgramArgs.push_back(0); // NULL terminator + ProgramArgs.push_back(nullptr); // NULL terminator // Now that we have a binary, run it! outs() << ""; outs().flush(); @@ -885,7 +885,7 @@ int GCC::MakeSharedObject(const std::string &InputFile, FileType fileType, // command line, so this should be safe. for (unsigned i = 0, e = ArgsForGCC.size(); i != e; ++i) GCCArgs.push_back(ArgsForGCC[i].c_str()); - GCCArgs.push_back(0); // NULL terminator + GCCArgs.push_back(nullptr); // NULL terminator @@ -910,7 +910,7 @@ GCC *GCC::create(std::string &Message, std::string GCCPath = sys::FindProgramByName(GCCBinary); if (GCCPath.empty()) { Message = "Cannot find `"+ GCCBinary +"' in PATH!\n"; - return 0; + return nullptr; } std::string RemoteClientPath; diff --git a/tools/bugpoint/bugpoint.cpp b/tools/bugpoint/bugpoint.cpp index 5c03b41abb..c7dae0f45b 100644 --- a/tools/bugpoint/bugpoint.cpp +++ b/tools/bugpoint/bugpoint.cpp @@ -99,7 +99,7 @@ namespace { class AddToDriver : public FunctionPassManager { BugDriver &D; public: - AddToDriver(BugDriver &_D) : FunctionPassManager(0), D(_D) {} + AddToDriver(BugDriver &_D) : FunctionPassManager(nullptr), D(_D) {} void add(Pass *P) override { const void *ID = P->getPassID(); diff --git a/tools/llc/llc.cpp b/tools/llc/llc.cpp index 0c8d14d11d..6dc5a32263 100644 --- a/tools/llc/llc.cpp +++ b/tools/llc/llc.cpp @@ -157,7 +157,7 @@ static tool_output_file *GetOutputStream(const char *TargetName, if (!error.empty()) { errs() << error << '\n'; delete FDOut; - return 0; + return nullptr; } return FDOut; @@ -207,7 +207,7 @@ static int compileModule(char **argv, LLVMContext &Context) { // Load the module to be compiled... SMDiagnostic Err; std::unique_ptr M; - Module *mod = 0; + Module *mod = nullptr; Triple TheTriple; bool SkipModule = MCPU == "help" || @@ -223,7 +223,7 @@ static int compileModule(char **argv, LLVMContext &Context) { if (!SkipModule) { M.reset(ParseIRFile(InputFilename, Err, Context)); mod = M.get(); - if (mod == 0) { + if (mod == nullptr) { Err.print(argv[0], errs()); return 1; } @@ -321,8 +321,8 @@ static int compileModule(char **argv, LLVMContext &Context) { { formatted_raw_ostream FOS(Out->os()); - AnalysisID StartAfterID = 0; - AnalysisID StopAfterID = 0; + AnalysisID StartAfterID = nullptr; + AnalysisID StopAfterID = nullptr; const PassRegistry *PR = PassRegistry::getPassRegistry(); if (!StartAfter.empty()) { const PassInfo *PI = PR->getPassInfo(StartAfter); diff --git a/tools/lli/RemoteMemoryManager.cpp b/tools/lli/RemoteMemoryManager.cpp index 7e0f8cb76d..200ab75152 100644 --- a/tools/lli/RemoteMemoryManager.cpp +++ b/tools/lli/RemoteMemoryManager.cpp @@ -179,16 +179,16 @@ void RemoteMemoryManager::setPoisonMemory(bool poison) { llvm_unreachable("Unexp void RemoteMemoryManager::AllocateGOT() { llvm_unreachable("Unexpected!"); } uint8_t *RemoteMemoryManager::getGOTBase() const { llvm_unreachable("Unexpected!"); - return 0; + return nullptr; } uint8_t *RemoteMemoryManager::startFunctionBody(const Function *F, uintptr_t &ActualSize){ llvm_unreachable("Unexpected!"); - return 0; + return nullptr; } uint8_t *RemoteMemoryManager::allocateStub(const GlobalValue* F, unsigned StubSize, unsigned Alignment) { llvm_unreachable("Unexpected!"); - return 0; + return nullptr; } void RemoteMemoryManager::endFunctionBody(const Function *F, uint8_t *FunctionStart, uint8_t *FunctionEnd) { @@ -196,11 +196,11 @@ void RemoteMemoryManager::endFunctionBody(const Function *F, uint8_t *FunctionSt } uint8_t *RemoteMemoryManager::allocateSpace(intptr_t Size, unsigned Alignment) { llvm_unreachable("Unexpected!"); - return 0; + return nullptr; } uint8_t *RemoteMemoryManager::allocateGlobal(uintptr_t Size, unsigned Alignment) { llvm_unreachable("Unexpected!"); - return 0; + return nullptr; } void RemoteMemoryManager::deallocateFunctionBody(void *Body) { llvm_unreachable("Unexpected!"); diff --git a/tools/lli/RemoteTarget.cpp b/tools/lli/RemoteTarget.cpp index 55fc064ad3..850fdc5069 100644 --- a/tools/lli/RemoteTarget.cpp +++ b/tools/lli/RemoteTarget.cpp @@ -30,9 +30,9 @@ using namespace llvm; bool RemoteTarget::allocateSpace(size_t Size, unsigned Alignment, uint64_t &Address) { - sys::MemoryBlock *Prev = Allocations.size() ? &Allocations.back() : NULL; + sys::MemoryBlock *Prev = Allocations.size() ? &Allocations.back() : nullptr; sys::MemoryBlock Mem = sys::Memory::AllocateRWX(Size, Prev, &ErrorMsg); - if (Mem.base() == NULL) + if (Mem.base() == nullptr) return false; if ((uintptr_t)Mem.base() % Alignment) { ErrorMsg = "unable to allocate sufficiently aligned memory"; diff --git a/tools/lli/lli.cpp b/tools/lli/lli.cpp index 904a9e5830..f1413f302a 100644 --- a/tools/lli/lli.cpp +++ b/tools/lli/lli.cpp @@ -283,13 +283,13 @@ public: const std::string ModuleID = M->getModuleIdentifier(); std::string CacheName; if (!getCacheFilename(ModuleID, CacheName)) - return NULL; + return nullptr; // Load the object from the cache filename std::unique_ptr IRObjectBuffer; MemoryBuffer::getFile(CacheName.c_str(), IRObjectBuffer, -1, false); // If the file isn't there, that's OK. if (!IRObjectBuffer) - return NULL; + return nullptr; // MCJIT will want to write into this buffer, and we don't want that // because the file has probably just been mmapped. Instead we make // a copy. The filed-based buffer will be released when it goes @@ -320,8 +320,8 @@ private: } }; -static ExecutionEngine *EE = 0; -static LLIObjectCache *CacheManager = 0; +static ExecutionEngine *EE = nullptr; +static LLIObjectCache *CacheManager = nullptr; static void do_shutdown() { // Cygwin-1.5 invokes DLL's dtors before atexit handler. @@ -450,7 +450,7 @@ int main(int argc, char **argv, char * const *envp) { Mod->setTargetTriple(Triple::normalize(TargetTriple)); // Enable MCJIT if desired. - RTDyldMemoryManager *RTDyldMM = 0; + RTDyldMemoryManager *RTDyldMM = nullptr; if (UseMCJIT && !ForceInterpreter) { builder.setUseMCJIT(true); if (RemoteMCJIT) @@ -463,7 +463,7 @@ int main(int argc, char **argv, char * const *envp) { errs() << "error: Remote process execution requires -use-mcjit\n"; exit(1); } - builder.setJITMemoryManager(ForceInterpreter ? 0 : + builder.setJITMemoryManager(ForceInterpreter ? nullptr : JITMemoryManager::CreateDefaultMemManager()); } diff --git a/tools/llvm-ar/llvm-ar.cpp b/tools/llvm-ar/llvm-ar.cpp index 047f54e56e..db95674d36 100644 --- a/tools/llvm-ar/llvm-ar.cpp +++ b/tools/llvm-ar/llvm-ar.cpp @@ -856,7 +856,7 @@ static void performWriteOperation(ArchiveOperation Operation, Output.keep(); Out.close(); sys::fs::rename(TemporaryOutput, ArchiveName); - TemporaryOutput = NULL; + TemporaryOutput = nullptr; } static void createSymbolTable(object::Archive *OldArchive) { @@ -969,6 +969,6 @@ static int performOperation(ArchiveOperation Operation) { } } - performOperation(Operation, NULL); + performOperation(Operation, nullptr); return 0; } diff --git a/tools/llvm-as/llvm-as.cpp b/tools/llvm-as/llvm-as.cpp index 7583b121b4..70c95080e9 100644 --- a/tools/llvm-as/llvm-as.cpp +++ b/tools/llvm-as/llvm-as.cpp @@ -94,7 +94,7 @@ int main(int argc, char **argv) { // Parse the file now... SMDiagnostic Err; std::unique_ptr M(ParseAssemblyFile(InputFilename, Err, Context)); - if (M.get() == 0) { + if (!M.get()) { Err.print(argv[0], errs()); return 1; } diff --git a/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp b/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp index 9e17783e70..dfdaa03163 100644 --- a/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp +++ b/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp @@ -84,7 +84,7 @@ static const char *GetBlockName(unsigned BlockID, if (BlockID < bitc::FIRST_APPLICATION_BLOCKID) { if (BlockID == bitc::BLOCKINFO_BLOCK_ID) return "BLOCKINFO_BLOCK"; - return 0; + return nullptr; } // Check to see if we have a blockinfo record for this block, with a name. @@ -95,10 +95,10 @@ static const char *GetBlockName(unsigned BlockID, } - if (CurStreamType != LLVMIRBitstream) return 0; + if (CurStreamType != LLVMIRBitstream) return nullptr; switch (BlockID) { - default: return 0; + default: return nullptr; case bitc::MODULE_BLOCK_ID: return "MODULE_BLOCK"; case bitc::PARAMATTR_BLOCK_ID: return "PARAMATTR_BLOCK"; case bitc::PARAMATTR_GROUP_BLOCK_ID: return "PARAMATTR_GROUP_BLOCK_ID"; @@ -120,13 +120,13 @@ static const char *GetCodeName(unsigned CodeID, unsigned BlockID, if (BlockID < bitc::FIRST_APPLICATION_BLOCKID) { if (BlockID == bitc::BLOCKINFO_BLOCK_ID) { switch (CodeID) { - default: return 0; + default: return nullptr; case bitc::BLOCKINFO_CODE_SETBID: return "SETBID"; case bitc::BLOCKINFO_CODE_BLOCKNAME: return "BLOCKNAME"; case bitc::BLOCKINFO_CODE_SETRECORDNAME: return "SETRECORDNAME"; } } - return 0; + return nullptr; } // Check to see if we have a blockinfo record for this record, with a name. @@ -138,13 +138,13 @@ static const char *GetCodeName(unsigned CodeID, unsigned BlockID, } - if (CurStreamType != LLVMIRBitstream) return 0; + if (CurStreamType != LLVMIRBitstream) return nullptr; switch (BlockID) { - default: return 0; + default: return nullptr; case bitc::MODULE_BLOCK_ID: switch (CodeID) { - default: return 0; + default: return nullptr; case bitc::MODULE_CODE_VERSION: return "VERSION"; case bitc::MODULE_CODE_TRIPLE: return "TRIPLE"; case bitc::MODULE_CODE_DATALAYOUT: return "DATALAYOUT"; @@ -159,14 +159,14 @@ static const char *GetCodeName(unsigned CodeID, unsigned BlockID, } case bitc::PARAMATTR_BLOCK_ID: switch (CodeID) { - default: return 0; + default: return nullptr; case bitc::PARAMATTR_CODE_ENTRY_OLD: return "ENTRY"; case bitc::PARAMATTR_CODE_ENTRY: return "ENTRY"; case bitc::PARAMATTR_GRP_CODE_ENTRY: return "ENTRY"; } case bitc::TYPE_BLOCK_ID_NEW: switch (CodeID) { - default: return 0; + default: return nullptr; case bitc::TYPE_CODE_NUMENTRY: return "NUMENTRY"; case bitc::TYPE_CODE_VOID: return "VOID"; case bitc::TYPE_CODE_FLOAT: return "FLOAT"; @@ -189,7 +189,7 @@ static const char *GetCodeName(unsigned CodeID, unsigned BlockID, case bitc::CONSTANTS_BLOCK_ID: switch (CodeID) { - default: return 0; + default: return nullptr; case bitc::CST_CODE_SETTYPE: return "SETTYPE"; case bitc::CST_CODE_NULL: return "NULL"; case bitc::CST_CODE_UNDEF: return "UNDEF"; @@ -215,7 +215,7 @@ static const char *GetCodeName(unsigned CodeID, unsigned BlockID, } case bitc::FUNCTION_BLOCK_ID: switch (CodeID) { - default: return 0; + default: return nullptr; case bitc::FUNC_CODE_DECLAREBLOCKS: return "DECLAREBLOCKS"; case bitc::FUNC_CODE_INST_BINOP: return "INST_BINOP"; @@ -249,18 +249,18 @@ static const char *GetCodeName(unsigned CodeID, unsigned BlockID, } case bitc::VALUE_SYMTAB_BLOCK_ID: switch (CodeID) { - default: return 0; + default: return nullptr; case bitc::VST_CODE_ENTRY: return "ENTRY"; case bitc::VST_CODE_BBENTRY: return "BBENTRY"; } case bitc::METADATA_ATTACHMENT_ID: switch(CodeID) { - default:return 0; + default:return nullptr; case bitc::METADATA_ATTACHMENT: return "METADATA_ATTACHMENT"; } case bitc::METADATA_BLOCK_ID: switch(CodeID) { - default:return 0; + default:return nullptr; case bitc::METADATA_STRING: return "METADATA_STRING"; case bitc::METADATA_NAME: return "METADATA_NAME"; case bitc::METADATA_KIND: return "METADATA_KIND"; @@ -270,7 +270,7 @@ static const char *GetCodeName(unsigned CodeID, unsigned BlockID, } case bitc::USELIST_BLOCK_ID: switch(CodeID) { - default:return 0; + default:return nullptr; case bitc::USELIST_CODE_ENTRY: return "USELIST_CODE_ENTRY"; } } @@ -345,7 +345,7 @@ static bool ParseBlock(BitstreamCursor &Stream, unsigned BlockID, if (Stream.EnterSubBlock(BlockID, &NumWords)) return Error("Malformed block record"); - const char *BlockName = 0; + const char *BlockName = nullptr; if (Dump) { outs() << Indent << "<"; if ((BlockName = GetBlockName(BlockID, *Stream.getBitStreamReader()))) diff --git a/tools/llvm-diff/DiffLog.cpp b/tools/llvm-diff/DiffLog.cpp index caf779bb40..24a1b08d54 100644 --- a/tools/llvm-diff/DiffLog.cpp +++ b/tools/llvm-diff/DiffLog.cpp @@ -35,11 +35,11 @@ void DiffLogBuilder::addMatch(Instruction *L, Instruction *R) { } void DiffLogBuilder::addLeft(Instruction *L) { // HACK: VS 2010 has a bug in the stdlib that requires this. - Diff.push_back(DiffRecord(L, DiffRecord::second_type(0))); + Diff.push_back(DiffRecord(L, DiffRecord::second_type(nullptr))); } void DiffLogBuilder::addRight(Instruction *R) { // HACK: VS 2010 has a bug in the stdlib that requires this. - Diff.push_back(DiffRecord(DiffRecord::first_type(0), R)); + Diff.push_back(DiffRecord(DiffRecord::first_type(nullptr), R)); } unsigned DiffLogBuilder::getNumLines() const { return Diff.size(); } diff --git a/tools/llvm-dis/llvm-dis.cpp b/tools/llvm-dis/llvm-dis.cpp index c6f0dcf6ae..2c9322ea56 100644 --- a/tools/llvm-dis/llvm-dis.cpp +++ b/tools/llvm-dis/llvm-dis.cpp @@ -135,7 +135,7 @@ int main(int argc, char **argv) { DisplayFilename = InputFilename; M.reset(getStreamedBitcodeModule(DisplayFilename, streamer, Context, &ErrorMessage)); - if(M.get() != 0) { + if(M.get()) { if (error_code EC = M->materializeAllPermanently()) { ErrorMessage = EC.message(); M.reset(); @@ -143,7 +143,7 @@ int main(int argc, char **argv) { } } - if (M.get() == 0) { + if (!M.get()) { errs() << argv[0] << ": "; if (ErrorMessage.size()) errs() << ErrorMessage << "\n"; diff --git a/tools/llvm-extract/llvm-extract.cpp b/tools/llvm-extract/llvm-extract.cpp index 2e5a2af244..4131177bd4 100644 --- a/tools/llvm-extract/llvm-extract.cpp +++ b/tools/llvm-extract/llvm-extract.cpp @@ -103,7 +103,7 @@ int main(int argc, char **argv) { std::unique_ptr M; M.reset(getLazyIRFileModule(InputFilename, Err, Context)); - if (M.get() == 0) { + if (!M.get()) { Err.print(argv[0], errs()); return 1; } diff --git a/tools/llvm-link/llvm-link.cpp b/tools/llvm-link/llvm-link.cpp index 1f0e2246ce..a756a1c33a 100644 --- a/tools/llvm-link/llvm-link.cpp +++ b/tools/llvm-link/llvm-link.cpp @@ -61,13 +61,13 @@ static inline Module *LoadFile(const char *argv0, const std::string &FN, LLVMContext& Context) { SMDiagnostic Err; if (Verbose) errs() << "Loading '" << FN << "'\n"; - Module* Result = 0; + Module* Result = nullptr; Result = ParseIRFile(FN, Err, Context); if (Result) return Result; // Load successful! Err.print(argv0, errs()); - return NULL; + return nullptr; } int main(int argc, char **argv) { @@ -84,7 +84,7 @@ int main(int argc, char **argv) { std::unique_ptr Composite( LoadFile(argv[0], InputFilenames[BaseArg], Context)); - if (Composite.get() == 0) { + if (!Composite.get()) { errs() << argv[0] << ": error loading file '" << InputFilenames[BaseArg] << "'\n"; return 1; @@ -93,7 +93,7 @@ int main(int argc, char **argv) { Linker L(Composite.get(), SuppressWarnings); for (unsigned i = BaseArg+1; i < InputFilenames.size(); ++i) { std::unique_ptr M(LoadFile(argv[0], InputFilenames[i], Context)); - if (M.get() == 0) { + if (!M.get()) { errs() << argv[0] << ": error loading file '" <(Code), len); } else { std::string ErrorInfo; - const char *OutputName = NULL; + const char *OutputName = nullptr; if (!CodeGen.compile_to_file(&OutputName, DisableOpt, DisableInline, DisableGVNLoadPRE, ErrorInfo)) { errs() << argv[0] diff --git a/tools/llvm-mc/Disassembler.cpp b/tools/llvm-mc/Disassembler.cpp index 28629c10c1..9367590398 100644 --- a/tools/llvm-mc/Disassembler.cpp +++ b/tools/llvm-mc/Disassembler.cpp @@ -175,7 +175,7 @@ int Disassembler::disassemble(const Target &T, } // Set up the MCContext for creating symbols and MCExpr's. - MCContext Ctx(MAI.get(), MRI.get(), 0); + MCContext Ctx(MAI.get(), MRI.get(), nullptr); std::unique_ptr DisAsm( T.createMCDisassembler(STI, Ctx)); diff --git a/tools/llvm-mc/llvm-mc.cpp b/tools/llvm-mc/llvm-mc.cpp index a8a3d994b5..dbe012b4d4 100644 --- a/tools/llvm-mc/llvm-mc.cpp +++ b/tools/llvm-mc/llvm-mc.cpp @@ -198,7 +198,7 @@ static const Target *GetTarget(const char *ProgName) { Error); if (!TheTarget) { errs() << ProgName << ": " << Error; - return 0; + return nullptr; } // Update the triple name and return the found target. @@ -216,7 +216,7 @@ static tool_output_file *GetOutputStream() { if (!Err.empty()) { errs() << Err << '\n'; delete Out; - return 0; + return nullptr; } return Out; @@ -435,12 +435,12 @@ int main(int argc, char **argv) { std::unique_ptr STI( TheTarget->createMCSubtargetInfo(TripleName, MCPU, FeaturesStr)); - MCInstPrinter *IP = NULL; + MCInstPrinter *IP = nullptr; if (FileType == OFT_AssemblyFile) { IP = TheTarget->createMCInstPrinter(OutputAsmVariant, *MAI, *MCII, *MRI, *STI); - MCCodeEmitter *CE = 0; - MCAsmBackend *MAB = 0; + MCCodeEmitter *CE = nullptr; + MCAsmBackend *MAB = nullptr; if (ShowEncoding) { CE = TheTarget->createMCCodeEmitter(*MCII, *MRI, *STI, Ctx); MAB = TheTarget->createMCAsmBackend(*MRI, TripleName, MCPU); diff --git a/tools/llvm-objdump/MachODump.cpp b/tools/llvm-objdump/MachODump.cpp index 376948e382..3ca582fdab 100644 --- a/tools/llvm-objdump/MachODump.cpp +++ b/tools/llvm-objdump/MachODump.cpp @@ -65,7 +65,7 @@ static const Target *GetTarget(const MachOObjectFile *MachOObj) { errs() << "llvm-objdump: error: unable to get target for '" << TripleName << "', see --version and --triple.\n"; - return 0; + return nullptr; } struct SymbolSorter { @@ -226,7 +226,7 @@ static void DisassembleInputMachO2(StringRef Filename, TheTarget->createMCAsmInfo(*MRI, TripleName)); std::unique_ptr STI( TheTarget->createMCSubtargetInfo(TripleName, "", "")); - MCContext Ctx(AsmInfo.get(), MRI.get(), 0); + MCContext Ctx(AsmInfo.get(), MRI.get(), nullptr); std::unique_ptr DisAsm( TheTarget->createMCDisassembler(*STI, Ctx)); int AsmPrinterVariant = AsmInfo->getAssemblerDialect(); diff --git a/tools/llvm-objdump/llvm-objdump.cpp b/tools/llvm-objdump/llvm-objdump.cpp index a4b94c9b6a..a4fc6d0e33 100644 --- a/tools/llvm-objdump/llvm-objdump.cpp +++ b/tools/llvm-objdump/llvm-objdump.cpp @@ -157,7 +157,7 @@ bool llvm::error(error_code EC) { return true; } -static const Target *getTarget(const ObjectFile *Obj = NULL) { +static const Target *getTarget(const ObjectFile *Obj = nullptr) { // Figure out the target triple. llvm::Triple TheTriple("unknown-unknown-unknown"); if (TripleName.empty()) { @@ -183,7 +183,7 @@ static const Target *getTarget(const ObjectFile *Obj = NULL) { Error); if (!TheTarget) { errs() << ToolName << ": " << Error; - return 0; + return nullptr; } // Update the triple name and return the found target. diff --git a/tools/llvm-profdata/llvm-profdata.cpp b/tools/llvm-profdata/llvm-profdata.cpp index 3e58bc205d..17710f64ae 100644 --- a/tools/llvm-profdata/llvm-profdata.cpp +++ b/tools/llvm-profdata/llvm-profdata.cpp @@ -156,7 +156,7 @@ int main(int argc, const char *argv[]) { StringRef ProgName(sys::path::filename(argv[0])); if (argc > 1) { - int (*func)(int, const char *[]) = 0; + int (*func)(int, const char *[]) = nullptr; if (strcmp(argv[1], "merge") == 0) func = merge_main; diff --git a/tools/llvm-readobj/ARMAttributeParser.cpp b/tools/llvm-readobj/ARMAttributeParser.cpp index cd0bcd4cb9..d35cd14265 100644 --- a/tools/llvm-readobj/ARMAttributeParser.cpp +++ b/tools/llvm-readobj/ARMAttributeParser.cpp @@ -126,7 +126,7 @@ void ARMAttributeParser::CPU_arch(AttrType Tag, const uint8_t *Data, uint64_t Value = ParseInteger(Data, Offset); StringRef ValueDesc = - (Value < array_lengthof(Strings)) ? Strings[Value] : NULL; + (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr; PrintAttribute(Tag, Value, ValueDesc); } @@ -153,7 +153,7 @@ void ARMAttributeParser::ARM_ISA_use(AttrType Tag, const uint8_t *Data, uint64_t Value = ParseInteger(Data, Offset); StringRef ValueDesc = - (Value < array_lengthof(Strings)) ? Strings[Value] : NULL; + (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr; PrintAttribute(Tag, Value, ValueDesc); } @@ -163,7 +163,7 @@ void ARMAttributeParser::THUMB_ISA_use(AttrType Tag, const uint8_t *Data, uint64_t Value = ParseInteger(Data, Offset); StringRef ValueDesc = - (Value < array_lengthof(Strings)) ? Strings[Value] : NULL; + (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr; PrintAttribute(Tag, Value, ValueDesc); } @@ -176,7 +176,7 @@ void ARMAttributeParser::FP_arch(AttrType Tag, const uint8_t *Data, uint64_t Value = ParseInteger(Data, Offset); StringRef ValueDesc = - (Value < array_lengthof(Strings)) ? Strings[Value] : NULL; + (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr; PrintAttribute(Tag, Value, ValueDesc); } @@ -186,7 +186,7 @@ void ARMAttributeParser::WMMX_arch(AttrType Tag, const uint8_t *Data, uint64_t Value = ParseInteger(Data, Offset); StringRef ValueDesc = - (Value < array_lengthof(Strings)) ? Strings[Value] : NULL; + (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr; PrintAttribute(Tag, Value, ValueDesc); } @@ -198,7 +198,7 @@ void ARMAttributeParser::Advanced_SIMD_arch(AttrType Tag, const uint8_t *Data, uint64_t Value = ParseInteger(Data, Offset); StringRef ValueDesc = - (Value < array_lengthof(Strings)) ? Strings[Value] : NULL; + (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr; PrintAttribute(Tag, Value, ValueDesc); } @@ -211,7 +211,7 @@ void ARMAttributeParser::PCS_config(AttrType Tag, const uint8_t *Data, uint64_t Value = ParseInteger(Data, Offset); StringRef ValueDesc = - (Value < array_lengthof(Strings)) ? Strings[Value] : NULL; + (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr; PrintAttribute(Tag, Value, ValueDesc); } @@ -221,7 +221,7 @@ void ARMAttributeParser::ABI_PCS_R9_use(AttrType Tag, const uint8_t *Data, uint64_t Value = ParseInteger(Data, Offset); StringRef ValueDesc = - (Value < array_lengthof(Strings)) ? Strings[Value] : NULL; + (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr; PrintAttribute(Tag, Value, ValueDesc); } @@ -233,7 +233,7 @@ void ARMAttributeParser::ABI_PCS_RW_data(AttrType Tag, const uint8_t *Data, uint64_t Value = ParseInteger(Data, Offset); StringRef ValueDesc = - (Value < array_lengthof(Strings)) ? Strings[Value] : NULL; + (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr; PrintAttribute(Tag, Value, ValueDesc); } @@ -243,7 +243,7 @@ void ARMAttributeParser::ABI_PCS_RO_data(AttrType Tag, const uint8_t *Data, uint64_t Value = ParseInteger(Data, Offset); StringRef ValueDesc = - (Value < array_lengthof(Strings)) ? Strings[Value] : NULL; + (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr; PrintAttribute(Tag, Value, ValueDesc); } @@ -253,7 +253,7 @@ void ARMAttributeParser::ABI_PCS_GOT_use(AttrType Tag, const uint8_t *Data, uint64_t Value = ParseInteger(Data, Offset); StringRef ValueDesc = - (Value < array_lengthof(Strings)) ? Strings[Value] : NULL; + (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr; PrintAttribute(Tag, Value, ValueDesc); } @@ -265,7 +265,7 @@ void ARMAttributeParser::ABI_PCS_wchar_t(AttrType Tag, const uint8_t *Data, uint64_t Value = ParseInteger(Data, Offset); StringRef ValueDesc = - (Value < array_lengthof(Strings)) ? Strings[Value] : NULL; + (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr; PrintAttribute(Tag, Value, ValueDesc); } @@ -275,7 +275,7 @@ void ARMAttributeParser::ABI_FP_rounding(AttrType Tag, const uint8_t *Data, uint64_t Value = ParseInteger(Data, Offset); StringRef ValueDesc = - (Value < array_lengthof(Strings)) ? Strings[Value] : NULL; + (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr; PrintAttribute(Tag, Value, ValueDesc); } @@ -285,7 +285,7 @@ void ARMAttributeParser::ABI_FP_denormal(AttrType Tag, const uint8_t *Data, uint64_t Value = ParseInteger(Data, Offset); StringRef ValueDesc = - (Value < array_lengthof(Strings)) ? Strings[Value] : NULL; + (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr; PrintAttribute(Tag, Value, ValueDesc); } @@ -295,7 +295,7 @@ void ARMAttributeParser::ABI_FP_exceptions(AttrType Tag, const uint8_t *Data, uint64_t Value = ParseInteger(Data, Offset); StringRef ValueDesc = - (Value < array_lengthof(Strings)) ? Strings[Value] : NULL; + (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr; PrintAttribute(Tag, Value, ValueDesc); } @@ -306,7 +306,7 @@ void ARMAttributeParser::ABI_FP_user_exceptions(AttrType Tag, uint64_t Value = ParseInteger(Data, Offset); StringRef ValueDesc = - (Value < array_lengthof(Strings)) ? Strings[Value] : NULL; + (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr; PrintAttribute(Tag, Value, ValueDesc); } @@ -318,7 +318,7 @@ void ARMAttributeParser::ABI_FP_number_model(AttrType Tag, const uint8_t *Data, uint64_t Value = ParseInteger(Data, Offset); StringRef ValueDesc = - (Value < array_lengthof(Strings)) ? Strings[Value] : NULL; + (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr; PrintAttribute(Tag, Value, ValueDesc); } @@ -371,7 +371,7 @@ void ARMAttributeParser::ABI_enum_size(AttrType Tag, const uint8_t *Data, uint64_t Value = ParseInteger(Data, Offset); StringRef ValueDesc = - (Value < array_lengthof(Strings)) ? Strings[Value] : NULL; + (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr; PrintAttribute(Tag, Value, ValueDesc); } @@ -383,7 +383,7 @@ void ARMAttributeParser::ABI_HardFP_use(AttrType Tag, const uint8_t *Data, uint64_t Value = ParseInteger(Data, Offset); StringRef ValueDesc = - (Value < array_lengthof(Strings)) ? Strings[Value] : NULL; + (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr; PrintAttribute(Tag, Value, ValueDesc); } @@ -395,7 +395,7 @@ void ARMAttributeParser::ABI_VFP_args(AttrType Tag, const uint8_t *Data, uint64_t Value = ParseInteger(Data, Offset); StringRef ValueDesc = - (Value < array_lengthof(Strings)) ? Strings[Value] : NULL; + (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr; PrintAttribute(Tag, Value, ValueDesc); } @@ -405,7 +405,7 @@ void ARMAttributeParser::ABI_WMMX_args(AttrType Tag, const uint8_t *Data, uint64_t Value = ParseInteger(Data, Offset); StringRef ValueDesc = - (Value < array_lengthof(Strings)) ? Strings[Value] : NULL; + (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr; PrintAttribute(Tag, Value, ValueDesc); } @@ -419,7 +419,7 @@ void ARMAttributeParser::ABI_optimization_goals(AttrType Tag, uint64_t Value = ParseInteger(Data, Offset); StringRef ValueDesc = - (Value < array_lengthof(Strings)) ? Strings[Value] : NULL; + (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr; PrintAttribute(Tag, Value, ValueDesc); } @@ -433,7 +433,7 @@ void ARMAttributeParser::ABI_FP_optimization_goals(AttrType Tag, uint64_t Value = ParseInteger(Data, Offset); StringRef ValueDesc = - (Value < array_lengthof(Strings)) ? Strings[Value] : NULL; + (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr; PrintAttribute(Tag, Value, ValueDesc); } @@ -465,7 +465,7 @@ void ARMAttributeParser::CPU_unaligned_access(AttrType Tag, const uint8_t *Data, uint64_t Value = ParseInteger(Data, Offset); StringRef ValueDesc = - (Value < array_lengthof(Strings)) ? Strings[Value] : NULL; + (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr; PrintAttribute(Tag, Value, ValueDesc); } @@ -475,7 +475,7 @@ void ARMAttributeParser::FP_HP_extension(AttrType Tag, const uint8_t *Data, uint64_t Value = ParseInteger(Data, Offset); StringRef ValueDesc = - (Value < array_lengthof(Strings)) ? Strings[Value] : NULL; + (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr; PrintAttribute(Tag, Value, ValueDesc); } @@ -485,7 +485,7 @@ void ARMAttributeParser::ABI_FP_16bit_format(AttrType Tag, const uint8_t *Data, uint64_t Value = ParseInteger(Data, Offset); StringRef ValueDesc = - (Value < array_lengthof(Strings)) ? Strings[Value] : NULL; + (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr; PrintAttribute(Tag, Value, ValueDesc); } @@ -495,7 +495,7 @@ void ARMAttributeParser::MPextension_use(AttrType Tag, const uint8_t *Data, uint64_t Value = ParseInteger(Data, Offset); StringRef ValueDesc = - (Value < array_lengthof(Strings)) ? Strings[Value] : NULL; + (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr; PrintAttribute(Tag, Value, ValueDesc); } @@ -507,7 +507,7 @@ void ARMAttributeParser::DIV_use(AttrType Tag, const uint8_t *Data, uint64_t Value = ParseInteger(Data, Offset); StringRef ValueDesc = - (Value < array_lengthof(Strings)) ? Strings[Value] : NULL; + (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr; PrintAttribute(Tag, Value, ValueDesc); } @@ -517,7 +517,7 @@ void ARMAttributeParser::T2EE_use(AttrType Tag, const uint8_t *Data, uint64_t Value = ParseInteger(Data, Offset); StringRef ValueDesc = - (Value < array_lengthof(Strings)) ? Strings[Value] : NULL; + (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr; PrintAttribute(Tag, Value, ValueDesc); } @@ -530,7 +530,7 @@ void ARMAttributeParser::Virtualization_use(AttrType Tag, const uint8_t *Data, uint64_t Value = ParseInteger(Data, Offset); StringRef ValueDesc = - (Value < array_lengthof(Strings)) ? Strings[Value] : NULL; + (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr; PrintAttribute(Tag, Value, ValueDesc); } diff --git a/tools/llvm-readobj/COFFDumper.cpp b/tools/llvm-readobj/COFFDumper.cpp index 48edf78a3d..b53520daef 100644 --- a/tools/llvm-readobj/COFFDumper.cpp +++ b/tools/llvm-readobj/COFFDumper.cpp @@ -534,7 +534,7 @@ void COFFDumper::printDataDirectory(uint32_t Index, const std::string &FieldName void COFFDumper::printFileHeaders() { // Print COFF header - const coff_file_header *COFFHeader = 0; + const coff_file_header *COFFHeader = nullptr; if (error(Obj->getCOFFHeader(COFFHeader))) return; @@ -557,13 +557,13 @@ void COFFDumper::printFileHeaders() { // Print PE header. This header does not exist if this is an object file and // not an executable. - const pe32_header *PEHeader = 0; + const pe32_header *PEHeader = nullptr; if (error(Obj->getPE32Header(PEHeader))) return; if (PEHeader) printPEHeader(PEHeader); - const pe32plus_header *PEPlusHeader = 0; + const pe32plus_header *PEPlusHeader = nullptr; if (error(Obj->getPE32PlusHeader(PEPlusHeader))) return; if (PEPlusHeader) @@ -693,7 +693,7 @@ void COFFDumper::printCodeViewLineTables(const SectionRef &Section) { break; } case COFF::DEBUG_STRING_TABLE_SUBSECTION: - if (PayloadSize == 0 || StringTable.data() != 0 || + if (PayloadSize == 0 || StringTable.data() != nullptr || Contents.back() != '\0') { // Empty or duplicate or non-null-terminated subsection. error(object_error::parse_failed); @@ -705,7 +705,8 @@ void COFFDumper::printCodeViewLineTables(const SectionRef &Section) { // Holds the translation table from file indices // to offsets in the string table. - if (PayloadSize == 0 || FileIndexToStringOffsetTable.data() != 0) { + if (PayloadSize == 0 || + FileIndexToStringOffsetTable.data() != nullptr) { // Empty or duplicate subsection. error(object_error::parse_failed); return; @@ -1090,7 +1091,7 @@ void COFFDumper::printRuntimeFunction( W.printString("UnwindInfoAddress", formatSymbol(Rels, OffsetInSection + 8, RTF.UnwindInfoOffset)); - const coff_section* XData = 0; + const coff_section* XData = nullptr; uint64_t UnwindInfoOffset = 0; if (error(getSection(Rels, OffsetInSection + 8, &XData, &UnwindInfoOffset))) return; diff --git a/tools/llvm-readobj/ELFDumper.cpp b/tools/llvm-readobj/ELFDumper.cpp index 4cd339347a..ab898327ca 100644 --- a/tools/llvm-readobj/ELFDumper.cpp +++ b/tools/llvm-readobj/ELFDumper.cpp @@ -652,7 +652,8 @@ void ELFDumper::printSymbol(typename ELFO::Elf_Sym_Iter Symbol) { std::string FullSymbolName(SymbolName); if (Symbol.isDynamic()) { bool IsDefault; - ErrorOr Version = Obj->getSymbolVersion(0, &*Symbol, IsDefault); + ErrorOr Version = Obj->getSymbolVersion(nullptr, &*Symbol, + IsDefault); if (Version) { FullSymbolName += (IsDefault ? "@@" : "@"); FullSymbolName += *Version; diff --git a/tools/llvm-rtdyld/llvm-rtdyld.cpp b/tools/llvm-rtdyld/llvm-rtdyld.cpp index 5e3c488c7b..2cea30cabd 100644 --- a/tools/llvm-rtdyld/llvm-rtdyld.cpp +++ b/tools/llvm-rtdyld/llvm-rtdyld.cpp @@ -69,7 +69,7 @@ public: void *getPointerToNamedFunction(const std::string &Name, bool AbortOnFailure = true) override { - return 0; + return nullptr; } bool finalizeMemory(std::string *ErrMsg) override { return false; } @@ -85,7 +85,7 @@ uint8_t *TrivialMemoryManager::allocateCodeSection(uintptr_t Size, unsigned Alignment, unsigned SectionID, StringRef SectionName) { - sys::MemoryBlock MB = sys::Memory::AllocateRWX(Size, 0, 0); + sys::MemoryBlock MB = sys::Memory::AllocateRWX(Size, nullptr, nullptr); FunctionMemory.push_back(MB); return (uint8_t*)MB.base(); } @@ -95,7 +95,7 @@ uint8_t *TrivialMemoryManager::allocateDataSection(uintptr_t Size, unsigned SectionID, StringRef SectionName, bool IsReadOnly) { - sys::MemoryBlock MB = sys::Memory::AllocateRWX(Size, 0, 0); + sys::MemoryBlock MB = sys::Memory::AllocateRWX(Size, nullptr, nullptr); DataMemory.push_back(MB); return (uint8_t*)MB.base(); } @@ -213,7 +213,7 @@ static int executeInput() { // Get the address of the entry point (_main by default). void *MainAddress = Dyld.getSymbolAddress(EntryPoint); - if (MainAddress == 0) + if (!MainAddress) return Error("no definition for '" + EntryPoint + "'"); // Invalidate the instruction cache for each loaded function. @@ -234,7 +234,7 @@ static int executeInput() { const char **Argv = new const char*[2]; // Use the name of the first input object module as argv[0] for the target. Argv[0] = InputFileList[0].c_str(); - Argv[1] = 0; + Argv[1] = nullptr; return Main(1, Argv); } diff --git a/tools/llvm-size/llvm-size.cpp b/tools/llvm-size/llvm-size.cpp index d1bd45a36b..58eafd4cba 100644 --- a/tools/llvm-size/llvm-size.cpp +++ b/tools/llvm-size/llvm-size.cpp @@ -93,7 +93,7 @@ static void PrintObjectSectionSizes(ObjectFile *Obj) { std::string fmtbuf; raw_string_ostream fmt(fmtbuf); - const char *radix_fmt = 0; + const char *radix_fmt = nullptr; switch (Radix) { case octal: radix_fmt = PRIo64; diff --git a/tools/llvm-stress/llvm-stress.cpp b/tools/llvm-stress/llvm-stress.cpp index 5e42bb9fcb..b7bcae7b73 100644 --- a/tools/llvm-stress/llvm-stress.cpp +++ b/tools/llvm-stress/llvm-stress.cpp @@ -245,7 +245,7 @@ protected: /// Pick a random scalar type. Type *pickScalarType() { - Type *t = 0; + Type *t = nullptr; do { switch (Ran->Rand() % 30) { case 0: t = Type::getInt1Ty(Context); break; @@ -271,7 +271,7 @@ protected: case 29: if (GenX86MMX) t = Type::getX86_MMXTy(Context); break; default: llvm_unreachable("Invalid scalar value"); } - } while (t == 0); + } while (t == nullptr); return t; } diff --git a/tools/llvm-symbolizer/LLVMSymbolize.cpp b/tools/llvm-symbolizer/LLVMSymbolize.cpp index 837ed19aa4..4a9bbe5e82 100644 --- a/tools/llvm-symbolizer/LLVMSymbolize.cpp +++ b/tools/llvm-symbolizer/LLVMSymbolize.cpp @@ -171,7 +171,7 @@ const char LLVMSymbolizer::kBadString[] = "??"; std::string LLVMSymbolizer::symbolizeCode(const std::string &ModuleName, uint64_t ModuleOffset) { ModuleInfo *Info = getOrCreateModuleInfo(ModuleName); - if (Info == 0) + if (!Info) return printDILineInfo(DILineInfo()); if (Opts.PrintInlining) { DIInliningInfo InlinedContext = @@ -232,7 +232,7 @@ static bool findDebugBinary(const std::string &OrigPath, std::string &Result) { std::string OrigRealPath = OrigPath; #if defined(HAVE_REALPATH) - if (char *RP = realpath(OrigPath.c_str(), NULL)) { + if (char *RP = realpath(OrigPath.c_str(), nullptr)) { OrigRealPath = RP; free(RP); } @@ -298,8 +298,8 @@ LLVMSymbolizer::getOrCreateBinary(const std::string &Path) { BinaryMapTy::iterator I = BinaryForPath.find(Path); if (I != BinaryForPath.end()) return I->second; - Binary *Bin = 0; - Binary *DbgBin = 0; + Binary *Bin = nullptr; + Binary *DbgBin = nullptr; ErrorOr BinaryOrErr = createBinary(Path); if (!error(BinaryOrErr.getError())) { std::unique_ptr ParsedBinary(BinaryOrErr.get()); @@ -319,7 +319,7 @@ LLVMSymbolizer::getOrCreateBinary(const std::string &Path) { } } // Try to locate the debug binary using .gnu_debuglink section. - if (DbgBin == 0) { + if (!DbgBin) { std::string DebuglinkName; uint32_t CRCHash; std::string DebugBinaryPath; @@ -333,7 +333,7 @@ LLVMSymbolizer::getOrCreateBinary(const std::string &Path) { } } } - if (DbgBin == 0) + if (!DbgBin) DbgBin = Bin; BinaryPair Res = std::make_pair(Bin, DbgBin); BinaryForPath[Path] = Res; @@ -342,9 +342,9 @@ LLVMSymbolizer::getOrCreateBinary(const std::string &Path) { ObjectFile * LLVMSymbolizer::getObjectFileFromBinary(Binary *Bin, const std::string &ArchName) { - if (Bin == 0) - return 0; - ObjectFile *Res = 0; + if (!Bin) + return nullptr; + ObjectFile *Res = nullptr; if (MachOUniversalBinary *UB = dyn_cast(Bin)) { ObjectFileForArchMapTy::iterator I = ObjectFileForArch.find( std::make_pair(UB, ArchName)); @@ -382,10 +382,10 @@ LLVMSymbolizer::getOrCreateModuleInfo(const std::string &ModuleName) { ObjectFile *Obj = getObjectFileFromBinary(Binaries.first, ArchName); ObjectFile *DbgObj = getObjectFileFromBinary(Binaries.second, ArchName); - if (Obj == 0) { + if (!Obj) { // Failed to find valid object file. - Modules.insert(make_pair(ModuleName, (ModuleInfo *)0)); - return 0; + Modules.insert(make_pair(ModuleName, (ModuleInfo *)nullptr)); + return nullptr; } DIContext *Context = DIContext::getDWARFContext(DbgObj); assert(Context); @@ -427,7 +427,7 @@ std::string LLVMSymbolizer::DemangleName(const std::string &Name) { if (Name.substr(0, 2) != "_Z") return Name; int status = 0; - char *DemangledName = __cxa_demangle(Name.c_str(), 0, 0, &status); + char *DemangledName = __cxa_demangle(Name.c_str(), nullptr, nullptr, &status); if (status != 0) return Name; std::string Result = DemangledName; diff --git a/tools/llvm-symbolizer/llvm-symbolizer.cpp b/tools/llvm-symbolizer/llvm-symbolizer.cpp index 83f5c5ea88..1680470f85 100644 --- a/tools/llvm-symbolizer/llvm-symbolizer.cpp +++ b/tools/llvm-symbolizer/llvm-symbolizer.cpp @@ -85,7 +85,7 @@ static bool parseCommand(bool &IsData, std::string &ModuleName, char quote = *pos; pos++; char *end = strchr(pos, quote); - if (end == 0) + if (!end) return false; ModuleName = std::string(pos, end - pos); pos = end + 1; diff --git a/tools/opt/PrintSCC.cpp b/tools/opt/PrintSCC.cpp index cbc0a55996..d5d4336ea5 100644 --- a/tools/opt/PrintSCC.cpp +++ b/tools/opt/PrintSCC.cpp @@ -39,7 +39,7 @@ namespace { CFGSCC() : FunctionPass(ID) {} bool runOnFunction(Function& func) override; - void print(raw_ostream &O, const Module* = 0) const override { } + void print(raw_ostream &O, const Module* = nullptr) const override { } void getAnalysisUsage(AnalysisUsage &AU) const override { AU.setPreservesAll(); @@ -53,7 +53,7 @@ namespace { // run - Print out SCCs in the call graph for the specified module. bool runOnModule(Module &M) override; - void print(raw_ostream &O, const Module* = 0) const override { } + void print(raw_ostream &O, const Module* = nullptr) const override { } // getAnalysisUsage - This pass requires the CallGraph. void getAnalysisUsage(AnalysisUsage &AU) const override { diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp index 006d4144d3..9b3ce9bdbe 100644 --- a/tools/opt/opt.cpp +++ b/tools/opt/opt.cpp @@ -295,7 +295,7 @@ static TargetMachine* GetTargetMachine(Triple TheTriple) { Error); // Some modules don't specify a triple, and this is okay. if (!TheTarget) { - return 0; + return nullptr; } // Package up features to be passed to target/subtarget @@ -373,7 +373,7 @@ int main(int argc, char **argv) { std::unique_ptr M; M.reset(ParseIRFile(InputFilename, Err, Context)); - if (M.get() == 0) { + if (!M.get()) { Err.print(argv[0], errs()); return 1; } @@ -453,7 +453,7 @@ int main(int argc, char **argv) { Passes.add(new DataLayoutPass(M.get())); Triple ModuleTriple(M->getTargetTriple()); - TargetMachine *Machine = 0; + TargetMachine *Machine = nullptr; if (ModuleTriple.getArch()) Machine = GetTargetMachine(Triple(ModuleTriple)); std::unique_ptr TM(Machine); @@ -537,7 +537,7 @@ int main(int argc, char **argv) { } const PassInfo *PassInf = PassList[i]; - Pass *P = 0; + Pass *P = nullptr; if (PassInf->getTargetMachineCtor()) P = PassInf->getTargetMachineCtor()(TM.get()); else if (PassInf->getNormalCtor()) -- cgit v1.2.3