]> granicus.if.org Git - clang/commitdiff
Fix another case (this time in JumpScopeChecker) where walking deeply nested CaseStmt...
authorTed Kremenek <kremenek@apple.com>
Mon, 2 Aug 2010 22:46:57 +0000 (22:46 +0000)
committerTed Kremenek <kremenek@apple.com>
Mon, 2 Aug 2010 22:46:57 +0000 (22:46 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110071 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/JumpDiagnostics.cpp

index 3431ac611886e6df692cbfd1748e60466b9898d1..f696d6acbf928beb69d47d1f5ece3a033f450440 100644 (file)
@@ -182,9 +182,19 @@ void JumpScopeChecker::BuildScopeInformation(Stmt *S, unsigned ParentScope) {
   switch (S->getStmtClass()) {
   case Stmt::LabelStmtClass:
   case Stmt::DefaultStmtClass:
-  case Stmt::CaseStmtClass:
     LabelAndGotoScopes[S] = ParentScope;
     break;
+  case Stmt::CaseStmtClass: {
+    // Specially handle CaseStmts since they can nest each other in the
+    // AST and blow out the stack when we walk them.
+    CaseStmt *CS = cast<CaseStmt>(S);
+    do {
+      LabelAndGotoScopes[CS] = ParentScope;
+      S = CS; // 'CS' is the new current statement (if it isn't already).
+      CS = dyn_cast<CaseStmt>(CS->getSubStmt());
+    } while (CS);
+    break;
+  }
 
   case Stmt::AddrLabelExprClass:
     IndirectJumpTargets.push_back(cast<AddrLabelExpr>(S)->getLabel());