llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) <details> <summary>Changes</summary> 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. --- Full diff: https://github.com/llvm/llvm-project/pull/202507.diff 2 Files Affected: - (modified) clang/lib/AST/ByteCode/Compiler.cpp (+5) - (modified) clang/test/AST/ByteCode/unions.cpp (+12) ``````````diff 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..ed435cb094a57 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 { + T t; + }; + } + struct S { + ~S(); + }; + template void foo<S>(); +} `````````` </details> https://github.com/llvm/llvm-project/pull/202507 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
