Ted Kremenek | 8382cf5 | 2009-11-13 18:46:29 +0000 | [diff] [blame] | 1 | // RUN: clang-cc -analyze -analyzer-experimental-internal-checks -checker-cfref -analyzer-store=basic -verify %s |
| 2 | // RUN: clang-cc -analyze -analyzer-experimental-internal-checks -checker-cfref -analyzer-store=region -verify %s |
Ted Kremenek | 3ad2cc8 | 2008-10-22 23:56:21 +0000 | [diff] [blame] | 3 | |
| 4 | typedef const struct __CFString * CFStringRef; |
| 5 | typedef const struct __CFAllocator * CFAllocatorRef; |
| 6 | typedef const struct __CFURL * CFURLRef; |
| 7 | extern CFURLRef CFURLCreateWithString(CFAllocatorRef allocator, CFStringRef URLString, CFURLRef baseURL); |
| 8 | typedef signed char BOOL; |
| 9 | @protocol NSObject - (BOOL)isEqual:(id)object; @end |
| 10 | @interface NSObject <NSObject> {} @end |
| 11 | @class NSArray, NSString, NSURL; |
| 12 | |
Ted Kremenek | b80976c | 2009-02-21 05:13:43 +0000 | [diff] [blame] | 13 | @interface NamingTest : NSObject {} |
| 14 | -(NSObject*)photocopy; // read as "photocopy" |
| 15 | -(NSObject*)photoCopy; // read as "photo Copy" |
| 16 | -(NSObject*)__blebPRCopy; // read as "bleb PRCopy" |
| 17 | -(NSObject*)__blebPRcopy; // read as "bleb P Rcopy" |
Ted Kremenek | e973183 | 2009-10-20 00:13:00 +0000 | [diff] [blame] | 18 | -(NSObject*)new_theprefixdoescount; // read as "new theprefixdoescount" |
Ted Kremenek | f0dff4c | 2009-02-23 02:50:20 +0000 | [diff] [blame] | 19 | -(NSObject*)newestAwesomeStuff; // read as "newest awesome stuff" |
| 20 | |
Ted Kremenek | b80976c | 2009-02-21 05:13:43 +0000 | [diff] [blame] | 21 | @end |
| 22 | |
Ted Kremenek | 3ad2cc8 | 2008-10-22 23:56:21 +0000 | [diff] [blame] | 23 | @interface MyClass : NSObject |
| 24 | { |
Ted Kremenek | f4b3548 | 2008-10-24 20:33:56 +0000 | [diff] [blame] | 25 | id myObject; |
Ted Kremenek | 3ad2cc8 | 2008-10-22 23:56:21 +0000 | [diff] [blame] | 26 | } |
| 27 | - (NSURL *)myMethod:(NSString *)inString; |
Ted Kremenek | f4b3548 | 2008-10-24 20:33:56 +0000 | [diff] [blame] | 28 | - (NSURL *)getMethod:(NSString*)inString; |
| 29 | - (void)addObject:(id)X; |
Ted Kremenek | 3ad2cc8 | 2008-10-22 23:56:21 +0000 | [diff] [blame] | 30 | @end |
| 31 | |
| 32 | @implementation MyClass |
| 33 | |
| 34 | - (NSURL *)myMethod:(NSString *)inString |
| 35 | { |
Ted Kremenek | cf118d4 | 2009-02-04 23:49:09 +0000 | [diff] [blame] | 36 | NSURL *url = (NSURL *)CFURLCreateWithString(0, (CFStringRef)inString, 0); // expected-warning{{leak}} |
| 37 | return url; |
Ted Kremenek | 3ad2cc8 | 2008-10-22 23:56:21 +0000 | [diff] [blame] | 38 | } |
| 39 | |
Ted Kremenek | f4b3548 | 2008-10-24 20:33:56 +0000 | [diff] [blame] | 40 | - (NSURL *)getMethod:(NSString *)inString |
| 41 | { |
| 42 | NSURL *url = (NSURL *)CFURLCreateWithString(0, (CFStringRef)inString, 0); |
| 43 | [self addObject:url]; |
| 44 | return url; // no-warning |
| 45 | } |
| 46 | |
Ted Kremenek | b80976c | 2009-02-21 05:13:43 +0000 | [diff] [blame] | 47 | void testNames(NamingTest* x) { |
| 48 | [x photocopy]; // no-warning |
| 49 | [x photoCopy]; // expected-warning{{leak}} |
| 50 | [x __blebPRCopy]; // expected-warning{{leak}} |
| 51 | [x __blebPRcopy]; // no-warning |
Ted Kremenek | e973183 | 2009-10-20 00:13:00 +0000 | [diff] [blame] | 52 | [x new_theprefixdoescount]; // expected-warning{{leak}} |
Ted Kremenek | f0dff4c | 2009-02-23 02:50:20 +0000 | [diff] [blame] | 53 | [x newestAwesomeStuff]; // no-warning |
Ted Kremenek | b80976c | 2009-02-21 05:13:43 +0000 | [diff] [blame] | 54 | } |
| 55 | |
Ted Kremenek | f4b3548 | 2008-10-24 20:33:56 +0000 | [diff] [blame] | 56 | |
| 57 | - (void)addObject:(id)X |
| 58 | { |
| 59 | myObject = X; |
| 60 | } |
| 61 | |
Ted Kremenek | 3ad2cc8 | 2008-10-22 23:56:21 +0000 | [diff] [blame] | 62 | @end |