]> granicus.if.org Git - clang/commitdiff
Don't do jump-scope checking when code completion is enabled. It's
authorDouglas Gregor <dgregor@apple.com>
Fri, 17 Aug 2012 05:12:08 +0000 (05:12 +0000)
committerDouglas Gregor <dgregor@apple.com>
Fri, 17 Aug 2012 05:12:08 +0000 (05:12 +0000)
both a waste of time, and prone to crash due to the use of the
error-recovery path in parser. Fixes <rdar://problem/12103608>, which
has been driving me nuts.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162081 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDecl.cpp
lib/Sema/SemaExpr.cpp
test/Index/complete-enums.cpp

index 75b8095a66f902767279fa70868b114d1b035217..cb3ac68852787cae42f9304058e53387b89cdf4c 100644 (file)
@@ -7792,7 +7792,8 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body,
     // Verify that gotos and switch cases don't jump into scopes illegally.
     if (getCurFunction()->NeedsScopeChecking() &&
         !dcl->isInvalidDecl() &&
-        !hasAnyUnrecoverableErrorsInThisFunction())
+        !hasAnyUnrecoverableErrorsInThisFunction() &&
+        !PP.isCodeCompletionEnabled())
       DiagnoseInvalidJumps(Body);
 
     if (CXXDestructorDecl *Destructor = dyn_cast<CXXDestructorDecl>(dcl)) {
index 6a503ee2d9b50a0d48d6075760e30243e8b0dad6..3875ba171366c1b22b43f72be13cc1053c8623fe 100644 (file)
@@ -9461,7 +9461,8 @@ ExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc,
 
   // If needed, diagnose invalid gotos and switches in the block.
   if (getCurFunction()->NeedsScopeChecking() &&
-      !hasAnyUnrecoverableErrorsInThisFunction())
+      !hasAnyUnrecoverableErrorsInThisFunction() &&
+      !PP.isCodeCompletionEnabled())
     DiagnoseInvalidJumps(cast<CompoundStmt>(Body));
 
   BSI->TheDecl->setBody(cast<CompoundStmt>(Body));
index 49a8932587730f28970d9fdc30d0b465fc323b9c..23c60ac4dfa5a02f747000d4a45c9adfea0d9cd9 100644 (file)
@@ -1,6 +1,6 @@
 // Note: the run lines follow their respective tests, since line/column
 // matter in this test.
-
+struct X { X(); ~X(); };
 enum class Color {
   Red = 17,
   Green,
@@ -9,7 +9,7 @@ enum class Color {
 int Greeby();
 void f(Color color) {
   switch (color) {
-  case Color::Green:
+  case Color::Green: { X x; }
   case Color::Red;
   }
 }