[cfe-commits] [PATCH] Don't warn on fall-through from unreachable code.
Richard Smith
richard at metafoo.co.uk
Mon Jan 28 12:03:18 PST 2013
================
Comment at: lib/Sema/AnalysisBasedWarnings.cpp:719-720
@@ +718,4 @@
+ I != E; ++I) {
+ if (!ReachableBlocks.count(*I)) {
+ ReachableBlocks.insert(*I);
+ BlockQueue.push_back(*I);
----------------
if (ReachableBlocks.insert(*I)) {
================
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()) {
----------------
Please use getEntry() not rbegin().
================
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);
+ }
+ }
+ }
+ }
+
----------------
Please factor this out into a separate function, and call it prior to the loop in DiagnoseSwitchLabelsFallthrough.
http://llvm-reviews.chandlerc.com/D330
More information about the cfe-commits
mailing list