summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2015-11-22 03:13:02 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2015-11-22 03:13:02 +0000
commit1f38eddee0525df1d3ef738bcb635a88dc51ba5e (patch)
tree0a11e4e8ed5515b6d34988b95d6feea3e0978e19 /clang/lib/Sema
parentd7bed4d6608fe4ce783676f38aabbeaf1a080763 (diff)
downloadbcm5719-llvm-1f38eddee0525df1d3ef738bcb635a88dc51ba5e.tar.gz
bcm5719-llvm-1f38eddee0525df1d3ef738bcb635a88dc51ba5e.zip
[coroutines] Materialize the awaitable before generating the await_* calls.
llvm-svn: 253812
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r--clang/lib/Sema/SemaCoroutine.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/clang/lib/Sema/SemaCoroutine.cpp b/clang/lib/Sema/SemaCoroutine.cpp
index a0d24b8cecd..20c9c551d46 100644
--- a/clang/lib/Sema/SemaCoroutine.cpp
+++ b/clang/lib/Sema/SemaCoroutine.cpp
@@ -195,7 +195,7 @@ static ReadySuspendResumeResult buildCoawaitCalls(Sema &S, SourceLocation Loc,
const StringRef Funcs[] = {"await_ready", "await_suspend", "await_resume"};
for (size_t I = 0, N = llvm::array_lengthof(Funcs); I != N; ++I) {
Expr *Operand = new (S.Context) OpaqueValueExpr(
- Loc, E->getType(), E->getValueKind(), E->getObjectKind(), E);
+ Loc, E->getType(), VK_LValue, E->getObjectKind(), E);
// FIXME: Pass coroutine handle to await_suspend.
ExprResult Result = buildMemberCall(S, Operand, Loc, Funcs[I], None);
@@ -237,8 +237,10 @@ ExprResult Sema::BuildCoawaitExpr(SourceLocation Loc, Expr *E) {
return Res;
}
- // FIXME: If E is a prvalue, create a temporary.
- // FIXME: If E is an xvalue, convert to lvalue.
+ // If the expression is a temporary, materialize it as an lvalue so that we
+ // can use it multiple times.
+ if (E->getValueKind() == VK_RValue)
+ E = new (Context) MaterializeTemporaryExpr(E->getType(), E, true);
// Build the await_ready, await_suspend, await_resume calls.
ReadySuspendResumeResult RSS = buildCoawaitCalls(*this, Loc, E);
@@ -306,8 +308,10 @@ ExprResult Sema::BuildCoyieldExpr(SourceLocation Loc, Expr *E) {
return Res;
}
- // FIXME: If E is a prvalue, create a temporary.
- // FIXME: If E is an xvalue, convert to lvalue.
+ // If the expression is a temporary, materialize it as an lvalue so that we
+ // can use it multiple times.
+ if (E->getValueKind() == VK_RValue)
+ E = new (Context) MaterializeTemporaryExpr(E->getType(), E, true);
// Build the await_ready, await_suspend, await_resume calls.
ReadySuspendResumeResult RSS = buildCoawaitCalls(*this, Loc, E);
OpenPOWER on IntegriCloud