[all-commits] [llvm/llvm-project] e39df0: [Clang] Rebind the closure temporary when rebuildi...
Yuxuan Chen via All-commits
all-commits at lists.llvm.org
Tue Jun 9 22:14:32 PDT 2026
Branch: refs/heads/users/yuxuanchen1997/fix-cwg1815-lambda-capture-cleanup
Home: https://github.com/llvm/llvm-project
Commit: e39df0f164091095fea19c49dd48a1912fb6acf7
https://github.com/llvm/llvm-project/commit/e39df0f164091095fea19c49dd48a1912fb6acf7
Author: Yuxuan Chen <ych at meta.com>
Date: 2026-06-09 (Tue, 09 Jun 2026)
Changed paths:
M clang/lib/Sema/SemaExpr.cpp
A clang/test/CodeGenCXX/gh196469-default-member-init-lambda-cleanup.cpp
Log Message:
-----------
[Clang] Rebind the closure temporary when rebuilding default member initializers
Fixes https://github.com/llvm/llvm-project/issues/196469
Since the CWG1815 implementation, InitListChecker rebuilds a default
member initializer at its point of use in aggregate initialization. The
rebuild uses the EnsureImmediateInvocationInDefaultArgs tree transform,
where TransformCXXBindTemporaryExpr strips CXXBindTemporaryExpr nodes,
relying on the subexpression's rebuild to re-create the temporary
binding: every Rebuild path funnels through Sema::MaybeBindToTemporary,
which also re-registers the cleanup in the current evaluation context.
However, the transform overrides TransformLambdaExpr to return the
closure unchanged (the body is not a subexpression), skipping the
MaybeBindToTemporary call that BuildLambdaExpr ends with. The rebuilt
initializer then lacks both the CXXBindTemporaryExpr around the closure
and the ExprWithCleanups marker, so CodeGen never emits the closure's
destructor and init-captured members leak.
Restore the side effect in the override: re-bind the closure to a
temporary, exactly as building the lambda would have. This is a no-op
for trivially destructible closures.
Co-Authored-By: Claude Fable 5 <noreply at anthropic.com>
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list