]> granicus.if.org Git - clang/commit
[analyzer] RetainCount: Accept more "safe" CFRetain wrappers.
authorArtem Dergachev <artem.dergachev@gmail.com>
Thu, 19 Apr 2018 23:00:22 +0000 (23:00 +0000)
committerArtem Dergachev <artem.dergachev@gmail.com>
Thu, 19 Apr 2018 23:00:22 +0000 (23:00 +0000)
commit0a0fb94463d3bb0c701d9e9904739a0c2d9f5aca
tree4f7bfb5277c9a09bdefca3c1c62cb64dd8b93b30
parent808c21458c0770aca5baacdcd56bf2716a26e26e
[analyzer] RetainCount: Accept more "safe" CFRetain wrappers.

r315736 added support for the misplaced CF_RETURNS_RETAINED annotation on
CFRetain() wrappers. It works by trusting the function's name (seeing if it
confirms to the CoreFoundation naming convention) rather than the annotation.

There are more false positives caused by users using a different naming
convention, namely starting the function name with "retain" or "release"
rather than suffixing it with "retain" or "release" respectively.

Because this isn't according to the naming convention, these functions
are usually inlined and the annotation is therefore ignored, which is correct.
But sometimes we run out of inlining stack depth and the function is
evaluated conservatively and then the annotation is trusted.

Add support for the "alternative" naming convention and test the situation when
we're running out of inlining stack depth.

rdar://problem/18270122

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@330375 91177308-0d34-0410-b5e6-96231b3b80d8
lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
test/Analysis/retain-release-safe.c