brintos

brintos / llvm-project-archived public Read only

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