[Analyzer] Iterator Modeling - Model `std::advance()`, `std::prev()` and `std::next()`
authorAdam Balogh <adam.balogh@ericsson.com>
Wed, 19 Feb 2020 08:03:39 +0000 (09:03 +0100)
committerAdam Balogh <adam.balogh@ericsson.com>
Mon, 23 Mar 2020 14:29:55 +0000 (15:29 +0100)
commit60bad941a1c1b745f570da8251f2ba9ee8b7d06e
treebc31ff924c4578a5aa637a3d5ffa78f0488bc116
parent6a4905ae2d65a2883112bf8cbf83c35c0c03f410
[Analyzer] Iterator Modeling - Model `std::advance()`, `std::prev()` and `std::next()`

Whenever the analyzer budget runs out just at the point where
`std::advance()`, `std::prev()` or `std::next()` is invoked the function
are not inlined. This results in strange behavior such as
`std::prev(v.end())` equals `v.end()`. To prevent this model these
functions if they were not inlined. It may also happend that although
`std::advance()` is inlined but a function it calls inside (e.g.
`__advance()` in some implementations) is not. This case is also handled
in this patch.

Differential Revision: https://reviews.llvm.org/D76361
clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
clang/test/Analysis/Inputs/system-header-simulator-cxx.h
clang/test/Analysis/iterator-modelling.cpp