Ted Kremenek | be1fe1e | 2009-02-17 04:27:41 +0000 | [diff] [blame] | 1 | // RUN: clang -analyze -checker-cfref -analyzer-store=basic -verify %s && |
| 2 | // RUN: clang -analyze -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" |
| 18 | -(NSObject*)new_theprefixdoesnotcount; // read as "theprefixdoesnotcount" |
| 19 | @end |
| 20 | |
Ted Kremenek | 3ad2cc8 | 2008-10-22 23:56:21 +0000 | [diff] [blame] | 21 | @interface MyClass : NSObject |
| 22 | { |
Ted Kremenek | f4b3548 | 2008-10-24 20:33:56 +0000 | [diff] [blame] | 23 | id myObject; |
Ted Kremenek | 3ad2cc8 | 2008-10-22 23:56:21 +0000 | [diff] [blame] | 24 | } |
| 25 | - (NSURL *)myMethod:(NSString *)inString; |
Ted Kremenek | f4b3548 | 2008-10-24 20:33:56 +0000 | [diff] [blame] | 26 | - (NSURL *)getMethod:(NSString*)inString; |
| 27 | - (void)addObject:(id)X; |
Ted Kremenek | 3ad2cc8 | 2008-10-22 23:56:21 +0000 | [diff] [blame] | 28 | @end |
| 29 | |
| 30 | @implementation MyClass |
| 31 | |
| 32 | - (NSURL *)myMethod:(NSString *)inString |
| 33 | { |
Ted Kremenek | cf118d4 | 2009-02-04 23:49:09 +0000 | [diff] [blame] | 34 | NSURL *url = (NSURL *)CFURLCreateWithString(0, (CFStringRef)inString, 0); // expected-warning{{leak}} |
| 35 | return url; |
Ted Kremenek | 3ad2cc8 | 2008-10-22 23:56:21 +0000 | [diff] [blame] | 36 | } |
| 37 | |
Ted Kremenek | f4b3548 | 2008-10-24 20:33:56 +0000 | [diff] [blame] | 38 | - (NSURL *)getMethod:(NSString *)inString |
| 39 | { |
| 40 | NSURL *url = (NSURL *)CFURLCreateWithString(0, (CFStringRef)inString, 0); |
| 41 | [self addObject:url]; |
| 42 | return url; // no-warning |
| 43 | } |
| 44 | |
Ted Kremenek | b80976c | 2009-02-21 05:13:43 +0000 | [diff] [blame^] | 45 | void testNames(NamingTest* x) { |
| 46 | [x photocopy]; // no-warning |
| 47 | [x photoCopy]; // expected-warning{{leak}} |
| 48 | [x __blebPRCopy]; // expected-warning{{leak}} |
| 49 | [x __blebPRcopy]; // no-warning |
| 50 | [x new_theprefixdoesnotcount]; // no-warning |
| 51 | } |
| 52 | |
Ted Kremenek | f4b3548 | 2008-10-24 20:33:56 +0000 | [diff] [blame] | 53 | |
| 54 | - (void)addObject:(id)X |
| 55 | { |
| 56 | myObject = X; |
| 57 | } |
| 58 | |
Ted Kremenek | 3ad2cc8 | 2008-10-22 23:56:21 +0000 | [diff] [blame] | 59 | @end |