diff options
| author | Ted Kremenek <kremenek@apple.com> | 2014-02-27 21:56:44 +0000 |
|---|---|---|
| committer | Ted Kremenek <kremenek@apple.com> | 2014-02-27 21:56:44 +0000 |
| commit | 9238c5c878c066fe46bd63ddbf4daf1a5e4f99bc (patch) | |
| tree | cda9b4e75cd5a1b93b6360907b79dcc56ef7801b /clang/lib/Analysis/CFG.cpp | |
| parent | 4b408e7a043aa1292e8c1705a17222ace9ba1191 (diff) | |
| download | bcm5719-llvm-9238c5c878c066fe46bd63ddbf4daf1a5e4f99bc.tar.gz bcm5719-llvm-9238c5c878c066fe46bd63ddbf4daf1a5e4f99bc.zip | |
[CFG] record the original (now unreachable) block of 'case:' and 'default:' cases.
llvm-svn: 202435
Diffstat (limited to 'clang/lib/Analysis/CFG.cpp')
| -rw-r--r-- | clang/lib/Analysis/CFG.cpp | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp index 180a01289b1..c28513324b4 100644 --- a/clang/lib/Analysis/CFG.cpp +++ b/clang/lib/Analysis/CFG.cpp @@ -2742,8 +2742,8 @@ CFGBlock *CFGBuilder::VisitSwitchStmt(SwitchStmt *Terminator) { SwitchAlwaysHasSuccessor |= switchExclusivelyCovered; SwitchAlwaysHasSuccessor |= Terminator->isAllEnumCasesCovered() && Terminator->getSwitchCaseList(); - addSuccessor(SwitchTerminatedBlock, - SwitchAlwaysHasSuccessor ? 0 : DefaultCaseBlock); + addSuccessor(SwitchTerminatedBlock, DefaultCaseBlock, + !SwitchAlwaysHasSuccessor); // Add the terminator and condition in the switch block. SwitchTerminatedBlock->setTerminator(Terminator); @@ -2844,10 +2844,9 @@ CFGBlock *CFGBuilder::VisitCaseStmt(CaseStmt *CS) { // Add this block to the list of successors for the block with the switch // statement. assert(SwitchTerminatedBlock); - addSuccessor(SwitchTerminatedBlock, + addSuccessor(SwitchTerminatedBlock, CaseBlock, shouldAddCase(switchExclusivelyCovered, switchCond, - CS, *Context) - ? CaseBlock : 0); + CS, *Context)); // We set Block to NULL to allow lazy creation of a new block (if necessary) Block = NULL; @@ -4034,12 +4033,24 @@ static void print_block(raw_ostream &OS, const CFG* cfg, if (i % 10 == 8) OS << "\n "; - if (*I) - OS << " B" << (*I)->getBlockID(); - else - OS << " NULL"; + CFGBlock *B = *I; + + bool Reachable = true; + if (!B) { + Reachable = false; + B = I->getPossiblyUnreachableBlock(); + } + + if (B) { + OS << " B" << B->getBlockID(); + if (!Reachable) + OS << "(Unreachable)"; + } + else { + OS << " NULL"; + } } - + if (ShowColors) OS.resetColor(); OS << '\n'; |

