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
diff --git a/clang/lib/Analysis/ReachableCode.cpp b/clang/lib/Analysis/ReachableCode.cpp
index 0543939..eb3f7d4 100644
--- a/clang/lib/Analysis/ReachableCode.cpp
+++ b/clang/lib/Analysis/ReachableCode.cpp
@@ -131,6 +131,9 @@
   }
 
   // Solve
+  CFGBlock::FilterOptions FO;
+  FO.IgnoreDefaultsWithCoveredEnums = 1;
+
   while (!WL.empty()) {
     const CFGBlock *item = WL.back();
     WL.pop_back();
@@ -147,8 +150,8 @@
         }
 
     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 @@
   ++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]) {