diff --git a/llvm/include/llvm/ADT/ArrayRef.h b/llvm/include/llvm/ADT/ArrayRef.h index 517ba39849e1..a801e985d15c 100644 --- a/llvm/include/llvm/ADT/ArrayRef.h +++ b/llvm/include/llvm/ADT/ArrayRef.h @@ -16,7 +16,6 @@ #include namespace llvm { - /// ArrayRef - Represent a constant reference to an array (0 or more elements /// consecutively in memory), i.e. a start pointer and a length. It allows /// various APIs to take consecutive elements easily and conveniently. @@ -92,19 +91,20 @@ namespace llvm { /// Construct an ArrayRef from ArrayRef. This uses SFINAE to /// ensure that only ArrayRefs of pointers can be converted. template - ArrayRef(const ArrayRef &A, - typename std::enable_if< - std::is_convertible::value>::type* = 0) + ArrayRef( + const ArrayRef &A, + typename std::enable_if< + std::is_convertible::value>::type * = nullptr) : Data(A.data()), Length(A.size()) {} /// Construct an ArrayRef from a SmallVector. This is /// templated in order to avoid instantiating SmallVectorTemplateCommon /// whenever we copy-construct an ArrayRef. template - /*implicit*/ ArrayRef(const SmallVectorTemplateCommon &Vec, - typename std::enable_if< - std::is_convertible::value>::type* = 0) + /*implicit*/ ArrayRef( + const SmallVectorTemplateCommon &Vec, + typename std::enable_if< + std::is_convertible::value>::type * = nullptr) : Data(Vec.data()), Length(Vec.size()) { } @@ -379,6 +379,6 @@ namespace llvm { template hash_code hash_value(ArrayRef S) { return hash_combine_range(S.begin(), S.end()); } -} +} // end namespace llvm -#endif +#endif // LLVM_ADT_ARRAYREF_H diff --git a/llvm/include/llvm/CodeGen/SlotIndexes.h b/llvm/include/llvm/CodeGen/SlotIndexes.h index a83e1587c7cc..15e1081421b4 100644 --- a/llvm/include/llvm/CodeGen/SlotIndexes.h +++ b/llvm/include/llvm/CodeGen/SlotIndexes.h @@ -66,7 +66,6 @@ namespace llvm { bool isPoisoned() const { return (reinterpret_cast(mi) & 0x1) == 0x1; } #endif // EXPENSIVE_CHECKS - }; template <> @@ -308,7 +307,6 @@ namespace llvm { SlotIndex getPrevIndex() const { return SlotIndex(&*--listEntry()->getIterator(), getSlot()); } - }; template <> struct isPodLike { static const bool value = true; }; @@ -382,7 +380,7 @@ namespace llvm { initializeSlotIndexesPass(*PassRegistry::getPassRegistry()); } - ~SlotIndexes() { + ~SlotIndexes() override { // The indexList's nodes are all allocated in the BumpPtrAllocator. indexList.clearAndLeakNodesUnsafely(); } @@ -709,15 +707,13 @@ namespace llvm { indexList.erase(entry); #endif } - }; - // Specialize IntervalMapInfo for half-open slot index intervals. template <> struct IntervalMapInfo : IntervalMapHalfOpenInfo { }; -} +} // end namespace llvm #endif // LLVM_CODEGEN_SLOTINDEXES_H diff --git a/llvm/include/llvm/DebugInfo/CodeView/MemoryTypeTableBuilder.h b/llvm/include/llvm/DebugInfo/CodeView/MemoryTypeTableBuilder.h index 5bfe2a068672..0fceac7b4367 100644 --- a/llvm/include/llvm/DebugInfo/CodeView/MemoryTypeTableBuilder.h +++ b/llvm/include/llvm/DebugInfo/CodeView/MemoryTypeTableBuilder.h @@ -56,13 +56,14 @@ public: } private: - virtual TypeIndex writeRecord(llvm::StringRef Data) override; + TypeIndex writeRecord(llvm::StringRef Data) override; private: std::vector> Records; std::unordered_map HashedRecords; }; -} -} -#endif +} // end namespace codeview +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_CODEVIEW_MEMORYTYPETABLEBUILDER_H diff --git a/llvm/include/llvm/ExecutionEngine/Orc/OrcRemoteTargetClient.h b/llvm/include/llvm/ExecutionEngine/Orc/OrcRemoteTargetClient.h index d76cd9ac9aae..8068733dcdd6 100644 --- a/llvm/include/llvm/ExecutionEngine/Orc/OrcRemoteTargetClient.h +++ b/llvm/include/llvm/ExecutionEngine/Orc/OrcRemoteTargetClient.h @@ -57,7 +57,7 @@ public: return *this; } - ~RCMemoryManager() { + ~RCMemoryManager() override { Client.destroyRemoteAllocator(Id); DEBUG(dbgs() << "Destroyed remote allocator " << Id << "\n"); } @@ -355,7 +355,9 @@ public: ResourceIdMgr::ResourceId Id) : Remote(Remote), Id(Id) {} - ~RCIndirectStubsManager() { Remote.destroyIndirectStubsManager(Id); } + ~RCIndirectStubsManager() override { + Remote.destroyIndirectStubsManager(Id); + } std::error_code createStub(StringRef StubName, TargetAddress StubAddr, JITSymbolFlags StubFlags) override { @@ -479,7 +481,7 @@ public: } private: - void grow() { + void grow() override { TargetAddress BlockAddr = 0; uint32_t NumTrampolines = 0; auto EC = Remote.emitTrampolineBlock(BlockAddr, NumTrampolines); @@ -797,4 +799,4 @@ private: #undef DEBUG_TYPE -#endif +#endif // LLVM_EXECUTIONENGINE_ORC_ORCREMOTETARGETCLIENT_H diff --git a/llvm/include/llvm/ProfileData/InstrProf.h b/llvm/include/llvm/ProfileData/InstrProf.h index e4d7d117520b..037c3fea8a2b 100644 --- a/llvm/include/llvm/ProfileData/InstrProf.h +++ b/llvm/include/llvm/ProfileData/InstrProf.h @@ -1,4 +1,4 @@ -//=-- InstrProf.h - Instrumented profiling format support ---------*- C++ -*-=// +//===-- InstrProf.h - Instrumented profiling format support -----*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -13,8 +13,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_PROFILEDATA_INSTRPROF_H_ -#define LLVM_PROFILEDATA_INSTRPROF_H_ +#ifndef LLVM_PROFILEDATA_INSTRPROF_H +#define LLVM_PROFILEDATA_INSTRPROF_H #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringRef.h" @@ -413,10 +413,10 @@ struct InstrProfRecord { /// Return the array of profiled values at \p Site. inline std::unique_ptr getValueForSite(uint32_t ValueKind, uint32_t Site, - uint64_t (*ValueMapper)(uint32_t, uint64_t) = 0) const; + uint64_t (*ValueMapper)(uint32_t, uint64_t) = nullptr) const; inline void getValueForSite(InstrProfValueData Dest[], uint32_t ValueKind, uint32_t Site, - uint64_t (*ValueMapper)(uint32_t, uint64_t) = 0) const; + uint64_t (*ValueMapper)(uint32_t, uint64_t) = nullptr) const; /// Reserve space for NumValueSites sites. inline void reserveSites(uint32_t ValueKind, uint32_t NumValueSites); /// Add ValueData for ValueKind at value Site. @@ -737,7 +737,7 @@ struct Header { #include "llvm/ProfileData/InstrProfData.inc" }; -} // end namespace RawInstrProf +} // end namespace RawInstrProf } // end namespace llvm @@ -746,4 +746,4 @@ template <> struct is_error_code_enum : std::true_type {}; } -#endif // LLVM_PROFILEDATA_INSTRPROF_H_ +#endif // LLVM_PROFILEDATA_INSTRPROF_H diff --git a/llvm/include/llvm/ProfileData/InstrProfData.inc b/llvm/include/llvm/ProfileData/InstrProfData.inc index 20b01f2046d8..79bc90f07cad 100644 --- a/llvm/include/llvm/ProfileData/InstrProfData.inc +++ b/llvm/include/llvm/ProfileData/InstrProfData.inc @@ -554,18 +554,18 @@ int initializeValueProfRuntimeRecord(ValueProfRuntimeRecord *RuntimeRecord, for (I = 0; I <= IPVK_Last; I++) { uint16_t N = NumValueSites[I]; if (!N) { - RuntimeRecord->SiteCountArray[I] = 0; + RuntimeRecord->SiteCountArray[I] = nullptr; continue; } NumValueKinds++; RuntimeRecord->SiteCountArray[I] = (uint8_t *)calloc(N, 1); if (!RuntimeRecord->SiteCountArray[I]) return 1; - RuntimeRecord->NodesKind[I] = Nodes ? &Nodes[S] : NULL; + RuntimeRecord->NodesKind[I] = Nodes ? &Nodes[S] : nullptr; for (J = 0; J < N; J++) { /* Compute value count for each site. */ uint32_t C = 0; - ValueProfNode *Site = Nodes ? RuntimeRecord->NodesKind[I][J] : NULL; + ValueProfNode *Site = Nodes ? RuntimeRecord->NodesKind[I][J] : nullptr; while (Site) { C++; Site = Site->Next; @@ -606,7 +606,7 @@ uint32_t getNumValueDataForSiteRT(const void *R, uint32_t VK, uint32_t S) { uint32_t getNumValueDataRT(const void *R, uint32_t VK) { unsigned I, S = 0; const ValueProfRuntimeRecord *Record = (const ValueProfRuntimeRecord *)R; - if (Record->SiteCountArray[VK] == 0) + if (Record->SiteCountArray[VK] == nullptr) return 0; for (I = 0; I < Record->NumValueSites[VK]; I++) S += Record->SiteCountArray[VK][I]; @@ -631,12 +631,12 @@ ValueProfData *allocValueProfDataRT(size_t TotalSizeInBytes) { return (ValueProfData *)calloc(TotalSizeInBytes, 1); } -static ValueProfRecordClosure RTRecordClosure = {0, +static ValueProfRecordClosure RTRecordClosure = {nullptr, getNumValueKindsRT, getNumValueSitesRT, getNumValueDataRT, getNumValueDataForSiteRT, - 0, + nullptr, getValueForSiteRT, allocValueProfDataRT}; @@ -663,17 +663,15 @@ serializeValueProfDataFromRT(const ValueProfRuntimeRecord *Record, return serializeValueProfDataFrom(&RTRecordClosure, DstData); } - #undef INSTR_PROF_COMMON_API_IMPL #endif /* INSTR_PROF_COMMON_API_IMPL */ /*============================================================================*/ - #ifndef INSTR_PROF_DATA_DEFINED -#ifndef INSTR_PROF_DATA_INC_ -#define INSTR_PROF_DATA_INC_ +#ifndef INSTR_PROF_DATA_INC +#define INSTR_PROF_DATA_INC /* Helper macros. */ #define INSTR_PROF_SIMPLE_QUOTE(x) #x @@ -760,7 +758,7 @@ typedef struct ValueProfNode { struct ValueProfNode *Next; } ValueProfNode; -#endif /* INSTR_PROF_DATA_INC_ */ +#endif /* INSTR_PROF_DATA_INC */ #else #undef INSTR_PROF_DATA_DEFINED diff --git a/llvm/include/llvm/Support/AlignOf.h b/llvm/include/llvm/Support/AlignOf.h index b8cca4c0490e..af7f20028b6d 100644 --- a/llvm/include/llvm/Support/AlignOf.h +++ b/llvm/include/llvm/Support/AlignOf.h @@ -38,7 +38,7 @@ struct AlignmentCalcImpl { #endif T t; private: - AlignmentCalcImpl() {} // Never instantiate. + AlignmentCalcImpl() = delete; }; // Abstract base class helper, this will have the minimal alignment and size @@ -55,7 +55,7 @@ struct AlignmentCalcImplBase { // of type T. template struct AlignmentCalcImpl : AlignmentCalcImplBase, T { - virtual ~AlignmentCalcImpl() = 0; + ~AlignmentCalcImpl() override = 0; }; } // End detail namespace. @@ -223,7 +223,7 @@ template )> { }; } // end namespace llvm -#endif + +#endif // LLVM_SUPPORT_ALIGNOF_H diff --git a/llvm/include/llvm/Support/ErrorOr.h b/llvm/include/llvm/Support/ErrorOr.h index ca6ede73e8df..ae1bd2b9e224 100644 --- a/llvm/include/llvm/Support/ErrorOr.h +++ b/llvm/include/llvm/Support/ErrorOr.h @@ -98,7 +98,7 @@ public: ErrorOr(E ErrorCode, typename std::enable_if::value || std::is_error_condition_enum::value, - void *>::type = 0) + void *>::type = nullptr) : HasError(true) { new (getErrorStorage()) std::error_code(make_error_code(ErrorCode)); } @@ -278,7 +278,6 @@ private: return const_cast *>(this)->getErrorStorage(); } - union { AlignedCharArrayUnion TStorage; AlignedCharArrayUnion ErrorStorage; @@ -295,4 +294,4 @@ operator==(const ErrorOr &Err, E Code) { } } // end namespace llvm -#endif +#endif // LLVM_SUPPORT_ERROROR_H diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index 59e736c18b34..36650dbe05af 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -35,6 +35,7 @@ #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/raw_ostream.h" #include + using namespace llvm; namespace { @@ -497,7 +498,7 @@ private: std::error_code initStreamFromBuffer(); std::error_code initLazyStream(std::unique_ptr Streamer); }; -} // namespace +} // end anonymous namespace BitcodeDiagnosticInfo::BitcodeDiagnosticInfo(std::error_code EC, DiagnosticSeverity Severity, @@ -872,7 +873,7 @@ public: /// Provide fast operand accessors DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); }; -} +} // end anonymous namespace // FIXME: can we inherit this from ConstantExpr? template <> @@ -880,7 +881,7 @@ struct OperandTraits : public FixedNumOperandTraits { }; DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ConstantPlaceHolder, Value) -} +} // end namespace llvm void BitcodeReaderValueList::assignValue(Value *V, unsigned Idx) { if (Idx == size()) { @@ -908,11 +909,8 @@ void BitcodeReaderValueList::assignValue(Value *V, unsigned Idx) { OldV->replaceAllUsesWith(V); delete PrevVal; } - - return; } - Constant *BitcodeReaderValueList::getConstantFwdRef(unsigned Idx, Type *Ty) { if (Idx >= size()) @@ -1129,7 +1127,6 @@ StructType *BitcodeReader::createIdentifiedStructType(LLVMContext &Context) { return Ret; } - //===----------------------------------------------------------------------===// // Functions for parsing blocks from the bitcode file //===----------------------------------------------------------------------===// @@ -2178,7 +2175,7 @@ std::error_code BitcodeReader::parseMetadata(bool ModuleLevel) { getMDOrNull(Record[9]), getMDOrNull(Record[10]), getMDOrNull(Record[11]), getMDOrNull(Record[12]), getMDOrNull(Record[13]), - Record.size() <= 15 ? 0 : getMDOrNull(Record[15]), + Record.size() <= 15 ? nullptr : getMDOrNull(Record[15]), Record.size() <= 14 ? 0 : Record[14]), NextMetadataNo++); break; @@ -2701,7 +2698,6 @@ std::error_code BitcodeReader::parseConstants() { } break; } - case bitc::CST_CODE_CE_BINOP: { // CE_BINOP: [opcode, opval, opval] if (Record.size() < 3) return error("Invalid record"); @@ -3375,7 +3371,6 @@ std::error_code BitcodeReader::parseModule(uint64_t ResumeBit, break; } - // Read a record. auto BitCode = Stream.readRecord(Entry.ID, Record); switch (BitCode) { @@ -5816,7 +5811,7 @@ class BitcodeErrorCategoryType : public std::error_category { llvm_unreachable("Unknown error type!"); } }; -} +} // end anonymous namespace static ManagedStatic ErrorCategory; diff --git a/llvm/lib/ProfileData/InstrProf.cpp b/llvm/lib/ProfileData/InstrProf.cpp index 8482b18f1e0c..00deec6f8e83 100644 --- a/llvm/lib/ProfileData/InstrProf.cpp +++ b/llvm/lib/ProfileData/InstrProf.cpp @@ -65,7 +65,7 @@ class InstrProfErrorCategoryType : public std::error_category { llvm_unreachable("A value of instrprof_error has no message."); } }; -} +} // end anonymous namespace static ManagedStatic ErrorCategory; @@ -443,12 +443,12 @@ ValueProfData *allocValueProfDataInstrProf(size_t TotalSizeInBytes) { } static ValueProfRecordClosure InstrProfRecordClosure = { - 0, + nullptr, getNumValueKindsInstrProf, getNumValueSitesInstrProf, getNumValueDataInstrProf, getNumValueDataForSiteInstrProf, - 0, + nullptr, getValueForSiteInstrProf, allocValueProfDataInstrProf}; @@ -638,7 +638,6 @@ void ProfileSummary::computeDetailedSummary() { ProfileSummaryEntry PSE = {Cutoff, Count, BlocksSeen}; DetailedSummary.push_back(PSE); } - return; } -} +} // end namespace llvm diff --git a/llvm/lib/Support/Unix/Memory.inc b/llvm/lib/Support/Unix/Memory.inc index d70319168b84..f3463e581735 100644 --- a/llvm/lib/Support/Unix/Memory.inc +++ b/llvm/lib/Support/Unix/Memory.inc @@ -73,7 +73,7 @@ int getPosixProtectionFlags(unsigned Flags) { return PROT_NONE; } -} // namespace +} // anonymous namespace namespace llvm { namespace sys { @@ -265,7 +265,7 @@ bool Memory::setWritable (MemoryBlock &M, std::string *ErrMsg) { } bool Memory::setExecutable (MemoryBlock &M, std::string *ErrMsg) { - if (M.Address == 0 || M.Size == 0) return false; + if (M.Address == nullptr || M.Size == 0) return false; Memory::InvalidateInstructionCache(M.Address, M.Size); #if defined(__APPLE__) && (defined(__arm__) || defined(__arm64__)) kern_return_t kr = vm_protect(mach_task_self(), (vm_address_t)M.Address, diff --git a/llvm/lib/Target/X86/X86ISelLowering.h b/llvm/lib/Target/X86/X86ISelLowering.h index 3f87a4926b70..6e48a2d46047 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.h +++ b/llvm/lib/Target/X86/X86ISelLowering.h @@ -556,7 +556,7 @@ namespace llvm { // have memop! In fact, starting from ATOMADD64_DAG all opcodes will be // thought as target memory ops! }; - } + } // end namespace X86ISD /// Define some predicates that are used for node matching. namespace X86 { @@ -608,13 +608,12 @@ namespace llvm { bool isOffsetSuitableForCodeModel(int64_t Offset, CodeModel::Model M, bool hasSymbolicDisplacement = true); - /// Determines whether the callee is required to pop its /// own arguments. Callee pop is necessary to support tail calls. bool isCalleePop(CallingConv::ID CallingConv, bool is64Bit, bool IsVarArg, bool GuaranteeTCO); - } + } // end namespace X86 //===--------------------------------------------------------------------===// // X86 Implementation of the TargetLowering interface @@ -685,9 +684,9 @@ namespace llvm { /// and types must exactly match those of the original return values of /// the node), or leaves Results empty, which indicates that the node is not /// to be custom lowered after all. - virtual void LowerOperationWrapper(SDNode *N, - SmallVectorImpl &Results, - SelectionDAG &DAG) const override; + void LowerOperationWrapper(SDNode *N, + SmallVectorImpl &Results, + SelectionDAG &DAG) const override; /// Replace the results of node with an illegal result /// type with new values built out of custom code. @@ -695,7 +694,6 @@ namespace llvm { void ReplaceNodeResults(SDNode *N, SmallVectorImpl&Results, SelectionDAG &DAG) const override; - SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override; /// Return true if the target has native support for @@ -1180,7 +1178,7 @@ namespace llvm { namespace X86 { FastISel *createFastISel(FunctionLoweringInfo &funcInfo, const TargetLibraryInfo *libInfo); - } -} + } // end namespace X86 +} // end namespace llvm -#endif // X86ISELLOWERING_H +#endif // LLVM_LIB_TARGET_X86_X86ISELLOWERING_H diff --git a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp index 64aa94fc60c2..f9e421df354f 100644 --- a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp +++ b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp @@ -257,7 +257,7 @@ public: if (CreateGlobalVar) FuncNameVar = createPGOFuncNameVar(F, FuncName); - }; + } }; // Compute Hash value for the CFG: the lower 32 bits are CRC32 of the index @@ -690,7 +690,7 @@ void PGOUseFunc::setBranchWeights() { const PGOUseEdge *E = BBCountInfo.OutEdges[s]; const BasicBlock *SrcBB = E->SrcBB; const BasicBlock *DestBB = E->DestBB; - if (DestBB == 0) + if (DestBB == nullptr) continue; unsigned SuccNum = GetSuccessorNumber(SrcBB, DestBB); uint64_t EdgeCount = E->CountValue; diff --git a/llvm/lib/Transforms/Utils/AddDiscriminators.cpp b/llvm/lib/Transforms/Utils/AddDiscriminators.cpp index 0262358fa3d5..3e585c623dd5 100644 --- a/llvm/lib/Transforms/Utils/AddDiscriminators.cpp +++ b/llvm/lib/Transforms/Utils/AddDiscriminators.cpp @@ -80,7 +80,7 @@ struct AddDiscriminators : public FunctionPass { bool runOnFunction(Function &F) override; }; -} +} // end anonymous namespace char AddDiscriminators::ID = 0; INITIALIZE_PASS_BEGIN(AddDiscriminators, "add-discriminators", @@ -217,7 +217,7 @@ bool AddDiscriminators::runOnFunction(Function &F) { // Sample base profile needs to distinguish different function calls within // a same source line for correct profile annotation. for (BasicBlock &B : F) { - const DILocation *FirstDIL = NULL; + const DILocation *FirstDIL = nullptr; for (auto &I : B.getInstList()) { CallInst *Current = dyn_cast(&I); if (!Current || isa(&I)) diff --git a/llvm/lib/Transforms/Utils/SanitizerStats.cpp b/llvm/lib/Transforms/Utils/SanitizerStats.cpp index af3df2fd9488..9afd175c10ed 100644 --- a/llvm/lib/Transforms/Utils/SanitizerStats.cpp +++ b/llvm/lib/Transforms/Utils/SanitizerStats.cpp @@ -27,7 +27,7 @@ SanitizerStatReport::SanitizerStatReport(Module *M) : M(M) { EmptyModuleStatsTy = makeModuleStatsTy(); ModuleStatsGV = new GlobalVariable(*M, EmptyModuleStatsTy, false, - GlobalValue::InternalLinkage, 0); + GlobalValue::InternalLinkage, nullptr); } ArrayType *SanitizerStatReport::makeModuleStatsArrayTy() { diff --git a/llvm/tools/sanstats/sanstats.cpp b/llvm/tools/sanstats/sanstats.cpp index f089fd4dec7a..3a8cc9aea8ce 100644 --- a/llvm/tools/sanstats/sanstats.cpp +++ b/llvm/tools/sanstats/sanstats.cpp @@ -51,12 +51,12 @@ const char *ReadModule(char SizeofPtr, const char *Begin, const char *End) { while (Begin != End && *Begin) ++Begin; if (Begin == End) - return 0; + return nullptr; StringRef Filename(FilenameBegin, Begin - FilenameBegin); ++Begin; if (Begin == End) - return 0; + return nullptr; symbolize::LLVMSymbolizer::Options SymbolizerOptions; SymbolizerOptions.Demangle = ClDemangle; @@ -70,11 +70,11 @@ const char *ReadModule(char SizeofPtr, const char *Begin, const char *End) { Begin += SizeofPtr; if (Begin > End) - return 0; + return nullptr; if (Addr == 0 && Data == 0) return Begin; if (Begin == End) - return 0; + return nullptr; ErrorOr LineInfo = Symbolizer.symbolizeCode(Filename, Addr); if (LineInfo) { @@ -129,7 +129,7 @@ int main(int argc, char **argv) { char SizeofPtr = *Begin++; while (Begin != End) { Begin = ReadModule(SizeofPtr, Begin, End); - if (Begin == 0) { + if (Begin == nullptr) { errs() << argv[0] << ": " << ClInputFile << ": short read\n"; return 1; } diff --git a/llvm/unittests/ExecutionEngine/Orc/ObjectLinkingLayerTest.cpp b/llvm/unittests/ExecutionEngine/Orc/ObjectLinkingLayerTest.cpp index f4267c95be03..a733bd558c8e 100644 --- a/llvm/unittests/ExecutionEngine/Orc/ObjectLinkingLayerTest.cpp +++ b/llvm/unittests/ExecutionEngine/Orc/ObjectLinkingLayerTest.cpp @@ -37,14 +37,13 @@ public: return SectionMemoryManager::needsToReserveAllocationSpace(); } - bool finalizeMemory(std::string *ErrMsg = 0) override { + bool finalizeMemory(std::string *ErrMsg = nullptr) override { ++FinalizationCount; return SectionMemoryManager::finalizeMemory(ErrMsg); } }; TEST(ObjectLinkingLayerTest, TestSetProcessAllSections) { - class SectionMemoryManagerWrapper : public SectionMemoryManager { public: SectionMemoryManagerWrapper(bool &DebugSeen) : DebugSeen(DebugSeen) {} @@ -113,9 +112,7 @@ TEST(ObjectLinkingLayerTest, TestSetProcessAllSections) { } } - TEST_F(ObjectLinkingLayerExecutionTest, NoDuplicateFinalization) { - if (!TM) return; @@ -187,7 +184,6 @@ TEST_F(ObjectLinkingLayerExecutionTest, NoDuplicateFinalization) { } TEST_F(ObjectLinkingLayerExecutionTest, NoPrematureAllocation) { - if (!TM) return; @@ -250,4 +246,4 @@ TEST_F(ObjectLinkingLayerExecutionTest, NoPrematureAllocation) { "(multiple unrelated objects loaded prior to finalization)"; } -} +} // end anonymous namespace diff --git a/llvm/unittests/IR/VerifierTest.cpp b/llvm/unittests/IR/VerifierTest.cpp index c24e8d732b53..1acedf38fc8f 100644 --- a/llvm/unittests/IR/VerifierTest.cpp +++ b/llvm/unittests/IR/VerifierTest.cpp @@ -1,4 +1,4 @@ -//===- llvm/unittest/IR/VerifierTest.cpp - Verifier unit tests ------------===// +//===- llvm/unittest/IR/VerifierTest.cpp - Verifier unit tests --*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -126,7 +126,8 @@ TEST(VerifierTest, CrossModuleMetadataRef) { Module M2("M2", C); GlobalVariable *newGV = new GlobalVariable(M1, Type::getInt8Ty(C), false, - GlobalVariable::ExternalLinkage, NULL, "Some Global"); + GlobalVariable::ExternalLinkage, nullptr, + "Some Global"); DIBuilder dbuilder(M2); auto CU = dbuilder.createCompileUnit(dwarf::DW_LANG_Julia, "test.jl", ".", @@ -143,5 +144,5 @@ TEST(VerifierTest, CrossModuleMetadataRef) { EXPECT_TRUE(StringRef(ErrorOS.str()) .startswith("Referencing global in another module!")); } -} -} +} // end anonymous namespace +} // end namespace llvm diff --git a/llvm/unittests/ProfileData/InstrProfTest.cpp b/llvm/unittests/ProfileData/InstrProfTest.cpp index 64eec387b3ea..fe29f98e2bce 100644 --- a/llvm/unittests/ProfileData/InstrProfTest.cpp +++ b/llvm/unittests/ProfileData/InstrProfTest.cpp @@ -14,7 +14,6 @@ #include "llvm/ProfileData/InstrProfWriter.h" #include "llvm/Support/Compression.h" #include "gtest/gtest.h" - #include using namespace llvm; @@ -490,22 +489,24 @@ ValueProfNode Site1Values[5] = {{{uint64_t("callee1"), 400}, &Site1Values[1]}, {{uint64_t("callee2"), 1000}, &Site1Values[2]}, {{uint64_t("callee3"), 500}, &Site1Values[3]}, {{uint64_t("callee4"), 300}, &Site1Values[4]}, - {{uint64_t("callee5"), 100}, 0}}; + {{uint64_t("callee5"), 100}, nullptr}}; ValueProfNode Site2Values[4] = {{{uint64_t("callee5"), 800}, &Site2Values[1]}, {{uint64_t("callee3"), 1000}, &Site2Values[2]}, {{uint64_t("callee2"), 2500}, &Site2Values[3]}, - {{uint64_t("callee1"), 1300}, 0}}; + {{uint64_t("callee1"), 1300}, nullptr}}; ValueProfNode Site3Values[3] = {{{uint64_t("callee6"), 800}, &Site3Values[1]}, {{uint64_t("callee3"), 1000}, &Site3Values[2]}, - {{uint64_t("callee4"), 5500}, 0}}; + {{uint64_t("callee4"), 5500}, nullptr}}; ValueProfNode Site4Values[2] = {{{uint64_t("callee2"), 1800}, &Site4Values[1]}, - {{uint64_t("callee3"), 2000}, 0}}; + {{uint64_t("callee3"), 2000}, nullptr}}; static ValueProfNode *ValueProfNodes[5] = {&Site1Values[0], &Site2Values[0], - &Site3Values[0], &Site4Values[0], 0}; + &Site3Values[0], &Site4Values[0], + nullptr}; + static uint16_t NumValueSites[IPVK_Last + 1] = {5}; TEST_F(InstrProfTest, runtime_value_prof_data_read_write) { ValueProfRuntimeRecord RTRecord; @@ -516,7 +517,7 @@ TEST_F(InstrProfTest, runtime_value_prof_data_read_write) { InstrProfRecord Record("caller", 0x1234, {1ULL << 31, 2}); - VPData->deserializeTo(Record, 0); + VPData->deserializeTo(Record, nullptr); // Now read data from Record and sanity check the data ASSERT_EQ(5U, Record.getNumValueSites(IPVK_IndirectCallTarget)); @@ -687,7 +688,7 @@ TEST_F(InstrProfTest, instr_prof_symtab_module_test) { for (unsigned I = 0; I < sizeof(Funcs) / sizeof(*Funcs); I++) { Function *F = M->getFunction(Funcs[I]); - ASSERT_TRUE(F != NULL); + ASSERT_TRUE(F != nullptr); std::string PGOName = getPGOFuncName(*F); uint64_t Key = IndexedInstrProf::ComputeHash(PGOName); ASSERT_EQ(StringRef(PGOName), diff --git a/llvm/unittests/Support/AlignOfTest.cpp b/llvm/unittests/Support/AlignOfTest.cpp index be208f7d28ea..393bfebd6647 100644 --- a/llvm/unittests/Support/AlignOfTest.cpp +++ b/llvm/unittests/Support/AlignOfTest.cpp @@ -1,4 +1,4 @@ -//=== - llvm/unittest/Support/AlignOfTest.cpp - Alignment utility tests ----===// +//=== - llvm/unittest/Support/AlignOfTest.cpp - Alignment utility tests ---===// // // The LLVM Compiler Infrastructure // @@ -90,14 +90,14 @@ V7::~V7() {} V8::~V8() {} struct Abstract1 { - virtual ~Abstract1() {} + virtual ~Abstract1() = default; virtual void method() = 0; char c; }; struct Abstract2 : Abstract1 { - virtual ~Abstract2() {} + ~Abstract2() override = default; double d; }; @@ -354,4 +354,4 @@ TEST(AlignOfTest, BasicAlignedArray) { EXPECT_EQ(2u, sizeof(AlignedCharArray<2, 2>)); EXPECT_EQ(16u, sizeof(AlignedCharArray<2, 16>)); } -} +} // end anonymous namespace diff --git a/llvm/utils/TableGen/DFAPacketizerEmitter.cpp b/llvm/utils/TableGen/DFAPacketizerEmitter.cpp index 77afff7ab5c2..17e9e40acd48 100644 --- a/llvm/utils/TableGen/DFAPacketizerEmitter.cpp +++ b/llvm/utils/TableGen/DFAPacketizerEmitter.cpp @@ -1,4 +1,4 @@ -//===- DFAPacketizerEmitter.cpp - Packetization DFA for a VLIW machine-----===// +//===- DFAPacketizerEmitter.cpp - Packetization DFA for a VLIW machine ----===// // // The LLVM Compiler Infrastructure // @@ -28,6 +28,7 @@ #include #include #include + using namespace llvm; // -------------------------------------------------------------------- @@ -73,7 +74,8 @@ namespace { InsnInput = addDFAFuncUnits(InsnInput, U); return InsnInput; } -} +} // end anonymous namespace + // -------------------------------------------------------------------- #ifndef NDEBUG @@ -149,7 +151,7 @@ public: void run(raw_ostream &OS); }; -} // End anonymous namespace. +} // end anonymous namespace // // @@ -234,7 +236,7 @@ class State { // bool hasTransition(std::vector InsnClass) const; }; -} // End anonymous namespace. +} // end anonymous namespace // // class DFA: deterministic finite automaton for processor resource tracking. @@ -262,7 +264,7 @@ public: int numInsnClasses = 0, int maxResources = 0, int numCombos = 0, int maxStages = 0); }; -} // End anonymous namespace. +} // end anonymous namespace #ifndef NDEBUG // To enable debugging, run llvm-tblgen with: "-debug-only dfa-emitter". @@ -305,7 +307,7 @@ void dbgsIndent(unsigned indent) { DEBUG(dbgs() << " "); } } -#endif +#endif // NDEBUG // // Constructors and destructors for State and DFA @@ -454,7 +456,6 @@ void State::AddInsnClassStages(std::vector &InsnClass, } } - // // canMaybeAddInsnClass - Quickly verifies if an instruction of type InsnClass // may be a valid transition from this state i.e., can an instruction of type @@ -505,7 +506,6 @@ bool State::canMaybeAddInsnClass(std::vector &InsnClass, return false; } - const State &DFA::newState() { auto IterPair = states.insert(State()); assert(IterPair.second && "State already exists"); @@ -518,7 +518,6 @@ DFAPacketizerEmitter::DFAPacketizerEmitter(RecordKeeper &R): TargetName(CodeGenTarget(R).getName()), allInsnClasses(), Records(R) {} - // // writeTableAndAPI - Print out a table representing the DFA and the // associated API to create a DFA packetizer. @@ -626,7 +625,6 @@ void DFA::writeTableAndAPI(raw_ostream &OS, const std::string &TargetName, OS << "};\n"; OS << "} // namespace\n"; - // // Emit DFA Packetizer tables if the target is a VLIW machine. // @@ -640,7 +638,6 @@ void DFA::writeTableAndAPI(raw_ostream &OS, const std::string &TargetName, OS << "} // End llvm namespace \n"; } - // // collectAllFuncUnits - Construct a map of function unit names to bits. // @@ -735,7 +732,6 @@ int DFAPacketizerEmitter::collectAllComboFuncs( return numCombos; } - // // collectOneInsnClass - Populate allInsnClasses with one instruction class // @@ -940,7 +936,7 @@ void DFAPacketizerEmitter::run(raw_ostream &OS) { // if (!current->hasTransition(InsnClass) && current->canMaybeAddInsnClass(InsnClass, ComboBitToBitsMap)) { - const State *NewState = NULL; + const State *NewState = nullptr; current->AddInsnClass(InsnClass, ComboBitToBitsMap, NewStateResources); if (NewStateResources.size() == 0) { DEBUG(dbgs() << " Skipped - no new states generated\n"); @@ -994,4 +990,4 @@ void EmitDFAPacketizer(RecordKeeper &RK, raw_ostream &OS) { DFAPacketizerEmitter(RK).run(OS); } -} // End llvm namespace +} // end namespaec llvm