]> granicus.if.org Git - clang/commitdiff
[coroutines] Fix handling of dependent co_await in StmtProfiler.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 31 Jul 2018 00:47:41 +0000 (00:47 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 31 Jul 2018 00:47:41 +0000 (00:47 +0000)
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

lib/AST/StmtProfile.cpp
test/PCH/coroutines.cpp

index 34175bf9fe1a6bf0b712934a1cc19ab70cfc9d93..15653c4fd838c9daa76060dbb376a6603d920c2e 100644 (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");
index 46a2872420bf60fb54fde0489f9f506a428870c3..f907d12137316ecd789f76b04a7e7b54894420d6 100644 (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