[cfe-commits] r147506 - in /cfe/trunk: lib/Analysis/CocoaConventions.cpp test/Analysis/retain-release.m

Ted Kremenek kremenek at apple.com
Tue Jan 3 16:35:49 PST 2012


Author: kremenek
Date: Tue Jan  3 18:35:48 2012
New Revision: 147506

URL: http://llvm.org/viewvc/llvm-project?rev=147506&view=rev
Log:
Teach the static analyzer to not treat XPC types as CF types.

Modified:
    cfe/trunk/lib/Analysis/CocoaConventions.cpp
    cfe/trunk/test/Analysis/retain-release.m

Modified: cfe/trunk/lib/Analysis/CocoaConventions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CocoaConventions.cpp?rev=147506&r1=147505&r2=147506&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/CocoaConventions.cpp (original)
+++ cfe/trunk/lib/Analysis/CocoaConventions.cpp Tue Jan  3 18:35:48 2012
@@ -68,7 +68,9 @@
     StringRef TDName = TD->getDecl()->getIdentifier()->getName();
     if (TDName.startswith(Prefix) && TDName.endswith("Ref"))
       return true;
-    
+    // XPC unfortunately uses CF-style function names, but aren't CF types.
+    if (TDName.startswith("xpc_"))
+      return false;
     RetTy = TD->getDecl()->getUnderlyingType();
   }
   

Modified: cfe/trunk/test/Analysis/retain-release.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/retain-release.m?rev=147506&r1=147505&r2=147506&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/retain-release.m (original)
+++ cfe/trunk/test/Analysis/retain-release.m Tue Jan  3 18:35:48 2012
@@ -42,6 +42,7 @@
 typedef unsigned long long uint64_t;
 typedef unsigned int UInt32;
 typedef signed long CFIndex;
+typedef CFIndex CFByteOrder;
 typedef struct {
     CFIndex location;
     CFIndex length;
@@ -1604,3 +1605,18 @@
   NSLog(@"%@", otherString);
 }
 
+// RetainCountChecker support for XPC.
+// <rdar://problem/9658496>
+typedef void * xpc_object_t;
+xpc_object_t _CFXPCCreateXPCObjectFromCFObject(CFTypeRef cf);
+void xpc_release(xpc_object_t object);
+
+void rdar9658496() {
+  CFStringRef cf;
+  xpc_object_t xpc;
+  cf = CFStringCreateWithCString( ((CFAllocatorRef)0), "test", kCFStringEncodingUTF8 ); // no-warning
+  xpc = _CFXPCCreateXPCObjectFromCFObject( cf );
+  CFRelease(cf);
+  xpc_release(xpc);
+}
+





More information about the cfe-commits mailing list