[clang] [llvm] [NFC] Fix C++23 build failures caused by incomplete types (PR #196814)
via cfe-commits
cfe-commits at lists.llvm.org
Sun May 10 08:55:55 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-globalisel
Author: Iris Shi (el-ev)
<details>
<summary>Changes</summary>
GCC 15's libstdc++ in C++23 mode eagerly instantiates `unique_ptr<T>::~unique_ptr()` during type trait checks, trigging `static_assert(sizeof(T) > 0)` assertions on incomplete types.
Fix by moving constructors and destructors out-of-line.
---
Full diff: https://github.com/llvm/llvm-project/pull/196814.diff
8 Files Affected:
- (modified) clang/lib/Interpreter/IncrementalParser.h (+1-4)
- (modified) clang/tools/libclang/CIndexDiagnostic.cpp (+3)
- (modified) clang/tools/libclang/CIndexDiagnostic.h (+1-2)
- (modified) llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp (+6)
- (modified) llvm/lib/Target/BPF/BPFAsmPrinter.cpp (+6)
- (modified) llvm/lib/Target/BPF/BPFAsmPrinter.h (+2-2)
- (modified) llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.cpp (+3)
- (modified) llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.h (+2-1)
``````````diff
diff --git a/clang/lib/Interpreter/IncrementalParser.h b/clang/lib/Interpreter/IncrementalParser.h
index 9b042bc494efb..a2b654d2ac0f4 100644
--- a/clang/lib/Interpreter/IncrementalParser.h
+++ b/clang/lib/Interpreter/IncrementalParser.h
@@ -14,15 +14,12 @@
#define LLVM_CLANG_LIB_INTERPRETER_INCREMENTALPARSER_H
#include "llvm/ADT/StringRef.h"
+#include "llvm/IR/Module.h"
#include "llvm/Support/Error.h"
#include <list>
#include <memory>
-namespace llvm {
-class Module;
-}
-
namespace clang {
class ASTConsumer;
class CompilerInstance;
diff --git a/clang/tools/libclang/CIndexDiagnostic.cpp b/clang/tools/libclang/CIndexDiagnostic.cpp
index d37597e747a84..22fc8f5f9c163 100644
--- a/clang/tools/libclang/CIndexDiagnostic.cpp
+++ b/clang/tools/libclang/CIndexDiagnostic.cpp
@@ -27,6 +27,9 @@ using namespace clang::cxloc;
using namespace clang::cxdiag;
using namespace llvm;
+CXDiagnosticSetImpl::CXDiagnosticSetImpl(bool isManaged)
+ : IsExternallyManaged(isManaged) {}
+
CXDiagnosticSetImpl::~CXDiagnosticSetImpl() {}
void
diff --git a/clang/tools/libclang/CIndexDiagnostic.h b/clang/tools/libclang/CIndexDiagnostic.h
index 25589bb57474a..6824f3c170424 100644
--- a/clang/tools/libclang/CIndexDiagnostic.h
+++ b/clang/tools/libclang/CIndexDiagnostic.h
@@ -28,8 +28,7 @@ class CXDiagnosticSetImpl {
std::vector<std::unique_ptr<CXDiagnosticImpl>> Diagnostics;
const bool IsExternallyManaged;
public:
- CXDiagnosticSetImpl(bool isManaged = false)
- : IsExternallyManaged(isManaged) {}
+ CXDiagnosticSetImpl(bool isManaged = false);
virtual ~CXDiagnosticSetImpl();
diff --git a/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp b/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
index aaa01ee2e549a..e3d7b7a5a519e 100644
--- a/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
+++ b/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
@@ -528,6 +528,10 @@ class SIInsertWaitcnts {
struct BlockInfo {
std::unique_ptr<WaitcntBrackets> Incoming;
bool Dirty = true;
+ BlockInfo() = default;
+ BlockInfo(BlockInfo &&) = default;
+ BlockInfo &operator=(BlockInfo &&) = default;
+ ~BlockInfo();
};
MapVector<MachineBasicBlock *, BlockInfo> BlockInfos;
@@ -1051,6 +1055,8 @@ class WaitcntBrackets {
CounterValueArray AsyncScore{};
};
+SIInsertWaitcnts::BlockInfo::~BlockInfo() = default;
+
class SIInsertWaitcntsLegacy : public MachineFunctionPass {
public:
static char ID;
diff --git a/llvm/lib/Target/BPF/BPFAsmPrinter.cpp b/llvm/lib/Target/BPF/BPFAsmPrinter.cpp
index 18c92af077ac7..2e72cb840c577 100644
--- a/llvm/lib/Target/BPF/BPFAsmPrinter.cpp
+++ b/llvm/lib/Target/BPF/BPFAsmPrinter.cpp
@@ -42,6 +42,12 @@ using namespace llvm;
#define DEBUG_TYPE "asm-printer"
+BPFAsmPrinter::BPFAsmPrinter(TargetMachine &TM,
+ std::unique_ptr<MCStreamer> Streamer)
+ : AsmPrinter(TM, std::move(Streamer), ID), BTF(nullptr), TM(TM) {}
+
+BPFAsmPrinter::~BPFAsmPrinter() = default;
+
bool BPFAsmPrinter::doInitialization(Module &M) {
AsmPrinter::doInitialization(M);
diff --git a/llvm/lib/Target/BPF/BPFAsmPrinter.h b/llvm/lib/Target/BPF/BPFAsmPrinter.h
index d1db65d878463..c9707e03fcabf 100644
--- a/llvm/lib/Target/BPF/BPFAsmPrinter.h
+++ b/llvm/lib/Target/BPF/BPFAsmPrinter.h
@@ -18,8 +18,8 @@ namespace llvm {
class BPFAsmPrinter : public AsmPrinter {
public:
explicit BPFAsmPrinter(TargetMachine &TM,
- std::unique_ptr<MCStreamer> Streamer)
- : AsmPrinter(TM, std::move(Streamer), ID), BTF(nullptr), TM(TM) {}
+ std::unique_ptr<MCStreamer> Streamer);
+ ~BPFAsmPrinter() override;
StringRef getPassName() const override { return "BPF Assembly Printer"; }
bool doInitialization(Module &M) override;
diff --git a/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.cpp b/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.cpp
index 4ce1565b4c387..ab20eb6e2f790 100644
--- a/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.cpp
+++ b/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.cpp
@@ -628,6 +628,9 @@ void GroupMatcher::optimize() {
//===- SwitchMatcher ------------------------------------------------------===//
+SwitchMatcher::SwitchMatcher() : Matcher(MK_Switch) {}
+SwitchMatcher::~SwitchMatcher() = default;
+
bool SwitchMatcher::recordsOperand() const {
assert(!isa_and_present<RecordNamedOperandMatcher>(Condition.get()) &&
"Switch conditions should not record named operands");
diff --git a/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.h b/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.h
index 5fb3ef1a87c88..ad02b1adb58b8 100644
--- a/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.h
+++ b/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.h
@@ -445,7 +445,8 @@ class SwitchMatcher : public Matcher {
std::vector<std::unique_ptr<Matcher>> MatcherStorage;
public:
- SwitchMatcher() : Matcher(MK_Switch) {}
+ SwitchMatcher();
+ ~SwitchMatcher();
static bool classof(const Matcher *M) { return M->getKind() == MK_Switch; }
``````````
</details>
https://github.com/llvm/llvm-project/pull/196814
More information about the cfe-commits
mailing list