From e703fcb9757820fe27d9ef98ce3775d9c6d6e898 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Thu, 24 Apr 2014 06:44:33 +0000 Subject: [C++] Use 'nullptr'. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207083 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/EquivalenceClasses.h | 4 +- include/llvm/ADT/ImmutableMap.h | 4 +- include/llvm/ADT/ImmutableSet.h | 14 ++-- include/llvm/ADT/OwningPtr.h | 8 +- include/llvm/ADT/ilist_node.h | 4 +- include/llvm/CodeGen/LinkAllCodegenComponents.h | 15 ++-- include/llvm/CodeGen/MachineCodeInfo.h | 2 +- include/llvm/ExecutionEngine/JITEventListener.h | 8 +- .../llvm/ExecutionEngine/SectionMemoryManager.h | 2 +- include/llvm/IR/PassManager.h | 6 +- include/llvm/IR/ValueHandle.h | 2 +- include/llvm/LinkAllPasses.h | 16 ++-- include/llvm/MC/MCParser/MCParsedAsmOperand.h | 2 +- include/llvm/Object/ELF.h | 2 +- include/llvm/Support/OnDiskHashTable.h | 12 +-- include/llvm/Support/YAMLTraits.h | 4 +- lib/Analysis/IPA/CallGraph.cpp | 10 +-- lib/Analysis/IPA/CallGraphSCCPass.cpp | 12 +-- lib/Analysis/IPA/GlobalsModRef.cpp | 10 +-- lib/Analysis/IPA/InlineCost.cpp | 4 +- lib/CodeGen/AsmPrinter/ARMException.cpp | 2 +- lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 38 ++++----- lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp | 16 ++-- lib/CodeGen/AsmPrinter/DIE.cpp | 4 +- lib/CodeGen/AsmPrinter/DIE.h | 4 +- lib/CodeGen/AsmPrinter/DIEHash.h | 2 +- lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 95 +++++++++++----------- lib/CodeGen/AsmPrinter/DwarfException.cpp | 14 ++-- lib/CodeGen/AsmPrinter/DwarfUnit.cpp | 27 +++--- lib/CodeGen/AsmPrinter/WinCodeViewLineTables.cpp | 8 +- lib/CodeGen/AtomicExpandLoadLinkedPass.cpp | 4 +- lib/ExecutionEngine/Interpreter/Execution.cpp | 2 +- .../Interpreter/ExternalFunctions.cpp | 6 +- lib/ExecutionEngine/Interpreter/Interpreter.cpp | 2 +- lib/ExecutionEngine/JIT/JIT.cpp | 20 ++--- lib/ExecutionEngine/JIT/JITEmitter.cpp | 31 +++---- lib/ExecutionEngine/JIT/JITMemoryManager.cpp | 16 ++-- lib/ExecutionEngine/MCJIT/MCJIT.cpp | 22 ++--- lib/ExecutionEngine/MCJIT/SectionMemoryManager.cpp | 2 +- lib/ExecutionEngine/RuntimeDyld/GDBRegistrar.cpp | 13 ++- lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp | 12 +-- lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp | 17 ++-- .../RuntimeDyld/RuntimeDyldMachO.cpp | 2 +- lib/MC/MCDisassembler/Disassembler.cpp | 22 ++--- lib/MC/MCParser/AsmLexer.cpp | 8 +- lib/MC/MCParser/AsmParser.cpp | 32 ++++---- lib/MC/MCParser/COFFAsmParser.cpp | 6 +- lib/MC/MCParser/DarwinAsmParser.cpp | 8 +- lib/MC/MCParser/ELFAsmParser.cpp | 8 +- lib/MC/MCParser/MCAsmLexer.cpp | 2 +- lib/MC/MCParser/MCAsmParser.cpp | 2 +- lib/MC/WinCOFFObjectWriter.cpp | 2 +- 52 files changed, 299 insertions(+), 291 deletions(-) diff --git a/include/llvm/ADT/EquivalenceClasses.h b/include/llvm/ADT/EquivalenceClasses.h index 2256ee7ae4..f50992ee60 100644 --- a/include/llvm/ADT/EquivalenceClasses.h +++ b/include/llvm/ADT/EquivalenceClasses.h @@ -147,10 +147,10 @@ public: class member_iterator; member_iterator member_begin(iterator I) const { // Only leaders provide anything to iterate over. - return member_iterator(I->isLeader() ? &*I : 0); + return member_iterator(I->isLeader() ? &*I : nullptr); } member_iterator member_end() const { - return member_iterator(0); + return member_iterator(nullptr); } /// findValue - Return an iterator to the specified value. If it does not diff --git a/include/llvm/ADT/ImmutableMap.h b/include/llvm/ADT/ImmutableMap.h index 8f8fb98770..11f281be3d 100644 --- a/include/llvm/ADT/ImmutableMap.h +++ b/include/llvm/ADT/ImmutableMap.h @@ -241,14 +241,14 @@ public: if (T) return &T->getValue().second; } - return 0; + return nullptr; } /// getMaxElement - Returns the pair in the ImmutableMap for /// which key is the highest in the ordering of keys in the map. This /// method returns NULL if the map is empty. value_type* getMaxElement() const { - return Root ? &(Root->getMaxElement()->getValue()) : 0; + return Root ? &(Root->getMaxElement()->getValue()) : nullptr; } //===--------------------------------------------------===// diff --git a/include/llvm/ADT/ImmutableSet.h b/include/llvm/ADT/ImmutableSet.h index 530315c91d..5a3d8ad21f 100644 --- a/include/llvm/ADT/ImmutableSet.h +++ b/include/llvm/ADT/ImmutableSet.h @@ -81,7 +81,7 @@ public: else T = T->getRight(); } - return NULL; + return nullptr; } /// getMaxElement - Find the subtree associated with the highest ranged @@ -242,9 +242,9 @@ private: /// ImutAVLFactory. ImutAVLTree(Factory *f, ImutAVLTree* l, ImutAVLTree* r, value_type_ref v, unsigned height) - : factory(f), left(l), right(r), prev(0), next(0), height(height), - IsMutable(true), IsDigestCached(false), IsCanonicalized(0), - value(v), digest(0), refCount(0) + : factory(f), left(l), right(r), prev(nullptr), next(nullptr), + height(height), IsMutable(true), IsDigestCached(false), + IsCanonicalized(0), value(v), digest(0), refCount(0) { if (left) left->retain(); if (right) right->retain(); @@ -411,7 +411,7 @@ public: return T; } - TreeTy* getEmptyTree() const { return NULL; } + TreeTy* getEmptyTree() const { return nullptr; } protected: @@ -607,7 +607,7 @@ protected: public: TreeTy *getCanonicalTree(TreeTy *TNew) { if (!TNew) - return 0; + return nullptr; if (TNew->IsCanonicalized) return TNew; @@ -619,7 +619,7 @@ public: do { if (!entry) break; - for (TreeTy *T = entry ; T != 0; T = T->next) { + for (TreeTy *T = entry ; T != nullptr; T = T->next) { // Compare the Contents('T') with Contents('TNew') typename TreeTy::iterator TI = T->begin(), TE = T->end(); if (!compareTreeWithSection(TNew, TI, TE)) diff --git a/include/llvm/ADT/OwningPtr.h b/include/llvm/ADT/OwningPtr.h index 240079dca4..5e83358fc0 100644 --- a/include/llvm/ADT/OwningPtr.h +++ b/include/llvm/ADT/OwningPtr.h @@ -69,7 +69,7 @@ public: /// not delete the pointer before returning it. T *take() { T *Tmp = Ptr; - Ptr = 0; + Ptr = nullptr; return Tmp; } @@ -84,9 +84,9 @@ public: T *operator->() const { return Ptr; } T *get() const { return Ptr; } - LLVM_EXPLICIT operator bool() const { return Ptr != 0; } - bool operator!() const { return Ptr == 0; } - bool isValid() const { return Ptr != 0; } + LLVM_EXPLICIT operator bool() const { return Ptr != nullptr; } + bool operator!() const { return Ptr == nullptr; } + bool isValid() const { return Ptr != nullptr; } void swap(OwningPtr &RHS) { T *Tmp = RHS.Ptr; diff --git a/include/llvm/ADT/ilist_node.h b/include/llvm/ADT/ilist_node.h index 51c0328bfb..85aa7a4b1f 100644 --- a/include/llvm/ADT/ilist_node.h +++ b/include/llvm/ADT/ilist_node.h @@ -71,7 +71,7 @@ public: // Check for sentinel. if (!Prev->getNext()) - return 0; + return nullptr; return Prev; } @@ -93,7 +93,7 @@ public: // Check for sentinel. if (!Next->getNext()) - return 0; + return nullptr; return Next; } diff --git a/include/llvm/CodeGen/LinkAllCodegenComponents.h b/include/llvm/CodeGen/LinkAllCodegenComponents.h index 916c0f233e..372c294da3 100644 --- a/include/llvm/CodeGen/LinkAllCodegenComponents.h +++ b/include/llvm/CodeGen/LinkAllCodegenComponents.h @@ -40,12 +40,15 @@ namespace { llvm::linkErlangGC(); llvm::linkShadowStackGC(); - (void) llvm::createBURRListDAGScheduler(NULL, llvm::CodeGenOpt::Default); - (void) llvm::createSourceListDAGScheduler(NULL,llvm::CodeGenOpt::Default); - (void) llvm::createHybridListDAGScheduler(NULL,llvm::CodeGenOpt::Default); - (void) llvm::createFastDAGScheduler(NULL, llvm::CodeGenOpt::Default); - (void) llvm::createDefaultScheduler(NULL, llvm::CodeGenOpt::Default); - (void) llvm::createVLIWDAGScheduler(NULL, llvm::CodeGenOpt::Default); + (void) llvm::createBURRListDAGScheduler(nullptr, + llvm::CodeGenOpt::Default); + (void) llvm::createSourceListDAGScheduler(nullptr, + llvm::CodeGenOpt::Default); + (void) llvm::createHybridListDAGScheduler(nullptr, + llvm::CodeGenOpt::Default); + (void) llvm::createFastDAGScheduler(nullptr, llvm::CodeGenOpt::Default); + (void) llvm::createDefaultScheduler(nullptr, llvm::CodeGenOpt::Default); + (void) llvm::createVLIWDAGScheduler(nullptr, llvm::CodeGenOpt::Default); } } ForceCodegenLinking; // Force link by creating a global definition. diff --git a/include/llvm/CodeGen/MachineCodeInfo.h b/include/llvm/CodeGen/MachineCodeInfo.h index ba9dfab91a..820bc87425 100644 --- a/include/llvm/CodeGen/MachineCodeInfo.h +++ b/include/llvm/CodeGen/MachineCodeInfo.h @@ -27,7 +27,7 @@ private: void *Address; // The address of the function in memory public: - MachineCodeInfo() : Size(0), Address(0) {} + MachineCodeInfo() : Size(0), Address(nullptr) {} void setSize(size_t s) { Size = s; diff --git a/include/llvm/ExecutionEngine/JITEventListener.h b/include/llvm/ExecutionEngine/JITEventListener.h index 8daf2bdacf..99fe36c6b5 100644 --- a/include/llvm/ExecutionEngine/JITEventListener.h +++ b/include/llvm/ExecutionEngine/JITEventListener.h @@ -98,11 +98,11 @@ public: static JITEventListener *createIntelJITEventListener( IntelJITEventsWrapper* AlternativeImpl); #else - static JITEventListener *createIntelJITEventListener() { return 0; } + static JITEventListener *createIntelJITEventListener() { return nullptr; } static JITEventListener *createIntelJITEventListener( IntelJITEventsWrapper* AlternativeImpl) { - return 0; + return nullptr; } #endif // USE_INTEL_JITEVENTS @@ -115,11 +115,11 @@ public: OProfileWrapper* AlternativeImpl); #else - static JITEventListener *createOProfileJITEventListener() { return 0; } + static JITEventListener *createOProfileJITEventListener() { return nullptr; } static JITEventListener *createOProfileJITEventListener( OProfileWrapper* AlternativeImpl) { - return 0; + return nullptr; } #endif // USE_OPROFILE diff --git a/include/llvm/ExecutionEngine/SectionMemoryManager.h b/include/llvm/ExecutionEngine/SectionMemoryManager.h index f68028b52d..f24bb4d5a5 100644 --- a/include/llvm/ExecutionEngine/SectionMemoryManager.h +++ b/include/llvm/ExecutionEngine/SectionMemoryManager.h @@ -72,7 +72,7 @@ public: /// operations needed to reliably use the memory are also performed. /// /// \returns true if an error occurred, false otherwise. - bool finalizeMemory(std::string *ErrMsg = 0) override; + bool finalizeMemory(std::string *ErrMsg = nullptr) override; /// \brief Invalidate instruction cache for code sections. /// diff --git a/include/llvm/IR/PassManager.h b/include/llvm/IR/PassManager.h index 9575e12edb..cc2a80b9ff 100644 --- a/include/llvm/IR/PassManager.h +++ b/include/llvm/IR/PassManager.h @@ -193,7 +193,7 @@ class PassRunAcceptsAnalysisManager { template static BigType f(...); public: - enum { Value = sizeof(f(0)) == sizeof(SmallType) }; + enum { Value = sizeof(f(nullptr)) == sizeof(SmallType) }; }; /// \brief A template wrapper used to implement the polymorphic API. @@ -293,7 +293,7 @@ template class ResultHasInvalidateMethod { template static BigType f(...); public: - enum { Value = sizeof(f(0)) == sizeof(SmallType) }; + enum { Value = sizeof(f(nullptr)) == sizeof(SmallType) }; }; /// \brief Wrapper to model the analysis result concept. @@ -616,7 +616,7 @@ public: ResultConceptT *ResultConcept = derived_this()->getCachedResultImpl(PassT::ID(), IR); if (!ResultConcept) - return 0; + return nullptr; typedef detail::AnalysisResultModel ResultModelT; diff --git a/include/llvm/IR/ValueHandle.h b/include/llvm/IR/ValueHandle.h index 888313c4e3..aa29b2ed69 100644 --- a/include/llvm/IR/ValueHandle.h +++ b/include/llvm/IR/ValueHandle.h @@ -214,7 +214,7 @@ public: AssertingVH(ValueTy *P) : ValueHandleBase(Assert, GetAsValue(P)) {} AssertingVH(const AssertingVH &RHS) : ValueHandleBase(Assert, RHS) {} #else - AssertingVH() : ThePtr(0) {} + AssertingVH() : ThePtr(nullptr) {} AssertingVH(ValueTy *P) : ThePtr(P) {} #endif diff --git a/include/llvm/LinkAllPasses.h b/include/llvm/LinkAllPasses.h index 16032504cb..9cb1c5c8a8 100644 --- a/include/llvm/LinkAllPasses.h +++ b/include/llvm/LinkAllPasses.h @@ -53,7 +53,7 @@ namespace { (void) llvm::createAliasDebugger(); (void) llvm::createArgumentPromotionPass(); (void) llvm::createBasicAliasAnalysisPass(); - (void) llvm::createLibCallAliasAnalysisPass(0); + (void) llvm::createLibCallAliasAnalysisPass(nullptr); (void) llvm::createScalarEvolutionAliasAnalysisPass(); (void) llvm::createTypeBasedAliasAnalysisPass(); (void) llvm::createBoundsCheckingPass(); @@ -140,9 +140,9 @@ namespace { (void) llvm::createMetaRenamerPass(); (void) llvm::createFunctionAttrsPass(); (void) llvm::createMergeFunctionsPass(); - (void) llvm::createPrintModulePass(*(llvm::raw_ostream*)0); - (void) llvm::createPrintFunctionPass(*(llvm::raw_ostream*)0); - (void) llvm::createPrintBasicBlockPass(*(llvm::raw_ostream*)0); + (void) llvm::createPrintModulePass(*(llvm::raw_ostream*)nullptr); + (void) llvm::createPrintFunctionPass(*(llvm::raw_ostream*)nullptr); + (void) llvm::createPrintBasicBlockPass(*(llvm::raw_ostream*)nullptr); (void) llvm::createModuleDebugInfoPrinterPass(); (void) llvm::createPartialInliningPass(); (void) llvm::createLintPass(); @@ -160,11 +160,11 @@ namespace { (void)new llvm::IntervalPartition(); (void)new llvm::FindUsedTypes(); (void)new llvm::ScalarEvolution(); - ((llvm::Function*)0)->viewCFGOnly(); + ((llvm::Function*)nullptr)->viewCFGOnly(); llvm::RGPassManager RGM; - ((llvm::RegionPass*)0)->runOnRegion((llvm::Region*)0, RGM); - llvm::AliasSetTracker X(*(llvm::AliasAnalysis*)0); - X.add((llvm::Value*)0, 0, 0); // for -print-alias-sets + ((llvm::RegionPass*)nullptr)->runOnRegion((llvm::Region*)nullptr, RGM); + llvm::AliasSetTracker X(*(llvm::AliasAnalysis*)nullptr); + X.add((llvm::Value*)nullptr, 0, nullptr); // for -print-alias-sets } } ForcePassLinking; // Force link by creating a global definition. } diff --git a/include/llvm/MC/MCParser/MCParsedAsmOperand.h b/include/llvm/MC/MCParser/MCParsedAsmOperand.h index 818fbbd6c6..e8740aa10a 100644 --- a/include/llvm/MC/MCParser/MCParsedAsmOperand.h +++ b/include/llvm/MC/MCParser/MCParsedAsmOperand.h @@ -38,7 +38,7 @@ public: unsigned getMCOperandNum() { return MCOperandNum; } virtual StringRef getSymName() { return StringRef(); } - virtual void *getOpDecl() { return 0; } + virtual void *getOpDecl() { return nullptr; } /// isToken - Is this a token operand? virtual bool isToken() const = 0; diff --git a/include/llvm/Object/ELF.h b/include/llvm/Object/ELF.h index 268b273f43..bc9cc673cb 100644 --- a/include/llvm/Object/ELF.h +++ b/include/llvm/Object/ELF.h @@ -565,7 +565,7 @@ std::pair::Elf_Shdr *, const typename ELFFile::Elf_Sym *> ELFFile::getRelocationSymbol(const Elf_Shdr *Sec, const RelT *Rel) const { if (!Sec->sh_link) - return std::make_pair((const Elf_Shdr *)0, (const Elf_Sym *)0); + return std::make_pair(nullptr, nullptr); const Elf_Shdr *SymTable = getSection(Sec->sh_link); return std::make_pair( SymTable, getEntry(SymTable, Rel->getSymbol(isMips64EL()))); diff --git a/include/llvm/Support/OnDiskHashTable.h b/include/llvm/Support/OnDiskHashTable.h index 14bfd9ad4f..2310580bf3 100644 --- a/include/llvm/Support/OnDiskHashTable.h +++ b/include/llvm/Support/OnDiskHashTable.h @@ -71,7 +71,7 @@ template class OnDiskChainedHashTableGenerator { Item(typename Info::key_type_ref Key, typename Info::data_type_ref Data, Info &InfoObj) - : Key(Key), Data(Data), Next(0), Hash(InfoObj.ComputeHash(Key)) {} + : Key(Key), Data(Data), Next(nullptr), Hash(InfoObj.ComputeHash(Key)) {} }; /// \brief A linked list of values in a particular hash bucket. @@ -102,7 +102,7 @@ private: for (size_t I = 0; I < NumBuckets; ++I) for (Item *E = Buckets[I].Head; E;) { Item *N = E->Next; - E->Next = 0; + E->Next = nullptr; insert(NewBuckets, NewSize, E); E = N; } @@ -273,7 +273,7 @@ public: Info *InfoObj; public: - iterator() : Data(0), Len(0) {} + iterator() : Data(nullptr), Len(0) {} iterator(const internal_key_type K, const unsigned char *D, offset_type L, Info *InfoObj) : Key(K), Data(D), Len(L), InfoObj(InfoObj) {} @@ -406,7 +406,8 @@ public: : Ptr(Ptr), NumItemsInBucketLeft(0), NumEntriesLeft(NumEntries), InfoObj(InfoObj) {} key_iterator() - : Ptr(0), NumItemsInBucketLeft(0), NumEntriesLeft(0), InfoObj(0) {} + : Ptr(nullptr), NumItemsInBucketLeft(0), NumEntriesLeft(0), + InfoObj(0) {} friend bool operator==(const key_iterator &X, const key_iterator &Y) { return X.NumEntriesLeft == Y.NumEntriesLeft; @@ -478,7 +479,8 @@ public: : Ptr(Ptr), NumItemsInBucketLeft(0), NumEntriesLeft(NumEntries), InfoObj(InfoObj) {} data_iterator() - : Ptr(0), NumItemsInBucketLeft(0), NumEntriesLeft(0), InfoObj(0) {} + : Ptr(nullptr), NumItemsInBucketLeft(0), NumEntriesLeft(0), + InfoObj(nullptr) {} bool operator==(const data_iterator &X) const { return X.NumEntriesLeft == NumEntriesLeft; diff --git a/include/llvm/Support/YAMLTraits.h b/include/llvm/Support/YAMLTraits.h index d736b2637f..7f4a922935 100644 --- a/include/llvm/Support/YAMLTraits.h +++ b/include/llvm/Support/YAMLTraits.h @@ -249,7 +249,7 @@ struct has_MappingValidateTraits static double test(...); public: - static bool const value = (sizeof(test >(0)) == 1); + static bool const value = (sizeof(test >(nullptr)) == 1); }; @@ -321,7 +321,7 @@ struct has_DocumentListTraits static double test(...); public: - static bool const value = (sizeof(test >(0)) == 1); + static bool const value = (sizeof(test >(nullptr))==1); }; inline bool isNumber(StringRef S) { diff --git a/lib/Analysis/IPA/CallGraph.cpp b/lib/Analysis/IPA/CallGraph.cpp index f43675b846..1d29d64a13 100644 --- a/lib/Analysis/IPA/CallGraph.cpp +++ b/lib/Analysis/IPA/CallGraph.cpp @@ -21,14 +21,14 @@ using namespace llvm; // CallGraph::CallGraph(Module &M) - : M(M), Root(0), ExternalCallingNode(getOrInsertFunction(0)), - CallsExternalNode(new CallGraphNode(0)) { + : M(M), Root(nullptr), ExternalCallingNode(getOrInsertFunction(nullptr)), + CallsExternalNode(new CallGraphNode(nullptr)) { // Add every function to the call graph. for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) addToCallGraph(I); // If we didn't find a main function, use the external call graph node - if (Root == 0) + if (!Root) Root = ExternalCallingNode; } @@ -210,7 +210,7 @@ void CallGraphNode::removeOneAbstractEdgeTo(CallGraphNode *Callee) { for (CalledFunctionsVector::iterator I = CalledFunctions.begin(); ; ++I) { assert(I != CalledFunctions.end() && "Cannot find callee to remove!"); CallRecord &CR = *I; - if (CR.second == Callee && CR.first == 0) { + if (CR.second == Callee && CR.first == nullptr) { Callee->DropRef(); *I = CalledFunctions.back(); CalledFunctions.pop_back(); @@ -267,7 +267,7 @@ INITIALIZE_PASS(CallGraphWrapperPass, "basiccg", "CallGraph Construction", char CallGraphWrapperPass::ID = 0; -void CallGraphWrapperPass::releaseMemory() { G.reset(0); } +void CallGraphWrapperPass::releaseMemory() { G.reset(nullptr); } void CallGraphWrapperPass::print(raw_ostream &OS, const Module *) const { if (!G) { diff --git a/lib/Analysis/IPA/CallGraphSCCPass.cpp b/lib/Analysis/IPA/CallGraphSCCPass.cpp index 07f420fb1d..498bc148a0 100644 --- a/lib/Analysis/IPA/CallGraphSCCPass.cpp +++ b/lib/Analysis/IPA/CallGraphSCCPass.cpp @@ -113,7 +113,7 @@ bool CGPassManager::RunPassOnSCC(Pass *P, CallGraphSCC &CurSCC, bool Changed = false; PMDataManager *PM = P->getAsPMDataManager(); - if (PM == 0) { + if (!PM) { CallGraphSCCPass *CGSP = (CallGraphSCCPass*)P; if (!CallGraphUpToDate) { DevirtualizedCall |= RefreshCallGraph(CurSCC, CG, false); @@ -191,7 +191,7 @@ bool CGPassManager::RefreshCallGraph(CallGraphSCC &CurSCC, SCCIdx != E; ++SCCIdx, ++FunctionNo) { CallGraphNode *CGN = *SCCIdx; Function *F = CGN->getFunction(); - if (F == 0 || F->isDeclaration()) continue; + if (!F || F->isDeclaration()) continue; // Walk the function body looking for call sites. Sync up the call sites in // CGN with those actually in the function. @@ -204,7 +204,7 @@ bool CGPassManager::RefreshCallGraph(CallGraphSCC &CurSCC, for (CallGraphNode::iterator I = CGN->begin(), E = CGN->end(); I != E; ) { // If this call site is null, then the function pass deleted the call // entirely and the WeakVH nulled it out. - if (I->first == 0 || + if (!I->first || // If we've already seen this call site, then the FunctionPass RAUW'd // one call with another, which resulted in two "uses" in the edge // list of the same call. @@ -218,7 +218,7 @@ bool CGPassManager::RefreshCallGraph(CallGraphSCC &CurSCC, "CallGraphSCCPass did not update the CallGraph correctly!"); // If this was an indirect call site, count it. - if (I->second->getFunction() == 0) + if (!I->second->getFunction()) ++NumIndirectRemoved; else ++NumDirectRemoved; @@ -274,7 +274,7 @@ bool CGPassManager::RefreshCallGraph(CallGraphSCC &CurSCC, // site could be turned direct), don't reject it in checking mode, and // don't tweak it to be more precise. if (CheckingMode && CS.getCalledFunction() && - ExistingNode->getFunction() == 0) + ExistingNode->getFunction() == nullptr) continue; assert(!CheckingMode && @@ -287,7 +287,7 @@ bool CGPassManager::RefreshCallGraph(CallGraphSCC &CurSCC, CalleeNode = CG.getOrInsertFunction(Callee); // Keep track of whether we turned an indirect call into a direct // one. - if (ExistingNode->getFunction() == 0) { + if (!ExistingNode->getFunction()) { DevirtualizedCall = true; DEBUG(dbgs() << " CGSCCPASSMGR: Devirtualized call to '" << Callee->getName() << "'\n"); diff --git a/lib/Analysis/IPA/GlobalsModRef.cpp b/lib/Analysis/IPA/GlobalsModRef.cpp index dd981521b3..e460f01fe2 100644 --- a/lib/Analysis/IPA/GlobalsModRef.cpp +++ b/lib/Analysis/IPA/GlobalsModRef.cpp @@ -178,14 +178,14 @@ namespace { FunctionInfo.find(F); if (I != FunctionInfo.end()) return &I->second; - return 0; + return nullptr; } void AnalyzeGlobals(Module &M); void AnalyzeCallGraph(CallGraph &CG, Module &M); bool AnalyzeUsesOfPointer(Value *V, std::vector &Readers, std::vector &Writers, - GlobalValue *OkayStoreDest = 0); + GlobalValue *OkayStoreDest = nullptr); bool AnalyzeIndirectGlobalMemory(GlobalValue *GV); }; } @@ -493,8 +493,8 @@ GlobalsModRef::alias(const Location &LocA, if (GV1 || GV2) { // If the global's address is taken, pretend we don't know it's a pointer to // the global. - if (GV1 && !NonAddressTakenGlobals.count(GV1)) GV1 = 0; - if (GV2 && !NonAddressTakenGlobals.count(GV2)) GV2 = 0; + if (GV1 && !NonAddressTakenGlobals.count(GV1)) GV1 = nullptr; + if (GV2 && !NonAddressTakenGlobals.count(GV2)) GV2 = nullptr; // If the two pointers are derived from two different non-addr-taken // globals, or if one is and the other isn't, we know these can't alias. @@ -508,7 +508,7 @@ GlobalsModRef::alias(const Location &LocA, // These pointers may be based on the memory owned by an indirect global. If // so, we may be able to handle this. First check to see if the base pointer // is a direct load from an indirect global. - GV1 = GV2 = 0; + GV1 = GV2 = nullptr; if (const LoadInst *LI = dyn_cast(UV1)) if (GlobalVariable *GV = dyn_cast(LI->getOperand(0))) if (IndirectGlobals.count(GV)) diff --git a/lib/Analysis/IPA/InlineCost.cpp b/lib/Analysis/IPA/InlineCost.cpp index 620a0de5d4..c43b5ca250 100644 --- a/lib/Analysis/IPA/InlineCost.cpp +++ b/lib/Analysis/IPA/InlineCost.cpp @@ -926,7 +926,7 @@ bool CallAnalyzer::analyzeBlock(BasicBlock *BB) { /// no constant offsets applied. ConstantInt *CallAnalyzer::stripAndComputeInBoundsConstantOffsets(Value *&V) { if (!DL || !V->getType()->isPointerTy()) - return 0; + return nullptr; unsigned IntPtrWidth = DL->getPointerSizeInBits(); APInt Offset = APInt::getNullValue(IntPtrWidth); @@ -938,7 +938,7 @@ ConstantInt *CallAnalyzer::stripAndComputeInBoundsConstantOffsets(Value *&V) { do { if (GEPOperator *GEP = dyn_cast(V)) { if (!GEP->isInBounds() || !accumulateGEPOffset(*GEP, Offset)) - return 0; + return nullptr; V = GEP->getPointerOperand(); } else if (Operator::getOpcode(V) == Instruction::BitCast) { V = cast(V)->getOperand(0); diff --git a/lib/CodeGen/AsmPrinter/ARMException.cpp b/lib/CodeGen/AsmPrinter/ARMException.cpp index 403feb4583..1a8173cd17 100644 --- a/lib/CodeGen/AsmPrinter/ARMException.cpp +++ b/lib/CodeGen/AsmPrinter/ARMException.cpp @@ -144,7 +144,7 @@ void ARMException::EmitTypeInfos(unsigned TTypeEncoding) { Asm->OutStreamer.AddComment("FilterInfo " + Twine(Entry)); } - Asm->EmitTTypeReference((TypeID == 0 ? 0 : TypeInfos[TypeID - 1]), + Asm->EmitTTypeReference((TypeID == 0 ? nullptr : TypeInfos[TypeID - 1]), TTypeEncoding); } } diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 644d30b065..b67e3e84e6 100644 --- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -65,7 +65,7 @@ char AsmPrinter::ID = 0; typedef DenseMap> gcp_map_type; static gcp_map_type &getGCMap(void *&P) { - if (P == 0) + if (!P) P = new gcp_map_type(); return *(gcp_map_type*)P; } @@ -102,21 +102,21 @@ AsmPrinter::AsmPrinter(TargetMachine &tm, MCStreamer &Streamer) TM(tm), MAI(tm.getMCAsmInfo()), MII(tm.getInstrInfo()), OutContext(Streamer.getContext()), OutStreamer(Streamer), - LastMI(0), LastFn(0), Counter(~0U), SetCounter(0) { - DD = 0; MMI = 0; LI = 0; MF = 0; - CurrentFnSym = CurrentFnSymForSize = 0; - GCMetadataPrinters = 0; + LastMI(nullptr), LastFn(0), Counter(~0U), SetCounter(0) { + DD = nullptr; MMI = nullptr; LI = nullptr; MF = nullptr; + CurrentFnSym = CurrentFnSymForSize = nullptr; + GCMetadataPrinters = nullptr; VerboseAsm = Streamer.isVerboseAsm(); } AsmPrinter::~AsmPrinter() { assert(DD == 0 && Handlers.empty() && "Debug/EH info didn't get finalized"); - if (GCMetadataPrinters != 0) { + if (GCMetadataPrinters) { gcp_map_type &GCMap = getGCMap(GCMetadataPrinters); delete &GCMap; - GCMetadataPrinters = 0; + GCMetadataPrinters = nullptr; } delete &OutStreamer; @@ -232,7 +232,7 @@ bool AsmPrinter::doInitialization(Module &M) { } } - DwarfException *DE = 0; + DwarfException *DE = nullptr; switch (MAI->getExceptionHandlingType()) { case ExceptionHandling::None: break; @@ -743,7 +743,7 @@ void AsmPrinter::EmitFunctionBody() { // Print out code for the function. bool HasAnyRealCode = false; - const MachineInstr *LastMI = 0; + const MachineInstr *LastMI = nullptr; for (auto &MBB : *MF) { // Print a label for the basic block. EmitBasicBlockStart(MBB); @@ -904,7 +904,7 @@ bool AsmPrinter::doFinalization(Module &M) { delete HI.Handler; } Handlers.clear(); - DD = 0; + DD = nullptr; // If the target wants to know about weak references, print them all. if (MAI->getWeakRefDirective()) { @@ -971,8 +971,8 @@ bool AsmPrinter::doFinalization(Module &M) { // after everything else has gone out. EmitEndOfAsmFile(M); - delete Mang; Mang = 0; - MMI = 0; + delete Mang; Mang = nullptr; + MMI = nullptr; OutStreamer.Finish(); OutStreamer.reset(); @@ -1088,7 +1088,7 @@ void AsmPrinter::EmitConstantPool() { void AsmPrinter::EmitJumpTableInfo() { const DataLayout *DL = MF->getTarget().getDataLayout(); const MachineJumpTableInfo *MJTI = MF->getJumpTableInfo(); - if (MJTI == 0) return; + if (!MJTI) return; if (MJTI->getEntryKind() == MachineJumpTableInfo::EK_Inline) return; const std::vector &JT = MJTI->getJumpTables(); if (JT.empty()) return; @@ -1173,7 +1173,7 @@ void AsmPrinter::EmitJumpTableEntry(const MachineJumpTableInfo *MJTI, const MachineBasicBlock *MBB, unsigned UID) const { assert(MBB && MBB->getNumber() >= 0 && "Invalid basic block"); - const MCExpr *Value = 0; + const MCExpr *Value = nullptr; switch (MJTI->getEntryKind()) { case MachineJumpTableInfo::EK_Inline: llvm_unreachable("Cannot emit EK_Inline jump table entry"); @@ -1491,7 +1491,7 @@ static const MCExpr *lowerConstant(const Constant *CV, AsmPrinter &AP) { return MCSymbolRefExpr::Create(AP.GetBlockAddressSymbol(BA), Ctx); const ConstantExpr *CE = dyn_cast(CV); - if (CE == 0) { + if (!CE) { llvm_unreachable("Unknown constant value to lower!"); } @@ -1516,7 +1516,7 @@ static const MCExpr *lowerConstant(const Constant *CV, AsmPrinter &AP) { raw_string_ostream OS(S); OS << "Unsupported expression in static initializer: "; CE->printAsOperand(OS, /*PrintType=*/false, - !AP.MF ? 0 : AP.MF->getFunction()->getParent()); + !AP.MF ? nullptr : AP.MF->getFunction()->getParent()); report_fatal_error(OS.str()); } case Instruction::GetElementPtr: { @@ -2043,7 +2043,7 @@ MCSymbol *AsmPrinter::GetExternalSymbolSymbol(StringRef Sym) const { /// PrintParentLoopComment - Print comments about parent loops of this one. static void PrintParentLoopComment(raw_ostream &OS, const MachineLoop *Loop, unsigned FunctionNumber) { - if (Loop == 0) return; + if (!Loop) return; PrintParentLoopComment(OS, Loop->getParentLoop(), FunctionNumber); OS.indent(Loop->getLoopDepth()*2) << "Parent Loop BB" << FunctionNumber << "_" @@ -2072,7 +2072,7 @@ static void emitBasicBlockLoopComments(const MachineBasicBlock &MBB, const AsmPrinter &AP) { // Add loop depth information const MachineLoop *Loop = LI->getLoopFor(&MBB); - if (Loop == 0) return; + if (!Loop) return; MachineBasicBlock *Header = Loop->getHeader(); assert(Header && "No header for loop"); @@ -2214,7 +2214,7 @@ isBlockOnlyReachableByFallthrough(const MachineBasicBlock *MBB) const { GCMetadataPrinter *AsmPrinter::GetOrCreateGCPrinter(GCStrategy &S) { if (!S.usesMetadata()) - return 0; + return nullptr; gcp_map_type &GCMap = getGCMap(GCMetadataPrinters); gcp_map_type::iterator GCPI = GCMap.find(&S); diff --git a/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp b/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp index 022de00a37..46ee0c856b 100644 --- a/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp +++ b/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp @@ -90,7 +90,7 @@ void AsmPrinter::EmitInlineAsm(StringRef Str, const MDNode *LocMDNode, if (!MCAI->useIntegratedAssembler() && !OutStreamer.isIntegratedAssemblerRequired()) { OutStreamer.EmitRawText(Str); - emitInlineAsmEnd(TM.getSubtarget(), 0); + emitInlineAsmEnd(TM.getSubtarget(), nullptr); return; } @@ -100,7 +100,7 @@ void AsmPrinter::EmitInlineAsm(StringRef Str, const MDNode *LocMDNode, // If the current LLVMContext has an inline asm handler, set it in SourceMgr. LLVMContext &LLVMCtx = MMI->getModule()->getContext(); bool HasDiagHandler = false; - if (LLVMCtx.getInlineAsmDiagnosticHandler() != 0) { + if (LLVMCtx.getInlineAsmDiagnosticHandler() != nullptr) { // If the source manager has an issue, we arrange for srcMgrDiagHandler // to be invoked, getting DiagInfo passed into it. DiagInfo.LocInfo = LocMDNode; @@ -234,10 +234,10 @@ static void EmitMSInlineAsmStr(const char *AsmStr, const MachineInstr *MI, if (InlineAsm::isMemKind(OpFlags)) { Error = AP->PrintAsmMemoryOperand(MI, OpNo, InlineAsmVariant, - /*Modifier*/ 0, OS); + /*Modifier*/ nullptr, OS); } else { Error = AP->PrintAsmOperand(MI, OpNo, InlineAsmVariant, - /*Modifier*/ 0, OS); + /*Modifier*/ nullptr, OS); } } if (Error) { @@ -329,7 +329,7 @@ static void EmitGCCInlineAsmStr(const char *AsmStr, const MachineInstr *MI, ++LastEmitted; const char *StrStart = LastEmitted; const char *StrEnd = strchr(StrStart, '}'); - if (StrEnd == 0) + if (!StrEnd) report_fatal_error("Unterminated ${:foo} operand in inline asm" " string: '" + Twine(AsmStr) + "'"); @@ -404,11 +404,11 @@ static void EmitGCCInlineAsmStr(const char *AsmStr, const MachineInstr *MI, else { if (InlineAsm::isMemKind(OpFlags)) { Error = AP->PrintAsmMemoryOperand(MI, OpNo, InlineAsmVariant, - Modifier[0] ? Modifier : 0, + Modifier[0] ? Modifier : nullptr, OS); } else { Error = AP->PrintAsmOperand(MI, OpNo, InlineAsmVariant, - Modifier[0] ? Modifier : 0, OS); + Modifier[0] ? Modifier : nullptr, OS); } } } @@ -457,7 +457,7 @@ void AsmPrinter::EmitInlineAsm(const MachineInstr *MI) const { // Get the !srcloc metadata node if we have it, and decode the loc cookie from // it. unsigned LocCookie = 0; - const MDNode *LocMD = 0; + const MDNode *LocMD = nullptr; for (unsigned i = MI->getNumOperands(); i != 0; --i) { if (MI->getOperand(i-1).isMetadata() && (LocMD = MI->getOperand(i-1).getMetadata()) && diff --git a/lib/CodeGen/AsmPrinter/DIE.cpp b/lib/CodeGen/AsmPrinter/DIE.cpp index db891ae8d3..30518ba3d5 100644 --- a/lib/CodeGen/AsmPrinter/DIE.cpp +++ b/lib/CodeGen/AsmPrinter/DIE.cpp @@ -122,7 +122,7 @@ const DIE *DIE::getUnitOrNull() const { return p; p = p->getParent(); } - return NULL; + return nullptr; } DIEValue *DIE::findAttribute(dwarf::Attribute Attribute) const { @@ -134,7 +134,7 @@ DIEValue *DIE::findAttribute(dwarf::Attribute Attribute) const { for (size_t i = 0; i < Values.size(); ++i) if (Abbrevs.getData()[i].getAttribute() == Attribute) return Values[i]; - return NULL; + return nullptr; } #ifndef NDEBUG diff --git a/lib/CodeGen/AsmPrinter/DIE.h b/lib/CodeGen/AsmPrinter/DIE.h index 3876728307..7d7fd743c4 100644 --- a/lib/CodeGen/AsmPrinter/DIE.h +++ b/lib/CodeGen/AsmPrinter/DIE.h @@ -135,12 +135,12 @@ protected: protected: DIE() : Offset(0), Size(0), Abbrev((dwarf::Tag)0, dwarf::DW_CHILDREN_no), - Parent(0) {} + Parent(nullptr) {} public: explicit DIE(dwarf::Tag Tag) : Offset(0), Size(0), Abbrev((dwarf::Tag)Tag, dwarf::DW_CHILDREN_no), - Parent(0) {} + Parent(nullptr) {} // Accessors. DIEAbbrev &getAbbrev() { return Abbrev; } diff --git a/lib/CodeGen/AsmPrinter/DIEHash.h b/lib/CodeGen/AsmPrinter/DIEHash.h index 48f16011e8..175d66063d 100644 --- a/lib/CodeGen/AsmPrinter/DIEHash.h +++ b/lib/CodeGen/AsmPrinter/DIEHash.h @@ -89,7 +89,7 @@ class DIEHash { }; public: - DIEHash(AsmPrinter *A = NULL) : AP(A) {} + DIEHash(AsmPrinter *A = nullptr) : AP(A) {} /// \brief Computes the ODR signature. uint64_t computeDIEODRSignature(const DIE &Die); diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index bc155f4f03..a44fd3de3e 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -170,8 +170,8 @@ static LLVM_CONSTEXPR DwarfAccelTable::Atom TypeAtoms[] = { DwarfAccelTable::Atom(dwarf::DW_ATOM_type_flags, dwarf::DW_FORM_data1)}; DwarfDebug::DwarfDebug(AsmPrinter *A, Module *M) - : Asm(A), MMI(Asm->MMI), FirstCU(0), PrevLabel(NULL), GlobalRangeCount(0), - InfoHolder(A, "info_string", DIEValueAllocator), + : Asm(A), MMI(Asm->MMI), FirstCU(nullptr), PrevLabel(nullptr), + GlobalRangeCount(0), InfoHolder(A, "info_string", DIEValueAllocator), UsedNonDefaultText(false), SkeletonHolder(A, "skel_string", DIEValueAllocator), AccelNames(DwarfAccelTable::Atom(dwarf::DW_ATOM_die_offset, @@ -182,13 +182,14 @@ DwarfDebug::DwarfDebug(AsmPrinter *A, Module *M) dwarf::DW_FORM_data4)), AccelTypes(TypeAtoms) { - DwarfInfoSectionSym = DwarfAbbrevSectionSym = DwarfStrSectionSym = 0; - DwarfDebugRangeSectionSym = DwarfDebugLocSectionSym = DwarfLineSectionSym = 0; - DwarfAddrSectionSym = 0; - DwarfAbbrevDWOSectionSym = DwarfStrDWOSectionSym = 0; - FunctionBeginSym = FunctionEndSym = 0; - CurFn = 0; - CurMI = 0; + DwarfInfoSectionSym = DwarfAbbrevSectionSym = DwarfStrSectionSym = nullptr; + DwarfDebugRangeSectionSym = DwarfDebugLocSectionSym = nullptr; + DwarfLineSectionSym = nullptr; + DwarfAddrSectionSym = nullptr; + DwarfAbbrevDWOSectionSym = DwarfStrDWOSectionSym = nullptr; + FunctionBeginSym = FunctionEndSym = nullptr; + CurFn = nullptr; + CurMI = nullptr; // Turn on accelerator tables for Darwin by default, pubnames by // default for non-Darwin, and handle split dwarf. @@ -222,10 +223,10 @@ DwarfDebug::DwarfDebug(AsmPrinter *A, Module *M) // Switch to the specified MCSection and emit an assembler // temporary label to it if SymbolStem is specified. static MCSymbol *emitSectionSym(AsmPrinter *Asm, const MCSection *Section, - const char *SymbolStem = 0) { + const char *SymbolStem = nullptr) { Asm->OutStreamer.SwitchSection(Section); if (!SymbolStem) - return 0; + return nullptr; MCSymbol *TmpSym = Asm->GetTempSymbol(SymbolStem); Asm->OutStreamer.EmitLabel(TmpSym); @@ -423,7 +424,7 @@ void DwarfDebug::addScopeRangeList(DwarfCompileUnit &TheCU, DIE *ScopeDIE, DIE *DwarfDebug::constructLexicalScopeDIE(DwarfCompileUnit &TheCU, LexicalScope *Scope) { if (isLexicalScopeDIENull(Scope)) - return 0; + return nullptr; DIE *ScopeDIE = new DIE(dwarf::DW_TAG_lexical_block); if (Scope->isAbstractScope()) @@ -460,13 +461,13 @@ DIE *DwarfDebug::constructInlinedScopeDIE(DwarfCompileUnit &TheCU, "LexicalScope does not have instruction markers!"); if (!Scope->getScopeNode()) - return NULL; + return nullptr; DIScope DS(Scope->getScopeNode()); DISubprogram InlinedSP = getDISubprogram(DS); DIE *OriginDIE = TheCU.getDIE(InlinedSP); if (!OriginDIE) { DEBUG(dbgs() << "Unable to find original DIE for an inlined subprogram."); - return NULL; + return nullptr; } DIE *ScopeDIE = new DIE(dwarf::DW_TAG_inlined_subroutine); @@ -480,7 +481,7 @@ DIE *DwarfDebug::constructInlinedScopeDIE(DwarfCompileUnit &TheCU, MCSymbol *StartLabel = getLabelBeforeInsn(RI->first); MCSymbol *EndLabel = getLabelAfterInsn(RI->second); - if (StartLabel == 0 || EndLabel == 0) + if (!StartLabel || !EndLabel) llvm_unreachable("Unexpected Start and End labels for an inlined scope!"); assert(StartLabel->isDefined() && @@ -508,7 +509,7 @@ DIE *DwarfDebug::constructInlinedScopeDIE(DwarfCompileUnit &TheCU, DIE *DwarfDebug::createScopeChildrenDIE(DwarfCompileUnit &TheCU, LexicalScope *Scope, SmallVectorImpl &Children) { - DIE *ObjectPointer = NULL; + DIE *ObjectPointer = nullptr; // Collect arguments for current function. if (LScopes.isCurrentFunctionScope(Scope)) { @@ -549,18 +550,18 @@ DIE *DwarfDebug::createScopeChildrenDIE(DwarfCompileUnit &TheCU, DIE *DwarfDebug::constructScopeDIE(DwarfCompileUnit &TheCU, LexicalScope *Scope) { if (!Scope || !Scope->getScopeNode()) - return NULL; + return nullptr; DIScope DS(Scope->getScopeNode()); SmallVector Children; - DIE *ObjectPointer = NULL; + DIE *ObjectPointer = nullptr; bool ChildrenCreated = false; // We try to create the scope DIE first, then the children DIEs. This will // avoid creating un-used children then removing them later when we find out // the scope DIE is null. - DIE *ScopeDIE = NULL; + DIE *ScopeDIE = nullptr; if (Scope->getInlinedAt()) ScopeDIE = constructInlinedScopeDIE(TheCU, Scope); else if (DS.isSubprogram()) { @@ -575,7 +576,7 @@ DIE *DwarfDebug::constructScopeDIE(DwarfCompileUnit &TheCU, } else { // Early exit when we know the scope DIE is going to be null. if (isLexicalScopeDIENull(Scope)) - return NULL; + return nullptr; // We create children here when we know the scope DIE is not going to be // null and the children will be added to the scope DIE. @@ -588,10 +589,10 @@ DIE *DwarfDebug::constructScopeDIE(DwarfCompileUnit &TheCU, std::equal_range( ScopesWithImportedEntities.begin(), ScopesWithImportedEntities.end(), - std::pair(DS, (const MDNode *)0), + std::pair(DS, nullptr), less_first()); if (Children.empty() && Range.first == Range.second) - return NULL; + return nullptr; ScopeDIE = constructLexicalScopeDIE(TheCU, Scope); assert(ScopeDIE && "Scope DIE should not be null."); for (ImportedEntityMap::const_iterator i = Range.first; i != Range.second; @@ -602,7 +603,7 @@ DIE *DwarfDebug::constructScopeDIE(DwarfCompileUnit &TheCU, if (!ScopeDIE) { assert(Children.empty() && "We create children only when the scope DIE is not null."); - return NULL; + return nullptr; } if (!ChildrenCreated) // We create children when the scope DIE is not null. @@ -612,7 +613,7 @@ DIE *DwarfDebug::constructScopeDIE(DwarfCompileUnit &TheCU, for (DIE *I : Children) ScopeDIE->addChild(I); - if (DS.isSubprogram() && ObjectPointer != NULL) + if (DS.isSubprogram() && ObjectPointer != nullptr) TheCU.addDIEEntry(ScopeDIE, dwarf::DW_AT_object_pointer, ObjectPointer); return ScopeDIE; @@ -860,7 +861,7 @@ void DwarfDebug::collectDeadVariables() { DIVariable DV(Variables.getElement(vi)); if (!DV.isVariable()) continue; - DbgVariable NewVar(DV, NULL, this); + DbgVariable NewVar(DV, nullptr, this); if (DIE *VariableDIE = SPCU->constructVariableDIE(NewVar, false)) SPDIE->addChild(VariableDIE); } @@ -959,7 +960,7 @@ void DwarfDebug::endSections() { // Some symbols (e.g. common/bss on mach-o) can have no section but still // appear in the output. This sucks as we rely on sections to build // arange spans. We can do it without, but it's icky. - SectionMap[NULL].push_back(SCU); + SectionMap[nullptr].push_back(SCU); } } @@ -977,7 +978,7 @@ void DwarfDebug::endSections() { // Add terminating symbols for each section. for (unsigned ID = 0, E = Sections.size(); ID != E; ID++) { const MCSection *Section = Sections[ID]; - MCSymbol *Sym = NULL; + MCSymbol *Sym = nullptr; if (Section) { // We can't call MCSection::getLabelEndName, as it's only safe to do so @@ -990,7 +991,7 @@ void DwarfDebug::endSections() { } // Insert a final terminator. - SectionMap[Section].push_back(SymbolCU(NULL, Sym)); + SectionMap[Section].push_back(SymbolCU(nullptr, Sym)); } } @@ -1054,7 +1055,7 @@ void DwarfDebug::endModule() { SPMap.clear(); // Reset these for the next Module if we have one. - FirstCU = NULL; + FirstCU = nullptr; } // Find abstract variable, if any, associated with Var. @@ -1069,9 +1070,9 @@ DbgVariable *DwarfDebug::findAbstractVariable(DIVariable &DV, LexicalScope *Scope = LScopes.findAbstractScope(ScopeLoc.getScope(Ctx)); if (!Scope) - return NULL; + return nullptr; - AbsDbgVariable = new DbgVariable(Var, NULL, this); + AbsDbgVariable = new DbgVariable(Var, nullptr, this); addScopeVariable(Scope, AbsDbgVariable); AbstractVariables[Var] = AbsDbgVariable; return AbsDbgVariable; @@ -1110,7 +1111,7 @@ void DwarfDebug::collectVariableInfoFromMMITable( LexicalScope *Scope = LScopes.findLexicalScope(VI.Loc); // If variable scope is not found then skip this variable. - if (Scope == 0) + if (!Scope) continue; DbgVariable *AbsDbgVariable = findAbstractVariable(DV, VI.Loc); @@ -1183,7 +1184,7 @@ DwarfDebug::collectVariableInfo(SmallPtrSet &Processed) { const MachineInstr *MInsn = History.front(); DIVariable DV(Var); - LexicalScope *Scope = NULL; + LexicalScope *Scope = nullptr; if (DV.getTag() == dwarf::DW_TAG_arg_variable && DISubprogram(DV.getContext()).describes(CurFn->getFunction())) Scope = LScopes.getCurrentFunctionScope(); @@ -1233,7 +1234,7 @@ DwarfDebug::collectVariableInfo(SmallPtrSet &Processed) { // Compute the range for a register location. const MCSymbol *FLabel = getLabelBeforeInsn(Begin); - const MCSymbol *SLabel = 0; + const MCSymbol *SLabel = nullptr; if (HI + 1 == HE) // If Begin is the last instruction in History then its value is valid @@ -1270,7 +1271,7 @@ DwarfDebug::collectVariableInfo(SmallPtrSet &Processed) { if (!DV || !DV.isVariable() || !Processed.insert(DV)) continue; if (LexicalScope *Scope = LScopes.findLexicalScope(DV.getContext())) - addScopeVariable(Scope, new DbgVariable(DV, NULL, this)); + addScopeVariable(Scope, new DbgVariable(DV, nullptr, this)); } } @@ -1307,7 +1308,7 @@ void DwarfDebug::beginInstruction(const MachineInstr *MI) { const MDNode *Scope = DL.getScope(Asm->MF->getFunction()->getContext()); recordSourceLine(DL.getLine(), DL.getCol(), Scope, Flags); } else - recordSourceLine(0, 0, 0, 0); + recordSourceLine(0, 0, nullptr, 0); } } @@ -1336,11 +1337,11 @@ void DwarfDebug::endInstruction() { // Don't create a new label after DBG_VALUE instructions. // They don't generate code. if (!CurMI->isDebugValue()) - PrevLabel = 0; + PrevLabel = nullptr; DenseMap::iterator I = LabelsAfterInsn.find(CurMI); - CurMI = 0; + CurMI = nullptr; // No label needed. if (I == LabelsAfterInsn.end()) @@ -1507,7 +1508,7 @@ void DwarfDebug::beginFunction(const MachineFunction *MF) { if (!Var) continue; // Reg is now clobbered. - LiveUserVar[Reg] = 0; + LiveUserVar[Reg] = nullptr; // Was MD last defined by a DBG_VALUE referring to Reg? DbgValueHistoryMap::iterator HistI = DbgValues.find(Var); @@ -1613,7 +1614,7 @@ void DwarfDebug::endFunction(const MachineFunction *MF) { // Every beginFunction(MF) call should be followed by an endFunction(MF) call, // though the beginFunction may not be called at all. // We should handle both cases. - if (CurFn == 0) + if (!CurFn) CurFn = MF; else assert(CurFn == MF); @@ -1625,7 +1626,7 @@ void DwarfDebug::endFunction(const MachineFunction *MF) { // previously used section to nullptr. PrevSection = nullptr; PrevCU = nullptr; - CurFn = 0; + CurFn = nullptr; return; } @@ -1660,7 +1661,7 @@ void DwarfDebug::endFunction(const MachineFunction *MF) { if (AbstractVariables.lookup(CleanDV)) continue; if (LexicalScope *Scope = LScopes.findAbstractScope(DV.getContext())) - addScopeVariable(Scope, new DbgVariable(DV, NULL, this)); + addScopeVariable(Scope, new DbgVariable(DV, nullptr, this)); } } if (ProcessedSPNodes.count(AScope->getScopeNode()) == 0) @@ -1687,8 +1688,8 @@ void DwarfDebug::endFunction(const MachineFunction *MF) { AbstractVariables.clear(); LabelsBeforeInsn.clear(); LabelsAfterInsn.clear(); - PrevLabel = NULL; - CurFn = 0; + PrevLabel = nullptr; + CurFn = nullptr; } // Register a source line with debug info. Returns the unique label that was @@ -2229,11 +2230,11 @@ void DwarfDebug::emitDebugARanges() { // If we have no section (e.g. common), just write out // individual spans for each symbol. - if (Section == NULL) { + if (!Section) { for (const SymbolCU &Cur : List) { ArangeSpan Span; Span.Start = Cur.Sym; - Span.End = NULL; + Span.End = nullptr; if (Cur.CU) Spans[Cur.CU].push_back(Span); } @@ -2426,7 +2427,7 @@ DwarfTypeUnit &DwarfDebug::constructSkeletonTU(DwarfTypeUnit &TU) { this, &SkeletonHolder); DwarfTypeUnit &NewTU = *OwnedUnit; NewTU.setTypeSignature(TU.getTypeSignature()); - NewTU.setType(NULL); + NewTU.setType(nullptr); NewTU.initSection( Asm->getObjFileLowering().getDwarfTypesSection(TU.getTypeSignature())); diff --git a/lib/CodeGen/AsmPrinter/DwarfException.cpp b/lib/CodeGen/AsmPrinter/DwarfException.cpp index 113a9e4cd4..282a1bf5b4 100644 --- a/lib/CodeGen/AsmPrinter/DwarfException.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfException.cpp @@ -103,7 +103,7 @@ ComputeActionsTable(const SmallVectorImpl &LandingPads, int FirstAction = 0; unsigned SizeActions = 0; - const LandingPadInfo *PrevLPI = 0; + const LandingPadInfo *PrevLPI = nullptr; for (SmallVectorImpl::const_iterator I = LandingPads.begin(), E = LandingPads.end(); I != E; ++I) { @@ -181,7 +181,7 @@ bool DwarfException::CallToNoUnwindFunction(const MachineInstr *MI) { if (!MO.isGlobal()) continue; const Function *F = dyn_cast(MO.getGlobal()); - if (F == 0) continue; + if (!F) continue; if (SawFunc) { // Be conservative. If we have more than one function operand for this @@ -214,7 +214,7 @@ ComputeCallSiteTable(SmallVectorImpl &CallSites, const SmallVectorImpl &LandingPads, const SmallVectorImpl &FirstActions) { // The end label of the previous invoke or nounwind try-range. - MCSymbol *LastLabel = 0; + MCSymbol *LastLabel = nullptr; // Whether there is a potentially throwing instruction (currently this means // an ordinary call) between the end of the previous try-range and now. @@ -255,7 +255,7 @@ ComputeCallSiteTable(SmallVectorImpl &CallSites, // create a call-site entry with no landing pad for the region between the // try-ranges. if (SawPotentiallyThrowing && Asm->MAI->isExceptionHandlingDwarf()) { - CallSiteEntry Site = { LastLabel, BeginLabel, 0, 0 }; + CallSiteEntry Site = { LastLabel, BeginLabel, nullptr, 0 }; CallSites.push_back(Site); PreviousIsInvoke = false; } @@ -305,7 +305,7 @@ ComputeCallSiteTable(SmallVectorImpl &CallSites, // function may throw, create a call-site entry with no landing pad for the // region following the try-range. if (SawPotentiallyThrowing && Asm->MAI->isExceptionHandlingDwarf()) { - CallSiteEntry Site = { LastLabel, 0, 0, 0 }; + CallSiteEntry Site = { LastLabel, nullptr, nullptr, 0 }; CallSites.push_back(Site); } } @@ -571,10 +571,10 @@ void DwarfException::EmitExceptionTable() { Asm->GetTempSymbol("eh_func_begin", Asm->getFunctionNumber()); MCSymbol *BeginLabel = S.BeginLabel; - if (BeginLabel == 0) + if (!BeginLabel) BeginLabel = EHFuncBeginSym; MCSymbol *EndLabel = S.EndLabel; - if (EndLabel == 0) + if (!EndLabel) EndLabel = Asm->GetTempSymbol("eh_func_end", Asm->getFunctionNumber()); diff --git a/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/lib/CodeGen/AsmPrinter/DwarfUnit.cpp index 333829e8a7..6a2cb6880c 100644 --- a/lib/CodeGen/AsmPrinter/DwarfUnit.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfUnit.cpp @@ -44,7 +44,8 @@ GenerateDwarfTypeUnits("generate-type-units", cl::Hidden, DwarfUnit::DwarfUnit(unsigned UID, DIE *D, DICompileUnit Node, AsmPrinter *A, DwarfDebug *DW, DwarfFile *DWU) : UniqueID(UID), CUNode(Node), UnitDie(D), DebugInfoOffset(0), Asm(A), - DD(DW), DU(DWU), IndexTyDie(0), Section(0), Skeleton(0) { + DD(DW), DU(DWU), IndexTyDie(nullptr), Section(nullptr), + Skeleton(nullptr) { DIEIntegerOne = new (DIEValueAllocator) DIEInteger(1); } @@ -979,7 +980,7 @@ DIE *DwarfUnit::createTypeDIE(DICompositeType Ty) { /// given DIType. DIE *DwarfUnit::getOrCreateTypeDIE(const MDNode *TyNode) { if (!TyNode) - return NULL; + return nullptr; DIType Ty(TyNode); assert(Ty.isType()); @@ -1226,7 +1227,7 @@ void DwarfUnit::constructTypeDIE(DIE &Buffer, DICompositeType CTy) { DIArray Elements = CTy.getTypeArray(); for (unsigned i = 0, N = Elements.getNumElements(); i < N; ++i) { DIDescriptor Element = Elements.getElement(i); - DIE *ElemDie = NULL; + DIE *ElemDie = nullptr; if (Element.isSubprogram()) ElemDie = getOrCreateSubprogramDIE(DISubprogram(Element)); else if (Element.isDerivedType()) { @@ -1430,7 +1431,7 @@ DIE *DwarfUnit::getOrCreateSubprogramDIE(DISubprogram SP) { // DW_TAG_inlined_subroutine may refer to this DIE. SPDie = createAndAddDIE(dwarf::DW_TAG_subprogram, *ContextDIE, SP); - DIE *DeclDie = NULL; + DIE *DeclDie = nullptr; if (SPDecl.isSubprogram()) DeclDie = getOrCreateSubprogramDIE(SPDecl); @@ -1542,22 +1543,22 @@ static const ConstantExpr *getMergedGlobalExpr(const Value *V) { const ConstantExpr *CE = dyn_cast_or_null(V); if (!CE || CE->getNumOperands() != 3 || CE->getOpcode() != Instruction::GetElementPtr) - return NULL; + return nullptr; // First operand points to a global struct. Value *Ptr = CE->getOperand(0); if (!isa(Ptr) || !isa(cast(Ptr->getType())->getElementType())) - return NULL; + return nullptr; // Second operand is zero. const ConstantInt *CI = dyn_cast_or_null(CE->getOperand(1)); if (!CI || !CI->isZero()) - return NULL; + return nullptr; // Third operand is offset. if (!isa(CE->getOperand(2))) - return NULL; + return nullptr; return CE; } @@ -1575,7 +1576,7 @@ void DwarfCompileUnit::createGlobalVariableDIE(DIGlobalVariable GV) { // If this is a static data member definition, some attributes belong // to the declaration DIE. - DIE *VariableDIE = NULL; + DIE *VariableDIE = nullptr; bool IsStaticMember = false; DIDerivedType SDMDecl = GV.getStaticDataMemberDeclaration(); if (SDMDecl.Verify()) { @@ -1609,8 +1610,8 @@ void DwarfCompileUnit::createGlobalVariableDIE(DIGlobalVariable GV) { // Add location. bool addToAccelTable = false; - DIE *VariableSpecDIE = NULL; - bool isGlobalVariable = GV.getGlobal() != NULL; + DIE *VariableSpecDIE = nullptr; + bool isGlobalVariable = GV.getGlobal() != nullptr; if (isGlobalVariable) { addToAccelTable = true; DIELoc *Loc = new (DIEValueAllocator) DIELoc(); @@ -1806,7 +1807,7 @@ DIE *DwarfUnit::constructVariableDIE(DbgVariable &DV, bool isScopeAbstract) { // Define variable debug information entry. DIE *VariableDie = new DIE(DV.getTag()); DbgVariable *AbsVar = DV.getAbstractVariable(); - DIE *AbsDIE = AbsVar ? AbsVar->getDIE() : NULL; + DIE *AbsDIE = AbsVar ? AbsVar->getDIE() : nullptr; if (AbsDIE) addDIEEntry(VariableDie, dwarf::DW_AT_abstract_origin, AbsDIE); else { @@ -1963,7 +1964,7 @@ void DwarfUnit::constructMemberDIE(DIE &Buffer, DIDerivedType DT) { /// getOrCreateStaticMemberDIE - Create new DIE for C++ static member. DIE *DwarfUnit::getOrCreateStaticMemberDIE(DIDerivedType DT) { if (!DT.Verify()) - return NULL; + return nullptr; // Construct the context before querying for the existence of the DIE in case // such construction creates the DIE. diff --git a/lib/CodeGen/AsmPrinter/WinCodeViewLineTables.cpp b/lib/CodeGen/AsmPrinter/WinCodeViewLineTables.cpp index 50b2ca82ec..abf0c4b12c 100644 --- a/lib/CodeGen/AsmPrinter/WinCodeViewLineTables.cpp +++ b/lib/CodeGen/AsmPrinter/WinCodeViewLineTables.cpp @@ -29,7 +29,7 @@ StringRef WinCodeViewLineTables::getFullFilepath(const MDNode *S) { StringRef Dir = Scope.getDirectory(), Filename = Scope.getFilename(); char *&Result = DirAndFilenameToFilepathMap[std::make_pair(Dir, Filename)]; - if (Result != 0) + if (Result) return Result; // Clang emits directory and relative filename info into the IR, but CodeView @@ -102,7 +102,7 @@ void WinCodeViewLineTables::maybeRecordLocation(DebugLoc DL, } WinCodeViewLineTables::WinCodeViewLineTables(AsmPrinter *AP) - : Asm(0), CurFn(0) { + : Asm(nullptr), CurFn(nullptr) { MachineModuleInfo *MMI = AP->MMI; // If module doesn't have named metadata anchors or COFF debug section @@ -171,7 +171,7 @@ void WinCodeViewLineTables::emitDebugInfoForFunction(const Function *GV) { EmitLabelDiff(Asm->OutStreamer, Fn, FI.End); // PC-to-linenumber lookup table: - MCSymbol *FileSegmentEnd = 0; + MCSymbol *FileSegmentEnd = nullptr; for (size_t J = 0, F = FI.Instrs.size(); J != F; ++J) { MCSymbol *Instr = FI.Instrs[J]; assert(InstrInfo.count(Instr)); @@ -321,7 +321,7 @@ void WinCodeViewLineTables::endFunction(const MachineFunction *MF) { Asm->OutStreamer.EmitLabel(FunctionEndSym); CurFn->End = FunctionEndSym; } - CurFn = 0; + CurFn = nullptr; } void WinCodeViewLineTables::beginInstruction(const MachineInstr *MI) { diff --git a/lib/CodeGen/AtomicExpandLoadLinkedPass.cpp b/lib/CodeGen/AtomicExpandLoadLinkedPass.cpp index 2678b8106d..d995333971 100644 --- a/lib/CodeGen/AtomicExpandLoadLinkedPass.cpp +++ b/lib/CodeGen/AtomicExpandLoadLinkedPass.cpp @@ -30,8 +30,8 @@ namespace { const TargetLowering *TLI; public: static char ID; // Pass identification, replacement for typeid - explicit AtomicExpandLoadLinked(const TargetMachine *TM = 0) - : FunctionPass(ID), TLI(TM ? TM->getTargetLowering() : 0) { + explicit AtomicExpandLoadLinked(const TargetMachine *TM = nullptr) + : FunctionPass(ID), TLI(TM ? TM->getTargetLowering() : nullptr) { initializeAtomicExpandLoadLinkedPass(*PassRegistry::getPassRegistry()); } diff --git a/lib/ExecutionEngine/Interpreter/Execution.cpp b/lib/ExecutionEngine/Interpreter/Execution.cpp index a0a945be62..2275f57ab8 100644 --- a/lib/ExecutionEngine/Interpreter/Execution.cpp +++ b/lib/ExecutionEngine/Interpreter/Execution.cpp @@ -897,7 +897,7 @@ void Interpreter::visitSwitchInst(SwitchInst &I) { GenericValue CondVal = getOperandValue(Cond, SF); // Check to see if any of the cases match... - BasicBlock *Dest = 0; + BasicBlock *Dest = nullptr; for (SwitchInst::CaseIt i = I.case_begin(), e = I.case_end(); i != e; ++i) { GenericValue CaseVal = getOperandValue(i.getCaseValue(), SF); if (executeICMP_EQ(CondVal, CaseVal, ElTy).IntVal != 0) { diff --git a/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp b/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp index a03c7f5596..671bbeea8d 100644 --- a/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp +++ b/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp @@ -98,13 +98,13 @@ static ExFunc lookupFunction(const Function *F) { sys::ScopedLock Writer(*FunctionsLock); ExFunc FnPtr = FuncNames[ExtName]; - if (FnPtr == 0) + if (!FnPtr) FnPtr = FuncNames["lle_X_" + F->getName().str()]; - if (FnPtr == 0) // Try calling a generic function... if it exists... + if (!FnPtr) // Try calling a generic function... if it exists... FnPtr = (ExFunc)(intptr_t) sys::DynamicLibrary::SearchForAddressOfSymbol("lle_X_" + F->getName().str()); - if (FnPtr != 0) + if (FnPtr) ExportedFunctions->insert(std::make_pair(F, FnPtr)); // Cache for later return FnPtr; } diff --git a/lib/ExecutionEngine/Interpreter/Interpreter.cpp b/lib/ExecutionEngine/Interpreter/Interpreter.cpp index 6d4f6f716f..c589457b67 100644 --- a/lib/ExecutionEngine/Interpreter/Interpreter.cpp +++ b/lib/ExecutionEngine/Interpreter/Interpreter.cpp @@ -38,7 +38,7 @@ ExecutionEngine *Interpreter::create(Module *M, std::string* ErrStr) { if (ErrStr) *ErrStr = EC.message(); // We got an error, just return 0 - return 0; + return nullptr; } return new Interpreter(M); diff --git a/lib/ExecutionEngine/JIT/JIT.cpp b/lib/ExecutionEngine/JIT/JIT.cpp index 76101927d2..f8b2827945 100644 --- a/lib/ExecutionEngine/JIT/JIT.cpp +++ b/lib/ExecutionEngine/JIT/JIT.cpp @@ -79,7 +79,7 @@ ExecutionEngine *JIT::createJIT(Module *M, // Try to register the program as a source of symbols to resolve against. // // FIXME: Don't do this here. - sys::DynamicLibrary::LoadLibraryPermanently(0, NULL); + sys::DynamicLibrary::LoadLibraryPermanently(nullptr, nullptr); // If the target supports JIT code generation, create the JIT. if (TargetJITInfo *TJ = TM->getJITInfo()) { @@ -87,7 +87,7 @@ ExecutionEngine *JIT::createJIT(Module *M, } else { if (ErrorStr) *ErrorStr = "target does not support JIT code generation"; - return 0; + return nullptr; } } @@ -210,7 +210,7 @@ bool JIT::removeModule(Module *M) { if (jitstate && jitstate->getModule() == M) { delete jitstate; - jitstate = 0; + jitstate = nullptr; } if (!jitstate && !Modules.empty()) { @@ -353,7 +353,7 @@ GenericValue JIT::runFunction(Function *F, // currently don't support varargs. SmallVector Args; for (unsigned i = 0, e = ArgValues.size(); i != e; ++i) { - Constant *C = 0; + Constant *C = nullptr; Type *ArgTy = FTy->getParamType(i); const GenericValue &AV = ArgValues[i]; switch (ArgTy->getTypeID()) { @@ -406,13 +406,13 @@ GenericValue JIT::runFunction(Function *F, } void JIT::RegisterJITEventListener(JITEventListener *L) { - if (L == NULL) + if (!L) return; MutexGuard locked(lock); EventListeners.push_back(L); } void JIT::UnregisterJITEventListener(JITEventListener *L) { - if (L == NULL) + if (!L) return; MutexGuard locked(lock); std::vector::reverse_iterator I= @@ -584,7 +584,7 @@ void *JIT::getPointerToNamedFunction(const std::string &Name, report_fatal_error("Program used external function '"+Name+ "' which could not be resolved!"); } - return 0; + return nullptr; } @@ -604,7 +604,7 @@ void *JIT::getOrEmitGlobalVariable(const GlobalVariable *GV) { return (void*)&__dso_handle; #endif Ptr = sys::DynamicLibrary::SearchForAddressOfSymbol(GV->getName()); - if (Ptr == 0) { + if (!Ptr) { report_fatal_error("Could not resolve external global address: " +GV->getName()); } @@ -629,10 +629,10 @@ void *JIT::recompileAndRelinkFunction(Function *F) { void *OldAddr = getPointerToGlobalIfAvailable(F); // If it's not already compiled there is no reason to patch it up. - if (OldAddr == 0) { return getPointerToFunction(F); } + if (!OldAddr) return getPointerToFunction(F); // Delete the old function mapping. - addGlobalMapping(F, 0); + addGlobalMapping(F, nullptr); // Recodegen the function runJITOnFunction(F); diff --git a/lib/ExecutionEngine/JIT/JITEmitter.cpp b/lib/ExecutionEngine/JIT/JITEmitter.cpp index ed23ae3dd0..3ac6ca0878 100644 --- a/lib/ExecutionEngine/JIT/JITEmitter.cpp +++ b/lib/ExecutionEngine/JIT/JITEmitter.cpp @@ -344,7 +344,8 @@ namespace { void *FunctionBody; // Beginning of the function's allocation. void *Code; // The address the function's code actually starts at. void *ExceptionTable; - EmittedCode() : FunctionBody(0), Code(0), ExceptionTable(0) {} + EmittedCode() : FunctionBody(nullptr), Code(nullptr), + ExceptionTable(nullptr) {} }; struct EmittedFunctionConfig : public ValueMapConfig { typedef JITEmitter *ExtraData; @@ -361,7 +362,7 @@ namespace { public: JITEmitter(JIT &jit, JITMemoryManager *JMM, TargetMachine &TM) - : SizeEstimate(0), Resolver(jit, *this), MMI(0), CurFn(0), + : SizeEstimate(0), Resolver(jit, *this), MMI(nullptr), CurFn(nullptr), EmittedFunctions(this), TheJIT(&jit) { MemMgr = JMM ? JMM : JITMemoryManager::CreateDefaultMemManager(); if (jit.getJITInfo().needsGOT()) { @@ -517,7 +518,7 @@ void *JITResolver::getLazyFunctionStub(Function *F) { // Call the lazy resolver function if we are JIT'ing lazily. Otherwise we // must resolve the symbol now. void *Actual = TheJIT->isCompilingLazily() - ? (void *)(intptr_t)LazyResolverFn : (void *)0; + ? (void *)(intptr_t)LazyResolverFn : (void *)nullptr; // If this is an external declaration, attempt to resolve the address now // to place in the stub. @@ -526,7 +527,7 @@ void *JITResolver::getLazyFunctionStub(Function *F) { // If we resolved the symbol to a null address (eg. a weak external) // don't emit a stub. Return a null pointer to the application. - if (!Actual) return 0; + if (!Actual) return nullptr; } TargetJITInfo::StubLayout SL = TheJIT->getJITInfo().getStubLayout(); @@ -593,8 +594,8 @@ void *JITResolver::getExternalFunctionStub(void *FnAddr) { if (Stub) return Stub; TargetJITInfo::StubLayout SL = TheJIT->getJITInfo().getStubLayout(); - JE.startGVStub(0, SL.Size, SL.Alignment); - Stub = TheJIT->getJITInfo().emitFunctionStub(0, FnAddr, JE); + JE.startGVStub(nullptr, SL.Size, SL.Alignment); + Stub = TheJIT->getJITInfo().emitFunctionStub(nullptr, FnAddr, JE); JE.finishGVStub(); DEBUG(dbgs() << "JIT: Stub emitted at [" << Stub @@ -620,8 +621,8 @@ void *JITResolver::JITCompilerFn(void *Stub) { JITResolver *JR = StubToResolverMap->getResolverFromStub(Stub); assert(JR && "Unable to find the corresponding JITResolver to the call site"); - Function* F = 0; - void* ActualPtr = 0; + Function* F = nullptr; + void* ActualPtr = nullptr; { // Only lock for getting the Function. The call getPointerToFunction made @@ -736,7 +737,7 @@ void JITEmitter::processDebugLoc(DebugLoc DL, bool BeforePrintingInsn) { const LLVMContext &Context = EmissionDetails.MF->getFunction()->getContext(); - if (DL.getScope(Context) != 0 && PrevDL != DL) { + if (DL.getScope(Context) != nullptr && PrevDL != DL) { JITEvent_EmittedFunctionDetails::LineStart NextLine; NextLine.Address = getCurrentPCValue(); NextLine.Loc = DL; @@ -825,7 +826,7 @@ bool JITEmitter::finishFunction(MachineFunction &F) { // Resolve the relocations to concrete pointers. for (unsigned i = 0, e = Relocations.size(); i != e; ++i) { MachineRelocation &MR = Relocations[i]; - void *ResultPtr = 0; + void *ResultPtr = nullptr; if (!MR.letTargetResolve()) { if (MR.isExternalSymbol()) { ResultPtr = TheJIT->getPointerToNamedFunction(MR.getExternalSymbol(), @@ -871,7 +872,7 @@ bool JITEmitter::finishFunction(MachineFunction &F) { } } - CurFn = 0; + CurFn = nullptr; TheJIT->getJITInfo().relocate(BufferBegin, &Relocations[0], Relocations.size(), MemMgr->getGOTBase()); } @@ -900,7 +901,7 @@ bool JITEmitter::finishFunction(MachineFunction &F) { SizeEstimate = 0; } - BufferBegin = CurBufferPtr = 0; + BufferBegin = CurBufferPtr = nullptr; NumBytes += FnEnd-FnStart; // Invalidate the icache if necessary. @@ -1018,7 +1019,7 @@ void JITEmitter::emitConstantPool(MachineConstantPool *MCP) { ConstantPoolBase = allocateSpace(Size, Align); ConstantPool = MCP; - if (ConstantPoolBase == 0) return; // Buffer overflow. + if (!ConstantPoolBase) return; // Buffer overflow. DEBUG(dbgs() << "JIT: Emitted constant pool at [" << ConstantPoolBase << "] (size: " << Size << ", alignment: " << Align << ")\n"); @@ -1074,7 +1075,7 @@ void JITEmitter::emitJumpTableInfo(MachineJumpTableInfo *MJTI) { return; const std::vector &JT = MJTI->getJumpTables(); - if (JT.empty() || JumpTableBase == 0) return; + if (JT.empty() || !JumpTableBase) return; switch (MJTI->getEntryKind()) { @@ -1244,7 +1245,7 @@ void JIT::updateFunctionStub(Function *F) { void JIT::freeMachineCodeForFunction(Function *F) { // Delete translation for this from the ExecutionEngine, so it will get // retranslated next time it is used. - updateGlobalMapping(F, 0); + updateGlobalMapping(F, nullptr); // Free the actual memory for the function body and related stuff. static_cast(JCE)->deallocateMemForFunction(F); diff --git a/lib/ExecutionEngine/JIT/JITMemoryManager.cpp b/lib/ExecutionEngine/JIT/JITMemoryManager.cpp index e5e0cfa51d..d0e38137f2 100644 --- a/lib/ExecutionEngine/JIT/JITMemoryManager.cpp +++ b/lib/ExecutionEngine/JIT/JITMemoryManager.cpp @@ -81,7 +81,7 @@ namespace { /// getFreeBlockBefore - If the block before this one is free, return it, /// otherwise return null. FreeRangeHeader *getFreeBlockBefore() const { - if (PrevAllocated) return 0; + if (PrevAllocated) return nullptr; intptr_t PrevSize = reinterpret_cast( const_cast(this))[-1]; return reinterpret_cast( @@ -175,7 +175,7 @@ FreeRangeHeader *MemoryRangeHeader::FreeBlock(FreeRangeHeader *FreeList) { // coalesce with it, update our notion of what the free list is. if (&FollowingFreeBlock == FreeList) { FreeList = FollowingFreeBlock.Next; - FreeListToReturn = 0; + FreeListToReturn = nullptr; assert(&FollowingFreeBlock != FreeList && "No tombstone block?"); } FollowingFreeBlock.RemoveFromFreeList(); @@ -586,7 +586,7 @@ DefaultJITMemoryManager::DefaultJITMemoryManager() #else PoisonMemory(true), #endif - LastSlab(0, 0), StubAllocator(*this), DataAllocator(*this) { + LastSlab(nullptr, 0), StubAllocator(*this), DataAllocator(*this) { // Allocate space for code. sys::MemoryBlock MemBlock = allocateNewSlab(DefaultCodeSlabSize); @@ -639,7 +639,7 @@ DefaultJITMemoryManager::DefaultJITMemoryManager() // Start out with the freelist pointing to Mem0. FreeMemoryList = Mem0; - GOTBase = NULL; + GOTBase = nullptr; } void DefaultJITMemoryManager::AllocateGOT() { @@ -658,9 +658,9 @@ DefaultJITMemoryManager::~DefaultJITMemoryManager() { sys::MemoryBlock DefaultJITMemoryManager::allocateNewSlab(size_t size) { // Allocate a new block close to the last one. std::string ErrMsg; - sys::MemoryBlock *LastSlabPtr = LastSlab.base() ? &LastSlab : 0; + sys::MemoryBlock *LastSlabPtr = LastSlab.base() ? &LastSlab : nullptr; sys::MemoryBlock B = sys::Memory::AllocateRWX(size, LastSlabPtr, &ErrMsg); - if (B.base() == 0) { + if (!B.base()) { report_fatal_error("Allocation failed when allocating new memory in the" " JIT\n" + Twine(ErrMsg)); } @@ -721,7 +721,7 @@ bool DefaultJITMemoryManager::CheckInvariants(std::string &ErrorStr) { char *End = Start + I->size(); // Check each memory range. - for (MemoryRangeHeader *Hdr = (MemoryRangeHeader*)Start, *LastHdr = NULL; + for (MemoryRangeHeader *Hdr = (MemoryRangeHeader*)Start, *LastHdr = nullptr; Start <= (char*)Hdr && (char*)Hdr < End; Hdr = &Hdr->getBlockAfter()) { if (Hdr->ThisAllocated == 0) { @@ -890,7 +890,7 @@ void *DefaultJITMemoryManager::getPointerToNamedFunction(const std::string &Name report_fatal_error("Program used external function '"+Name+ "' which could not be resolved!"); } - return 0; + return nullptr; } diff --git a/lib/ExecutionEngine/MCJIT/MCJIT.cpp b/lib/ExecutionEngine/MCJIT/MCJIT.cpp index bccdd1e195..6b9dff238a 100644 --- a/lib/ExecutionEngine/MCJIT/MCJIT.cpp +++ b/lib/ExecutionEngine/MCJIT/MCJIT.cpp @@ -50,7 +50,7 @@ ExecutionEngine *MCJIT::createJIT(Module *M, // Try to register the program as a source of symbols to resolve against. // // FIXME: Don't do this here. - sys::DynamicLibrary::LoadLibraryPermanently(0, NULL); + sys::DynamicLibrary::LoadLibraryPermanently(nullptr, nullptr); return new MCJIT(M, TM, MemMgr ? MemMgr : new SectionMemoryManager(), GVsWithCode); @@ -58,8 +58,8 @@ ExecutionEngine *MCJIT::createJIT(Module *M, MCJIT::MCJIT(Module *m, TargetMachine *tm, RTDyldMemoryManager *MM, bool AllocateGVsWithCode) - : ExecutionEngine(m), TM(tm), Ctx(0), MemMgr(this, MM), Dyld(&MemMgr), - ObjCache(0) { + : ExecutionEngine(m), TM(tm), Ctx(nullptr), MemMgr(this, MM), Dyld(&MemMgr), + ObjCache(nullptr) { OwnedModules.addModule(m); setDataLayout(TM->getDataLayout()); @@ -186,9 +186,9 @@ void MCJIT::generateCodeForModule(Module *M) { std::unique_ptr ObjectToLoad; // Try to load the pre-compiled object from cache if possible - if (0 != ObjCache) { + if (ObjCache) { std::unique_ptr PreCompiledObject(ObjCache->getObject(M)); - if (0 != PreCompiledObject.get()) + if (PreCompiledObject.get()) ObjectToLoad.reset(new ObjectBuffer(PreCompiledObject.release())); } @@ -286,7 +286,7 @@ Module *MCJIT::findModuleForSymbol(const std::string &Name, } } // We didn't find the symbol in any of our modules. - return NULL; + return nullptr; } uint64_t MCJIT::getSymbolAddress(const std::string &Name, @@ -366,7 +366,7 @@ void *MCJIT::getPointerToFunction(Function *F) { generateCodeForModule(M); else if (!OwnedModules.hasModuleBeenLoaded(M)) // If this function doesn't belong to one of our modules, we're done. - return NULL; + return nullptr; // FIXME: Should the Dyld be retaining module information? Probably not. // @@ -410,7 +410,7 @@ Function *MCJIT::FindFunctionNamedInModulePtrSet(const char *FnName, if (Function *F = (*I)->getFunction(FnName)) return F; } - return 0; + return nullptr; } Function *MCJIT::FindFunctionNamed(const char *FnName) { @@ -542,17 +542,17 @@ void *MCJIT::getPointerToNamedFunction(const std::string &Name, report_fatal_error("Program used external function '"+Name+ "' which could not be resolved!"); } - return 0; + return nullptr; } void MCJIT::RegisterJITEventListener(JITEventListener *L) { - if (L == NULL) + if (!L) return; MutexGuard locked(lock); EventListeners.push_back(L); } void MCJIT::UnregisterJITEventListener(JITEventListener *L) { - if (L == NULL) + if (!L) return; MutexGuard locked(lock); SmallVector::reverse_iterator I= diff --git a/lib/ExecutionEngine/MCJIT/SectionMemoryManager.cpp b/lib/ExecutionEngine/MCJIT/SectionMemoryManager.cpp index f1dd5a6a51..9ceaa90b0d 100644 --- a/lib/ExecutionEngine/MCJIT/SectionMemoryManager.cpp +++ b/lib/ExecutionEngine/MCJIT/SectionMemoryManager.cpp @@ -79,7 +79,7 @@ uint8_t *SectionMemoryManager::allocateSection(MemoryGroup &MemGroup, ec); if (ec) { // FIXME: Add error propagation to the interface. - return NULL; + return nullptr; } // Save this address as the basis for our next request diff --git a/lib/ExecutionEngine/RuntimeDyld/GDBRegistrar.cpp b/lib/ExecutionEngine/RuntimeDyld/GDBRegistrar.cpp index 1d0e9b3f92..8546571587 100644 --- a/lib/ExecutionEngine/RuntimeDyld/GDBRegistrar.cpp +++ b/lib/ExecutionEngine/RuntimeDyld/GDBRegistrar.cpp @@ -45,7 +45,7 @@ extern "C" { // We put information about the JITed function in this global, which the // debugger reads. Make sure to specify the version statically, because the // debugger checks the version before we can set it during runtime. - struct jit_descriptor __jit_debug_descriptor = { 1, 0, 0, 0 }; + struct jit_descriptor __jit_debug_descriptor = { 1, 0, nullptr, nullptr }; // Debuggers puts a breakpoint in this function. LLVM_ATTRIBUTE_NOINLINE void __jit_debug_register_code() { @@ -108,10 +108,10 @@ void NotifyDebugger(jit_code_entry* JITCodeEntry) { __jit_debug_descriptor.action_flag = JIT_REGISTER_FN; // Insert this entry at the head of the list. - JITCodeEntry->prev_entry = NULL; + JITCodeEntry->prev_entry = nullptr; jit_code_entry* NextEntry = __jit_debug_descriptor.first_entry; JITCodeEntry->next_entry = NextEntry; - if (NextEntry != NULL) { + if (NextEntry) { NextEntry->prev_entry = JITCodeEntry; } __jit_debug_descriptor.first_entry = JITCodeEntry; @@ -142,11 +142,10 @@ void GDBJITRegistrar::registerObject(const ObjectBuffer &Object) { "Second attempt to perform debug registration."); jit_code_entry* JITCodeEntry = new jit_code_entry(); - if (JITCodeEntry == 0) { + if (!JITCodeEntry) { llvm::report_fatal_error( "Allocation failed when registering a JIT entry!\n"); - } - else { + } else { JITCodeEntry->symfile_addr = Buffer; JITCodeEntry->symfile_size = Size; @@ -198,7 +197,7 @@ void GDBJITRegistrar::deregisterObjectInternal( } delete JITCodeEntry; - JITCodeEntry = NULL; + JITCodeEntry = nullptr; } llvm::ManagedStatic TheRegistrar; diff --git a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp index 65b544dcaf..cc2f29d9df 100644 --- a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp +++ b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp @@ -106,7 +106,7 @@ ObjectImage *RuntimeDyldImpl::loadObject(ObjectImage *InputObject) { std::unique_ptr Obj(InputObject); if (!Obj) - return NULL; + return nullptr; // Save information about our target Arch = (Triple::ArchType)Obj->getArch(); @@ -426,7 +426,7 @@ unsigned RuntimeDyldImpl::emitSection(ObjectImage &Obj, uintptr_t Allocate; unsigned SectionID = Sections.size(); uint8_t *Addr; - const char *pData = 0; + const char *pData = nullptr; // Some sections, such as debug info, don't need to be loaded for execution. // Leave those where they are. @@ -467,7 +467,7 @@ unsigned RuntimeDyldImpl::emitSection(ObjectImage &Obj, // to handle later processing (and by 'handle' I mean don't do anything // with these sections). Allocate = 0; - Addr = 0; + Addr = nullptr; DEBUG(dbgs() << "emitSection SectionID: " << SectionID << " Name: " << Name << " obj addr: " << format("%p", data.data()) << " new addr: 0" << " DataSize: " << DataSize << " StubBufSize: " << StubBufSize @@ -612,7 +612,7 @@ void RuntimeDyldImpl::resolveRelocationList(const RelocationList &Relocs, for (unsigned i = 0, e = Relocs.size(); i != e; ++i) { const RelocationEntry &RE = Relocs[i]; // Ignore relocations for sections that were not loaded - if (Sections[RE.SectionID].Address == 0) + if (Sections[RE.SectionID].Address == nullptr) continue; resolveRelocation(RE, Value); } @@ -677,7 +677,7 @@ RuntimeDyld::RuntimeDyld(RTDyldMemoryManager *mm) { // though the public class spawns a new 'impl' instance for each load, // they share a single memory manager. This can become a problem when page // permissions are applied. - Dyld = 0; + Dyld = nullptr; MM = mm; ProcessAllSections = false; } @@ -766,7 +766,7 @@ ObjectImage *RuntimeDyld::loadObject(ObjectBuffer *InputBuffer) { void *RuntimeDyld::getSymbolAddress(StringRef Name) { if (!Dyld) - return NULL; + return nullptr; return Dyld->getSymbolAddress(Name); } diff --git a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp index 434a1adf4f..abe8b6c388 100644 --- a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp +++ b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp @@ -167,7 +167,7 @@ void RuntimeDyldELF::deregisterEHFrames() { ObjectImage * RuntimeDyldELF::createObjectImageFromFile(object::ObjectFile *ObjFile) { if (!ObjFile) - return NULL; + return nullptr; error_code ec; MemoryBuffer *Buffer = @@ -176,19 +176,19 @@ RuntimeDyldELF::createObjectImageFromFile(object::ObjectFile *ObjFile) { if (ObjFile->getBytesInAddress() == 4 && ObjFile->isLittleEndian()) { DyldELFObject> *Obj = new DyldELFObject>(Buffer, ec); - return new ELFObjectImage>(NULL, Obj); + return new ELFObjectImage>(nullptr, Obj); } else if (ObjFile->getBytesInAddress() == 4 && !ObjFile->isLittleEndian()) { DyldELFObject> *Obj = new DyldELFObject>(Buffer, ec); - return new ELFObjectImage>(NULL, Obj); + return new ELFObjectImage>(nullptr, Obj); } else if (ObjFile->getBytesInAddress() == 8 && !ObjFile->isLittleEndian()) { DyldELFObject> *Obj = new DyldELFObject>(Buffer, ec); - return new ELFObjectImage>(NULL, Obj); + return new ELFObjectImage>(nullptr, Obj); } else if (ObjFile->getBytesInAddress() == 8 && ObjFile->isLittleEndian()) { DyldELFObject> *Obj = new DyldELFObject>(Buffer, ec); - return new ELFObjectImage>(NULL, Obj); + return new ELFObjectImage>(nullptr, Obj); } else llvm_unreachable("Unexpected ELF format"); } @@ -1152,7 +1152,7 @@ relocation_iterator RuntimeDyldELF::processRelocationRef( // Extra check to avoid relocation againt empty symbols (usually // the R_PPC64_TOC). if (SymType != SymbolRef::ST_Unknown && TargetName.empty()) - Value.SymbolName = NULL; + Value.SymbolName = nullptr; if (Value.SymbolName) addRelocationForSymbol(RE, Value.SymbolName); @@ -1284,7 +1284,8 @@ void RuntimeDyldELF::updateGOTEntries(StringRef Name, uint64_t Addr) { for (it = GOTs.begin(); it != end; ++it) { GOTRelocations &GOTEntries = it->second; for (int i = 0, e = GOTEntries.size(); i != e; ++i) { - if (GOTEntries[i].SymbolName != 0 && GOTEntries[i].SymbolName == Name) { + if (GOTEntries[i].SymbolName != nullptr && + GOTEntries[i].SymbolName == Name) { GOTEntries[i].Offset = Addr; } } @@ -1332,7 +1333,7 @@ uint64_t RuntimeDyldELF::findGOTEntry(uint64_t LoadAddress, uint64_t Offset) { // Find the matching entry in our vector. uint64_t SymbolOffset = 0; for (int i = 0, e = GOTEntries.size(); i != e; ++i) { - if (GOTEntries[i].SymbolName == 0) { + if (!GOTEntries[i].SymbolName) { if (getSectionLoadAddress(GOTEntries[i].SectionID) == LoadAddress && GOTEntries[i].Offset == Offset) { GOTIndex = i; diff --git a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp index 999e8f3261..d91c9bcd0e 100644 --- a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp +++ b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp @@ -67,7 +67,7 @@ void RuntimeDyldMachO::registerEHFrames() { continue; SectionEntry *Text = &Sections[SectionInfo.TextSID]; SectionEntry *EHFrame = &Sections[SectionInfo.EHFrameSID]; - SectionEntry *ExceptTab = NULL; + SectionEntry *ExceptTab = nullptr; if (SectionInfo.ExceptTabSID != RTDYLD_INVALID_SECTION_ID) ExceptTab = &Sections[SectionInfo.ExceptTabSID]; diff --git a/lib/MC/MCDisassembler/Disassembler.cpp b/lib/MC/MCDisassembler/Disassembler.cpp index b1f9c6b172..0530c26369 100644 --- a/lib/MC/MCDisassembler/Disassembler.cpp +++ b/lib/MC/MCDisassembler/Disassembler.cpp @@ -41,20 +41,20 @@ LLVMDisasmContextRef LLVMCreateDisasmCPU(const char *Triple, const char *CPU, std::string Error; const Target *TheTarget = TargetRegistry::lookupTarget(Triple, Error); if (!TheTarget) - return 0; + return nullptr; const MCRegisterInfo *MRI = TheTarget->createMCRegInfo(Triple); if (!MRI) - return 0; + return nullptr; // Get the assembler info needed to setup the MCContext. const MCAsmInfo *MAI = TheTarget->createMCAsmInfo(*MRI, Triple); if (!MAI) - return 0; + return nullptr; const MCInstrInfo *MII = TheTarget->createMCInstrInfo(); if (!MII) - return 0; + return nullptr; // Package up features to be passed to target/subtarget std::string FeaturesStr; @@ -62,22 +62,22 @@ LLVMDisasmContextRef LLVMCreateDisasmCPU(const char *Triple, const char *CPU, const MCSubtargetInfo *STI = TheTarget->createMCSubtargetInfo(Triple, CPU, FeaturesStr); if (!STI) - return 0; + return nullptr; // Set up the MCContext for creating symbols and MCExpr's. - MCContext *Ctx = new MCContext(MAI, MRI, 0); + MCContext *Ctx = new MCContext(MAI, MRI, nullptr); if (!Ctx) - return 0; + return nullptr; // Set up disassembler. MCDisassembler *DisAsm = TheTarget->createMCDisassembler(*STI, *Ctx); if (!DisAsm) - return 0; + return nullptr; std::unique_ptr RelInfo( TheTarget->createMCRelocationInfo(Triple, *Ctx)); if (!RelInfo) - return 0; + return nullptr; std::unique_ptr Symbolizer(TheTarget->createMCSymbolizer( Triple, GetOpInfo, SymbolLookUp, DisInfo, Ctx, RelInfo.release())); @@ -88,14 +88,14 @@ LLVMDisasmContextRef LLVMCreateDisasmCPU(const char *Triple, const char *CPU, MCInstPrinter *IP = TheTarget->createMCInstPrinter(AsmPrinterVariant, *MAI, *MII, *MRI, *STI); if (!IP) - return 0; + return nullptr; LLVMDisasmContext *DC = new LLVMDisasmContext(Triple, DisInfo, TagType, GetOpInfo, SymbolLookUp, TheTarget, MAI, MRI, STI, MII, Ctx, DisAsm, IP); if (!DC) - return 0; + return nullptr; DC->setCPU(CPU); return DC; diff --git a/lib/MC/MCParser/AsmLexer.cpp b/lib/MC/MCParser/AsmLexer.cpp index a3b68d8380..bca516eca0 100644 --- a/lib/MC/MCParser/AsmLexer.cpp +++ b/lib/MC/MCParser/AsmLexer.cpp @@ -22,8 +22,8 @@ using namespace llvm; AsmLexer::AsmLexer(const MCAsmInfo &_MAI) : MAI(_MAI) { - CurBuf = NULL; - CurPtr = NULL; + CurBuf = nullptr; + CurPtr = nullptr; isAtStartOfLine = true; AllowAtInIdentifier = !StringRef(MAI.getCommentString()).startswith("@"); } @@ -39,7 +39,7 @@ void AsmLexer::setBuffer(const MemoryBuffer *buf, const char *ptr) { else CurPtr = CurBuf->getBufferStart(); - TokStart = 0; + TokStart = nullptr; } /// ReturnError - Set the error to the specified string at the specified @@ -218,7 +218,7 @@ static void SkipIgnoredIntegerSuffix(const char *&CurPtr) { // Look ahead to search for first non-hex digit, if it's [hH], then we treat the // integer as a hexadecimal, possibly with leading zeroes. static unsigned doLookAhead(const char *&CurPtr, unsigned DefaultRadix) { - const char *FirstHex = 0; + const char *FirstHex = nullptr; const char *LookAhead = CurPtr; while (1) { if (isdigit(*LookAhead)) { diff --git a/lib/MC/MCParser/AsmParser.cpp b/lib/MC/MCParser/AsmParser.cpp index c34fe8a413..bad28ef87d 100644 --- a/lib/MC/MCParser/AsmParser.cpp +++ b/lib/MC/MCParser/AsmParser.cpp @@ -111,7 +111,7 @@ struct ParseStatementInfo { SmallVectorImpl *AsmRewrites; - ParseStatementInfo() : Opcode(~0U), ParseError(false), AsmRewrites(0) {} + ParseStatementInfo() : Opcode(~0U), ParseError(false), AsmRewrites(nullptr) {} ParseStatementInfo(SmallVectorImpl *rewrites) : Opcode(~0), ParseError(false), AsmRewrites(rewrites) {} @@ -496,7 +496,7 @@ enum { DEFAULT_ADDRSPACE = 0 }; AsmParser::AsmParser(SourceMgr &_SM, MCContext &_Ctx, MCStreamer &_Out, const MCAsmInfo &_MAI) : Lexer(_MAI), Ctx(_Ctx), Out(_Out), MAI(_MAI), SrcMgr(_SM), - PlatformParser(0), CurBuffer(0), MacrosEnabledFlag(true), + PlatformParser(nullptr), CurBuffer(0), MacrosEnabledFlag(true), CppHashLineNumber(0), AssemblerDialect(~0U), IsDarwin(false), ParsingInlineAsm(false) { // Save the old handler. @@ -960,7 +960,7 @@ AsmParser::applyModifierToExpr(const MCExpr *E, switch (E->getKind()) { case MCExpr::Target: case MCExpr::Constant: - return 0; + return nullptr; case MCExpr::SymbolRef: { const MCSymbolRefExpr *SRE = cast(E); @@ -978,7 +978,7 @@ AsmParser::applyModifierToExpr(const MCExpr *E, const MCUnaryExpr *UE = cast(E); const MCExpr *Sub = applyModifierToExpr(UE->getSubExpr(), Variant); if (!Sub) - return 0; + return nullptr; return MCUnaryExpr::Create(UE->getOpcode(), Sub, getContext()); } @@ -988,7 +988,7 @@ AsmParser::applyModifierToExpr(const MCExpr *E, const MCExpr *RHS = applyModifierToExpr(BE->getRHS(), Variant); if (!LHS && !RHS) - return 0; + return nullptr; if (!LHS) LHS = BE->getLHS(); @@ -1014,7 +1014,7 @@ AsmParser::applyModifierToExpr(const MCExpr *E, /// bool AsmParser::parseExpression(const MCExpr *&Res, SMLoc &EndLoc) { // Parse the expression. - Res = 0; + Res = nullptr; if (parsePrimaryExpr(Res, EndLoc) || parseBinOpRHS(1, Res, EndLoc)) return true; @@ -1051,7 +1051,7 @@ bool AsmParser::parseExpression(const MCExpr *&Res, SMLoc &EndLoc) { } bool AsmParser::parseParenExpression(const MCExpr *&Res, SMLoc &EndLoc) { - Res = 0; + Res = nullptr; return parseParenExpr(Res, EndLoc) || parseBinOpRHS(1, Res, EndLoc); } @@ -1702,7 +1702,7 @@ void AsmParser::DiagHandler(const SMDiagnostic &Diag, void *Context) { if (Parser->SavedDiagHandler) Parser->SavedDiagHandler(Diag, Parser->SavedDiagContext); else - Diag.print(0, OS); + Diag.print(nullptr, OS); return; } @@ -1724,7 +1724,7 @@ void AsmParser::DiagHandler(const SMDiagnostic &Diag, void *Context) { if (Parser->SavedDiagHandler) Parser->SavedDiagHandler(NewDiag, Parser->SavedDiagContext); else - NewDiag.print(0, OS); + NewDiag.print(nullptr, OS); } // FIXME: This is mostly duplicated from the function in AsmLexer.cpp. The @@ -2066,7 +2066,7 @@ bool AsmParser::parseMacroArguments(const MCAsmMacro *M, const MCAsmMacro *AsmParser::lookupMacro(StringRef Name) { StringMap::iterator I = MacroMap.find(Name); - return (I == MacroMap.end()) ? NULL : I->getValue(); + return (I == MacroMap.end()) ? nullptr : I->getValue(); } void AsmParser::defineMacro(StringRef Name, const MCAsmMacro &Macro) { @@ -3930,9 +3930,9 @@ bool AsmParser::parseDirectiveIfdef(SMLoc DirectiveLoc, bool expect_defined) { MCSymbol *Sym = getContext().LookupSymbol(Name); if (expect_defined) - TheCondState.CondMet = (Sym != NULL && !Sym->isUndefined()); + TheCondState.CondMet = (Sym && !Sym->isUndefined()); else - TheCondState.CondMet = (Sym == NULL || Sym->isUndefined()); + TheCondState.CondMet = (!Sym || Sym->isUndefined()); TheCondState.Ignore = !TheCondState.CondMet; } @@ -4175,7 +4175,7 @@ MCAsmMacro *AsmParser::parseMacroLikeBody(SMLoc DirectiveLoc) { // Check whether we have reached the end of the file. if (getLexer().is(AsmToken::Eof)) { Error(DirectiveLoc, "no matching '.endr' in definition"); - return 0; + return nullptr; } if (Lexer.is(AsmToken::Identifier) && @@ -4190,7 +4190,7 @@ MCAsmMacro *AsmParser::parseMacroLikeBody(SMLoc DirectiveLoc) { Lex(); if (Lexer.isNot(AsmToken::EndOfStatement)) { TokError("unexpected token in '.endr' directive"); - return 0; + return nullptr; } break; } @@ -4284,7 +4284,7 @@ bool AsmParser::parseDirectiveIrp(SMLoc DirectiveLoc) { Lex(); MCAsmMacroArguments A; - if (parseMacroArguments(0, A)) + if (parseMacroArguments(nullptr, A)) return true; // Eat the end of statement. @@ -4324,7 +4324,7 @@ bool AsmParser::parseDirectiveIrpc(SMLoc DirectiveLoc) { Lex(); MCAsmMacroArguments A; - if (parseMacroArguments(0, A)) + if (parseMacroArguments(nullptr, A)) return true; if (A.size() != 1 || A.front().size() != 1) diff --git a/lib/MC/MCParser/COFFAsmParser.cpp b/lib/MC/MCParser/COFFAsmParser.cpp index 76d3f813fc..decf01c46c 100644 --- a/lib/MC/MCParser/COFFAsmParser.cpp +++ b/lib/MC/MCParser/COFFAsmParser.cpp @@ -293,7 +293,7 @@ bool COFFAsmParser::ParseSectionSwitch(StringRef Section, unsigned Characteristics, SectionKind Kind) { return ParseSectionSwitch(Section, Characteristics, Kind, "", - COFF::IMAGE_COMDAT_SELECT_ANY, 0); + COFF::IMAGE_COMDAT_SELECT_ANY, nullptr); } bool COFFAsmParser::ParseSectionSwitch(StringRef Section, @@ -359,7 +359,7 @@ bool COFFAsmParser::ParseDirectiveSection(StringRef, SMLoc) { } COFF::COMDATType Type = COFF::IMAGE_COMDAT_SELECT_ANY; - const MCSectionCOFF *Assoc = 0; + const MCSectionCOFF *Assoc = nullptr; StringRef COMDATSymName; if (getLexer().is(AsmToken::Comma)) { Lex(); @@ -504,7 +504,7 @@ bool COFFAsmParser::parseCOMDATTypeAndAssoc(COFF::COMDATType &Type, /// ::= .linkonce [ identifier [ identifier ] ] bool COFFAsmParser::ParseDirectiveLinkOnce(StringRef, SMLoc Loc) { COFF::COMDATType Type = COFF::IMAGE_COMDAT_SELECT_ANY; - const MCSectionCOFF *Assoc = 0; + const MCSectionCOFF *Assoc = nullptr; if (getLexer().is(AsmToken::Identifier)) if (parseCOMDATTypeAndAssoc(Type, Assoc)) return true; diff --git a/lib/MC/MCParser/DarwinAsmParser.cpp b/lib/MC/MCParser/DarwinAsmParser.cpp index 0856b6e388..873a87d413 100644 --- a/lib/MC/MCParser/DarwinAsmParser.cpp +++ b/lib/MC/MCParser/DarwinAsmParser.cpp @@ -612,8 +612,8 @@ bool DarwinAsmParser::parseDirectivePopSection(StringRef, SMLoc) { /// ::= .previous bool DarwinAsmParser::parseDirectivePrevious(StringRef DirName, SMLoc) { MCSectionSubPair PreviousSection = getStreamer().getPreviousSection(); - if (PreviousSection.first == NULL) - return TokError(".previous without corresponding .section"); + if (!PreviousSection.first) + return TokError(".previous without corresponding .section"); getStreamer().SwitchSection(PreviousSection.first, PreviousSection.second); return false; } @@ -630,13 +630,13 @@ bool DarwinAsmParser::parseDirectiveSecureLogUnique(StringRef, SMLoc IDLoc) { // Get the secure log path. const char *SecureLogFile = getContext().getSecureLogFile(); - if (SecureLogFile == NULL) + if (!SecureLogFile) return Error(IDLoc, ".secure_log_unique used but AS_SECURE_LOG_FILE " "environment variable unset."); // Open the secure log file if we haven't already. raw_ostream *OS = getContext().getSecureLog(); - if (OS == NULL) { + if (!OS) { std::string Err; OS = new raw_fd_ostream(SecureLogFile, Err, sys::fs::F_Append | sys::fs::F_Text); diff --git a/lib/MC/MCParser/ELFAsmParser.cpp b/lib/MC/MCParser/ELFAsmParser.cpp index d79dd670bb..95c4971c52 100644 --- a/lib/MC/MCParser/ELFAsmParser.cpp +++ b/lib/MC/MCParser/ELFAsmParser.cpp @@ -193,7 +193,7 @@ bool ELFAsmParser::ParseDirectiveSymbolAttribute(StringRef Directive, SMLoc) { bool ELFAsmParser::ParseSectionSwitch(StringRef Section, unsigned Type, unsigned Flags, SectionKind Kind) { - const MCExpr *Subsection = 0; + const MCExpr *Subsection = nullptr; if (getLexer().isNot(AsmToken::EndOfStatement)) { if (getParser().parseExpression(Subsection)) return true; @@ -411,7 +411,7 @@ bool ELFAsmParser::ParseSectionArguments(bool IsPush) { int64_t Size = 0; StringRef GroupName; unsigned Flags = 0; - const MCExpr *Subsection = 0; + const MCExpr *Subsection = nullptr; bool UseLastGroup = false; // Set the defaults first. @@ -554,7 +554,7 @@ EndStmt: bool ELFAsmParser::ParseDirectivePrevious(StringRef DirName, SMLoc) { MCSectionSubPair PreviousSection = getStreamer().getPreviousSection(); - if (PreviousSection.first == NULL) + if (PreviousSection.first == nullptr) return TokError(".previous without corresponding .section"); getStreamer().SwitchSection(PreviousSection.first, PreviousSection.second); @@ -730,7 +730,7 @@ bool ELFAsmParser::ParseDirectiveWeakref(StringRef, SMLoc) { } bool ELFAsmParser::ParseDirectiveSubsection(StringRef, SMLoc) { - const MCExpr *Subsection = 0; + const MCExpr *Subsection = nullptr; if (getLexer().isNot(AsmToken::EndOfStatement)) { if (getParser().parseExpression(Subsection)) return true; diff --git a/lib/MC/MCParser/MCAsmLexer.cpp b/lib/MC/MCParser/MCAsmLexer.cpp index 3867691107..530814b006 100644 --- a/lib/MC/MCParser/MCAsmLexer.cpp +++ b/lib/MC/MCParser/MCAsmLexer.cpp @@ -13,7 +13,7 @@ using namespace llvm; MCAsmLexer::MCAsmLexer() : CurTok(AsmToken::Error, StringRef()), - TokStart(0), SkipSpace(true) { + TokStart(nullptr), SkipSpace(true) { } MCAsmLexer::~MCAsmLexer() { diff --git a/lib/MC/MCParser/MCAsmParser.cpp b/lib/MC/MCParser/MCAsmParser.cpp index 6e1ebad36c..e417aa9771 100644 --- a/lib/MC/MCParser/MCAsmParser.cpp +++ b/lib/MC/MCParser/MCAsmParser.cpp @@ -17,7 +17,7 @@ #include "llvm/Support/raw_ostream.h" using namespace llvm; -MCAsmParser::MCAsmParser() : TargetParser(0), ShowParsedOperands(0) { +MCAsmParser::MCAsmParser() : TargetParser(nullptr), ShowParsedOperands(0) { } MCAsmParser::~MCAsmParser() { diff --git a/lib/MC/WinCOFFObjectWriter.cpp b/lib/MC/WinCOFFObjectWriter.cpp index fba519fca8..46af32ba63 100644 --- a/lib/MC/WinCOFFObjectWriter.cpp +++ b/lib/MC/WinCOFFObjectWriter.cpp @@ -633,7 +633,7 @@ void WinCOFFObjectWriter::ExecutePostLayoutBinding(MCAssembler &Asm, // "Define" each section & symbol. This creates section & symbol // entries in the staging area. - static_assert(sizeof(((COFF::AuxiliaryFile *)0)->FileName) == COFF::SymbolSize, + static_assert(sizeof(((COFF::AuxiliaryFile *)nullptr)->FileName) == COFF::SymbolSize, "size mismatch for COFF::AuxiliaryFile::FileName"); for (auto FI = Asm.file_names_begin(), FE = Asm.file_names_end(); FI != FE; ++FI) { -- cgit v1.2.3