[llvm] [llvm] Support building with c++23 (PR #154372)

Kyle Krüger via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 19 14:01:11 PDT 2025


https://github.com/kykrueger updated https://github.com/llvm/llvm-project/pull/154372

>From 4c8f57f462c416f19b4e6ef144c280cf8c1bac9f Mon Sep 17 00:00:00 2001
From: Kyle Krueger <kyle-steven.krueger at charite.de>
Date: Tue, 19 Aug 2025 16:02:17 +0200
Subject: [PATCH 01/13] move RecordsEntry constructors out of header

[172/6259] Building CXX object lib/TableGen/CMakeFiles/LLVMTableGen.dir/Parser.cpp.o
FAILED: [code=1] lib/TableGen/CMakeFiles/LLVMTableGen.dir/Parser.cpp.o
/usr/bin/c++ -DEXPERIMENTAL_KEY_INSTRUCTIONS -DGTEST_HAS_RTTI=0 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/Users/kykrueger/repos/llvm-project/build/lib/TableGen -I/Users/kykrueger/repos
/llvm-project/llvm/lib/TableGen -I/Users/kykrueger/repos/llvm-project/build/include -I/Users/kykrueger/repos/llvm-project/llvm/include -isystem /opt/homebrew/include -fPIC -fvisibility-inlines-hidden -Werror=date-ti
me -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-
switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -O3 -DNDEBUG -std=c++2b -ar
ch arm64  -fno-exceptions -funwind-tables -fno-rtti -MD -MT lib/TableGen/CMakeFiles/LLVMTableGen.dir/Parser.cpp.o -MF lib/TableGen/CMakeFiles/LLVMTableGen.dir/Parser.cpp.o.d -o lib/TableGen/CMakeFiles/LLVMTableGen.d
ir/Parser.cpp.o -c /Users/kykrueger/repos/llvm-project/llvm/lib/TableGen/Parser.cpp
In file included from /Users/kykrueger/repos/llvm-project/llvm/lib/TableGen/Parser.cpp:10:
In file included from /Users/kykrueger/repos/llvm-project/llvm/lib/TableGen/TGParser.h:16:
In file included from /Users/kykrueger/repos/llvm-project/llvm/lib/TableGen/TGLexer.h:16:
In file included from /Users/kykrueger/repos/llvm-project/llvm/include/llvm/ADT/SmallVector.h:19:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/algorithm:1846:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__algorithm/inplace_merge.h:28:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/unique_ptr.h:79:19: error: invalid application of 'sizeof' to an incomplete type 'llvm::ForeachLoop'
   79 |     static_assert(sizeof(_Tp) >= 0, "cannot delete an incomplete type");
      |                   ^~~~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/unique_ptr.h:293:7: note: in instantiation of member function 'std::default_delete<llvm::ForeachLoop>::operator()' requested here
  293 |       __ptr_.second()(__tmp);
      |       ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/unique_ptr.h:262:71: note: in instantiation of member function 'std::unique_ptr<llvm::ForeachLoop>::reset' requested here
  262 |   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 ~unique_ptr() { reset(); }
      |                                                                       ^
/Users/kykrueger/repos/llvm-project/llvm/lib/TableGen/TGParser.h:49:3: note: in instantiation of member function 'std::unique_ptr<llvm::ForeachLoop>::~unique_ptr' requested here
   49 |   RecordsEntry(std::unique_ptr<Record> Rec) : Rec(std::move(Rec)) {}
      |   ^
/Users/kykrueger/repos/llvm-project/llvm/lib/TableGen/TGParser.h:24:8: note: forward declaration of 'llvm::ForeachLoop'
   24 | struct ForeachLoop;
      |        ^
1 error generated.
---
 llvm/lib/TableGen/TGParser.cpp |  7 +++++++
 llvm/lib/TableGen/TGParser.h   | 10 ++++------
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/llvm/lib/TableGen/TGParser.cpp b/llvm/lib/TableGen/TGParser.cpp
index 0c6add59cb282..5d23416b4610b 100644
--- a/llvm/lib/TableGen/TGParser.cpp
+++ b/llvm/lib/TableGen/TGParser.cpp
@@ -33,6 +33,13 @@ using namespace llvm;
 
 namespace llvm {
 
+RecordsEntry::RecordsEntry(std::unique_ptr<Record> Rec) : Rec(std::move(Rec)) {}
+RecordsEntry::RecordsEntry(std::unique_ptr<ForeachLoop> Loop) : Loop(std::move(Loop)) {}
+RecordsEntry::RecordsEntry(std::unique_ptr<Record::AssertionInfo> Assertion)
+      : Assertion(std::move(Assertion)) {}
+RecordsEntry::RecordsEntry(std::unique_ptr<Record::DumpInfo> Dump)
+      : Dump(std::move(Dump)) {}
+
 struct SubClassReference {
   SMRange RefRange;
   const Record *Rec = nullptr;
diff --git a/llvm/lib/TableGen/TGParser.h b/llvm/lib/TableGen/TGParser.h
index 7edb6c7a9aac6..09b7d5380695d 100644
--- a/llvm/lib/TableGen/TGParser.h
+++ b/llvm/lib/TableGen/TGParser.h
@@ -46,12 +46,10 @@ struct RecordsEntry {
   void dump() const;
 
   RecordsEntry() = default;
-  RecordsEntry(std::unique_ptr<Record> Rec) : Rec(std::move(Rec)) {}
-  RecordsEntry(std::unique_ptr<ForeachLoop> Loop) : Loop(std::move(Loop)) {}
-  RecordsEntry(std::unique_ptr<Record::AssertionInfo> Assertion)
-      : Assertion(std::move(Assertion)) {}
-  RecordsEntry(std::unique_ptr<Record::DumpInfo> Dump)
-      : Dump(std::move(Dump)) {}
+  RecordsEntry(std::unique_ptr<Record> Rec);
+  RecordsEntry(std::unique_ptr<ForeachLoop> Loop);
+  RecordsEntry(std::unique_ptr<Record::AssertionInfo> Assertion);
+  RecordsEntry(std::unique_ptr<Record::DumpInfo> Dump);
 };
 
 /// ForeachLoop - Record the iteration state associated with a for loop.

>From 49f1a4ca0704d5dac341795c2aac46d67e3a204f Mon Sep 17 00:00:00 2001
From: Kyle Krueger <kyle-steven.krueger at charite.de>
Date: Tue, 19 Aug 2025 16:08:01 +0200
Subject: [PATCH 02/13] move BitstreamRemarkParser constructor out of header

---
 llvm/lib/Remarks/BitstreamRemarkParser.cpp | 2 ++
 llvm/lib/Remarks/BitstreamRemarkParser.h   | 3 +--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/Remarks/BitstreamRemarkParser.cpp b/llvm/lib/Remarks/BitstreamRemarkParser.cpp
index 312886013598d..20a8ebbadc681 100644
--- a/llvm/lib/Remarks/BitstreamRemarkParser.cpp
+++ b/llvm/lib/Remarks/BitstreamRemarkParser.cpp
@@ -600,3 +600,5 @@ BitstreamRemarkParser::processRemark(BitstreamRemarkParserHelper &Helper) {
 
   return std::move(Result);
 }
+llvm::remarks::BitstreamRemarkParser::BitstreamRemarkParser(StringRef Buf)
+    : RemarkParser(Format::Bitstream), ParserHelper(Buf) {}
diff --git a/llvm/lib/Remarks/BitstreamRemarkParser.h b/llvm/lib/Remarks/BitstreamRemarkParser.h
index f6f79ef199f7e..061206471fee4 100644
--- a/llvm/lib/Remarks/BitstreamRemarkParser.h
+++ b/llvm/lib/Remarks/BitstreamRemarkParser.h
@@ -45,8 +45,7 @@ struct BitstreamRemarkParser : public RemarkParser {
 
   /// Create a parser that expects to find a string table embedded in the
   /// stream.
-  explicit BitstreamRemarkParser(StringRef Buf)
-      : RemarkParser(Format::Bitstream), ParserHelper(Buf) {}
+  explicit BitstreamRemarkParser(StringRef Buf);
 
   Expected<std::unique_ptr<Remark>> next() override;
 

>From f8ba12aa8f91c42cdc0321bab1f3520cefc710b3 Mon Sep 17 00:00:00 2001
From: Kyle Krueger <kyle-steven.krueger at charite.de>
Date: Tue, 19 Aug 2025 16:11:44 +0200
Subject: [PATCH 03/13] move MCGOFFStreamer constructor out of header

---
 llvm/include/llvm/MC/MCGOFFStreamer.h | 4 +---
 llvm/lib/MC/MCGOFFStreamer.cpp        | 7 +++++++
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/llvm/include/llvm/MC/MCGOFFStreamer.h b/llvm/include/llvm/MC/MCGOFFStreamer.h
index 6d029f6bd4a29..8888d9e7bdbb3 100644
--- a/llvm/include/llvm/MC/MCGOFFStreamer.h
+++ b/llvm/include/llvm/MC/MCGOFFStreamer.h
@@ -20,9 +20,7 @@ class MCGOFFStreamer : public MCObjectStreamer {
 public:
   MCGOFFStreamer(MCContext &Context, std::unique_ptr<MCAsmBackend> MAB,
                  std::unique_ptr<MCObjectWriter> OW,
-                 std::unique_ptr<MCCodeEmitter> Emitter)
-      : MCObjectStreamer(Context, std::move(MAB), std::move(OW),
-                         std::move(Emitter)) {}
+                 std::unique_ptr<MCCodeEmitter> Emitter);
 
   ~MCGOFFStreamer() override;
 
diff --git a/llvm/lib/MC/MCGOFFStreamer.cpp b/llvm/lib/MC/MCGOFFStreamer.cpp
index 1718e2a4eb2d7..f164c2d7365a8 100644
--- a/llvm/lib/MC/MCGOFFStreamer.cpp
+++ b/llvm/lib/MC/MCGOFFStreamer.cpp
@@ -45,3 +45,10 @@ MCStreamer *llvm::createGOFFStreamer(MCContext &Context,
       new MCGOFFStreamer(Context, std::move(MAB), std::move(OW), std::move(CE));
   return S;
 }
+llvm::MCGOFFStreamer::MCGOFFStreamer(MCContext &Context,
+                                     std::unique_ptr<MCAsmBackend> MAB,
+                                     std::unique_ptr<MCObjectWriter> OW,
+                                     std::unique_ptr<MCCodeEmitter> Emitter)
+    : MCObjectStreamer(Context, std::move(MAB), std::move(OW),
+                       std::move(Emitter)) {}
+

>From ddd4519b4db1e247e7e72c0259f67ab9de3d90ea Mon Sep 17 00:00:00 2001
From: Kyle Krueger <kyle-steven.krueger at charite.de>
Date: Tue, 19 Aug 2025 16:21:52 +0200
Subject: [PATCH 04/13] move default destructor of GsymContext out of header

[210/5529] Building CXX object lib/DebugInfo/GSYM/CMakeFiles/LLVMDebugInfoGSYM.dir/GsymContext.cpp.o
FAILED: [code=1] lib/DebugInfo/GSYM/CMakeFiles/LLVMDebugInfoGSYM.dir/GsymContext.cpp.o
/usr/bin/c++ -DEXPERIMENTAL_KEY_INSTRUCTIONS -DGTEST_HAS_RTTI=0 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/Users/kykrueger/repos/llvm-project/build/lib/DebugInfo/GSYM -I/Users/kykrueger
/repos/llvm-project/llvm/lib/DebugInfo/GSYM -I/Users/kykrueger/repos/llvm-project/build/include -I/Users/kykrueger/repos/llvm-project/llvm/include -isystem /opt/homebrew/include -fPIC -fvisibility-inlines-hidden -We
rror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthroug
h -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -O3 -DNDEBUG -s
td=c++2b -arch arm64  -fno-exceptions -funwind-tables -fno-rtti -MD -MT lib/DebugInfo/GSYM/CMakeFiles/LLVMDebugInfoGSYM.dir/GsymContext.cpp.o -MF lib/DebugInfo/GSYM/CMakeFiles/LLVMDebugInfoGSYM.dir/GsymContext.cpp.o
.d -o lib/DebugInfo/GSYM/CMakeFiles/LLVMDebugInfoGSYM.dir/GsymContext.cpp.o -c /Users/kykrueger/repos/llvm-project/llvm/lib/DebugInfo/GSYM/GsymContext.cpp
In file included from /Users/kykrueger/repos/llvm-project/llvm/lib/DebugInfo/GSYM/GsymContext.cpp:9:
In file included from /Users/kykrueger/repos/llvm-project/llvm/include/llvm/DebugInfo/GSYM/GsymContext.h:12:
In file included from /Users/kykrueger/repos/llvm-project/llvm/include/llvm/DebugInfo/DIContext.h:17:
In file included from /Users/kykrueger/repos/llvm-project/llvm/include/llvm/ADT/SmallVector.h:19:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/algorithm:1846:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__algorithm/inplace_merge.h:28:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/unique_ptr.h:79:19: error: invalid application of 'sizeof' to an incomplete type 'llvm::gsym::GsymReader'
   79 |     static_assert(sizeof(_Tp) >= 0, "cannot delete an incomplete type");
      |                   ^~~~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/unique_ptr.h:293:7: note: in instantiation of member function 'std::default_delete<llvm::gsym::GsymReader>::operator()' requested here
  293 |       __ptr_.second()(__tmp);
      |       ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/unique_ptr.h:262:71: note: in instantiation of member function 'std::unique_ptr<llvm::gsym::GsymReader>::reset' requested here
  262 |   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 ~unique_ptr() { reset(); }
      |                                                                       ^
/Users/kykrueger/repos/llvm-project/llvm/include/llvm/DebugInfo/GSYM/GsymContext.h:30:7: note: in instantiation of member function 'std::unique_ptr<llvm::gsym::GsymReader>::~unique_ptr' requested here
   30 | class GsymContext : public DIContext {
      |       ^
/Users/kykrueger/repos/llvm-project/llvm/include/llvm/DebugInfo/GSYM/GsymContext.h:30:7: note: in implicit destructor for 'llvm::gsym::GsymContext' first required here
/Users/kykrueger/repos/llvm-project/llvm/include/llvm/DebugInfo/GSYM/GsymContext.h:21:7: note: forward declaration of 'llvm::gsym::GsymReader'
   21 | class GsymReader;
      |       ^
1 error generated.
---
 llvm/include/llvm/DebugInfo/GSYM/GsymContext.h | 1 +
 llvm/lib/DebugInfo/GSYM/GsymContext.cpp        | 1 +
 2 files changed, 2 insertions(+)

diff --git a/llvm/include/llvm/DebugInfo/GSYM/GsymContext.h b/llvm/include/llvm/DebugInfo/GSYM/GsymContext.h
index 9c04ff63c8059..07d599cf9b5c6 100644
--- a/llvm/include/llvm/DebugInfo/GSYM/GsymContext.h
+++ b/llvm/include/llvm/DebugInfo/GSYM/GsymContext.h
@@ -30,6 +30,7 @@ class GsymReader;
 class GsymContext : public DIContext {
 public:
   GsymContext(std::unique_ptr<GsymReader> Reader);
+  ~GsymContext();
 
   GsymContext(GsymContext &) = delete;
   GsymContext &operator=(GsymContext &) = delete;
diff --git a/llvm/lib/DebugInfo/GSYM/GsymContext.cpp b/llvm/lib/DebugInfo/GSYM/GsymContext.cpp
index 18be6d0985462..62b4caa327d87 100644
--- a/llvm/lib/DebugInfo/GSYM/GsymContext.cpp
+++ b/llvm/lib/DebugInfo/GSYM/GsymContext.cpp
@@ -14,6 +14,7 @@
 using namespace llvm;
 using namespace llvm::gsym;
 
+GsymContext::~GsymContext() = default;
 GsymContext::GsymContext(std::unique_ptr<GsymReader> Reader)
     : DIContext(CK_GSYM), Reader(std::move(Reader)) {}
 

>From b48f2dbfebdcb03c68f1945eb1b2d4044dbe4534 Mon Sep 17 00:00:00 2001
From: Kyle Krueger <kyle-steven.krueger at charite.de>
Date: Tue, 19 Aug 2025 17:15:27 +0200
Subject: [PATCH 05/13] complete forward-declared DebugInfo types for c++23
 constexpr

---
 llvm/include/llvm/DebugInfo/PDB/IPDBRawSymbol.h        | 1 +
 llvm/include/llvm/DebugInfo/PDB/PDBSymbolFunc.h        | 2 +-
 llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h | 1 +
 llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h    | 2 ++
 llvm/lib/DebugInfo/PDB/PDBSymbolTypeBuiltin.cpp        | 6 ++++++
 5 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/llvm/include/llvm/DebugInfo/PDB/IPDBRawSymbol.h b/llvm/include/llvm/DebugInfo/PDB/IPDBRawSymbol.h
index 7e15433b839ed..98f219ae76f31 100644
--- a/llvm/include/llvm/DebugInfo/PDB/IPDBRawSymbol.h
+++ b/llvm/include/llvm/DebugInfo/PDB/IPDBRawSymbol.h
@@ -10,6 +10,7 @@
 #define LLVM_DEBUGINFO_PDB_IPDBRAWSYMBOL_H
 
 #include "PDBTypes.h"
+#include "llvm/DebugInfo/PDB/IPDBLineNumber.h"
 #include "llvm/ADT/BitmaskEnum.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/DebugInfo/CodeView/CodeView.h"
diff --git a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolFunc.h b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolFunc.h
index d797d00cfa123..a7e8e60af7160 100644
--- a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolFunc.h
+++ b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolFunc.h
@@ -10,6 +10,7 @@
 #define LLVM_DEBUGINFO_PDB_PDBSYMBOLFUNC_H
 
 #include "llvm/DebugInfo/PDB/IPDBRawSymbol.h"
+#include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h"
 #include "llvm/Support/Compiler.h"
 
 #include "PDBSymbol.h"
@@ -21,7 +22,6 @@ namespace pdb {
 
 class PDBSymDumper;
 class PDBSymbolData;
-class PDBSymbolTypeFunctionSig;
 template <typename ChildType> class IPDBEnumChildren;
 
 class LLVM_ABI PDBSymbolFunc : public PDBSymbol {
diff --git a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h
index a054b0c02db83..b21cd092939e6 100644
--- a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h
+++ b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h
@@ -20,6 +20,7 @@ namespace pdb {
 class LLVM_ABI PDBSymbolTypeBuiltin : public PDBSymbol {
   DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::BuiltinType)
 public:
+  ~PDBSymbolTypeBuiltin();
   void dump(PDBSymDumper &Dumper) const override;
 
   FORWARD_SYMBOL_METHOD(getBuiltinType)
diff --git a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h
index 431bf0dab90d9..acc58e10e71c7 100644
--- a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h
+++ b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h
@@ -11,9 +11,11 @@
 
 #include "PDBSymbol.h"
 #include "PDBTypes.h"
+#include "llvm/DebugInfo/PDB/IPDBLineNumber.h"
 #include "llvm/Support/Compiler.h"
 
 #include "llvm/DebugInfo/PDB/IPDBRawSymbol.h"
+#include "llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h"
 
 namespace llvm {
 
diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeBuiltin.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeBuiltin.cpp
index eca2a09c1f77b..7c8ef18f126dd 100644
--- a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeBuiltin.cpp
+++ b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeBuiltin.cpp
@@ -10,6 +10,12 @@
 
 #include "llvm/DebugInfo/PDB/PDBSymDumper.h"
 
+namespace llvm {
+namespace pdb {
+PDBSymbolTypeBuiltin::~PDBSymbolTypeBuiltin() = default;
+} // namespace pdb
+} // namespace llvm
+
 using namespace llvm;
 using namespace llvm::pdb;
 

>From 214772c474c61b1f1f2b116c6eef2e9599938dd0 Mon Sep 17 00:00:00 2001
From: Kyle Krueger <kyle-steven.krueger at charite.de>
Date: Tue, 19 Aug 2025 17:19:31 +0200
Subject: [PATCH 06/13] move InputFile constructors out of header

---
 llvm/include/llvm/DebugInfo/PDB/Native/InputFile.h | 6 +++---
 llvm/lib/DebugInfo/PDB/Native/InputFile.cpp        | 5 +++++
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/llvm/include/llvm/DebugInfo/PDB/Native/InputFile.h b/llvm/include/llvm/DebugInfo/PDB/Native/InputFile.h
index 0e7b9663f27d2..71df1d59c2177 100644
--- a/llvm/include/llvm/DebugInfo/PDB/Native/InputFile.h
+++ b/llvm/include/llvm/DebugInfo/PDB/Native/InputFile.h
@@ -55,9 +55,9 @@ class InputFile {
   getOrCreateTypeCollection(TypeCollectionKind Kind);
 
 public:
-  InputFile(PDBFile *Pdb) { PdbOrObj = Pdb; }
-  InputFile(object::COFFObjectFile *Obj) { PdbOrObj = Obj; }
-  InputFile(MemoryBuffer *Buffer) { PdbOrObj = Buffer; }
+  InputFile(PDBFile *Pdb);
+  InputFile(object::COFFObjectFile *Obj);
+  InputFile(MemoryBuffer *Buffer);
   LLVM_ABI ~InputFile();
   InputFile(InputFile &&Other) = default;
 
diff --git a/llvm/lib/DebugInfo/PDB/Native/InputFile.cpp b/llvm/lib/DebugInfo/PDB/Native/InputFile.cpp
index 328d0f5ab060f..49be0edc33a10 100644
--- a/llvm/lib/DebugInfo/PDB/Native/InputFile.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/InputFile.cpp
@@ -586,3 +586,8 @@ bool llvm::pdb::shouldDumpSymbolGroup(uint32_t Idx, const SymbolGroup &Group,
   // Otherwise, only dump if this is the same module specified.
   return (Filters.DumpModi == Idx);
 }
+llvm::pdb::InputFile::InputFile(PDBFile *Pdb) { PdbOrObj = Pdb; }
+
+llvm::pdb::InputFile::InputFile(object::COFFObjectFile *Obj) { PdbOrObj = Obj; }
+
+llvm::pdb::InputFile::InputFile(MemoryBuffer *Buffer) { PdbOrObj = Buffer; }

>From b922f7491ab91f2b7caa0c972ee4bbf72cda0588 Mon Sep 17 00:00:00 2001
From: Kyle Krueger <kyle-steven.krueger at charite.de>
Date: Tue, 19 Aug 2025 22:08:39 +0200
Subject: [PATCH 07/13] move GlobalISelMatchTable methods that require
 completed classes out of header

---
 .../Common/GlobalISel/GlobalISelMatchTable.cpp      | 13 +++++++++++++
 .../Common/GlobalISel/GlobalISelMatchTable.h        | 12 +++---------
 2 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.cpp b/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.cpp
index efaf05adc8f06..42c1cc91a3c1e 100644
--- a/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.cpp
+++ b/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.cpp
@@ -479,6 +479,14 @@ bool GroupMatcher::candidateConditionMatches(
   return Predicate.isIdentical(RepresentativeCondition);
 }
 
+std::unique_ptr<PredicateMatcher> GroupMatcher::popFirstCondition() {
+  assert(!Conditions.empty() &&
+         "Trying to pop a condition from a condition-less group");
+  std::unique_ptr<PredicateMatcher> P = std::move(Conditions.front());
+  Conditions.erase(Conditions.begin());
+  return P;
+}
+
 bool GroupMatcher::addMatcher(Matcher &Candidate) {
   if (!Candidate.hasFirstCondition())
     return false;
@@ -693,6 +701,9 @@ void SwitchMatcher::emit(MatchTable &Table) {
 
 //===- RuleMatcher --------------------------------------------------------===//
 
+RuleMatcher::RuleMatcher(ArrayRef<SMLoc> SrcLoc)
+    : SrcLoc(SrcLoc), RuleID(NextRuleID++) {}
+
 uint64_t RuleMatcher::NextRuleID = 0;
 
 StringRef RuleMatcher::getOpcode() const {
@@ -1099,6 +1110,8 @@ unsigned RuleMatcher::countRendererFns() const {
       });
 }
 
+void RuleMatcher::insnmatchers_pop_front() { Matchers.erase(Matchers.begin()); }
+
 //===- PredicateMatcher ---------------------------------------------------===//
 
 PredicateMatcher::~PredicateMatcher() {}
diff --git a/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.h b/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.h
index 620f88db66109..361146714a70c 100644
--- a/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.h
+++ b/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.h
@@ -366,13 +366,7 @@ class GroupMatcher final : public Matcher {
   size_t size() const { return Matchers.size(); }
   bool empty() const { return Matchers.empty(); }
 
-  std::unique_ptr<PredicateMatcher> popFirstCondition() override {
-    assert(!Conditions.empty() &&
-           "Trying to pop a condition from a condition-less group");
-    std::unique_ptr<PredicateMatcher> P = std::move(Conditions.front());
-    Conditions.erase(Conditions.begin());
-    return P;
-  }
+  std::unique_ptr<PredicateMatcher> popFirstCondition() override;
   const PredicateMatcher &getFirstCondition() const override {
     assert(!Conditions.empty() &&
            "Trying to get a condition from a condition-less group");
@@ -545,7 +539,7 @@ class RuleMatcher : public Matcher {
                              StringRef FlagName, GISelFlags FlagBit);
 
 public:
-  RuleMatcher(ArrayRef<SMLoc> SrcLoc) : SrcLoc(SrcLoc), RuleID(NextRuleID++) {}
+  RuleMatcher(ArrayRef<SMLoc> SrcLoc);
   RuleMatcher(RuleMatcher &&Other) = default;
   RuleMatcher &operator=(RuleMatcher &&Other) = default;
 
@@ -704,7 +698,7 @@ class RuleMatcher : public Matcher {
     return make_range(Matchers.begin(), Matchers.end());
   }
   bool insnmatchers_empty() const { return Matchers.empty(); }
-  void insnmatchers_pop_front() { Matchers.erase(Matchers.begin()); }
+  void insnmatchers_pop_front();
 };
 
 template <class PredicateTy> class PredicateListMatcher {

>From d62570ec9f0588989fc5b38a12c0ee92de253008 Mon Sep 17 00:00:00 2001
From: Kyle Krueger <kyle-steven.krueger at charite.de>
Date: Tue, 19 Aug 2025 22:23:50 +0200
Subject: [PATCH 08/13] remove nullptr init from unique_ptr to
 SwitchMatcher.Condition

---
 .../utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.cpp | 4 ++--
 llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.h  | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.cpp b/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.cpp
index 42c1cc91a3c1e..2e190d4a48fe0 100644
--- a/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.cpp
+++ b/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.cpp
@@ -623,7 +623,7 @@ bool SwitchMatcher::addMatcher(Matcher &Candidate) {
 }
 
 void SwitchMatcher::finalize() {
-  assert(Condition == nullptr && "Already finalized");
+  assert(Condition.get() == nullptr && "Already finalized");
   assert(Values.size() == Matchers.size() && "Broken SwitchMatcher");
   if (empty())
     return;
@@ -662,7 +662,7 @@ void SwitchMatcher::emit(MatchTable &Table) {
   assert(Values.size() == Matchers.size() && "Broken SwitchMatcher");
   if (empty())
     return;
-  assert(Condition != nullptr &&
+  assert(Condition.get() != nullptr &&
          "Broken SwitchMatcher, hasn't been finalized?");
 
   std::vector<unsigned> LabelIDs(Values.size());
diff --git a/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.h b/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.h
index 361146714a70c..13f29e10beba2 100644
--- a/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.h
+++ b/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.h
@@ -404,7 +404,7 @@ class SwitchMatcher : public Matcher {
 
   /// The representative condition, with a type and a path (InsnVarID and OpIdx
   /// in most cases)  shared by all the matchers contained.
-  std::unique_ptr<PredicateMatcher> Condition = nullptr;
+  std::unique_ptr<PredicateMatcher> Condition;
 
   /// Temporary set used to check that the case values don't repeat within the
   /// same switch.

>From 2a29c49b4531347b72816b76b0de8c8dbfda618c Mon Sep 17 00:00:00 2001
From: Kyle Krueger <kyle-steven.krueger at charite.de>
Date: Tue, 19 Aug 2025 22:29:02 +0200
Subject: [PATCH 09/13] remove Result constructor def out of
 MachineFunctionAnalysis.h

---
 llvm/include/llvm/CodeGen/MachineFunctionAnalysis.h | 2 +-
 llvm/lib/CodeGen/MachineFunctionAnalysis.cpp        | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/llvm/include/llvm/CodeGen/MachineFunctionAnalysis.h b/llvm/include/llvm/CodeGen/MachineFunctionAnalysis.h
index 1982ac68d61ae..cd00e5f3934c6 100644
--- a/llvm/include/llvm/CodeGen/MachineFunctionAnalysis.h
+++ b/llvm/include/llvm/CodeGen/MachineFunctionAnalysis.h
@@ -36,7 +36,7 @@ class MachineFunctionAnalysis
     std::unique_ptr<MachineFunction> MF;
 
   public:
-    Result(std::unique_ptr<MachineFunction> MF) : MF(std::move(MF)) {}
+    Result(std::unique_ptr<MachineFunction> MF);
     MachineFunction &getMF() { return *MF; };
     LLVM_ABI bool invalidate(Function &, const PreservedAnalyses &PA,
                              FunctionAnalysisManager::Invalidator &);
diff --git a/llvm/lib/CodeGen/MachineFunctionAnalysis.cpp b/llvm/lib/CodeGen/MachineFunctionAnalysis.cpp
index 116a919585d70..17a7f48e3f2e4 100644
--- a/llvm/lib/CodeGen/MachineFunctionAnalysis.cpp
+++ b/llvm/lib/CodeGen/MachineFunctionAnalysis.cpp
@@ -21,6 +21,10 @@ using namespace llvm;
 
 AnalysisKey MachineFunctionAnalysis::Key;
 
+llvm::MachineFunctionAnalysis::Result::Result(
+    std::unique_ptr<MachineFunction> MF)
+    : MF(std::move(MF)) {}
+
 bool MachineFunctionAnalysis::Result::invalidate(
     Function &, const PreservedAnalyses &PA,
     FunctionAnalysisManager::Invalidator &) {

>From a8016968b13e6fc51616239e803654b040ac2d55 Mon Sep 17 00:00:00 2001
From: Kyle Krueger <kyle-steven.krueger at charite.de>
Date: Tue, 19 Aug 2025 22:36:56 +0200
Subject: [PATCH 10/13] move LiveDebugVariable constructors and destructors to
 after pImpl definition

---
 llvm/lib/CodeGen/LiveDebugVariables.cpp | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/llvm/lib/CodeGen/LiveDebugVariables.cpp b/llvm/lib/CodeGen/LiveDebugVariables.cpp
index f12f437c493e1..9d98e6c085fe3 100644
--- a/llvm/lib/CodeGen/LiveDebugVariables.cpp
+++ b/llvm/lib/CodeGen/LiveDebugVariables.cpp
@@ -536,12 +536,6 @@ class UserLabel {
 
 namespace llvm {
 
-/// Implementation of the LiveDebugVariables pass.
-
-LiveDebugVariables::LiveDebugVariables() = default;
-LiveDebugVariables::~LiveDebugVariables() = default;
-LiveDebugVariables::LiveDebugVariables(LiveDebugVariables &&) = default;
-
 class LiveDebugVariables::LDVImpl {
   LocMap::Allocator allocator;
   MachineFunction *MF = nullptr;
@@ -683,6 +677,12 @@ class LiveDebugVariables::LDVImpl {
   void print(raw_ostream&);
 };
 
+/// Implementation of the LiveDebugVariables pass.
+
+LiveDebugVariables::LiveDebugVariables() = default;
+LiveDebugVariables::~LiveDebugVariables() = default;
+LiveDebugVariables::LiveDebugVariables(LiveDebugVariables &&) = default;
+
 } // namespace llvm
 
 static void printDebugLoc(const DebugLoc &DL, raw_ostream &CommentOS,

>From cafcfad05d2d0144f7aa15d6998b2ff53efca9b0 Mon Sep 17 00:00:00 2001
From: Kyle Krueger <kyle-steven.krueger at charite.de>
Date: Tue, 19 Aug 2025 22:45:34 +0200
Subject: [PATCH 11/13] add ResourcePriorityQueue dtor after definition of
 pointee DFAPacketizer

---
 llvm/include/llvm/CodeGen/ResourcePriorityQueue.h       | 1 +
 llvm/lib/CodeGen/SelectionDAG/ResourcePriorityQueue.cpp | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/llvm/include/llvm/CodeGen/ResourcePriorityQueue.h b/llvm/include/llvm/CodeGen/ResourcePriorityQueue.h
index bd63dd8756210..c15bc677ae53f 100644
--- a/llvm/include/llvm/CodeGen/ResourcePriorityQueue.h
+++ b/llvm/include/llvm/CodeGen/ResourcePriorityQueue.h
@@ -75,6 +75,7 @@ namespace llvm {
 
   public:
     ResourcePriorityQueue(SelectionDAGISel *IS);
+    ~ResourcePriorityQueue();
 
     bool isBottomUp() const override { return false; }
 
diff --git a/llvm/lib/CodeGen/SelectionDAG/ResourcePriorityQueue.cpp b/llvm/lib/CodeGen/SelectionDAG/ResourcePriorityQueue.cpp
index 0a449fd011e69..72ea0898f9754 100644
--- a/llvm/lib/CodeGen/SelectionDAG/ResourcePriorityQueue.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/ResourcePriorityQueue.cpp
@@ -63,6 +63,8 @@ ResourcePriorityQueue::ResourcePriorityQueue(SelectionDAGISel *IS)
   HorizontalVerticalBalance = 0;
 }
 
+ResourcePriorityQueue::~ResourcePriorityQueue() = default;
+
 unsigned
 ResourcePriorityQueue::numberRCValPredInSU(SUnit *SU, unsigned RCId) {
   unsigned NumberDeps = 0;

>From 932c256b3f40b6d21989074f8d1e800fa621367e Mon Sep 17 00:00:00 2001
From: Kyle Krueger <kyle-steven.krueger at charite.de>
Date: Tue, 19 Aug 2025 22:51:32 +0200
Subject: [PATCH 12/13] move RISCVELFStreamer constructor definition to .cpp

---
 llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp | 5 +++++
 llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.h   | 3 +--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp
index 543c4c5ddfc9d..ef57a92d9cc35 100644
--- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp
+++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp
@@ -36,6 +36,11 @@ RISCVTargetELFStreamer::RISCVTargetELFStreamer(MCStreamer &S,
   setFlagsFromFeatures(STI);
 }
 
+RISCVELFStreamer::RISCVELFStreamer(MCContext &C, std::unique_ptr<MCAsmBackend> MAB,
+                   std::unique_ptr<MCObjectWriter> MOW,
+                   std::unique_ptr<MCCodeEmitter> MCE)
+      : MCELFStreamer(C, std::move(MAB), std::move(MOW), std::move(MCE)) {}
+
 RISCVELFStreamer &RISCVTargetELFStreamer::getStreamer() {
   return static_cast<RISCVELFStreamer &>(Streamer);
 }
diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.h b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.h
index 98948cd3e9493..26da2441d4ae1 100644
--- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.h
+++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.h
@@ -28,8 +28,7 @@ class RISCVELFStreamer : public MCELFStreamer {
 public:
   RISCVELFStreamer(MCContext &C, std::unique_ptr<MCAsmBackend> MAB,
                    std::unique_ptr<MCObjectWriter> MOW,
-                   std::unique_ptr<MCCodeEmitter> MCE)
-      : MCELFStreamer(C, std::move(MAB), std::move(MOW), std::move(MCE)) {}
+                   std::unique_ptr<MCCodeEmitter> MCE);
 
   void changeSection(MCSection *Section, uint32_t Subsection) override;
   void emitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI) override;

>From bc927cea2b12885bb14335cfb70f5a962037b775 Mon Sep 17 00:00:00 2001
From: Kyle Krueger <kyle-steven.krueger at charite.de>
Date: Tue, 19 Aug 2025 23:00:52 +0200
Subject: [PATCH 13/13] move BasicELFBuilder ctor and dtor to .cpp

---
 llvm/lib/ObjCopy/ELF/ELFObject.cpp | 3 +++
 llvm/lib/ObjCopy/ELF/ELFObject.h   | 3 ++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/ObjCopy/ELF/ELFObject.cpp b/llvm/lib/ObjCopy/ELF/ELFObject.cpp
index e5de17e093dfd..78b674c5fa348 100644
--- a/llvm/lib/ObjCopy/ELF/ELFObject.cpp
+++ b/llvm/lib/ObjCopy/ELF/ELFObject.cpp
@@ -1307,6 +1307,9 @@ Error BasicELFBuilder::initSections() {
   return Error::success();
 }
 
+BasicELFBuilder::BasicELFBuilder() : Obj(std::make_unique<Object>()) {}
+BasicELFBuilder::~BasicELFBuilder() = default;
+
 void BinaryELFBuilder::addData(SymbolTableSection *SymTab) {
   auto Data = ArrayRef<uint8_t>(
       reinterpret_cast<const uint8_t *>(MemBuf->getBufferStart()),
diff --git a/llvm/lib/ObjCopy/ELF/ELFObject.h b/llvm/lib/ObjCopy/ELF/ELFObject.h
index d8f79a4b1a3cc..7ec0e9be3ddaf 100644
--- a/llvm/lib/ObjCopy/ELF/ELFObject.h
+++ b/llvm/lib/ObjCopy/ELF/ELFObject.h
@@ -1059,7 +1059,8 @@ class BasicELFBuilder {
   Error initSections();
 
 public:
-  BasicELFBuilder() : Obj(std::make_unique<Object>()) {}
+  BasicELFBuilder();
+  ~BasicELFBuilder();
 };
 
 class BinaryELFBuilder : public BasicELFBuilder {



More information about the llvm-commits mailing list