]> granicus.if.org Git - clang/commitdiff
Revert "[Analysis] -Wunreachable-code shouldn't fire on the increment of a foreach...
authorSam McCall <sam.mccall@gmail.com>
Fri, 15 Feb 2019 09:18:49 +0000 (09:18 +0000)
committerSam McCall <sam.mccall@gmail.com>
Fri, 15 Feb 2019 09:18:49 +0000 (09:18 +0000)
This reverts commit r354102.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@354109 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/ReachableCode.cpp
test/SemaCXX/unreachable-code.cpp

index 6f1814deb00b687852dc6b102953043522e9e0de..cc64efa7f07fbdf106fac5dab8f2709c4bb79479 100644 (file)
@@ -631,10 +631,6 @@ void DeadCodeScan::reportDeadCode(const CFGBlock *B,
     // a for/for-range loop.  This is the block that contains
     // the increment code.
     if (const Stmt *LoopTarget = B->getLoopTarget()) {
-      // The increment on a foreach statement is not written.
-      if (isa<CXXForRangeStmt>(LoopTarget))
-        return;
-
       SourceLocation Loc = LoopTarget->getBeginLoc();
       SourceRange R1(Loc, Loc), R2;
 
index 61805837dc29bbbf54d21773548adce424455191..fd006c099e7dc6b07a7e8efa0b3445b34bd85827 100644 (file)
@@ -52,11 +52,6 @@ void test3() {
   }
 }
 
-void test4() {
-  for (char c : "abc") // no-warning
-    break;
-}
-
 // PR 6130 - Don't warn about bogus unreachable code with throw's and
 // temporary objects.
 class PR6130 {