| 1 |
// RUN: %clang_analyze_cc1 -verify -Wno-objc-root-class %s \ |
| 2 |
// RUN: -analyzer-checker=core,osx.cocoa.RetainCount |
| 3 |
|
| 4 |
#define NULL 0 |
| 5 |
#define CF_RETURNS_RETAINED __attribute__((cf_returns_retained)) |
| 6 |
#define CF_CONSUMED __attribute__((cf_consumed)) |
| 7 |
|
| 8 |
void clang_analyzer_eval(int); |
| 9 |
|
| 10 |
typedef const void *CFTypeRef; |
| 11 |
|
| 12 |
extern CFTypeRef CFCreate(void) CF_RETURNS_RETAINED; |
| 13 |
extern CFTypeRef CFRetain(CFTypeRef cf); |
| 14 |
extern void CFRelease(CFTypeRef cf); |
| 15 |
|
| 16 |
void bar(CFTypeRef *v) {} |
| 17 |
|
| 18 |
void test1(void) { |
| 19 |
CFTypeRef *values = (CFTypeRef[]){ |
| 20 |
CFCreate(), // no-warning |
| 21 |
CFCreate(), // expected-warning{{leak}} |
| 22 |
CFCreate()}; // no-warning |
| 23 |
CFRelease(values[0]); |
| 24 |
CFRelease(values[2]); |
| 25 |
} |