[clang] [C++20][Coroutines] Lambda-coroutine with operator new in promise_type (PR #84193)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 6 08:51:29 PST 2024


================
@@ -1378,8 +1379,21 @@ bool CoroutineStmtBuilder::makeReturnOnAllocFailure() {
 static bool collectPlacementArgs(Sema &S, FunctionDecl &FD, SourceLocation Loc,
                                  SmallVectorImpl<Expr *> &PlacementArgs) {
   if (auto *MD = dyn_cast<CXXMethodDecl>(&FD)) {
-    if (MD->isImplicitObjectMemberFunction() && !isLambdaCallOperator(MD)) {
-      ExprResult ThisExpr = S.ActOnCXXThis(Loc);
+    if (MD->isImplicitObjectMemberFunction()) {
+      ExprResult ThisExpr{};
+
+      if (isLambdaCallOperator(MD) && !MD->isStatic()) {
+        Qualifiers ThisQuals = MD->getMethodQualifiers();
+        CXXRecordDecl *Record = MD->getParent();
+
+        Sema::CXXThisScopeRAII ThisScope(S, Record, ThisQuals,
+                                         Record != nullptr);
+
+        ThisExpr = S.ActOnCXXThis(Loc, /*SkipLambdaCaptureCheck*/ true);
----------------
erichkeane wrote:

```suggestion
        ThisExpr = S.ActOnCXXThis(Loc, /*SkipLambdaCaptureCheck=*/ true);
```

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


More information about the cfe-commits mailing list