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