From: Ted Kremenek Date: Wed, 4 Jan 2012 00:35:48 +0000 (+0000) Subject: Teach the static analyzer to not treat XPC types as CF types. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1c87980ef18dbf4669c7194d60138ff9747d7ab7;p=clang Teach the static analyzer to not treat XPC types as CF types. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147506 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Analysis/CocoaConventions.cpp b/lib/Analysis/CocoaConventions.cpp index 9dc5ef4906..0c1531da14 100644 --- a/lib/Analysis/CocoaConventions.cpp +++ b/lib/Analysis/CocoaConventions.cpp @@ -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(); } diff --git a/test/Analysis/retain-release.m b/test/Analysis/retain-release.m index 6f8bf09ebd..a6c24cee00 100644 --- a/test/Analysis/retain-release.m +++ b/test/Analysis/retain-release.m @@ -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. +// +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); +} +