[clang] 7581dc5 - [clang][bytecode] Fix an assertion failure in visitDtorCall() (#202507)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 9 04:46:33 PDT 2026
Author: Timm Baeder
Date: 2026-06-09T13:46:29+02:00
New Revision: 7581dc5a298dd1736c84ff21fbc310d40901a894
URL: https://github.com/llvm/llvm-project/commit/7581dc5a298dd1736c84ff21fbc310d40901a894
DIFF: https://github.com/llvm/llvm-project/commit/7581dc5a298dd1736c84ff21fbc310d40901a894.diff
LOG: [clang][bytecode] Fix an assertion failure in visitDtorCall() (#202507)
In `emitDestructionPop()`, we assert that the Descriptor has a
non-trivial dtor. Check this first here so we don't do all this work for
nothing.
Added:
Modified:
clang/lib/AST/ByteCode/Compiler.cpp
clang/test/AST/ByteCode/unions.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp
index 76688e30a0acd..b89849b6983d8 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -5418,6 +5418,11 @@ bool Compiler<Emitter>::visitDtorCall(const VarDecl *VD, const APValue &Value) {
if (!D)
return false;
+ // FIXME: Would be nice if we didn't allocate the descriptor at all in this
+ // case.
+ if (D->hasTrivialDtor())
+ return true;
+
Scope::Local Local = this->createLocal(D);
Locals.insert({VD, Local});
VarScope->addForScopeKind(Local, ScopeKind::Block);
diff --git a/clang/test/AST/ByteCode/unions.cpp b/clang/test/AST/ByteCode/unions.cpp
index 5f3676785fde6..4c72af986c333 100644
--- a/clang/test/AST/ByteCode/unions.cpp
+++ b/clang/test/AST/ByteCode/unions.cpp
@@ -1084,3 +1084,15 @@ namespace Revive {
// both-note {{in call to}}
}
#endif
+
+namespace TrivialDtorInEvaluateDtor{
+ template <class T> void foo() {
+ union { // both-error {{attempt to use a deleted function}}
+ T t; // both-note {{implicitly deleted}}
+ };
+ }
+ struct S {
+ ~S();
+ };
+ template void foo<S>(); // both-note {{in instantiation of function template specialization}}
+}
More information about the cfe-commits
mailing list