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