================
@@ -5724,9 +5710,17 @@ struct EnsureImmediateInvocationInDefaultArgs
 
   // 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.
+  // The body is not a subexpression, so we do not transform the lambda
+  // itself. However, the closure object is returned without rebuilding it,
+  // so we must redo the effects building a lambda has on the enclosing
+  // context: any CXXBindTemporaryExpr around it has been dropped by
+  // TransformCXXBindTemporaryExpr, and the enclosing context must be
+  // marked as requiring cleanups for the closure's destructor to be run
+  // at the end of the full-expression.
   // FIXME: Immediate calls in capture initializers should be transformed.
-  ExprResult TransformLambdaExpr(LambdaExpr *E) { return E; }
+  ExprResult TransformLambdaExpr(LambdaExpr *E) {
+    return SemaRef.MaybeBindToTemporary(E);
----------------
yuxuanchen1997 wrote:

Thanks. Let me see if it makes sense to file another issue for this. I want to 
properly scope the fix for this issue at hand. 

https://github.com/llvm/llvm-project/pull/196597
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to