[llvm] 65d4d62 - Fix uninitialized pointer members in MC

via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 18 02:46:22 PDT 2023


Author: Akshay Khadse
Date: 2023-04-18T17:45:58+08:00
New Revision: 65d4d62ab781b0433f03b2b685329fb3033e9e3c

URL: https://github.com/llvm/llvm-project/commit/65d4d62ab781b0433f03b2b685329fb3033e9e3c
DIFF: https://github.com/llvm/llvm-project/commit/65d4d62ab781b0433f03b2b685329fb3033e9e3c.diff

LOG: Fix uninitialized pointer members in MC

Reviewed By: LuoYuanke

Differential Revision: https://reviews.llvm.org/D148421

Added: 
    

Modified: 
    llvm/include/llvm/CodeGen/MachineSSAContext.h
    llvm/include/llvm/MC/MCContext.h
    llvm/include/llvm/MC/MCFragment.h
    llvm/include/llvm/MC/MCParser/MCAsmParserExtension.h
    llvm/include/llvm/MC/MCPseudoProbe.h
    llvm/include/llvm/MC/MCWinEH.h
    llvm/include/llvm/Object/COFF.h
    llvm/lib/MC/WasmObjectWriter.cpp
    llvm/lib/MC/WinCOFFObjectWriter.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/CodeGen/MachineSSAContext.h b/llvm/include/llvm/CodeGen/MachineSSAContext.h
