[llvm] r208282 - SCEV: Use I = vector<>.erase(I) to iterate and delete at the same time
Tobias Grosser
tobias at grosser.es
Thu May 8 01:05:23 PDT 2014
On 08/05/2014 09:51, Pasi Parviainen wrote:
> 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.
I tried, but the test was still failing. I decided to just revert it.
Thanks for the comment.
Tobias
More information about the llvm-commits
mailing list