[clang] [Clang] Rebuild lambda captures in default member initializers while skipping body (PR #196597)
Eli Friedman via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 30 11:47:00 PDT 2026
================
@@ -5723,16 +5728,51 @@ struct ImmediateCallVisitor : DynamicRecursiveASTVisitor {
struct EnsureImmediateInvocationInDefaultArgs
: TreeTransform<EnsureImmediateInvocationInDefaultArgs> {
+ using Base = TreeTransform<EnsureImmediateInvocationInDefaultArgs>;
+
EnsureImmediateInvocationInDefaultArgs(Sema &SemaRef)
: TreeTransform(SemaRef) {}
bool AlwaysRebuild() { return true; }
+ bool ReplacingOriginal() { return true; }
+
+ // Lambda bodies are not subexpressions of the enclosing default initializer,
+ // but init-capture expressions are evaluated in the enclosing context. Keep
+ // the existing closure type and capture declarations so the existing body
+ // still refers to the right declarations.
+ ExprResult TransformLambdaExpr(LambdaExpr *E) {
+ SmallVector<Expr *, 4> CaptureInits(E->capture_inits());
----------------
efriedma-quic wrote:
I suspect we want to refactor this to use it in other places, but I guess that can go in a followup.
https://github.com/llvm/llvm-project/pull/196597
More information about the cfe-commits
mailing list