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