Teach the static analyzer to not treat XPC types as CF types.

llvm-svn: 147506
This commit is contained in:
Ted Kremenek 2012-01-04 00:35:48 +00:00
parent e8300e5eba
commit 990464cb30
2 changed files with 19 additions and 1 deletions

View File

@ -68,7 +68,9 @@ bool cocoa::isRefType(QualType RetTy, StringRef Prefix,
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();
}

View File

@ -42,6 +42,7 @@ typedef unsigned int uint32_t;
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 @@ void rdar10232019_positive() {
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);
}