index a3788f1046ec9..3bf0f728907ec 100644
--- a/llvm/include/llvm/CodeGen/MachineSSAContext.h
+++ b/llvm/include/llvm/CodeGen/MachineSSAContext.h
@@ -36,7 +36,7 @@ inline auto instrs(const MachineBasicBlock &BB) { return BB.instrs(); }
 
 template <> class GenericSSAContext<MachineFunction> {
   const MachineRegisterInfo *RegInfo = nullptr;
-  MachineFunction *MF;
+  MachineFunction *MF = nullptr;
 
 public:
   using BlockT = MachineBasicBlock;

diff  --git a/llvm/include/llvm/MC/MCContext.h b/llvm/include/llvm/MC/MCContext.h
index 59f05bbc10cf1..74c3fe5c61f29 100644
--- a/llvm/include/llvm/MC/MCContext.h
+++ b/llvm/include/llvm/MC/MCContext.h
@@ -101,7 +101,7 @@ class MCContext {
   Triple TT;
 
   /// The SourceMgr for this object, if any.
-  const SourceMgr *SrcMgr;
+  const SourceMgr *SrcMgr = nullptr;
 
   /// The SourceMgr for inline assembly, if any.
   std::unique_ptr<SourceMgr> InlineSrcMgr;
@@ -110,16 +110,16 @@ class MCContext {
   DiagHandlerTy DiagHandler;
 
   /// The MCAsmInfo for this target.
-  const MCAsmInfo *MAI;
+  const MCAsmInfo *MAI = nullptr;
 
   /// The MCRegisterInfo for this target.
-  const MCRegisterInfo *MRI;
+  const MCRegisterInfo *MRI = nullptr;
 
   /// The MCObjectFileInfo for this target.
-  const MCObjectFileInfo *MOFI;
+  const MCObjectFileInfo *MOFI = nullptr;
 
   /// The MCSubtargetInfo for this target.
-  const MCSubtargetInfo *MSTI;
+  const MCSubtargetInfo *MSTI = nullptr;
 
   std::unique_ptr<CodeViewContext> CVContext;
 

diff  --git a/llvm/include/llvm/MC/MCFragment.h b/llvm/include/llvm/MC/MCFragment.h
index b6329b1316240..f040cea801f84 100644
--- a/llvm/include/llvm/MC/MCFragment.h
+++ b/llvm/include/llvm/MC/MCFragment.h
@@ -311,7 +311,7 @@ class MCAlignFragment : public MCFragment {
   unsigned MaxBytesToEmit;
 
   /// When emitting Nops some subtargets have specific nop encodings.
-  const MCSubtargetInfo *STI;
+  const MCSubtargetInfo *STI = nullptr;
 
 public:
   MCAlignFragment(Align Alignment, int64_t Value, unsigned ValueSize,

diff  --git a/llvm/include/llvm/MC/MCParser/MCAsmParserExtension.h b/llvm/include/llvm/MC/MCParser/MCAsmParserExtension.h
index cbabc2c9d69d5..e596a7195447d 100644
--- a/llvm/include/llvm/MC/MCParser/MCAsmParserExtension.h
+++ b/llvm/include/llvm/MC/MCParser/MCAsmParserExtension.h
@@ -22,7 +22,7 @@ class Twine;
 /// which is implemented by target and object file assembly parser
 /// implementations.
 class MCAsmParserExtension {
-  MCAsmParser *Parser;
+  MCAsmParser *Parser = nullptr;
 
 protected:
   MCAsmParserExtension();

diff  --git a/llvm/include/llvm/MC/MCPseudoProbe.h b/llvm/include/llvm/MC/MCPseudoProbe.h
index f5796f5c7948d..cd1bf805b50a0 100644
--- a/llvm/include/llvm/MC/MCPseudoProbe.h
+++ b/llvm/include/llvm/MC/MCPseudoProbe.h
@@ -235,7 +235,8 @@ class MCPseudoProbeInlineTreeBase {
   std::vector<ProbeType> &getProbes() { return Probes; }
   void addProbes(ProbeType Probe) { Probes.push_back(Probe); }
   // Caller node of the inline site
-  MCPseudoProbeInlineTreeBase<ProbeType, DerivedProbeInlineTreeType> *Parent;
+  MCPseudoProbeInlineTreeBase<ProbeType, DerivedProbeInlineTreeType> *Parent =
+      nullptr;
   DerivedProbeInlineTreeType *getOrAddNode(const InlineSite &Site) {
     auto Ret = Children.emplace(
         Site, std::make_unique<DerivedProbeInlineTreeType>(Site));

diff  --git a/llvm/include/llvm/MC/MCWinEH.h b/llvm/include/llvm/MC/MCWinEH.h
index 2c516f78efef2..fcce2dcd54837 100644
--- a/llvm/include/llvm/MC/MCWinEH.h
+++ b/llvm/include/llvm/MC/MCWinEH.h
@@ -68,7 +68,7 @@ struct FrameInfo {
     int64_t Offset;
     int64_t Length;
     bool HasProlog;
-    MCSymbol *Symbol;
+    MCSymbol *Symbol = nullptr;
     // Map an Epilog's symbol to its offset within the function.
     MapVector<MCSymbol *, int64_t> Epilogs;
 

diff  --git a/llvm/include/llvm/Object/COFF.h b/llvm/include/llvm/Object/COFF.h
index 4afd11f5a1965..1abf2c2da5951 100644
--- a/llvm/include/llvm/Object/COFF.h
+++ b/llvm/include/llvm/Object/COFF.h
@@ -1259,7 +1259,7 @@ class ResourceSectionRef {
   BinaryByteStream BBS;
 
   SectionRef Section;
-  const COFFObjectFile *Obj;
+  const COFFObjectFile *Obj = nullptr;
 
   std::vector<const coff_relocation *> Relocs;
 

diff  --git a/llvm/lib/MC/WasmObjectWriter.cpp b/llvm/lib/MC/WasmObjectWriter.cpp
index a4cb4149f0369..8c879e3d3b70e 100644
--- a/llvm/lib/MC/WasmObjectWriter.cpp
+++ b/llvm/lib/MC/WasmObjectWriter.cpp
@@ -197,7 +197,7 @@ bool isDwoSection(const MCSection &Sec) {
 }
 
 class WasmObjectWriter : public MCObjectWriter {
-  support::endian::Writer *W;
+  support::endian::Writer *W = nullptr;
 
   /// The target specific Wasm writer instance.
   std::unique_ptr<MCWasmObjectTargetWriter> TargetObjectWriter;

diff  --git a/llvm/lib/MC/WinCOFFObjectWriter.cpp b/llvm/lib/MC/WinCOFFObjectWriter.cpp
index 6687fd6af9c8f..25bd1b8737784 100644
--- a/llvm/lib/MC/WinCOFFObjectWriter.cpp
+++ b/llvm/lib/MC/WinCOFFObjectWriter.cpp
@@ -154,7 +154,7 @@ class WinCOFFObjectWriter : public MCObjectWriter {
   bool UseBigObj;
   bool UseOffsetLabels = false;
 
-  MCSectionCOFF *AddrsigSection;
+  MCSectionCOFF *AddrsigSection = nullptr;
 
   MCSectionCOFF *CGProfileSection = nullptr;
 


        


More information about the llvm-commits mailing list