[llvm] r208282 - SCEV: Use I = vector<>.erase(I) to iterate and delete at the same time
Pasi Parviainen
pasi.parviainen at iki.fi
Thu May 8 00:51:04 PDT 2014
On 8.5.2014 10:12, Tobias Grosser wrote:
> Author: grosser
> Date: Thu May 8 02:12:44 2014
> New Revision: 208282
>
> URL: http://llvm.org/viewvc/llvm-project?rev=208282&view=rev
> Log:
> SCEV: Use I = vector<>.erase(I) to iterate and delete at the same time
>
> Modified:
> llvm/trunk/lib/Analysis/ScalarEvolution.cpp
>
> Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=208282&r1=208281&r2=208282&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original)
> +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Thu May 8 02:12:44 2014
> @@ -7223,12 +7223,9 @@ static void findArrayDimensionsRec(Scala
> Terms[I] = Q;
> }
>
> - // Remove all SCEVConstants.
> - for (unsigned I = 0; I < Terms.size();)
> - if (isa<SCEVConstant>(Terms[I]))
> - Terms.erase(Terms.begin() + I);
> - else
> - ++I;
> + for (auto I = Terms.begin(), E = Terms.end(); I != E; I++)
> + if (isa<SCEVConstant>(*I))
> + I = Terms.erase(I);
Since erase() returns iterator to item after erased item, those items
will be skipped. Incrementing iterator should be moved to else clause to
fix this.
> if (Terms.size() > 0)
> findArrayDimensionsRec(SE, Terms, Sizes, Zero, One);
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
More information about the llvm-commits
mailing list