[PATCH] D53812: [Analyzer] Iterator Checker - Forbid increments past the begin() and decrements past the end() of containers

Artem Dergachev via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 30 14:25:35 PST 2018


I suspect that the point is that previously we believed that 
decrementing below begin and than *incrementing* it back to begin() 
would yield begin(), but now we disallow this "incrementing back" 
behavior and warn immediately on decrement because in fact it's already UB.

Though, yeah, the title is wonky.

On 11/30/18 2:19 PM, Roman Lebedev wrote:
> ""Re: [PATCH] D53812: [Analyzer] Iterator Checker - Forbid increments
> past the begin() and decrements past the end() of containers"
> Is it be or that reads backwards?
> Why can't you increment past the begin()? Can you decrement past the
> begin() instead?
> And the opposite for the end().
>
> On Sat, Dec 1, 2018 at 1:17 AM Artem Dergachev via Phabricator via
> cfe-commits <cfe-commits at lists.llvm.org> wrote:
>> NoQ accepted this revision.
>> NoQ added a comment.
>> This revision is now accepted and ready to land.
>>
>> Makes perfect sense to me!
>>
>>
>>
>> ================
>> Comment at: test/Analysis/iterator-range.cpp:190
>> +  auto i0 = L.begin();
>> +  --i0;  // expected-warning{{Iterator accessed outside of its range}}
>> +}
>> ----------------
>> I guess we'll have to come up with a separate warning text for this case, as there's no access happening through the iterator.
>>
>> Regardless of how the final message would look, i suggest adding logic for having a different message now, so that we didn't forget about this case later.
>>
>>
>> CHANGES SINCE LAST ACTION
>>    https://reviews.llvm.org/D53812/new/
>>
>> https://reviews.llvm.org/D53812
>>
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits



More information about the cfe-commits mailing list