1 // RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=basic -verify %s
2 // RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=range -verify %s
3 // RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=basic -verify %s
4 // RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=range -verify %s
6 typedef unsigned char Boolean
;
7 typedef signed long CFIndex
;
8 typedef const void * CFTypeRef
;
9 typedef const struct __CFString
* CFStringRef
;
10 typedef const struct __CFAllocator
* CFAllocatorRef
;
11 extern const CFAllocatorRef kCFAllocatorDefault
;
12 typedef struct {} CFAllocatorContext
;
13 extern void CFRelease(CFTypeRef cf
);
15 CFDictionaryKeyCallBacks
;
16 extern const CFDictionaryKeyCallBacks kCFTypeDictionaryKeyCallBacks
;
18 CFDictionaryValueCallBacks
;
19 extern const CFDictionaryValueCallBacks kCFTypeDictionaryValueCallBacks
;
20 typedef const struct __CFDictionary
* CFDictionaryRef
;
21 extern CFDictionaryRef
CFDictionaryCreate(CFAllocatorRef allocator
, const void **keys
, const void **values
, CFIndex numValues
, const CFDictionaryKeyCallBacks
*keyCallBacks
, const CFDictionaryValueCallBacks
*valueCallBacks
);
22 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 };
23 typedef CFIndex CFNumberType
;
24 typedef const struct __CFNumber
* CFNumberRef
;
25 extern CFNumberRef
CFNumberCreate(CFAllocatorRef allocator
, CFNumberType theType
, const void *valuePtr
);
26 typedef struct __CFNotificationCenter
* CFNotificationCenterRef
;
27 extern CFNotificationCenterRef
CFNotificationCenterGetDistributedCenter(void);
28 extern void CFNotificationCenterPostNotification(CFNotificationCenterRef center
, CFStringRef name
, const void *object
, CFDictionaryRef userInfo
, Boolean deliverImmediately
);
30 // This test case was reported in PR2519 as a false positive (_value was
31 // reported as being leaked).
33 int main(int argc
, char **argv
) {
34 CFStringRef _key
= ((CFStringRef
) __builtin___CFStringMakeConstantString ("" "Process identifier" ""));
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" "")),
44 CFRelease(userInfo
); // no-warning