[clang] 1d579f5 - [AST] Fix recovery-AST crash: dependent overloaded call exprs are now possible.

Sam McCall via cfe-commits cfe-commits at lists.llvm.org
Tue May 19 02:11:16 PDT 2020


Author: Sam McCall
Date: 2020-05-19T11:11:09+02:00
New Revision: 1d579f54d720dcc53e11386fdec59e07614599a5

URL: https://github.com/llvm/llvm-project/commit/1d579f54d720dcc53e11386fdec59e07614599a5
DIFF: https://github.com/llvm/llvm-project/commit/1d579f54d720dcc53e11386fdec59e07614599a5.diff

LOG: [AST] Fix recovery-AST crash: dependent overloaded call exprs are now possible.

Reviewers: hokein

Subscribers: cfe-commits

Tags: #clang

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

Added: 
    

Modified: 
    clang/lib/AST/StmtProfile.cpp
    clang/test/AST/ast-dump-recovery.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/StmtProfile.cpp b/clang/lib/AST/StmtProfile.cpp
index 2d8e30aac4c8..501c07b9b667 100644
--- a/clang/lib/AST/StmtProfile.cpp
+++ b/clang/lib/AST/StmtProfile.cpp
@@ -1446,7 +1446,6 @@ static Stmt::StmtClass DecodeOperatorCall(const CXXOperatorCallExpr *S,
   case OO_Array_New:
   case OO_Array_Delete:
   case OO_Arrow:
-  case OO_Call:
   case OO_Conditional:
   case NUM_OVERLOADED_OPERATORS:
     llvm_unreachable("Invalid operator call kind");
@@ -1620,6 +1619,9 @@ static Stmt::StmtClass DecodeOperatorCall(const CXXOperatorCallExpr *S,
   case OO_Subscript:
     return Stmt::ArraySubscriptExprClass;
 
+  case OO_Call:
+    return Stmt::CallExprClass;
+
   case OO_Coawait:
     UnaryOp = UO_Coawait;
     return Stmt::UnaryOperatorClass;
@@ -1660,7 +1662,7 @@ void StmtProfiler::VisitCXXOperatorCallExpr(const CXXOperatorCallExpr *S) {
              SC == Stmt::CompoundAssignOperatorClass)
       ID.AddInteger(BinaryOp);
     else
-      assert(SC == Stmt::ArraySubscriptExprClass);
+      assert(SC == Stmt::ArraySubscriptExprClass || SC == Stmt::CallExprClass);
 
     return;
   }

diff  --git a/clang/test/AST/ast-dump-recovery.cpp b/clang/test/AST/ast-dump-recovery.cpp
index 3fce48a7a34e..b63483fba416 100644
--- a/clang/test/AST/ast-dump-recovery.cpp
+++ b/clang/test/AST/ast-dump-recovery.cpp
@@ -177,3 +177,11 @@ void InitializerForAuto() {
   // CHECK: `-VarDecl {{.*}} invalid unresolved_typo 'auto'
   auto unresolved_typo = gned.*[] {};
 }
+
+// CHECK:      `-TypeAliasDecl {{.*}} Escape 'decltype([] {
+// CHECK-NEXT:   return <recovery-expr>(undef);
+// CHECK-NEXT: }())'
+// CHECK-NEXT:   `-DecltypeType {{.*}} 'decltype([] {
+// CHECK-NEXT:     return <recovery-expr>(undef);
+// CHECK-NEXT:   }())' dependent
+using Escape = decltype([] { return undef(); }());


        


More information about the cfe-commits mailing list