cfref_PR2519.c revision 66e855fb8ae1da1eccf24fa6c7ddfec4f1b5fcc5
1// RUN: clang -checker-cfref -verify %s 2 3typedef unsigned char Boolean; 4typedef signed long CFIndex; 5typedef const void * CFTypeRef; 6typedef const struct __CFString * CFStringRef; 7typedef const struct __CFAllocator * CFAllocatorRef; 8extern const CFAllocatorRef kCFAllocatorDefault; 9typedef struct {} CFAllocatorContext; 10extern void CFRelease(CFTypeRef cf); 11typedef struct {} 12CFDictionaryKeyCallBacks; 13extern const CFDictionaryKeyCallBacks kCFTypeDictionaryKeyCallBacks; 14typedef struct {} 15CFDictionaryValueCallBacks; 16extern const CFDictionaryValueCallBacks kCFTypeDictionaryValueCallBacks; 17typedef const struct __CFDictionary * CFDictionaryRef; 18extern CFDictionaryRef CFDictionaryCreate(CFAllocatorRef allocator, const void **keys, const void **values, CFIndex numValues, const CFDictionaryKeyCallBacks *keyCallBacks, const CFDictionaryValueCallBacks *valueCallBacks); 19enum { kCFNumberSInt8Type = 1, kCFNumberSInt16Type = 2, kCFNumberSInt32Type = 3, kCFNumberSInt64Type = 4, kCFNumberFloat32Type = 5, kCFNumberFloat64Type = 6, kCFNumberCharType = 7, kCFNumberShortType = 8, kCFNumberIntType = 9, kCFNumberLongType = 10, kCFNumberLongLongType = 11, kCFNumberFloatType = 12, kCFNumberDoubleType = 13, kCFNumberCFIndexType = 14, kCFNumberNSIntegerType = 15, kCFNumberCGFloatType = 16, kCFNumberMaxType = 16 }; 20typedef CFIndex CFNumberType; 21typedef const struct __CFNumber * CFNumberRef; 22extern CFNumberRef CFNumberCreate(CFAllocatorRef allocator, CFNumberType theType, const void *valuePtr); 23typedef struct __CFNotificationCenter * CFNotificationCenterRef; 24extern CFNotificationCenterRef CFNotificationCenterGetDistributedCenter(void); 25extern void CFNotificationCenterPostNotification(CFNotificationCenterRef center, CFStringRef name, const void *object, CFDictionaryRef userInfo, Boolean deliverImmediately); 26 27// This test case was reported in PR2519 as a false positive (_value was 28// reported as being leaked). 29 30int main(int argc, char **argv) { 31 CFStringRef _key = ((CFStringRef) __builtin___CFStringMakeConstantString ("" "Process identifier" "")); 32 int pid = 42; 33 34 CFNumberRef _value = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &pid); 35 CFDictionaryRef userInfo = CFDictionaryCreate(kCFAllocatorDefault, (const void **)&_key, (const void **)&_value, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); 36 CFRelease(_value); // no-warning 37 CFNotificationCenterPostNotification(CFNotificationCenterGetDistributedCenter(), 38 ((CFStringRef) __builtin___CFStringMakeConstantString ("" "GrowlPreferencesChanged" "")), 39 ((CFStringRef) __builtin___CFStringMakeConstantString ("" "GrowlUserDefaults" "")), 40 userInfo, 0); 41 CFRelease(userInfo); // no-warning 42 43 return 0; 44} 45 46