aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/ReachableCode.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2010-09-09 00:06:10 +0000
committerTed Kremenek <kremenek@apple.com>2010-09-09 00:06:10 +0000
commit8caec849a765de7b0b4ae8b9769397ce62236321 (patch)
treed035767e26077c15e3e69e3a7bd46f68ae700cd4 /lib/Analysis/ReachableCode.cpp
parent90b828aa279542559f655d1af666580288cb1841 (diff)
Enhance -Wunreachable-code to not consider the 'default:' branch of a switch statement live if a switch on an enum value has
explicit 'case:' statements for each enum value. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113451 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/ReachableCode.cpp')
-rw-r--r--lib/Analysis/ReachableCode.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/Analysis/ReachableCode.cpp b/lib/Analysis/ReachableCode.cpp
index 05439392f9..eb3f7d4c0f 100644
--- a/lib/Analysis/ReachableCode.cpp
+++ b/lib/Analysis/ReachableCode.cpp
@@ -131,6 +131,9 @@ static SourceLocation MarkLiveTop(const CFGBlock *Start,
}
// Solve
+ CFGBlock::FilterOptions FO;
+ FO.IgnoreDefaultsWithCoveredEnums = 1;
+
while (!WL.empty()) {
const CFGBlock *item = WL.back();
WL.pop_back();
@@ -147,8 +150,8 @@ static SourceLocation MarkLiveTop(const CFGBlock *Start,
}
reachable.set(item->getBlockID());
- for (CFGBlock::const_succ_iterator I=item->succ_begin(), E=item->succ_end();
- I != E; ++I)
+ for (CFGBlock::filtered_succ_iterator I =
+ item->filtered_succ_start_end(FO); I.hasMore(); ++I)
if (const CFGBlock *B = *I) {
unsigned blockID = B->getBlockID();
if (!reachable[blockID]) {
@@ -190,14 +193,17 @@ unsigned ScanReachableFromBlock(const CFGBlock &Start,
++count;
WL.push_back(&Start);
- // Find the reachable blocks from 'Start'.
+ // Find the reachable blocks from 'Start'.
+ CFGBlock::FilterOptions FO;
+ FO.IgnoreDefaultsWithCoveredEnums = 1;
+
while (!WL.empty()) {
const CFGBlock *item = WL.back();
WL.pop_back();
// Look at the successors and mark then reachable.
- for (CFGBlock::const_succ_iterator I=item->succ_begin(), E=item->succ_end();
- I != E; ++I)
+ for (CFGBlock::filtered_succ_iterator I= item->filtered_succ_start_end(FO);
+ I.hasMore(); ++I)
if (const CFGBlock *B = *I) {
unsigned blockID = B->getBlockID();
if (!Reachable[blockID]) {