diff options
author | Eric Fiselier <eric@efcs.ca> | 2017-07-31 07:48:13 +0000 |
---|---|---|
committer | Eric Fiselier <eric@efcs.ca> | 2017-07-31 07:48:13 +0000 |
commit | e9a5e7e407816f338b2aba97a5b92f729986556b (patch) | |
tree | 7bc9971bbd758147007ace7980382e01cf2e215b /clang/lib | |
parent | 126e91ab09f03dbc6f105b8fa5c4978773231d86 (diff) | |
download | bcm5719-llvm-e9a5e7e407816f338b2aba97a5b92f729986556b.tar.gz bcm5719-llvm-e9a5e7e407816f338b2aba97a5b92f729986556b.zip |
[coroutines] Evaluate the operand of void `co_return` expressions.
Summary:
Previously Clang incorrectly ignored the expression of a void `co_return`. This patch addresses that bug.
I'm not quite sure if I got the code-gen right, but this patch is at least a start.
Reviewers: rsmith, GorNishanov
Reviewed By: rsmith, GorNishanov
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D36070
llvm-svn: 309545
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/CodeGen/CGCoroutine.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGCoroutine.cpp b/clang/lib/CodeGen/CGCoroutine.cpp index a65faa602b3..d23697a5309 100644 --- a/clang/lib/CodeGen/CGCoroutine.cpp +++ b/clang/lib/CodeGen/CGCoroutine.cpp @@ -234,6 +234,13 @@ RValue CodeGenFunction::EmitCoyieldExpr(const CoyieldExpr &E, void CodeGenFunction::EmitCoreturnStmt(CoreturnStmt const &S) { ++CurCoro.Data->CoreturnCount; + const Expr *RV = S.getOperand(); + if (RV && RV->getType()->isVoidType()) { + // Make sure to evaluate the expression of a co_return with a void + // expression for side effects. + RunCleanupsScope cleanupScope(*this); + EmitIgnoredExpr(RV); + } EmitStmt(S.getPromiseCall()); EmitBranchThroughCleanup(CurCoro.Data->FinalJD); } |