| 1 |
// RUN: %clang_analyze_cc1 -analyzer-checker=core,osx -verify %s |
| 2 |
|
| 3 |
typedef signed char BOOL; |
| 4 |
|
| 5 |
@protocol NSObject - (BOOL)isEqual:(id)object; @end |
| 6 |
@interface NSObject <NSObject> {} |
| 7 |
+(id)alloc; |
| 8 |
+(id)new; |
| 9 |
-(id)init; |
| 10 |
-(id)autorelease; |
| 11 |
-(id)copy; |
| 12 |
- (Class)class; |
| 13 |
-(id)retain; |
| 14 |
- (oneway void)release; |
| 15 |
@end |
| 16 |
|
| 17 |
@interface Cell : NSObject { |
| 18 |
int x; |
| 19 |
} |
| 20 |
- (id) init; |
| 21 |
- (void)test; |
| 22 |
@end |
| 23 |
|
| 24 |
@implementation Cell |
| 25 |
- (id) init { |
| 26 |
if ((self = [super init])) { |
| 27 |
return self; |
| 28 |
} |
| 29 |
// Test that this is being analyzed. |
| 30 |
int m; |
| 31 |
m = m + 1; //expected-warning {{The left operand of '+' is a garbage value}} |
| 32 |
return self; |
| 33 |
} |
| 34 |
|
| 35 |
// Make sure that we do not propagate the 'nil' check from inlined 'init' to 'test'. |
| 36 |
- (void) test { |
| 37 |
Cell *newCell = [[Cell alloc] init]; |
| 38 |
newCell->x = 5; // no-warning |
| 39 |
[newCell release]; |
| 40 |
} |
| 41 |
@end |