[C++] Use 'nullptr'. Tools edition.
authorCraig Topper <craig.topper@gmail.com>
Fri, 25 Apr 2014 04:24:47 +0000 (04:24 +0000)
committerCraig Topper <craig.topper@gmail.com>
Fri, 25 Apr 2014 04:24:47 +0000 (04:24 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207176 91177308-0d34-0410-b5e6-96231b3b80d8

36 files changed:
tools/bugpoint/BugDriver.cpp
tools/bugpoint/CrashDebugger.cpp
tools/bugpoint/ExecutionDriver.cpp
tools/bugpoint/ExtractFunction.cpp
tools/bugpoint/FindBugs.cpp
tools/bugpoint/Miscompilation.cpp
tools/bugpoint/OptimizerDriver.cpp
tools/bugpoint/ToolRunner.cpp
tools/bugpoint/bugpoint.cpp
tools/llc/llc.cpp
tools/lli/RemoteMemoryManager.cpp
tools/lli/RemoteTarget.cpp
tools/lli/lli.cpp
tools/llvm-ar/llvm-ar.cpp
tools/llvm-as/llvm-as.cpp
tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
tools/llvm-diff/DiffLog.cpp
tools/llvm-dis/llvm-dis.cpp
tools/llvm-extract/llvm-extract.cpp
tools/llvm-link/llvm-link.cpp
tools/llvm-lto/llvm-lto.cpp
tools/llvm-mc/Disassembler.cpp
tools/llvm-mc/llvm-mc.cpp
tools/llvm-objdump/MachODump.cpp
tools/llvm-objdump/llvm-objdump.cpp
tools/llvm-profdata/llvm-profdata.cpp
tools/llvm-readobj/ARMAttributeParser.cpp
tools/llvm-readobj/COFFDumper.cpp
tools/llvm-readobj/ELFDumper.cpp
tools/llvm-rtdyld/llvm-rtdyld.cpp
tools/llvm-size/llvm-size.cpp
tools/llvm-stress/llvm-stress.cpp
tools/llvm-symbolizer/LLVMSymbolize.cpp
tools/llvm-symbolizer/llvm-symbolizer.cpp
tools/opt/PrintSCC.cpp
tools/opt/opt.cpp

index 2d1b903829fe47b120b4584d86137624bc38fd48..043863a354e654652deb4b28cec25ff462320b50 100644 (file)
@@ -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<std::string> &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<Module> 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;
index c646ff49b1c492ace6792c174d73f60df3d1b241..8bd61b3c0964baa0dd662571af4575e5dec4adbd 100644 (file)
@@ -63,7 +63,7 @@ ReducePassList::doTest(std::vector<std::string> &Prefix,
                        std::vector<std::string> &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<std::string> &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;
       }
index 609de03db82cf802ad4236f39ee9ff415f8c9545..5ed7d2cab3c7a252640ff20b57656c6eb7ea1ed1 100644 (file)
@@ -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;
 
index d1b1aff77850e84c54c8a550ee6e616317e01b19..38cdf241ce767394bd3cdb31ccbdb6f5603bb6cb 100644 (file)
@@ -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);
   }
index e2941f6f43aea81251af67d2dfe3607bba2b0032..a0c859b7f33e9a1c8f1d217d0bb00f6fdc862458 100644 (file)
@@ -45,7 +45,7 @@ bool BugDriver::runManyPasses(const std::vector<std::string> &AllPasses,
       return false;
   }
   
-  srand(time(NULL));  
+  srand(time(nullptr));
   
   unsigned num = 1;
   while(1) {  
index fecae60c41d1f113147b5606095fa75464b78a71..f5936ac88ea5e20fffaad3fe67e81ab30a3f7c50 100644 (file)
@@ -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) {
index eaea9d9ed538df654007fde129efaeafdb00f065..b2722e6d0e7d5fd1a83fa98ab69769b4ecf04b8e 100644 (file)
@@ -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);
index e1c995f519e0c8e484aa48c2d0331367bddee1e6..c481b03e2b9ec82eb5168de35b827adf53b389f5 100644 (file)
@@ -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() << "<lli>"; 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<std::string> 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<std::string> 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 ? "<llc-ia>" : "<llc>");
   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() << "<jit>"; 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() << "<gcc>"; 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() << "<program>"; 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;
