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

Shafik Yaghmour via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 9 14:46:04 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());
+    bool Changed = false;
+    auto Init = CaptureInits.begin();
+    for (LambdaExpr::capture_iterator C = E->capture_begin(),
+                                      CEnd = E->capture_end();
+         C != CEnd; ++C, ++Init) {
----------------
shafik wrote:

Please don't use images like this. We can block quote code and console output and it will display nicely use `` ```cpp ``and `` ```console ``

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


More information about the cfe-commits mailing list