[PATCH] D62525: [Analyzer] Add new visitor to the iterator checkers
Kristóf Umann via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Aug 3 11:22:50 PDT 2019
Szelethus added inline comments.
Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:1495-1496
// For deque-like containers invalidate all iterator positions. For
// vector-like containers invalidate iterator positions after the insertion.
const auto *Cont = Pos->getContainer();
> Szelethus wrote:
> > >>! In D62525#1523026, @baloghadamsoftware wrote:
> > > For example, an insertion happens into a vector that invalidates all the iterators at and after the position where it is inserted.
> > Is this actually correct?
> > https://en.cppreference.com/w/cpp/container/deque
> > > std::deque (double-ended queue) is an indexed sequence container that allows fast insertion and deletion at both its beginning and its end. In addition, insertion and deletion at either end of a deque never invalidates pointers or references to the rest of the elements.
> > https://en.cppreference.com/w/cpp/container/vector
> > > `insert`, `emplace`, `resize`: If the vector changed capacity, all of the iterators are invalidated. If not, only those after the insertion point.
> [[ https://en.cppreference.com/w/cpp/container/deque/insert | https://en.cppreference.com/w/cpp/container/deque/insert ]]
> //All iterators, including the past-the-end iterator, are invalidated.//
> I think I speak here about `insert()`, not about `push_back()` and `push_front()`.
> Since we use a conservative approach we always assume that vectors and double-end queues do not change capacities.
I stand corrected!
CHANGES SINCE LAST ACTION
More information about the cfe-commits