diff options
author | Ted Kremenek <kremenek@apple.com> | 2010-08-02 22:46:57 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2010-08-02 22:46:57 +0000 |
commit | f8dcf1a1d3c4f28fc96a45d7159e1a9c95484632 (patch) | |
tree | 20a7eedb58b2b39827a926e4371d87abb69ca0e0 /lib/Sema/JumpDiagnostics.cpp | |
parent | 074ae35bb156bd379cb9bc0b1b85d76e164a1776 (diff) |
Fix another case (this time in JumpScopeChecker) where walking deeply nested CaseStmts can blow out the stack. Fixes <rdar://problem/8125165>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110071 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/JumpDiagnostics.cpp')
-rw-r--r-- | lib/Sema/JumpDiagnostics.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/Sema/JumpDiagnostics.cpp b/lib/Sema/JumpDiagnostics.cpp index 3431ac6118..f696d6acbf 100644 --- a/lib/Sema/JumpDiagnostics.cpp +++ b/lib/Sema/JumpDiagnostics.cpp @@ -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()); |