Cleanup: avoid referring to std::vector<T> members when T is incomplete.
authorAlexander Kornienko <alexfh@google.com>
Fri, 30 Sep 2022 11:04:07 +0000 (13:04 +0200)
committerAlexander Kornienko <alexfh@google.com>
Fri, 30 Sep 2022 11:05:26 +0000 (13:05 +0200)
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@google.com.

lld/COFF/Chunks.h

index af3f2d5..ba2f0d4 100644 (file)
@@ -174,6 +174,23 @@ protected:
   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 @@ private:
   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: