summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorGor Nishanov <GorNishanov@gmail.com>2018-05-28 18:08:47 +0000
committerGor Nishanov <GorNishanov@gmail.com>2018-05-28 18:08:47 +0000
commit07ac63f89e4efb1916c3470700a91c6642b2c8c5 (patch)
treef28a136f741d037b81443f744ff0341f80d21ec3 /clang/lib
parentafa95ee03df98383f0873387a035ead1920f506f (diff)
downloadbcm5719-llvm-07ac63f89e4efb1916c3470700a91c6642b2c8c5.tar.gz
bcm5719-llvm-07ac63f89e4efb1916c3470700a91c6642b2c8c5.zip
[coroutines] Pass implicit object parameter to promise ctor (fix BUG37604)
Summary: Complete the implementation of p0914r1. Implicit object parameter should be passed to a promise constructor. Fixes: https://bugs.llvm.org/show_bug.cgi?id=37604 Reviewers: modocache, rsmith, lewissbaker Reviewed By: modocache Subscribers: cfe-commits, EricWF Differential Revision: https://reviews.llvm.org/D47454 llvm-svn: 333379
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/SemaCoroutine.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaCoroutine.cpp b/clang/lib/Sema/SemaCoroutine.cpp
index aefea981e59..c58172cabf9 100644
--- a/clang/lib/Sema/SemaCoroutine.cpp
+++ b/clang/lib/Sema/SemaCoroutine.cpp
@@ -510,6 +510,20 @@ VarDecl *Sema::buildCoroutinePromise(SourceLocation Loc) {
// Build a list of arguments, based on the coroutine functions arguments,
// that will be passed to the promise type's constructor.
llvm::SmallVector<Expr *, 4> CtorArgExprs;
+
+ // Add implicit object parameter.
+ if (auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
+ if (MD->isInstance() && !isLambdaCallOperator(MD)) {
+ ExprResult ThisExpr = ActOnCXXThis(Loc);
+ if (ThisExpr.isInvalid())
+ return nullptr;
+ ThisExpr = CreateBuiltinUnaryOp(Loc, UO_Deref, ThisExpr.get());
+ if (ThisExpr.isInvalid())
+ return nullptr;
+ CtorArgExprs.push_back(ThisExpr.get());
+ }
+ }
+
auto &Moves = ScopeInfo->CoroutineParameterMoves;
for (auto *PD : FD->parameters()) {
if (PD->getType()->isDependentType())
OpenPOWER on IntegriCloud