[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
================
@@ -5770,10 +5770,15 @@ struct ImmediateCallVisitor : DynamicRecursiveASTVisitor {
// A nested lambda might have parameters with immediate invocations
// in their default arguments.
// The compound statement is not visited (as it does not constitute a
- // subexpression).
- // FIXME: We should consider visiting and transforming captures
- // with init expressions.
+ // subexpression). Init-capture expressions, however, are evaluated as part
+ // of the lambda expression and need to be checked here.
bool VisitLambdaExpr(LambdaExpr *E) override {
+ auto Init = E->capture_init_begin();
+ for (const LambdaCapture &Capture : E->captures()) {
+ if (E->isInitCapture(&Capture) && !TraverseStmt(*Init))
+ return false;
+ ++Init;
----------------
Fznamznon wrote:
Will it break if lambda has both regular and init-captures mixed? Maybe something like
```
struct S {
int member = [this, captured = W(gv).value] { return captured; }();
};
```
https://github.com/llvm/llvm-project/pull/229953
More information about the cfe-commits
mailing list