]> granicus.if.org Git - clang/commit
[Analyzer] Iterator Checkers - Use the region of the topmost base class for iterators...
authorAdam Balogh <adam.balogh@ericsson.com>
Tue, 4 Dec 2018 10:22:28 +0000 (10:22 +0000)
committerAdam Balogh <adam.balogh@ericsson.com>
Tue, 4 Dec 2018 10:22:28 +0000 (10:22 +0000)
commitf9accceeaa5ef6b194d509949964d336e97be9ea
tree73f4f6d9be306c61b95a9583170d9773ff23353c
parent356705aa60b7e589eb00b1a5658d85c338b2102e
[Analyzer] Iterator Checkers - Use the region of the topmost base class for iterators stored in a region

If an iterator is represented by a derived C++ class but its comparison operator
is for its base the iterator checkers cannot recognize the iterators compared.
This results in false positives in very straightforward cases (range error when
dereferencing an iterator after disclosing that it is equal to the past-the-end
iterator).

To overcome this problem we always use the region of the topmost base class for
iterators stored in a region. A new method called getMostDerivedObjectRegion()
was added to the MemRegion class to get this region.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348244 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
lib/StaticAnalyzer/Core/MemRegion.cpp
test/Analysis/iterator-range.cpp