[clang] [Clang] Track temporary cleanups in rebuilt default member initializers (PR #196597)
Eli Friedman via cfe-commits
cfe-commits at lists.llvm.org
Fri May 8 14:01:09 PDT 2026
================
@@ -6730,7 +6731,15 @@ ExprResult Sema::MaybeBindToTemporary(Expr *E) {
CXXDestructorDecl *Destructor = IsDecltype ? nullptr : LookupDestructor(RD);
if (Destructor) {
+ bool HadBody = Destructor->doesThisDeclarationHaveABody();
MarkFunctionReferenced(E->getExprLoc(), Destructor);
+ // MarkFunctionReferenced can synthesize an implicit destructor. If that
+ // happens here, there may be no later top-level definition callback for
+ // CodeGen to see, for example for a closure type in a default member
+ // initializer.
+ if (Destructor->isImplicit() && !HadBody &&
+ Destructor->doesThisDeclarationHaveABody())
+ Consumer.HandleTopLevelDecl(DeclGroupRef(Destructor));
----------------
efriedma-quic wrote:
Please don't do this.
We already have infrastructure for delayed emission of inline functions; if that isn't working correctly, please fix it instead of trying to side-step it. (Maybe that means we need to hook up delayed emission for destructors where we currently don't have a body, but might synthesize one later?)
https://github.com/llvm/llvm-project/pull/196597
More information about the cfe-commits
mailing list