[coroutines] Fix handling of dependent co_await in StmtProfiler.

Fix "Invalid operator call kind" error (llvm_unreachable) in
DecodeOperatorCall when profiling a dependent co_await.

Patch by Victor Zverovich!

Differential Revision: https://reviews.llvm.org/D50002

llvm-svn: 338343
This commit is contained in:
Richard Smith 2018-07-31 00:47:41 +00:00
parent 9164b9b16e
commit 6fff5c412b
2 changed files with 12 additions and 1 deletions

View File

@ -1277,7 +1277,6 @@ static Stmt::StmtClass DecodeOperatorCall(const CXXOperatorCallExpr *S,
case OO_Arrow:
case OO_Call:
case OO_Conditional:
case OO_Coawait:
case NUM_OVERLOADED_OPERATORS:
llvm_unreachable("Invalid operator call kind");
@ -1449,6 +1448,10 @@ static Stmt::StmtClass DecodeOperatorCall(const CXXOperatorCallExpr *S,
case OO_Subscript:
return Stmt::ArraySubscriptExprClass;
case OO_Coawait:
UnaryOp = UO_Coawait;
return Stmt::UnaryOperatorClass;
}
llvm_unreachable("Invalid overloaded operator expression");

View File

@ -66,6 +66,14 @@ int f2(T x) { // checks coawait_expr and coroutine_body_stmt
co_return x; // checks coreturn_stmt with expr
}
struct S {};
S operator co_await(S) { return S(); }
template <typename T>
int f3(T x) {
co_await x; // checks dependent_coawait with overloaded co_await operator
}
#else
// expected-no-diagnostics