diff options
author | Ted Kremenek <kremenek@apple.com> | 2010-09-09 00:06:10 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2010-09-09 00:06:10 +0000 |
commit | f2b0a1bfa0f81ef92196bd6757474b18cfb36b09 (patch) | |
tree | d8b0c882b4dd32433113be33ecb8d6259914a8e8 /clang/lib/Analysis/ReachableCode.cpp | |
parent | 50205744c32d3925ba50d1bd69b1c9e6ab3a28b8 (diff) | |
download | bcm5719-llvm-f2b0a1bfa0f81ef92196bd6757474b18cfb36b09.tar.gz bcm5719-llvm-f2b0a1bfa0f81ef92196bd6757474b18cfb36b09.zip |
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.
llvm-svn: 113451
Diffstat (limited to 'clang/lib/Analysis/ReachableCode.cpp')
-rw-r--r-- | clang/lib/Analysis/ReachableCode.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/clang/lib/Analysis/ReachableCode.cpp b/clang/lib/Analysis/ReachableCode.cpp index 05439392f91..eb3f7d4c0f0 100644 --- a/clang/lib/Analysis/ReachableCode.cpp +++ b/clang/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]) { |