From: George Karpenkov Date: Tue, 5 Feb 2019 22:26:44 +0000 (+0000) Subject: [analyzer] [RetainCountChecker] Bugfix: in non-OSObject-mode, do not track CXX method... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f9305064908a455e56eeeb0b97b14bbc9b045161;p=clang [analyzer] [RetainCountChecker] Bugfix: in non-OSObject-mode, do not track CXX method calls Differential Revision: https://reviews.llvm.org/D57782 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@353227 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Analysis/RetainSummaryManager.cpp b/lib/Analysis/RetainSummaryManager.cpp index abaaffa78e..2eee01ca6a 100644 --- a/lib/Analysis/RetainSummaryManager.cpp +++ b/lib/Analysis/RetainSummaryManager.cpp @@ -499,19 +499,19 @@ RetainSummaryManager::generateSummary(const FunctionDecl *FD, if (const RetainSummary *S = getSummaryForOSObject(FD, FName, RetTy)) return S; - if (TrackObjCAndCFObjects) - if (const RetainSummary *S = - getSummaryForObjCOrCFObject(FD, FName, RetTy, FT, AllowAnnotations)) - return S; - if (const auto *MD = dyn_cast(FD)) - if (!(TrackOSObjects && isOSObjectRelated(MD))) + if (!isOSObjectRelated(MD)) return getPersistentSummary(RetEffect::MakeNoRet(), ArgEffects(AF.getEmptyMap()), ArgEffect(DoNothing), ArgEffect(StopTracking), ArgEffect(DoNothing)); + if (TrackObjCAndCFObjects) + if (const RetainSummary *S = + getSummaryForObjCOrCFObject(FD, FName, RetTy, FT, AllowAnnotations)) + return S; + return getDefaultSummary(); } diff --git a/test/Analysis/retain-release.mm b/test/Analysis/retain-release.mm index 5dc8f857d8..97ea5607d2 100644 --- a/test/Analysis/retain-release.mm +++ b/test/Analysis/retain-release.mm @@ -471,7 +471,6 @@ void rdar33832412() { void* x = IOBSDNameMatching(); // no-warning } - namespace member_CFRetains { class Foo { public: @@ -485,3 +484,22 @@ void bar() { foo.CFRetain(0); // no-warning } } + +namespace cxx_method_escaping { + +struct S { + static CFArrayRef testGetNoTracking(); + CFArrayRef testGetNoTrackingMember(); +}; + +void test_cxx_static_method_escaping() { + CFArrayRef arr = S::testGetNoTracking(); + CFRelease(arr); +} + +void test_cxx_method_escaping(S *s) { + CFArrayRef arr = s->testGetNoTrackingMember(); + CFRelease(arr); +} + +}