PR2978.m revision ccb55e3d0c173ed86ab440d9bf41c06fdddd39ef
1// RUN: clang -warn-objc-missing-dealloc %s -verify 2 3// Tests for the checker which checks missing/extra ivar 'release' calls 4// in dealloc. 5 6@interface NSObject 7- (void)release; 8@end 9 10@interface MyClass : NSObject { 11@private 12 id _X; 13 id _Y; 14 id _Z; 15 id _K; 16 id _N; 17 id _M; 18 id _V; 19 id _W; 20} 21@property(retain) id X; 22@property(retain) id Y; 23@property(assign) id Z; 24@property(assign) id K; 25@property(assign, readonly) id N; 26@property(retain) id M; 27@property(retain) id V; 28@property(retain) id W; 29-(id) O; 30-(void) setO: (id) arg; 31@end 32 33@implementation MyClass 34@synthesize X = _X; 35@synthesize Y = _Y; // expected-warning{{The '_Y' instance variable was retained by a synthesized property but wasn't released in 'dealloc'}} 36@synthesize Z = _Z; // expected-warning{{The '_Z' instance variable was not retained by a synthesized property but was released in 'dealloc'}} 37@synthesize K = _K; 38@synthesize N = _N; 39@synthesize M = _M; 40@synthesize V = _V; 41@synthesize W = _W; // expected-warning{{The '_W' instance variable was retained by a synthesized property but wasn't released in 'dealloc'}} 42 43-(id) O{ return 0; } 44-(void) setO:(id)arg { } 45 46- (void)dealloc 47{ 48 [_X release]; 49 [_Z release]; 50 [_N release]; 51 52 self.M = 0; // This will release '_M' 53 [self setV:0]; // This will release '_V' 54 [self setW:@"newW"]; // This will release '_W', but retain the new value 55 self.O = 0; // no-warning 56 [super dealloc]; 57} 58 59@end 60 61