[PATCH] D76379: [Analyzer] IteratorRangeChecker verify `std::advance()`, `std::prev()` and `std::next()`

Balogh, Ádám via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 18 12:29:51 PDT 2020


baloghadamsoftware created this revision.
baloghadamsoftware added reviewers: NoQ, Szelethus.
baloghadamsoftware added a project: clang.
Herald added subscribers: ASDenysPetrov, martong, steakhal, Charusso, gamesh411, dkrupp, donat.nagy, mikhail.ramalho, a.sidorin, rnkovacs, szepet, xazax.hun, whisperity.
baloghadamsoftware added a comment.

This patch replaces the verification part of D62895 <https://reviews.llvm.org/D62895>.


Upon calling one of the functions `std::advance()`, `std::prev()` and `std::next()` iterators could get out of their valid range which leads to undefined behavior. If all these funcions are inlined together with the functions they call internally (e.g. `__advance()` called by `std::advance()` in some implementations) the error is detected by `IteratorRangeChecker` but the bug location is inside the STL implementation. Even worse, if the budget runs out and one of the calls is not inlined the bug remains undetected. This patch fixes this behavior: all the bugs are detected at the point of the STL function invocation.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76379

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76379.251147.patch
Type: text/x-patch
Size: 17546 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200318/c9e775ab/attachment-0001.bin>


More information about the cfe-commits mailing list