1 // RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,alpha.core -analyzer-store=region -analyzer-constraints=range -verify %s 2 // expected-no-diagnostics 3 4 typedef unsigned char Boolean; 5 typedef signed long CFIndex; 6 typedef const void * CFTypeRef; 7 typedef const struct __CFString * CFStringRef; 8 typedef const struct __CFAllocator * CFAllocatorRef; 9 extern const CFAllocatorRef kCFAllocatorDefault; 10 typedef struct {} CFAllocatorContext; 11 extern void CFRelease(CFTypeRef cf); 12 typedef struct {} 13 CFDictionaryKeyCallBacks; 14 extern const CFDictionaryKeyCallBacks kCFTypeDictionaryKeyCallBacks; 15 typedef struct {} 16 CFDictionaryValueCallBacks; 17 extern const CFDictionaryValueCallBacks kCFTypeDictionaryValueCallBacks; 18 typedef const struct __CFDictionary * CFDictionaryRef; 19 extern CFDictionaryRef CFDictionaryCreate(CFAllocatorRef allocator, const void **keys, const void **values, CFIndex numValues, const CFDictionaryKeyCallBacks *keyCallBacks, const CFDictionaryValueCallBacks *valueCallBacks); 20 enum { 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 }; 21 typedef CFIndex CFNumberType; 22 typedef const struct __CFNumber * CFNumberRef; 23 extern CFNumberRef CFNumberCreate(CFAllocatorRef allocator, CFNumberType theType, const void *valuePtr); 24 typedef struct __CFNotificationCenter * CFNotificationCenterRef; 25 extern CFNotificationCenterRef CFNotificationCenterGetDistributedCenter(void); 26 extern void CFNotificationCenterPostNotification(CFNotificationCenterRef center, CFStringRef name, const void *object, CFDictionaryRef userInfo, Boolean deliverImmediately); 27 28 // This test case was reported in PR2519 as a false positive (_value was 29 // reported as being leaked). 30 31 int main(int argc, char **argv) { 32 CFStringRef _key = ((CFStringRef) __builtin___CFStringMakeConstantString ("" "Process identifier" "")); 33 int pid = 42; 34 35 CFNumberRef _value = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &pid); 36 CFDictionaryRef userInfo = CFDictionaryCreate(kCFAllocatorDefault, (const void **)&_key, (const void **)&_value, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); 37 CFRelease(_value); // no-warning 38 CFNotificationCenterPostNotification(CFNotificationCenterGetDistributedCenter(), 39 ((CFStringRef) __builtin___CFStringMakeConstantString ("" "GrowlPreferencesChanged" "")), 40 ((CFStringRef) __builtin___CFStringMakeConstantString ("" "GrowlUserDefaults" "")), 41 userInfo, 0); 42 CFRelease(userInfo); // no-warning 43 44 return 0; 45 } 46 47