diff options
author | Ted Kremenek <kremenek@apple.com> | 2011-09-30 03:51:54 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2011-09-30 03:51:54 +0000 |
commit | afedc07a9b640de44d9bbc7a5a3b81529d511dce (patch) | |
tree | f71163cbd0abafae1bb1593d985143a687e628c8 /clang/lib/StaticAnalyzer/Core/CoreEngine.cpp | |
parent | 753406221b55b95141c8c1239660dc4db4e35ea5 (diff) | |
download | bcm5719-llvm-afedc07a9b640de44d9bbc7a5a3b81529d511dce.tar.gz bcm5719-llvm-afedc07a9b640de44d9bbc7a5a3b81529d511dce.zip |
Fix crash when analyzing C++ code involving constant enums and switch statements (<rdar://problem/10202899>).
llvm-svn: 140844
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/CoreEngine.cpp')
-rw-r--r-- | clang/lib/StaticAnalyzer/Core/CoreEngine.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp b/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp index 20b86a8fd32..2511ca778dd 100644 --- a/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp +++ b/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp @@ -697,13 +697,18 @@ ExplodedNode* SwitchNodeBuilder::generateDefaultCaseNode(const ProgramState *St, bool isSink) { // Get the block for the default case. - assert (Src->succ_rbegin() != Src->succ_rend()); + assert(Src->succ_rbegin() != Src->succ_rend()); CFGBlock *DefaultBlock = *Src->succ_rbegin(); + // Sanity check for default blocks that are unreachable and not caught + // by earlier stages. + if (!DefaultBlock) + return NULL; + bool IsNew; ExplodedNode *Succ = Eng.G->getNode(BlockEdge(Src, DefaultBlock, - Pred->getLocationContext()), St, &IsNew); + Pred->getLocationContext()), St, &IsNew); Succ->addPredecessor(Pred, *Eng.G); if (IsNew) { |