Skip to content

Commit 0f501c3

Browse files
committed
Revert "[C++20][Coroutines] Lambda-coroutine with operator new in promise_type (llvm#84193)"
This reverts commit 35d3b33. See the comments in llvm#84193 for details
1 parent c9465e4 commit 0f501c3

File tree

5 files changed

+9
-169
lines changed

5 files changed

+9
-169
lines changed

clang/include/clang/Sema/Sema.h

+2-10
Original file line numberDiff line numberDiff line change
@@ -6752,18 +6752,10 @@ class Sema final {
67526752
SourceLocation RParenLoc);
67536753

67546754
//// ActOnCXXThis - Parse 'this' pointer.
6755-
///
6756-
/// \param ThisRefersToClosureObject Whether to skip the 'this' check for a
6757-
/// lambda because 'this' refers to the closure object.
6758-
ExprResult ActOnCXXThis(SourceLocation loc,
6759-
bool ThisRefersToClosureObject = false);
6755+
ExprResult ActOnCXXThis(SourceLocation loc);
67606756

67616757
/// Build a CXXThisExpr and mark it referenced in the current context.
6762-
///
6763-
/// \param ThisRefersToClosureObject Whether to skip the 'this' check for a
6764-
/// lambda because 'this' refers to the closure object.
6765-
Expr *BuildCXXThisExpr(SourceLocation Loc, QualType Type, bool IsImplicit,
6766-
bool ThisRefersToClosureObject = false);
6758+
Expr *BuildCXXThisExpr(SourceLocation Loc, QualType Type, bool IsImplicit);
67676759
void MarkThisReferenced(CXXThisExpr *This);
67686760

67696761
/// Try to retrieve the type of the 'this' pointer.

clang/lib/Sema/SemaCoroutine.cpp

+2-16
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include "clang/Sema/Initialization.h"
2626
#include "clang/Sema/Overload.h"
2727
#include "clang/Sema/ScopeInfo.h"
28-
#include "clang/Sema/Sema.h"
2928
#include "clang/Sema/SemaInternal.h"
3029
#include "llvm/ADT/SmallSet.h"
3130

@@ -1291,21 +1290,8 @@ bool CoroutineStmtBuilder::makeReturnOnAllocFailure() {
12911290
static bool collectPlacementArgs(Sema &S, FunctionDecl &FD, SourceLocation Loc,
12921291
SmallVectorImpl<Expr *> &PlacementArgs) {
12931292
if (auto *MD = dyn_cast<CXXMethodDecl>(&FD)) {
1294-
if (MD->isImplicitObjectMemberFunction()) {
1295-
ExprResult ThisExpr{};
1296-
1297-
if (isLambdaCallOperator(MD) && !MD->isStatic()) {
1298-
Qualifiers ThisQuals = MD->getMethodQualifiers();
1299-
CXXRecordDecl *Record = MD->getParent();
1300-
1301-
Sema::CXXThisScopeRAII ThisScope(S, Record, ThisQuals,
1302-
Record != nullptr);
1303-
1304-
ThisExpr = S.ActOnCXXThis(Loc, /*ThisRefersToClosureObject=*/true);
1305-
} else {
1306-
ThisExpr = S.ActOnCXXThis(Loc);
1307-
}
1308-
1293+
if (MD->isImplicitObjectMemberFunction() && !isLambdaCallOperator(MD)) {
1294+
ExprResult ThisExpr = S.ActOnCXXThis(Loc);
13091295
if (ThisExpr.isInvalid())
13101296
return false;
13111297
ThisExpr = S.CreateBuiltinUnaryOp(Loc, UO_Deref, ThisExpr.get());

clang/lib/Sema/SemaExprCXX.cpp

+5-11
Original file line numberDiff line numberDiff line change
@@ -1414,8 +1414,7 @@ bool Sema::CheckCXXThisCapture(SourceLocation Loc, const bool Explicit,
14141414
return false;
14151415
}
14161416

1417-
ExprResult Sema::ActOnCXXThis(SourceLocation Loc,
1418-
bool ThisRefersToClosureObject) {
1417+
ExprResult Sema::ActOnCXXThis(SourceLocation Loc) {
14191418
/// C++ 9.3.2: In the body of a non-static member function, the keyword this
14201419
/// is a non-lvalue expression whose value is the address of the object for
14211420
/// which the function is called.
@@ -1435,18 +1434,13 @@ ExprResult Sema::ActOnCXXThis(SourceLocation Loc,
14351434
return Diag(Loc, diag::err_invalid_this_use) << 0;
14361435
}
14371436

1438-
return BuildCXXThisExpr(Loc, ThisTy, /*IsImplicit=*/false,
1439-
ThisRefersToClosureObject);
1437+
return BuildCXXThisExpr(Loc, ThisTy, /*IsImplicit=*/false);
14401438
}
14411439

1442-
Expr *Sema::BuildCXXThisExpr(SourceLocation Loc, QualType Type, bool IsImplicit,
1443-
bool ThisRefersToClosureObject) {
1440+
Expr *Sema::BuildCXXThisExpr(SourceLocation Loc, QualType Type,
1441+
bool IsImplicit) {
14441442
auto *This = CXXThisExpr::Create(Context, Loc, Type, IsImplicit);
1445-
1446-
if (!ThisRefersToClosureObject) {
1447-
MarkThisReferenced(This);
1448-
}
1449-
1443+
MarkThisReferenced(This);
14501444
return This;
14511445
}
14521446

clang/test/SemaCXX/gh84064-1.cpp

-79
This file was deleted.

clang/test/SemaCXX/gh84064-2.cpp

-53
This file was deleted.

0 commit comments

Comments
 (0)