]> granicus.if.org Git - clang/commit
[analyzer] Improve misleading RetainCountChcker diagnostic under ARC
authorDevin Coughlin <dcoughlin@apple.com>
Sat, 12 Nov 2016 01:03:06 +0000 (01:03 +0000)
committerDevin Coughlin <dcoughlin@apple.com>
Sat, 12 Nov 2016 01:03:06 +0000 (01:03 +0000)
commiteb8ea39fcd6c5f7adf896a54aa972cf00372eb3f
treee218c0c38cabd6f51001a55170a80b0daf5b88b1
parentaf0fec2269df1c99897136ba636ee061209e6c22
[analyzer] Improve misleading RetainCountChcker diagnostic under ARC

Under automated reference counting the analyzer treats a methods -- even those
starting with  'copy' and friends -- as returning an unowned value. This is
because ownership of CoreFoundation objects must be transferred to ARC
with __bridge_transfer or CFBridgingRelease() before being returned as
ARC-managed bridged objects.

Unfortunately this could lead to a poor diagnostic inside copy methods under
ARC where the analyzer would complain about a leak of a returned CF value inside
a method "whose name does not start with 'copy'" -- even though the name did
start with 'copy'.

This commit improves the diagnostic under ARC to say inside a method "returned
from a method managed by Automated Reference Counting".

rdar://problem/28849667

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@286694 91177308-0d34-0410-b5e6-96231b3b80d8
lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
test/Analysis/retain-release-arc.m [new file with mode: 0644]