[lld] d5e4a5a - Cleanup: avoid referring to std::vector<T> members when T is incomplete.

Alexander Kornienko via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 30 04:05:37 PDT 2022


Author: Alexander Kornienko
Date: 2022-09-30T13:05:26+02:00
New Revision: d5e4a5a12f17f34e5840caf868a9839d5880d8ca

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

LOG: Cleanup: avoid referring to std::vector<T> members when T is incomplete.

This is not legal according to the C++ standard, and causes build errors in
particular in C++20 mode. Fix it by defining the vector's type before using the
vector.

Patch by poompatai at google.com.

Added: 
    

Modified: 
    lld/COFF/Chunks.h

Removed: 
    


################################################################################
diff  --git a/lld/COFF/Chunks.h b/lld/COFF/Chunks.h
index af3f2d5704832..ba2f0d43b7269 100644
--- a/lld/COFF/Chunks.h
+++ b/lld/COFF/Chunks.h
@@ -174,6 +174,23 @@ class NonSectionChunk : public Chunk {
   NonSectionChunk(Kind k = OtherKind) : Chunk(k) {}
 };
 
+// MinGW specific; information about one individual location in the image
+// that needs to be fixed up at runtime after loading. This represents
+// one individual element in the PseudoRelocTableChunk table.
+class RuntimePseudoReloc {
+public:
+  RuntimePseudoReloc(Defined *sym, SectionChunk *target, uint32_t targetOffset,
+                     int flags)
+      : sym(sym), target(target), targetOffset(targetOffset), flags(flags) {}
+
+  Defined *sym;
+  SectionChunk *target;
+  uint32_t targetOffset;
+  // The Flags field contains the size of the relocation, in bits. No other
+  // flags are currently defined.
+  int flags;
+};
+
 // A chunk corresponding a section of an input file.
 class SectionChunk final : public Chunk {
   // Identical COMDAT Folding feature accesses section internal data.
@@ -649,23 +666,6 @@ class PseudoRelocTableChunk : public NonSectionChunk {
   std::vector<RuntimePseudoReloc> relocs;
 };
 
-// MinGW specific; information about one individual location in the image
-// that needs to be fixed up at runtime after loading. This represents
-// one individual element in the PseudoRelocTableChunk table.
-class RuntimePseudoReloc {
-public:
-  RuntimePseudoReloc(Defined *sym, SectionChunk *target, uint32_t targetOffset,
-                     int flags)
-      : sym(sym), target(target), targetOffset(targetOffset), flags(flags) {}
-
-  Defined *sym;
-  SectionChunk *target;
-  uint32_t targetOffset;
-  // The Flags field contains the size of the relocation, in bits. No other
-  // flags are currently defined.
-  int flags;
-};
-
 // MinGW specific. A Chunk that contains one pointer-sized absolute value.
 class AbsolutePointerChunk : public NonSectionChunk {
 public:


        


More information about the llvm-commits mailing list