================
@@ -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
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to