[PATCH] D32905: [Analyzer] Iterator Checker - Part 9: Evaluation of std::find-like calls

Balogh, Ádám via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri May 5 06:23:39 PDT 2017


baloghadamsoftware created this revision.

This patch adds explicit evaluation of the following functions: std::find, std::find_end, std::find_first_of, std::find_if, std::find_if_not, std::lower_bound, std::upper_bound, std::search and std::search_n. On the one hand this is an optimization since the result of each of these functions is an iterators either inside the range or the iterator past the end of the range. This evaluation does exactly this. (We cannot simulate "inside the range" just an iterator bound to the same container with a new offset). On the other hand this evaluation is needed for random access operators since some STL implementations do some optimization where the length of the range is used instead of iterating until the end. This is hard to track in a checker so we must do this evaluation to prevent false positives and catch more real bugs.


https://reviews.llvm.org/D32905

Files:
  lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
  test/Analysis/Inputs/system-header-simulator-cxx.h
  test/Analysis/iterator-range.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32905.97945.patch
Type: text/x-patch
Size: 15115 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170505/306110fd/attachment.bin>


More information about the cfe-commits mailing list