r353227 - [analyzer] [RetainCountChecker] Bugfix: in non-OSObject-mode, do not track CXX method calls

George Karpenkov via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 5 14:26:44 PST 2019


Author: george.karpenkov
Date: Tue Feb  5 14:26:44 2019
New Revision: 353227

URL: http://llvm.org/viewvc/llvm-project?rev=353227&view=rev
Log:
[analyzer] [RetainCountChecker] Bugfix: in non-OSObject-mode, do not track CXX method calls

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

Modified:
    cfe/trunk/lib/Analysis/RetainSummaryManager.cpp
    cfe/trunk/test/Analysis/retain-release.mm

Modified: cfe/trunk/lib/Analysis/RetainSummaryManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/RetainSummaryManager.cpp?rev=353227&r1=353226&r2=353227&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/RetainSummaryManager.cpp (original)
+++ cfe/trunk/lib/Analysis/RetainSummaryManager.cpp Tue Feb  5 14:26:44 2019
@@ -499,19 +499,19 @@ RetainSummaryManager::generateSummary(co
     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<CXXMethodDecl>(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();
 }
 

Modified: cfe/trunk/test/Analysis/retain-release.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/retain-release.mm?rev=353227&r1=353226&r2=353227&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/retain-release.mm (original)
+++ cfe/trunk/test/Analysis/retain-release.mm Tue Feb  5 14:26:44 2019
@@ -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);
+}
+
+}




More information about the cfe-commits mailing list