[llvm] 606c189 - llvm-objcopy - fix uninitialized variable warnings. NFC.

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 18 05:59:29 PST 2019


Author: Simon Pilgrim
Date: 2019-11-18T13:57:34Z
New Revision: 606c189215d1c78681e8020b6393019b0c0ea181

URL: https://github.com/llvm/llvm-project/commit/606c189215d1c78681e8020b6393019b0c0ea181
DIFF: https://github.com/llvm/llvm-project/commit/606c189215d1c78681e8020b6393019b0c0ea181.diff

LOG: llvm-objcopy  - fix uninitialized variable warnings. NFC.

Added: 
    

Modified: 
    llvm/tools/llvm-objcopy/COFF/Object.h
    llvm/tools/llvm-objcopy/ELF/Object.h

Removed: 
    


################################################################################
diff  --git a/llvm/tools/llvm-objcopy/COFF/Object.h b/llvm/tools/llvm-objcopy/COFF/Object.h
index 21475b068629..a6a3901e9c8d 100644
--- a/llvm/tools/llvm-objcopy/COFF/Object.h
+++ b/llvm/tools/llvm-objcopy/COFF/Object.h
@@ -25,11 +25,11 @@ namespace objcopy {
 namespace coff {
 
 struct Relocation {
-  Relocation() {}
+  Relocation() = default;
   Relocation(const object::coff_relocation& R) : Reloc(R) {}
 
   object::coff_relocation Reloc;
-  size_t Target;
+  size_t Target = 0;
   StringRef TargetName; // Used for diagnostics only
 };
 

diff  --git a/llvm/tools/llvm-objcopy/ELF/Object.h b/llvm/tools/llvm-objcopy/ELF/Object.h
index 5fd58fecb7f7..97702a66bc47 100644
--- a/llvm/tools/llvm-objcopy/ELF/Object.h
+++ b/llvm/tools/llvm-objcopy/ELF/Object.h
@@ -355,7 +355,7 @@ class BinaryWriter : public Writer {
 private:
   std::unique_ptr<BinarySectionWriter> SecWriter;
 
-  uint64_t TotalSize;
+  uint64_t TotalSize = 0;
 
 public:
   ~BinaryWriter() {}
@@ -370,7 +370,7 @@ class IHexWriter : public Writer {
   };
 
   std::set<const SectionBase *, SectionCompare> Sections;
-  size_t TotalSize;
+  size_t TotalSize = 0;
 
   Error checkSection(const SectionBase &Sec);
   uint64_t writeEntryPointRecord(uint8_t *Buf);
@@ -387,8 +387,8 @@ class SectionBase {
 public:
   std::string Name;
   Segment *ParentSegment = nullptr;
-  uint64_t HeaderOffset;
-  uint32_t Index;
+  uint64_t HeaderOffset = 0;
+  uint32_t Index = 0;
   bool HasSymbol = false;
 
   uint64_t OriginalFlags = 0;
@@ -440,23 +440,23 @@ class Segment {
   };
 
 public:
-  uint32_t Type;
-  uint32_t Flags;
-  uint64_t Offset;
-  uint64_t VAddr;
-  uint64_t PAddr;
-  uint64_t FileSize;
-  uint64_t MemSize;
-  uint64_t Align;
-
-  uint32_t Index;
-  uint64_t OriginalOffset;
+  uint32_t Type = 0;
+  uint32_t Flags = 0;
+  uint64_t Offset = 0;
+  uint64_t VAddr = 0;
+  uint64_t PAddr = 0;
+  uint64_t FileSize = 0;
+  uint64_t MemSize = 0;
+  uint64_t Align = 0;
+
+  uint32_t Index = 0;
+  uint64_t OriginalOffset = 0;
   Segment *ParentSegment = nullptr;
   ArrayRef<uint8_t> Contents;
   std::set<const SectionBase *, SectionCompare> Sections;
 
   explicit Segment(ArrayRef<uint8_t> Data) : Contents(Data) {}
-  Segment() {}
+  Segment() = default;
 
   const SectionBase *firstSection() const {
     if (!Sections.empty())


        


More information about the llvm-commits mailing list