r338343 - [coroutines] Fix handling of dependent co_await in StmtProfiler.

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 30 17:47:41 PDT 2018


Author: rsmith
Date: Mon Jul 30 17:47:41 2018
New Revision: 338343

URL: http://llvm.org/viewvc/llvm-project?rev=338343&view=rev
Log:
[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

Modified:
    cfe/trunk/lib/AST/StmtProfile.cpp
    cfe/trunk/test/PCH/coroutines.cpp

Modified: cfe/trunk/lib/AST/StmtProfile.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtProfile.cpp?rev=338343&r1=338342&r2=338343&view=diff
==============================================================================
--- cfe/trunk/lib/AST/StmtProfile.cpp (original)
+++ cfe/trunk/lib/AST/StmtProfile.cpp Mon Jul 30 17:47:41 2018
@@ -1277,7 +1277,6 @@ static Stmt::StmtClass DecodeOperatorCal
   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 DecodeOperatorCal
 
   case OO_Subscript:
     return Stmt::ArraySubscriptExprClass;
+
+  case OO_Coawait:
+    UnaryOp = UO_Coawait;
+    return Stmt::UnaryOperatorClass;
   }
 
   llvm_unreachable("Invalid overloaded operator expression");

Modified: cfe/trunk/test/PCH/coroutines.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/coroutines.cpp?rev=338343&r1=338342&r2=338343&view=diff
==============================================================================
--- cfe/trunk/test/PCH/coroutines.cpp (original)
+++ cfe/trunk/test/PCH/coroutines.cpp Mon Jul 30 17:47:41 2018
@@ -66,6 +66,14 @@ int f2(T x) {  // checks coawait_expr an
   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




More information about the cfe-commits mailing list