From: Richard Smith Date: Tue, 31 Jul 2018 00:47:41 +0000 (+0000) Subject: [coroutines] Fix handling of dependent co_await in StmtProfiler. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a7a88118684e7ea75ae229b1ae9b2ac31c7d5fcc;p=clang [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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338343 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/StmtProfile.cpp b/lib/AST/StmtProfile.cpp index 34175bf9fe..15653c4fd8 100644 --- a/lib/AST/StmtProfile.cpp +++ b/lib/AST/StmtProfile.cpp @@ -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"); diff --git a/test/PCH/coroutines.cpp b/test/PCH/coroutines.cpp index 46a2872420..f907d12137 100644 --- a/test/PCH/coroutines.cpp +++ b/test/PCH/coroutines.cpp @@ -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 +int f3(T x) { + co_await x; // checks dependent_coawait with overloaded co_await operator +} + #else // expected-no-diagnostics