From c1cbb4e9a0b60b837ada83035ce3d3f1ae95bd54 Mon Sep 17 00:00:00 2001 From: Alessandro Di Federico Date: Fri, 20 Sep 2024 17:23:43 +0200 Subject: [PATCH] Initialize pointers to `nullptr` --- include/revng/ADT/GenericGraph.h | 12 ++--- include/revng/ADT/LazySmallBitVector.h | 2 +- include/revng/ADT/SortedVector.h | 2 +- .../revng/EarlyFunctionAnalysis/CFGAnalyzer.h | 2 +- include/revng/Model/VerifyHelper.h | 2 +- include/revng/Pipeline/ContainerEnumerator.h | 4 +- include/revng/Pipeline/Contract.h | 4 +- include/revng/Pipeline/ExecutionContext.h | 2 +- include/revng/Pipeline/Kind.h | 2 +- include/revng/Pipeline/Loader.h | 2 +- include/revng/Pipeline/RegisterKind.h | 2 +- include/revng/Pipeline/Runner.h | 2 +- include/revng/Pipeline/Step.h | 6 +-- include/revng/Pipeline/Target.h | 2 +- include/revng/Pipes/TaggedFunctionKind.h | 2 +- include/revng/Support/DynamicHierarchy.h | 2 +- include/revng/Support/IRHelpers.h | 2 +- include/revng/Support/TaggedFunctionPass.h | 4 +- include/revng/TupleTree/TupleTree.h | 2 +- include/revng/TupleTree/TupleTreeDiff.h | 6 +-- .../revng/UnitTestHelpers/DotGraphObject.h | 4 +- .../SegregateDirectStackAccesses.cpp | 4 +- .../FunctionCallIdentification.cpp | 6 +-- .../InvokeIsolatedFunctions.cpp | 4 +- lib/FunctionIsolation/PromoteCSVs.cpp | 4 +- .../SugiyamaStyle/GraphPreparation.cpp | 2 +- lib/GraphLayout/SugiyamaStyle/Helpers.h | 4 +- .../SugiyamaStyle/LaneDistribution.cpp | 2 +- lib/Lift/CPUStateAccessAnalysisPass.cpp | 36 +++++++------- lib/Lift/CPUStateAccessAnalysisPass.h | 2 +- lib/Lift/CodeGenerator.cpp | 6 +-- lib/Lift/ExternalJumpsHandler.h | 2 +- lib/Lift/InstructionTranslator.cpp | 4 +- lib/Lift/InstructionTranslator.h | 2 +- lib/Lift/JumpTargetManager.cpp | 2 +- lib/Lift/JumpTargetManager.h | 6 +-- lib/Lift/RootAnalyzer.cpp | 2 +- lib/Lift/SubGraph.h | 2 +- lib/Lift/VariableManager.cpp | 2 +- lib/Lift/VariableManager.h | 2 +- lib/Model/Importer/Binary/MachOImporter.cpp | 2 +- lib/Pipeline/Runner.cpp | 2 +- lib/PipelineC/PipelineC.cpp | 2 +- lib/Support/IRHelpers.cpp | 6 +-- lib/Support/ProgramCounterHandler.cpp | 14 +++--- .../templates/struct_late.h.tpl | 4 +- tests/unit/AdvancedValueInfo.cpp | 2 +- tests/unit/DepthFirstVisit.h | 2 +- tests/unit/GenericGraph.cpp | 8 ++-- tests/unit/GraphAlgorithms.cpp | 48 +++++++++---------- 50 files changed, 126 insertions(+), 126 deletions(-) diff --git a/include/revng/ADT/GenericGraph.h b/include/revng/ADT/GenericGraph.h index de3ee38c6..4115ac192 100644 --- a/include/revng/ADT/GenericGraph.h +++ b/include/revng/ADT/GenericGraph.h @@ -91,7 +91,7 @@ public: Parent(Parent &&) = default; private: - T *TheParent; + T *TheParent = nullptr; public: T *getParent() const { return TheParent; } @@ -594,20 +594,20 @@ struct MutableEdgeNodeBaseTCalc { template struct OwningEdge { - NodeType *Neighbor; + NodeType *Neighbor = nullptr; std::unique_ptr Label; }; template struct NonOwningEdge { - NodeType *Neighbor; - LabelType *Label; + NodeType *Neighbor = nullptr; + LabelType *Label = nullptr; }; template struct EdgeView { - NodeType *Neighbor; - LabelType *Label; + NodeType *Neighbor = nullptr; + LabelType *Label = nullptr; explicit EdgeView(OwningEdge &E) : Neighbor(E.Neighbor), Label(E.Label.get()) {} diff --git a/include/revng/ADT/LazySmallBitVector.h b/include/revng/ADT/LazySmallBitVector.h index 5aa5d2c79..737de9e64 100644 --- a/include/revng/ADT/LazySmallBitVector.h +++ b/include/revng/ADT/LazySmallBitVector.h @@ -89,7 +89,7 @@ private: private: friend class boost::iterator_core_access; - LSBV *BitVector; + LSBV *BitVector = nullptr; unsigned NextBitIndex; }; diff --git a/include/revng/ADT/SortedVector.h b/include/revng/ADT/SortedVector.h index db96ad176..b44af053d 100644 --- a/include/revng/ADT/SortedVector.h +++ b/include/revng/ADT/SortedVector.h @@ -320,7 +320,7 @@ public: template class BatchInserterBase { private: - SortedVector *SV; + SortedVector *SV = nullptr; public: BatchInserterBase(SortedVector &SV) : SV(&SV) { diff --git a/include/revng/EarlyFunctionAnalysis/CFGAnalyzer.h b/include/revng/EarlyFunctionAnalysis/CFGAnalyzer.h index 0d8bdfa8b..98087f4a1 100644 --- a/include/revng/EarlyFunctionAnalysis/CFGAnalyzer.h +++ b/include/revng/EarlyFunctionAnalysis/CFGAnalyzer.h @@ -68,7 +68,7 @@ class CFGAnalyzer { private: llvm::Module &M; GeneratedCodeBasicInfo &GCBI; - const ProgramCounterHandler *PCH; + const ProgramCounterHandler *PCH = nullptr; FunctionSummaryOracle &Oracle; const TupleTree &Binary; diff --git a/include/revng/Model/VerifyHelper.h b/include/revng/Model/VerifyHelper.h index 4e14e083f..912f822a4 100644 --- a/include/revng/Model/VerifyHelper.h +++ b/include/revng/Model/VerifyHelper.h @@ -26,7 +26,7 @@ private: template class TrackingSuspender { private: - VerifyHelper *TheContext; + VerifyHelper *TheContext = nullptr; std::optional> Guard; public: diff --git a/include/revng/Pipeline/ContainerEnumerator.h b/include/revng/Pipeline/ContainerEnumerator.h index 6ec87186f..a5ce8781f 100644 --- a/include/revng/Pipeline/ContainerEnumerator.h +++ b/include/revng/Pipeline/ContainerEnumerator.h @@ -31,7 +31,7 @@ namespace pipeline { template class ContainerEnumerator { private: - Kind *K; + Kind *K = nullptr; public: ContainerEnumerator(Kind &K) : K(&K) { @@ -82,7 +82,7 @@ private: } protected: - Context *TheContext; + Context *TheContext = nullptr; public: EnumerableContainer(Context &Context, llvm::StringRef Name) : diff --git a/include/revng/Pipeline/Contract.h b/include/revng/Pipeline/Contract.h index b5f00fbb5..3a14928b8 100644 --- a/include/revng/Pipeline/Contract.h +++ b/include/revng/Pipeline/Contract.h @@ -72,8 +72,8 @@ public: static constexpr auto Erase = InputPreservation::Erase; private: - const Kind *Source; - const Kind *TargetKind; + const Kind *Source = nullptr; + const Kind *TargetKind = nullptr; size_t PipeArgumentSourceIndex; size_t PipeArgumentTargetIndex; InputPreservation::Values Preservation; diff --git a/include/revng/Pipeline/ExecutionContext.h b/include/revng/Pipeline/ExecutionContext.h index e6733a9af..cc2d0c2e8 100644 --- a/include/revng/Pipeline/ExecutionContext.h +++ b/include/revng/Pipeline/ExecutionContext.h @@ -160,7 +160,7 @@ public: static char ID; private: - ExecutionContext *EC; + ExecutionContext *EC = nullptr; llvm::StringRef ContainerName; public: diff --git a/include/revng/Pipeline/Kind.h b/include/revng/Pipeline/Kind.h index 5339f851d..1582b17cb 100644 --- a/include/revng/Pipeline/Kind.h +++ b/include/revng/Pipeline/Kind.h @@ -52,7 +52,7 @@ locationsToRanks(std::tuple Locations) { class Kind : public DynamicHierarchy { private: RegisterKind Register; - const Rank *TheRank; + const Rank *TheRank = nullptr; std::vector DefinedLocations; std::vector PreferredKinds; diff --git a/include/revng/Pipeline/Loader.h b/include/revng/Pipeline/Loader.h index f7d93de31..a576aae93 100644 --- a/include/revng/Pipeline/Loader.h +++ b/include/revng/Pipeline/Loader.h @@ -107,7 +107,7 @@ private: std::set EnabledFlags; std::optional OnLLVMContainerCreationAction = std::nullopt; - Context *PipelineContext; + Context *PipelineContext = nullptr; public: explicit Loader(Context &C) : PipelineContext(&C) {} diff --git a/include/revng/Pipeline/RegisterKind.h b/include/revng/Pipeline/RegisterKind.h index 38a401d04..bf4fccb30 100644 --- a/include/revng/Pipeline/RegisterKind.h +++ b/include/revng/Pipeline/RegisterKind.h @@ -20,7 +20,7 @@ class Kind; /// register class RegisterKind : Registry { private: - Kind *K; + Kind *K = nullptr; public: RegisterKind(Kind &K) : K(&K) {} diff --git a/include/revng/Pipeline/Runner.h b/include/revng/Pipeline/Runner.h index ae4114eed..bb165c51d 100644 --- a/include/revng/Pipeline/Runner.h +++ b/include/revng/Pipeline/Runner.h @@ -35,7 +35,7 @@ private: using Vector = std::vector; private: - Context *TheContext; + Context *TheContext = nullptr; ContainerFactorySet ContainerFactoriesRegistry; bool IsContainerFactoriesRegistryFinalized = false; diff --git a/include/revng/Pipeline/Step.h b/include/revng/Pipeline/Step.h index e9e733778..074b620b0 100644 --- a/include/revng/Pipeline/Step.h +++ b/include/revng/Pipeline/Step.h @@ -45,7 +45,7 @@ public: private: struct ArtifactsInfo { std::string Container; - const Kind *Kind; + const Kind *Kind = nullptr; std::string SingleTargetFilename; ArtifactsInfo() : Container(), Kind(nullptr), SingleTargetFilename() {} @@ -66,10 +66,10 @@ private: std::string Component; ContainerSet Containers; std::vector Pipes; - Step *PreviousStep; + Step *PreviousStep = nullptr; ArtifactsInfo Artifacts; AnalysisMapType AnalysisMap; - Context *TheContext; + Context *TheContext = nullptr; public: template diff --git a/include/revng/Pipeline/Target.h b/include/revng/Pipeline/Target.h index 022a4df0a..08890212f 100644 --- a/include/revng/Pipeline/Target.h +++ b/include/revng/Pipeline/Target.h @@ -45,7 +45,7 @@ class Target { private: using PathComponents = std::vector; PathComponents Components; - const Kind *K; + const Kind *K = nullptr; public: Target(PathComponents Components, const Kind &K) : diff --git a/include/revng/Pipes/TaggedFunctionKind.h b/include/revng/Pipes/TaggedFunctionKind.h index 78ab04284..21da843ca 100644 --- a/include/revng/Pipes/TaggedFunctionKind.h +++ b/include/revng/Pipes/TaggedFunctionKind.h @@ -20,7 +20,7 @@ namespace revng::kinds { /// with that tag. class TaggedFunctionKind : public pipeline::LLVMKind { private: - const FunctionTags::Tag *Tag; + const FunctionTags::Tag *Tag = nullptr; // It is on the heap to avoid Initialization Order Fiasco std::unique_ptr> Children = nullptr; diff --git a/include/revng/Support/DynamicHierarchy.h b/include/revng/Support/DynamicHierarchy.h index d548ff8de..9791a1fc5 100644 --- a/include/revng/Support/DynamicHierarchy.h +++ b/include/revng/Support/DynamicHierarchy.h @@ -31,7 +31,7 @@ private: private: std::vector Children; - DynamicHierarchy *Parent; + DynamicHierarchy *Parent = nullptr; entry_t Start; entry_t End; std::string Name; diff --git a/include/revng/Support/IRHelpers.h b/include/revng/Support/IRHelpers.h index 0d20bf1df..029b74301 100644 --- a/include/revng/Support/IRHelpers.h +++ b/include/revng/Support/IRHelpers.h @@ -331,7 +331,7 @@ public: WorkItem(BasicBlock *BB) : BB(BB), Range(make_range(ID::begin(BB), ID::end(BB))) {} - BasicBlock *BB; + BasicBlock *BB = nullptr; instruction_range Range; }; diff --git a/include/revng/Support/TaggedFunctionPass.h b/include/revng/Support/TaggedFunctionPass.h index 79ef37e94..cb7690f4c 100644 --- a/include/revng/Support/TaggedFunctionPass.h +++ b/include/revng/Support/TaggedFunctionPass.h @@ -11,8 +11,8 @@ struct TaggedFunctionPass : public llvm::ModulePass { private: - FunctionTags::Tag *InputTag; - FunctionTags::Tag *OutputTag; + FunctionTags::Tag *InputTag = nullptr; + FunctionTags::Tag *OutputTag = nullptr; public: TaggedFunctionPass(char &ID, diff --git a/include/revng/TupleTree/TupleTree.h b/include/revng/TupleTree/TupleTree.h index a095863a8..b88444227 100644 --- a/include/revng/TupleTree/TupleTree.h +++ b/include/revng/TupleTree/TupleTree.h @@ -33,7 +33,7 @@ template struct DisableTracking { - const T *TrackedObject; + const T *TrackedObject = nullptr; public: DisableTracking(const T &TrackedObject) : TrackedObject(&TrackedObject) { diff --git a/include/revng/TupleTree/TupleTreeDiff.h b/include/revng/TupleTree/TupleTreeDiff.h index 75e3e073e..9f0d7410c 100644 --- a/include/revng/TupleTree/TupleTreeDiff.h +++ b/include/revng/TupleTree/TupleTreeDiff.h @@ -65,7 +65,7 @@ concept TupleTreeRootLike = StrictSpecializationOf, namespace detail { template struct CheckTypeIsCorrect { - const AllowedTupleTreeTypes *Alternatives; + const AllowedTupleTreeTypes *Alternatives = nullptr; bool IsCorrect = false; template @@ -213,7 +213,7 @@ namespace detail { template struct MapDiffVisitor { llvm::yaml::IO *Io; - AllowedTupleTreeTypes *Change; + AllowedTupleTreeTypes *Change = nullptr; const char *MappingName; template @@ -422,7 +422,7 @@ template struct ApplyDiffVisitor { public: using Change = typename TupleTreeDiff::Change; - const Change *C; + const Change *C = nullptr; size_t ChangeIndex; revng::DiffError *EL; diff --git a/include/revng/UnitTestHelpers/DotGraphObject.h b/include/revng/UnitTestHelpers/DotGraphObject.h index 5bfb4e5ba..c61e5b789 100644 --- a/include/revng/UnitTestHelpers/DotGraphObject.h +++ b/include/revng/UnitTestHelpers/DotGraphObject.h @@ -40,7 +40,7 @@ public: private: llvm::SmallString<8> Name; - DotGraph *Parent; + DotGraph *Parent = nullptr; // Actual container for the pointers to the successors nodes. child_container Successors; @@ -117,7 +117,7 @@ public: private: node_container Nodes; - DotNode *EntryNode; + DotNode *EntryNode = nullptr; public: DotGraph() {} diff --git a/lib/EarlyFunctionAnalysis/SegregateDirectStackAccesses.cpp b/lib/EarlyFunctionAnalysis/SegregateDirectStackAccesses.cpp index a8f88fb54..bd81e22da 100644 --- a/lib/EarlyFunctionAnalysis/SegregateDirectStackAccesses.cpp +++ b/lib/EarlyFunctionAnalysis/SegregateDirectStackAccesses.cpp @@ -120,7 +120,7 @@ void SDSAPI::segregateAccesses(Function &F) { // of the current instruction, where LoadPtr is SP? Change it with the // newly-created bitcasted load in order to prevent from using inttoptr. if (Pointer == LoadSP) { - Type *DestTy; + Type *DestTy = nullptr; if (isa(&I)) DestTy = I.getOperand(0)->getType(); else @@ -138,7 +138,7 @@ void SDSAPI::segregateAccesses(Function &F) { // to the original type of SP. auto *GEP = Builder.CreateGEP(Builder.getInt8Ty(), SPI8Ptr, Offset); - Type *DestTy; + Type *DestTy = nullptr; if (isa(&I)) DestTy = I.getOperand(0)->getType(); else diff --git a/lib/FunctionCallIdentification/FunctionCallIdentification.cpp b/lib/FunctionCallIdentification/FunctionCallIdentification.cpp index d44b28804..e3a30dcab 100644 --- a/lib/FunctionCallIdentification/FunctionCallIdentification.cpp +++ b/lib/FunctionCallIdentification/FunctionCallIdentification.cpp @@ -84,18 +84,18 @@ bool FunctionCallIdentification::runOnModule(llvm::Module &M) { using SuccessorsType = SmallVector; public: - BasicBlock *BB; + BasicBlock *BB = nullptr; const GeneratedCodeBasicInfo &GCBI; bool SaveRAFound; bool StorePCFound; - Constant *LinkRegister; + Constant *LinkRegister = nullptr; const MetaAddress ReturnPC; MetaAddress LastPC; // We can meet calls up to newpc up to (1 + "size of the delay slot") // times uint64_t NewPCLeft; - PointerType *PCPtrTy; + PointerType *PCPtrTy = nullptr; public: Visitor(BasicBlock *BB, diff --git a/lib/FunctionIsolation/InvokeIsolatedFunctions.cpp b/lib/FunctionIsolation/InvokeIsolatedFunctions.cpp index 995448904..6781ae3bf 100644 --- a/lib/FunctionIsolation/InvokeIsolatedFunctions.cpp +++ b/lib/FunctionIsolation/InvokeIsolatedFunctions.cpp @@ -65,8 +65,8 @@ private: private: const model::Binary &Binary; - Function *RootFunction; - Module *M; + Function *RootFunction = nullptr; + Module *M = nullptr; LLVMContext &Context; GeneratedCodeBasicInfo &GCBI; FunctionMap Map; diff --git a/lib/FunctionIsolation/PromoteCSVs.cpp b/lib/FunctionIsolation/PromoteCSVs.cpp index f6738563d..d51d4666e 100644 --- a/lib/FunctionIsolation/PromoteCSVs.cpp +++ b/lib/FunctionIsolation/PromoteCSVs.cpp @@ -43,7 +43,7 @@ struct CSVsUsageMap { struct WrapperKey { public: - Function *Helper; + Function *Helper = nullptr; /// GlobalVariables representing read CPU State Variables sorted by name. std::vector Read; @@ -364,7 +364,7 @@ void PromoteCSVs::promoteCSVs(Function *F) { } struct FunctionNodeData { - Function *F; + Function *F = nullptr; using UsedCSVSet = std::set>; UsedCSVSet UsedCSVs; }; diff --git a/lib/GraphLayout/SugiyamaStyle/GraphPreparation.cpp b/lib/GraphLayout/SugiyamaStyle/GraphPreparation.cpp index 85ca901fe..1a7929e86 100644 --- a/lib/GraphLayout/SugiyamaStyle/GraphPreparation.cpp +++ b/lib/GraphLayout/SugiyamaStyle/GraphPreparation.cpp @@ -14,7 +14,7 @@ // A simple container that's used to indicate a self-loop. struct SelfLoop { - InternalNode *Node; + InternalNode *Node = nullptr; InternalEdge Edge; SelfLoop(InternalNode *Node, InternalEdge &&Edge) : diff --git a/lib/GraphLayout/SugiyamaStyle/Helpers.h b/lib/GraphLayout/SugiyamaStyle/Helpers.h index bd4506edb..c63cc88c2 100644 --- a/lib/GraphLayout/SugiyamaStyle/Helpers.h +++ b/lib/GraphLayout/SugiyamaStyle/Helpers.h @@ -50,7 +50,7 @@ public: } private: - InternalNode *Pointer; + InternalNode *Pointer = nullptr; }; namespace std { @@ -166,7 +166,7 @@ using CornerContainer = std::map; /// for an edge to be routed. This data is usable even after the internal graph /// was destroyed. struct RoutableEdge { - InternalEdge *Label; + InternalEdge *Label = nullptr; Point FromCenter, ToCenter; Size FromSize, ToSize; Rank LaneIndex, ExitCount, EntryCount; diff --git a/lib/GraphLayout/SugiyamaStyle/LaneDistribution.cpp b/lib/GraphLayout/SugiyamaStyle/LaneDistribution.cpp index fd0184948..c8c641c05 100644 --- a/lib/GraphLayout/SugiyamaStyle/LaneDistribution.cpp +++ b/lib/GraphLayout/SugiyamaStyle/LaneDistribution.cpp @@ -54,7 +54,7 @@ public: struct EdgeDestination { NodeView Neighbor; - InternalEdge *Label; + InternalEdge *Label = nullptr; EdgeDestination(NodeView Neighbor, InternalEdge &Label) : Neighbor(Neighbor), Label(&Label) {} diff --git a/lib/Lift/CPUStateAccessAnalysisPass.cpp b/lib/Lift/CPUStateAccessAnalysisPass.cpp index cd2c0b8f4..6470f5987 100644 --- a/lib/Lift/CPUStateAccessAnalysisPass.cpp +++ b/lib/Lift/CPUStateAccessAnalysisPass.cpp @@ -245,8 +245,8 @@ forwardTaintAnalysis(const Module *M, revng_assert(CPUStatePtr->getType()->isPointerTy()); struct CallSiteInfo { - const CallInst *CallSite; - const Argument *Arg; + const CallInst *CallSite = nullptr; + const Argument *Arg = nullptr; const unsigned ArgNo; CallSiteInfo(const CallInst *C, const Argument *A, const unsigned N) : CallSite(C), Arg(A), ArgNo(N) {} @@ -675,7 +675,7 @@ public: private: // The value whose sources we're analyzing - Value *CurrentValue; + Value *CurrentValue = nullptr; // Sources are kind of the opposite of `Use`s. Every pointer in this vector // points to a `Use` whose `User` is the `Value` pointed by the `CurrentValue` @@ -947,8 +947,8 @@ protected: // static ConstantInt *get(IntegerType *Ty, uint64_t V, bool isSigned=false) // However, it does not really change Ty, because it only call const // methods on it, so it should be safe. - IntegerType *Int64Ty; - IntegerType *Int32Ty; + IntegerType *Int64Ty = nullptr; + IntegerType *Int32Ty = nullptr; const DataLayout &DL; public: @@ -1449,11 +1449,11 @@ private: const unsigned LoadMDKind; const unsigned StoreMDKind; const Module &M; - const Value *CPUStatePtr; - const Function *RootFunction; + const Value *CPUStatePtr = nullptr; + const Function *RootFunction = nullptr; const ConstFunctionPtrSet &ReachableFunctions; const TaintResults &TaintedAccesses; - VariableManager *Variables; + VariableManager *Variables = nullptr; AccessOffsetMap &LoadOffsets; // result, maps load or load-memcpy to offsets AccessOffsetMap &StoreOffsets; // result, maps store or store-memcpy to @@ -1487,7 +1487,7 @@ private: NumericOffsetFolder NumericFolder; GEPOffsetFolder GEPFolder; - const Function *CpuLoop; + const Function *CpuLoop = nullptr; public: CPUStateAccessOffsetAnalysis(const Module &Mod, @@ -2312,7 +2312,7 @@ void CPUSAOA::computeAggregatedOffsets() { int64_t End = Coarse + AccessSize; while (Refined < End) { unsigned InternalOffset = 0; - GlobalVariable *AccessedVar; + GlobalVariable *AccessedVar = nullptr; std::tie(AccessedVar, InternalOffset) = Variables->getByEnvOffset(Refined); int64_t SizeAtOffset = 0; @@ -2412,7 +2412,7 @@ private: // A reference to the analyzed Module const Module &M; - VariableManager *Variables; + VariableManager *Variables = nullptr; // References to the maps that were filled by CPUStateAccessAnalysis. // Every map maps an Instruction to the CSVOffset representing all the @@ -2471,10 +2471,10 @@ private: const DataLayout &DL; int64_t EnvStructSize; IRBuilder<> Builder; - Type *Int64Ty; - Constant *SizeOfEnv; - Constant *Zero; - Value *CPUStatePtr; + Type *Int64Ty = nullptr; + Constant *SizeOfEnv = nullptr; + Constant *Zero = nullptr; + Value *CPUStatePtr = nullptr; }; static Value *getLoadAddressValue(Instruction *I) { @@ -3059,7 +3059,7 @@ private: const Module &M; // A reference to the associated VariableManager - VariableManager *Variables; + VariableManager *Variables = nullptr; // References to the maps that will be filled by this analysis. // Every map maps an Instruction to the CSVOffset representing all the @@ -3075,8 +3075,8 @@ private: // Helpers const DataLayout &DL; - Type *Int64Ty; - Value *CPUStatePtr; + Type *Int64Ty = nullptr; + Value *CPUStatePtr = nullptr; public: CPUStateAccessAnalysis(const Module &Mod, diff --git a/lib/Lift/CPUStateAccessAnalysisPass.h b/lib/Lift/CPUStateAccessAnalysisPass.h index d4e6d2247..96d9e43e2 100644 --- a/lib/Lift/CPUStateAccessAnalysisPass.h +++ b/lib/Lift/CPUStateAccessAnalysisPass.h @@ -27,7 +27,7 @@ public: private: const bool Lazy; - VariableManager *Variables; + VariableManager *Variables = nullptr; public: static char ID; diff --git a/lib/Lift/CodeGenerator.cpp b/lib/Lift/CodeGenerator.cpp index 35363ef49..b6b098cda 100644 --- a/lib/Lift/CodeGenerator.cpp +++ b/lib/Lift/CodeGenerator.cpp @@ -80,7 +80,7 @@ inline std::array make_array(ArgTypes &&...Args) { class OpaqueIdentity { private: std::map Map; - Module *M; + Module *M = nullptr; public: OpaqueIdentity(Module *M) : M(M) {} @@ -263,7 +263,7 @@ static void replaceFunctionWithRet(Function *ToReplace, uint64_t Result) { return; BasicBlock *Body = replaceFunction(ToReplace); - Value *ResultValue; + Value *ResultValue = nullptr; if (ToReplace->getReturnType()->isVoidTy()) { revng_assert(Result == 0); @@ -407,7 +407,7 @@ public: bool runOnModule(llvm::Module &M) override; private: - VariableManager *VM; + VariableManager *VM = nullptr; }; char CpuLoopExitPass::ID = 0; diff --git a/lib/Lift/ExternalJumpsHandler.h b/lib/Lift/ExternalJumpsHandler.h index 18d637b4c..98f1e291e 100644 --- a/lib/Lift/ExternalJumpsHandler.h +++ b/lib/Lift/ExternalJumpsHandler.h @@ -39,7 +39,7 @@ private: llvm::Function &TheFunction; llvm::BasicBlock *Dispatcher; - ProgramCounterHandler *PCH; + ProgramCounterHandler *PCH = nullptr; public: /// \param TheFunction the root function. diff --git a/lib/Lift/InstructionTranslator.cpp b/lib/Lift/InstructionTranslator.cpp index c58f364e0..64752370c 100644 --- a/lib/Lift/InstructionTranslator.cpp +++ b/lib/Lift/InstructionTranslator.cpp @@ -86,7 +86,7 @@ public: uint64_t get(unsigned Index) const; private: - PTCInstruction *TheInstruction; + PTCInstruction *TheInstruction = nullptr; }; template<> @@ -159,7 +159,7 @@ public: } private: - PTCInstruction *TheInstruction; + PTCInstruction *TheInstruction = nullptr; public: const Range> InArguments; diff --git a/lib/Lift/InstructionTranslator.h b/lib/Lift/InstructionTranslator.h index 2053a704e..06f6538e1 100644 --- a/lib/Lift/InstructionTranslator.h +++ b/lib/Lift/InstructionTranslator.h @@ -142,6 +142,6 @@ private: MetaAddress LastPC; - ProgramCounterHandler *PCH; + ProgramCounterHandler *PCH = nullptr; llvm::SmallVector ExitBlocks; }; diff --git a/lib/Lift/JumpTargetManager.cpp b/lib/Lift/JumpTargetManager.cpp index 50b57bfcf..bd376ef2b 100644 --- a/lib/Lift/JumpTargetManager.cpp +++ b/lib/Lift/JumpTargetManager.cpp @@ -713,7 +713,7 @@ private: } private: - const SwitchInst *Dispatcher; + const SwitchInst *Dispatcher = nullptr; unsigned JumpTargetIndex; unsigned JumpTargetsCount; const DataLayout &DL; diff --git a/lib/Lift/JumpTargetManager.h b/lib/Lift/JumpTargetManager.h index 435a4e5c0..ae00cb329 100644 --- a/lib/Lift/JumpTargetManager.h +++ b/lib/Lift/JumpTargetManager.h @@ -103,8 +103,8 @@ public: static char ID; private: - JumpTargetManager *JTM; - ProgramCounterHandler *PCH; + JumpTargetManager *JTM = nullptr; + ProgramCounterHandler *PCH = nullptr; }; namespace CFGForm { @@ -609,7 +609,7 @@ private: std::set SimpleLiterals; CSAAFactory CreateCSAA; - ProgramCounterHandler *PCH; + ProgramCounterHandler *PCH = nullptr; MetaAddressSet ValueMaterializerPCWhiteList; const TupleTree &Model; diff --git a/lib/Lift/RootAnalyzer.cpp b/lib/Lift/RootAnalyzer.cpp index 8e064b05e..c11c49905 100644 --- a/lib/Lift/RootAnalyzer.cpp +++ b/lib/Lift/RootAnalyzer.cpp @@ -184,7 +184,7 @@ public: struct TrackedValue { MetaAddress Address; TrackedValueType Type; - Instruction *I; + Instruction *I = nullptr; }; private: diff --git a/lib/Lift/SubGraph.h b/lib/Lift/SubGraph.h index 5eb585902..12b93aa88 100644 --- a/lib/Lift/SubGraph.h +++ b/lib/Lift/SubGraph.h @@ -107,7 +107,7 @@ private: // We define a custom comparator so that Node still preserves the default // comparison operators std::set Nodes; - Node *EntryNode; + Node *EntryNode = nullptr; }; namespace llvm { diff --git a/lib/Lift/VariableManager.cpp b/lib/Lift/VariableManager.cpp index a22266b7a..ab879fbab 100644 --- a/lib/Lift/VariableManager.cpp +++ b/lib/Lift/VariableManager.cpp @@ -468,7 +468,7 @@ VariableManager::getByCPUStateOffsetInternal(intptr_t Offset, if (It == CPUStateGlobals.end() || (Name.size() != 0 && It->second->getName().startswith(UnknownCSVPref))) { - Type *VariableType; + Type *VariableType = nullptr; unsigned Remaining; std::tie(VariableType, Remaining) = getTypeAtOffset(ModuleLayout, CPUStateType, Offset); diff --git a/lib/Lift/VariableManager.h b/lib/Lift/VariableManager.h index ab9747916..bddba5fb5 100644 --- a/lib/Lift/VariableManager.h +++ b/lib/Lift/VariableManager.h @@ -183,7 +183,7 @@ private: GlobalsMap OtherGlobals; TemporariesMap Temporaries; TemporariesMap LocalTemporaries; - PTCInstructionList *Instructions; + PTCInstructionList *Instructions = nullptr; llvm::StructType *CPUStateType; const llvm::DataLayout *ModuleLayout; diff --git a/lib/Model/Importer/Binary/MachOImporter.cpp b/lib/Model/Importer/Binary/MachOImporter.cpp index 13b3e403e..83bc196f7 100644 --- a/lib/Model/Importer/Binary/MachOImporter.cpp +++ b/lib/Model/Importer/Binary/MachOImporter.cpp @@ -46,7 +46,7 @@ template class ArrayRefReader { private: ArrayRef Array; - const T *Cursor; + const T *Cursor = nullptr; bool Swap; public: diff --git a/lib/Pipeline/Runner.cpp b/lib/Pipeline/Runner.cpp index b519a2d50..fb6927ad8 100644 --- a/lib/Pipeline/Runner.cpp +++ b/lib/Pipeline/Runner.cpp @@ -26,7 +26,7 @@ using namespace pipeline; class PipelineExecutionEntry { public: - Step *ToExecute; + Step *ToExecute = nullptr; ContainerToTargetsMap Output; ContainerToTargetsMap Input; std::vector PipesExecuteEntries; diff --git a/lib/PipelineC/PipelineC.cpp b/lib/PipelineC/PipelineC.cpp index 11e61f607..4d0911af6 100644 --- a/lib/PipelineC/PipelineC.cpp +++ b/lib/PipelineC/PipelineC.cpp @@ -44,7 +44,7 @@ concept default_constructible = std::is_default_constructible::value; template class ExistingOrNew { private: - T *Pointer; + T *Pointer = nullptr; std::optional Default; public: diff --git a/lib/Support/IRHelpers.cpp b/lib/Support/IRHelpers.cpp index 6a1f1d97b..0d07d2e62 100644 --- a/lib/Support/IRHelpers.cpp +++ b/lib/Support/IRHelpers.cpp @@ -301,9 +301,9 @@ void dumpUsers(llvm::Value *V) { using namespace llvm; struct InstructionUser { - Function *F; - BasicBlock *BB; - Instruction *I; + Function *F = nullptr; + BasicBlock *BB = nullptr; + Instruction *I = nullptr; bool operator<(const InstructionUser &Other) const { return std::tie(F, BB, I) < std::tie(Other.F, Other.BB, Other.I); } diff --git a/lib/Support/ProgramCounterHandler.cpp b/lib/Support/ProgramCounterHandler.cpp index c374cd2c1..8972ddce2 100644 --- a/lib/Support/ProgramCounterHandler.cpp +++ b/lib/Support/ProgramCounterHandler.cpp @@ -87,7 +87,7 @@ private: static constexpr const char *IsThumbName = "is_thumb"; private: - GlobalVariable *IsThumb; + GlobalVariable *IsThumb = nullptr; public: ARMProgramCounterHandler() : ProgramCounterHandler(2), IsThumb(nullptr) {} @@ -557,13 +557,13 @@ PCH::getUniqueJumpTarget(BasicBlock *BB) { class SwitchManager { private: LLVMContext &Context; - Function *F; - BasicBlock *Default; + Function *F = nullptr; + BasicBlock *Default = nullptr; - Value *CurrentEpoch; - Value *CurrentAddressSpace; - Value *CurrentType; - Value *CurrentAddress; + Value *CurrentEpoch = nullptr; + Value *CurrentAddressSpace = nullptr; + Value *CurrentType = nullptr; + Value *CurrentAddress = nullptr; std::optional SetBlockType; diff --git a/scripts/tuple_tree_generator/tuple_tree_generator/templates/struct_late.h.tpl b/scripts/tuple_tree_generator/tuple_tree_generator/templates/struct_late.h.tpl index 14a3a82fa..c3f859f1c 100644 --- a/scripts/tuple_tree_generator/tuple_tree_generator/templates/struct_late.h.tpl +++ b/scripts/tuple_tree_generator/tuple_tree_generator/templates/struct_late.h.tpl @@ -216,7 +216,7 @@ public: template class ConstVisitor : public ConstVisitorBase { private: - L *Callable; + L *Callable = nullptr; public: ConstVisitor(L &Callable) : Callable(&Callable) {} @@ -242,7 +242,7 @@ public: template class Visitor : public VisitorBase { private: - L *Callable; + L *Callable = nullptr; public: Visitor(L &Callable) : Callable(&Callable) {} diff --git a/tests/unit/AdvancedValueInfo.cpp b/tests/unit/AdvancedValueInfo.cpp index 3faca919e..1b4748303 100644 --- a/tests/unit/AdvancedValueInfo.cpp +++ b/tests/unit/AdvancedValueInfo.cpp @@ -61,7 +61,7 @@ public: bool runOnModule(llvm::Module &M) override; private: - ResultsMap *Results; + ResultsMap *Results = nullptr; }; char TestAdvancedValueInfoPass::ID = 0; diff --git a/tests/unit/DepthFirstVisit.h b/tests/unit/DepthFirstVisit.h index a8b21e3f2..c9945183b 100644 --- a/tests/unit/DepthFirstVisit.h +++ b/tests/unit/DepthFirstVisit.h @@ -39,7 +39,7 @@ public: class Graph { private: std::deque Nodes; - Node *Root; + Node *Root = nullptr; public: Graph() : Nodes(), Root(newNode()) {} diff --git a/tests/unit/GenericGraph.cpp b/tests/unit/GenericGraph.cpp index 4716da847..d47e5e27f 100644 --- a/tests/unit/GenericGraph.cpp +++ b/tests/unit/GenericGraph.cpp @@ -282,10 +282,10 @@ struct DiamondGraph { using Node = NodeType; GenericGraph Graph; - Node *Root; - Node *Then; - Node *Else; - Node *Final; + Node *Root = nullptr; + Node *Then = nullptr; + Node *Else = nullptr; + Node *Final = nullptr; }; template diff --git a/tests/unit/GraphAlgorithms.cpp b/tests/unit/GraphAlgorithms.cpp index 5d08fc3ec..9d1b96ecf 100644 --- a/tests/unit/GraphAlgorithms.cpp +++ b/tests/unit/GraphAlgorithms.cpp @@ -27,9 +27,9 @@ template struct LoopGraph { using Node = NodeType; GenericGraph Graph; - Node *Entry; - Node *LoopLatch; - Node *Exit; + Node *Entry = nullptr; + Node *LoopLatch = nullptr; + Node *Exit = nullptr; }; template @@ -57,12 +57,12 @@ template struct NestedLoopGraph { using Node = NodeType; GenericGraph Graph; - Node *Entry; - Node *LoopHeader; - Node *SecondLoopHeader; - Node *LoopLatch; - Node *SecondLoopLatch; - Node *Exit; + Node *Entry = nullptr; + Node *LoopHeader = nullptr; + Node *SecondLoopHeader = nullptr; + Node *LoopLatch = nullptr; + Node *SecondLoopLatch = nullptr; + Node *Exit = nullptr; }; template @@ -94,12 +94,12 @@ template struct NonCanonicalLoopGraph { using Node = NodeType; GenericGraph Graph; - Node *LoopHeader; - Node *SecondLoopHeader; - Node *LoopLatch; - Node *LoopSuccessor; - Node *SecondLoopSuccessor; - Node *SecondLoopLatch; + Node *LoopHeader = nullptr; + Node *SecondLoopHeader = nullptr; + Node *LoopLatch = nullptr; + Node *LoopSuccessor = nullptr; + Node *SecondLoopSuccessor = nullptr; + Node *SecondLoopLatch = nullptr; }; template @@ -132,12 +132,12 @@ template struct NonCanonicalAlternateLoopGraph { using Node = NodeType; GenericGraph Graph; - Node *LoopHeader; - Node *SecondLoopHeader; - Node *LoopLatch; - Node *LoopSuccessor; - Node *SecondLoopSuccessor; - Node *SecondLoopLatch; + Node *LoopHeader = nullptr; + Node *SecondLoopHeader = nullptr; + Node *LoopLatch = nullptr; + Node *LoopSuccessor = nullptr; + Node *SecondLoopSuccessor = nullptr; + Node *SecondLoopLatch = nullptr; }; template @@ -164,9 +164,9 @@ template struct ReverseGraph { using Node = NodeType; GenericGraph Graph; - Node *InitialBlock; - Node *SmallerBlock; - Node *EndBlock; + Node *InitialBlock = nullptr; + Node *SmallerBlock = nullptr; + Node *EndBlock = nullptr; }; template