[analyzer] RetainCount: Allow offsets in return values.
authorArtem Dergachev <artem.dergachev@gmail.com>
Fri, 26 Apr 2019 02:05:15 +0000 (02:05 +0000)
committerArtem Dergachev <artem.dergachev@gmail.com>
Fri, 26 Apr 2019 02:05:15 +0000 (02:05 +0000)
commite264ac6ae19a5dfce26582c7240df402cba269ad
treece25df0b6952608932ca2d13301b1eb59196ce64
parentb591845f4b482a2aec74f121f5f03da2ebefcef4
[analyzer] RetainCount: Allow offsets in return values.

Because RetainCountChecker has custom "local" reasoning about escapes,
it has a separate facility to deal with tracked symbols at end of analysis
and check them for leaks regardless of whether they're dead or not.
This facility iterates over the list of tracked symbols and reports
them as leaks, but it needs to treat the return value specially.

Some custom allocators tend to return the value with an offset, storing
extra metadata at the beginning of the buffer. In this case the return value
would be a non-base region. In order to avoid false positives, we still need to
find the original symbol within the return value, otherwise it'll be unable
to match it to the item in the list of tracked symbols.

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

llvm-svn: 359263
clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
clang/test/Analysis/retain-release.mm