aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/CFG.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2011-03-16 04:32:01 +0000
committerTed Kremenek <kremenek@apple.com>2011-03-16 04:32:01 +0000
commit432c478fe0fec3946610d5dc7905daf5fbadf47b (patch)
tree848c91ec2a94d562d1226053e8ecc77c8cc572ef /lib/Analysis/CFG.cpp
parenta5bcb8fec45d127501cd70fe1654b5a08a8aeb35 (diff)
Teach CFGBuilder that the 'default' branch of a switch statement is dead if all enum values in a switch conditioned are handled.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127727 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/CFG.cpp')
-rw-r--r--lib/Analysis/CFG.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/Analysis/CFG.cpp b/lib/Analysis/CFG.cpp
index 4772a69b4a..a1afd60fe7 100644
--- a/lib/Analysis/CFG.cpp
+++ b/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);