[all-commits] [llvm/llvm-project] ccc0d3: [Analyzer] IteratorRangeChecker verify `std::advan...

Balogh, Ádám via All-commits all-commits at lists.llvm.org
Mon Mar 23 09:33:35 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: ccc0d351817bedf3a979144238ffb8e2797285d4
      https://github.com/llvm/llvm-project/commit/ccc0d351817bedf3a979144238ffb8e2797285d4
  Author: Adam Balogh <adam.balogh at ericsson.com>
  Date:   2020-03-23 (Mon, 23 Mar 2020)

  Changed paths:
    M clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp
    M clang/test/Analysis/iterator-range.cpp

  Log Message:
  -----------
  [Analyzer] IteratorRangeChecker verify `std::advance()`, `std::prev()` and `std::next()`

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.

Differential Revision: https://reviews.llvm.org/D76379




More information about the All-commits mailing list