[clang] [Clang] Check consteval calls in lambda init-captures (PR #229953)

Mariya Podchishchaeva via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 8 04:23:09 PDT 2026


================
@@ -5793,11 +5798,57 @@ struct EnsureImmediateInvocationInDefaultArgs
 
   bool AlwaysRebuild() { return true; }
 
-  // Lambda can only have immediate invocations in the default
-  // args of their parameters, which is transformed upon calling the closure.
-  // The body is not a subexpression, so we have nothing to do.
-  // FIXME: Immediate calls in capture initializers should be transformed.
-  ExprResult TransformLambdaExpr(LambdaExpr *E) { return E; }
+  // Lambda default arguments are transformed upon calling the closure. The
+  // body is not a subexpression, so only transform init-captures here.
+  ExprResult TransformLambdaExpr(LambdaExpr *E) {
+    SmallVector<Expr *, 4> CaptureInits(E->capture_inits().begin(),
+                                        E->capture_inits().end());
----------------
Fznamznon wrote:

That array seems a bit redundant, Init can be initialized with `capture_init_begin()` and I'm sure there is probably a proper accessor to pass an array to `LambdaExpr::Create` later.

https://github.com/llvm/llvm-project/pull/229953


More information about the cfe-commits mailing list