diff options
author | Ted Kremenek <kremenek@apple.com> | 2011-03-16 04:32:01 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2011-03-16 04:32:01 +0000 |
commit | 35c70f64db03b74f09846e8b38f5ba10cb84a32a (patch) | |
tree | 43f57e63e03fbe9727ed7488bfc251ef4d5116f8 /clang/lib | |
parent | 76e68ea916d13dfaf5e8f4feaab1d69fa0b5cc2b (diff) | |
download | bcm5719-llvm-35c70f64db03b74f09846e8b38f5ba10cb84a32a.tar.gz bcm5719-llvm-35c70f64db03b74f09846e8b38f5ba10cb84a32a.zip |
Teach CFGBuilder that the 'default' branch of a switch statement is dead if all enum values in a switch conditioned are handled.
llvm-svn: 127727
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Analysis/CFG.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp index 4772a69b4ae..a1afd60fe7a 100644 --- a/clang/lib/Analysis/CFG.cpp +++ b/clang/lib/Analysis/CFG.cpp @@ -2249,9 +2249,11 @@ CFGBlock* CFGBuilder::VisitSwitchStmt(SwitchStmt* Terminator) { } // If we have no "default:" case, the default transition is to the code - // following the switch body. + // following the switch body. Moreover, take into account if all the + // cases of a switch are covered (e.g., switching on an enum value). addSuccessor(SwitchTerminatedBlock, - switchExclusivelyCovered ? 0 : DefaultCaseBlock); + switchExclusivelyCovered || Terminator->isAllEnumCasesCovered() + ? 0 : DefaultCaseBlock); // Add the terminator and condition in the switch block. SwitchTerminatedBlock->setTerminator(Terminator); |