[PATCH] D62895: [Analyzer] Iterator Checkers - Check and simulate `std::advance`, `std::prev` and `std::next`

Balogh, Ádám via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 5 04:09:26 PDT 2019


baloghadamsoftware added a comment.

This patch definitely reduces the number of false positives, but may not be enough. The problem is that `std::advance()` may call another function that does the actual incremention or decremention, in the `gcc` implementation it is `__advance()`. If the `std::advance()` is inlined but `__advance()` not then we still get false positive. The obvious way would be to simulate `__advance()` as well but it is an implementation dependent internal function and may be totally different for other implementations. Another idea is that instead of querying the `CheckerContext` whether `advance()` was inlined we go up the exploded graph and find its "precall" state and compare the values of the first parameter related to the second one in the two states. This is a bit more complex and more expensive but this for me this seems to be the correct solution.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62895/new/

https://reviews.llvm.org/D62895





More information about the cfe-commits mailing list