[cfe-commits] r69929 - in /cfe/trunk: lib/Analysis/CFRefCount.cpp test/Analysis/NSString.m

Ted Kremenek kremenek at apple.com
Thu Apr 23 15:11:07 PDT 2009


Author: kremenek
Date: Thu Apr 23 17:11:07 2009
New Revision: 69929

URL: http://llvm.org/viewvc/llvm-project?rev=69929&view=rev
Log:
Further cleanups to isTrackedObjectType().

Modified:
    cfe/trunk/lib/Analysis/CFRefCount.cpp
    cfe/trunk/test/Analysis/NSString.m

Modified: cfe/trunk/lib/Analysis/CFRefCount.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFRefCount.cpp?rev=69929&r1=69928&r2=69929&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/CFRefCount.cpp (original)
+++ cfe/trunk/lib/Analysis/CFRefCount.cpp Thu Apr 23 17:11:07 2009
@@ -784,18 +784,22 @@
 // Predicates.
 //===----------------------------------------------------------------------===//
 
-bool RetainSummaryManager::isTrackedObjectType(QualType T) {
-  if (!Ctx.isObjCObjectPointerType(T))
+bool RetainSummaryManager::isTrackedObjectType(QualType Ty) {
+  if (!Ctx.isObjCObjectPointerType(Ty))
     return false;
 
-  // Does it subclass NSObject?
-  ObjCInterfaceType* OT = dyn_cast<ObjCInterfaceType>(T.getTypePtr());
+  // We assume that id<..>, id, and "Class" all represent tracked objects.
+  const PointerType *PT = Ty->getAsPointerType();
+  if (PT == 0)
+    return true;
+    
+  const ObjCInterfaceType *OT = PT->getPointeeType()->getAsObjCInterfaceType();
 
   // We assume that id<..>, id, and "Class" all represent tracked objects.
   if (!OT)
     return true;
-
-  // Does the object type subclass NSObject?
+    
+  // Does the interface subclass NSObject?
   // FIXME: We can memoize here if this gets too expensive.  
   IdentifierInfo* NSObjectII = &Ctx.Idents.get("NSObject");
   ObjCInterfaceDecl* ID = OT->getDecl();  

Modified: cfe/trunk/test/Analysis/NSString.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/NSString.m?rev=69929&r1=69928&r2=69929&view=diff

==============================================================================
--- cfe/trunk/test/Analysis/NSString.m (original)
+++ cfe/trunk/test/Analysis/NSString.m Thu Apr 23 17:11:07 2009
@@ -251,3 +251,12 @@
   [string release]; // expected-warning{{Incorrect decrement of the reference count}}
 }
 
+// Test isTrackedObjectType()
+typedef NSString* WonkyTypedef;
+ at interface TestIsTracked
++ (WonkyTypedef)newString;
+ at end
+
+void test_isTrackedObjectType(void) {
+  NSString *str = [TestIsTracked newString]; // expected-warning{{Potential leak}}
+}





More information about the cfe-commits mailing list