[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)
commit42d241fc0b25d71c4c048019a25e286b8bd4bb6f
tree0a1a0e0f8c4155aa10036b61d17c588d7146e450
parent026cc2ff9552fa372bd5a38397fd0866d69fd96d
[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

llvm-svn: 348244
clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
clang/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
clang/lib/StaticAnalyzer/Core/MemRegion.cpp
clang/test/Analysis/iterator-range.cpp