[cfe-dev] Iterator as SVal

Devin Coughlin via cfe-dev cfe-dev at lists.llvm.org
Thu Feb 25 13:04:04 PST 2016


> On Feb 25, 2016, at 9:02 AM, Ádám Balogh via cfe-dev <cfe-dev at lists.llvm.org> wrote:
> 
> I created a simple checker that tries to check whether an iterator is possibly used outside of its valid range (it equals to end()). However, it does not work, of course, since it turned out that iterators are not symbolic but value objects. I read this information in the archive of this list. There I read two suggestions: either to implement tracking of value objects in the Clang infrastructure (very much effort needed) or to do some hacking.

Anna Zaks started work on something similar several years ago. The basic approach was to create a callback which gets triggered on object copy(copy or move constructor). The idea is that we start tracking an iterator when it gets returned by begin() and monitor each time a copy is created. I’ve attached a very old patch of Anna’s that modifies the core and the beginnings of a new checker that she started working on, if you are interested in pursuing this.

One thing to note is that we’re not entirely sure whether this is right approach — it was just an initial exploration.

Devin

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160225/506872e5/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: iterators_infrastructure.diff
Type: application/octet-stream
Size: 9833 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160225/506872e5/attachment.obj>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160225/506872e5/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: IteratorsChecker.cpp
Type: application/octet-stream
Size: 4138 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160225/506872e5/attachment-0001.obj>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160225/506872e5/attachment-0002.html>


More information about the cfe-dev mailing list