Revert "SCEV: Use I = vector<>.erase(I) to iterate and delete at the same time"
authorTobias Grosser <tobias@grosser.es>
Thu, 8 May 2014 07:55:34 +0000 (07:55 +0000)
committerTobias Grosser <tobias@grosser.es>
Thu, 8 May 2014 07:55:34 +0000 (07:55 +0000)
as committed in r208282. The original commit was incorrect.

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

lib/Analysis/ScalarEvolution.cpp

index 8f5a2a98cc16c9e1e2147dd330554e2aca84cd91..148e58d548f1733d6e30d236124a167953b9d001 100644 (file)
@@ -7223,9 +7223,12 @@ static void findArrayDimensionsRec(ScalarEvolution &SE,
     Terms[I] = Q;
   }
 
-  for (auto I = Terms.begin(), E = Terms.end(); I != E; I++)
-    if (isa<SCEVConstant>(*I))
-      I = Terms.erase(I);
+  // Remove all SCEVConstants.
+  for (unsigned I = 0; I < Terms.size();)
+    if (isa<SCEVConstant>(Terms[I]))
+      Terms.erase(Terms.begin() + I);
+    else
+      ++I;
 
   if (Terms.size() > 0)
     findArrayDimensionsRec(SE, Terms, Sizes, Zero, One);