[llvm] 633375a - [llvm][DWARFLinker] Fix gcc 13 -Wuninitialized warnings (#143867)

via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 12 05:20:40 PDT 2025


Author: David Spickett
Date: 2025-06-12T13:20:36+01:00
New Revision: 633375a29f52504b0b23a30bb767de521dd3e2a8

URL: https://github.com/llvm/llvm-project/commit/633375a29f52504b0b23a30bb767de521dd3e2a8
DIFF: https://github.com/llvm/llvm-project/commit/633375a29f52504b0b23a30bb767de521dd3e2a8.diff

LOG: [llvm][DWARFLinker] Fix gcc 13 -Wuninitialized warnings (#143867)

A bit awkward that we have to switch from public to protected and back
again, but it seemed neater than putting OS all the way down at the
bottom. Since it is a public member that you're more likely to be
looking for.

llvm-project/llvm/lib/DWARFLinker/Parallel/OutputSections.h:157:67:
warning: member
‘llvm::dwarf_linker::parallel::SectionDescriptor::Contents’ is used
uninitialized [-Wuninitialized]

Which refers to the use in the constructor:
```
  SectionDescriptor(DebugSectionKind SectionKind, LinkingGlobalData &GlobalData,
                    dwarf::FormParams Format, llvm::endianness Endianess)
      : SectionDescriptorBase(SectionKind, Format, Endianess), OS(Contents),
```
Where Contents is passed to `OS`, before Contents has been constructed.

Added: 
    

Modified: 
    llvm/lib/DWARFLinker/Parallel/OutputSections.h

Removed: 
    


################################################################################
diff  --git a/llvm/lib/DWARFLinker/Parallel/OutputSections.h b/llvm/lib/DWARFLinker/Parallel/OutputSections.h
index da47f53b6c3d1..5043e918013e4 100644
--- a/llvm/lib/DWARFLinker/Parallel/OutputSections.h
+++ b/llvm/lib/DWARFLinker/Parallel/OutputSections.h
@@ -181,6 +181,11 @@ struct SectionDescriptor : SectionDescriptorBase {
   /// to the debug section, corresponding to this object.
   uint64_t StartOffset = 0;
 
+protected:
+  /// Section data bits.
+  OutSectionDataTy Contents;
+
+public:
   /// Stream which stores data to the Contents.
   raw_svector_ostream OS;
 
@@ -287,9 +292,6 @@ struct SectionDescriptor : SectionDescriptorBase {
 
   LinkingGlobalData &GlobalData;
 
-  /// Section data bits.
-  OutSectionDataTy Contents;
-
   /// Some sections are generated using AsmPrinter. The real section data
   /// located inside elf file in that case. Following fields points to the
   /// real section content inside elf file.


        


More information about the llvm-commits mailing list