[PATCH] Don't warn on fall-through from unreachable code.

Alexander Kornienko alexfh at google.com
Tue Jan 29 18:54:36 PST 2013



================
Comment at: lib/Sema/AnalysisBasedWarnings.cpp:711-712
@@ +710,4 @@
+        // Searching for all blocks reachable from the entry point.
+        ReachableBlocks.insert(*Cfg->rbegin());
+        BlockQueue.push_back(*Cfg->rbegin());
+        while (!BlockQueue.empty()) {
----------------
Richard Smith wrote:
> Please use getEntry() not rbegin().
Done.

================
Comment at: lib/Sema/AnalysisBasedWarnings.cpp:719-720
@@ +718,4 @@
+               I != E; ++I) {
+            if (!ReachableBlocks.count(*I)) {
+              ReachableBlocks.insert(*I);
+              BlockQueue.push_back(*I);
----------------
Richard Smith wrote:
> if (ReachableBlocks.insert(*I)) {
Done.

================
Comment at: lib/Sema/AnalysisBasedWarnings.cpp:709-725
@@ +708,19 @@
+
+      if (ReachableBlocks.empty()) {
+        // Searching for all blocks reachable from the entry point.
+        ReachableBlocks.insert(*Cfg->rbegin());
+        BlockQueue.push_back(*Cfg->rbegin());
+        while (!BlockQueue.empty()) {
+          const CFGBlock *P = BlockQueue.front();
+          BlockQueue.pop_front();
+          for (CFGBlock::const_succ_iterator I = P->succ_begin(),
+                                             E = P->succ_end();
+               I != E; ++I) {
+            if (!ReachableBlocks.count(*I)) {
+              ReachableBlocks.insert(*I);
+              BlockQueue.push_back(*I);
+            }
+          }
+        }
+      }
+
----------------
Richard Smith wrote:
> Please factor this out into a separate function, and call it prior to the loop in DiagnoseSwitchLabelsFallthrough.
Done.


http://llvm-reviews.chandlerc.com/D330



More information about the cfe-commits mailing list