index 5c03b41abbeecbf8b80102ee7845633335cbbfba..c7dae0f45b663bb6e6ca3eb8575e6d14aa827d1b 100644 (file)
@@ -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();
index 0c8d14d11db6d5078f58971146dcde2b1eb97f8d..6dc5a32263b52c8969d70a872c3f60f9d03a71d5 100644 (file)
@@ -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<Module> 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);
index 7e0f8cb76d23933d0daaffc0e913c71f47ba9cd4..200ab75152c22fcd75817bbf3f870683315113f9 100644 (file)
@@ -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!");
index 55fc064ad37459d3810f54c29e96c9049593688e..850fdc506999b81ae7fb4597607586d5fff5ab08 100644 (file)
@@ -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";
index 904a9e5830acf135d9b01622cd1ddf6526564acd..f1413f302a30cf419195976d1759b90f3aa7fb57 100644 (file)
@@ -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<MemoryBuffer> 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());
   }
 
index 047f54e56eea0b1d8196431c91b9adad6b6a647a..db95674d36ad8126f559df86419dd468ccff9cda 100644 (file)
@@ -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;
 }
index 7583b121b45c9095bcdf95ece090d03e747ca8dc..70c95080e902792dad9055a4010f1cf0097c61c6 100644 (file)
@@ -94,7 +94,7 @@ int main(int argc, char **argv) {
   // Parse the file now...
   SMDiagnostic Err;
   std::unique_ptr<Module> M(ParseAssemblyFile(InputFilename, Err, Context));
-  if (M.get() == 0) {
+  if (!M.get()) {
     Err.print(argv[0], errs());
     return 1;
   }
index 9e17783e707887bb3d36d0a72b19ea88f3ce9272..dfdaa031636bc07bbcbe2a65081b2171ee6446f7 100644 (file)
@@ -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())))
index caf779bb4030bab26dec265321869e7fae5f3832..24a1b08d545dad0ff9ac0623033fe2dd48a7c261 100644 (file)
@@ -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(); }
index c6f0dcf6ae831ab0a11b76bc6ebc637f9a8ed368..2c9322ea56c283cd5a9e2e687a484e60b437d30e 100644 (file)
@@ -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";
index 2e5a2af244d29f8ecfee60dbacbe68f40d7b84ee..4131177bd401f06d2b787e9280b2185b9794c577 100644 (file)
@@ -103,7 +103,7 @@ int main(int argc, char **argv) {
   std::unique_ptr<Module> M;
   M.reset(getLazyIRFileModule(InputFilename, Err, Context));
 
-  if (M.get() == 0) {
+  if (!M.get()) {
     Err.print(argv[0], errs());
     return 1;
   }
index 1f0e2246ce850c3e54e476baf372e20337b22db0..a756a1c33a2e5748db68a4b70cae6b603cbd471d 100644 (file)
@@ -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<Module> 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<Module> M(LoadFile(argv[0], InputFilenames[i], Context));
-    if (M.get() == 0) {
+    if (!M.get()) {
       errs() << argv[0] << ": error loading file '" <<InputFilenames[i]<< "'\n";
       return 1;
     }
index 05ffbf31910e89d4d683c675fe0ba70edfa4d9bf..1a92bf4f0ea3863fe6e1f586aa0dcbaec96e6796 100644 (file)
@@ -148,7 +148,7 @@ int main(int argc, char **argv) {
     std::string ErrorInfo;
     const void *Code = CodeGen.compile(&len, DisableOpt, DisableInline,
                                        DisableGVNLoadPRE, ErrorInfo);
-    if (Code == NULL) {
+    if (!Code) {
       errs() << argv[0]
              << ": error compiling the code: " << ErrorInfo << "\n";
       return 1;
@@ -165,7 +165,7 @@ int main(int argc, char **argv) {
     FileStream.write(reinterpret_cast<const char *>(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]
index 28629c10c1997d5d9246eb2ec7f22ab231c2b6e5..9367590398745729ceab16459187ea51c83a6423 100644 (file)
@@ -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<const MCDisassembler> DisAsm(
     T.createMCDisassembler(STI, Ctx));
index a8a3d994b506b630de2dbfbfe9da6ef8bf17a1f9..dbe012b4d4a0799b6c523b2ef9f4353e96e20888 100644 (file)
@@ -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<MCSubtargetInfo> 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);
index 376948e382952af6abf40cc6f770aaad12c6ebec..3ca582fdab168d2ba76e257e62daab0612584d76 100644 (file)
@@ -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<const MCSubtargetInfo> STI(
       TheTarget->createMCSubtargetInfo(TripleName, "", ""));
-  MCContext Ctx(AsmInfo.get(), MRI.get(), 0);
+  MCContext Ctx(AsmInfo.get(), MRI.get(), nullptr);
   std::unique_ptr<const MCDisassembler> DisAsm(
     TheTarget->createMCDisassembler(*STI, Ctx));
   int AsmPrinterVariant = AsmInfo->getAssemblerDialect();
index a4b94c9b6adf388bf5d844722ce204a095538d1b..a4fc6d0e33f8352f3e1b2066de231fb4f8dd3014 100644 (file)
@@ -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.
index 3e58bc205d0aa70b4533362fe73430e18e0ebfc0..17710f64ae4788273306393f83b52448b510effb 100644 (file)
@@ -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;
index cd0bcd4cb980994cb8bbd4a2a7ca18c5dfd413cc..d35cd14265fb147db97703c93768c0eb73cb3f13 100644 (file)
@@ -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);
 }
 
index 48edf78a3d569348e8b5daa6846a623706078175..b53520daefb048d1d9f76ac3b04711ff1b66c0f3 100644 (file)
@@ -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<pe32_header>(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;
index 4cd339347ad27f6d4b908aac407a8b52063f74b7..ab898327ca268bbf9e7b59d5012ed57dd2663fa1 100644 (file)
@@ -652,7 +652,8 @@ void ELFDumper<ELFT>::printSymbol(typename ELFO::Elf_Sym_Iter Symbol) {
   std::string FullSymbolName(SymbolName);
   if (Symbol.isDynamic()) {
     bool IsDefault;
-    ErrorOr<StringRef> Version = Obj->getSymbolVersion(0, &*Symbol, IsDefault);
+    ErrorOr<StringRef> Version = Obj->getSymbolVersion(nullptr, &*Symbol,
+                                                       IsDefault);
     if (Version) {
       FullSymbolName += (IsDefault ? "@@" : "@");
       FullSymbolName += *Version;
index 5e3c488c7bda235be747e3c8cb9ba8ca0183aa43..2cea30cabde9a9a6e91256a3d2dd9a21da1edce6 100644 (file)
@@ -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);
 }
 
index d1bd45a36b88ce8eee6b574be2faf979482b80f6..58eafd4cba3d2023c0394a40cad6253f5c9ce751 100644 (file)
@@ -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;
index 5e42bb9fcbf6beaf858cb4c478643c13680e19f5..b7bcae7b73cf7179649e056aac4fae2044f2e5e9 100644 (file)
@@ -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;
   }
index 837ed19aa4102226a758c534402557da4296563b..4a9bbe5e8220453ce92cb9015d6b9273a8d99edb 100644 (file)
@@ -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<Binary *> BinaryOrErr = createBinary(Path);
   if (!error(BinaryOrErr.getError())) {
     std::unique_ptr<Binary> 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<MachOUniversalBinary>(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;
index 83f5c5ea88b8f48c828ce740c83eb8052a0cc770..1680470f855489530b890b34f28eb6a475e1faf7 100644 (file)
@@ -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;
index cbc0a5599603cfe3c5cf6fc19e3cab0d41bbd309..d5d4336ea5df680a3038b3a84f710cfbc77e9a11 100644 (file)
@@ -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 {
index 006d4144d37c464b25ec827c3f41b342f0e55a80..9b3ce9bdbec3768f68c06b0e0e5e2d18f4995f16 100644 (file)
@@ -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<Module> 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<TargetMachine> 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())