[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:08 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) {
----------------
Fznamznon wrote:
Same assumption that all captures are init captures?
https://github.com/llvm/llvm-project/pull/229953
More information about the cfe-commits
mailing list