PR2978.m revision 997c1552acd4cf8745f6895a6ac3d0fbc3451326
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@end 30 31@implementation MyClass 32@synthesize X = _X; 33@synthesize Y = _Y; // expected-warning{{The '_Y' instance variable was retained by a synthesized property but wasn't released in 'dealloc'}} 34@synthesize Z = _Z; // expected-warning{{The '_Z' instance variable was not retained by a synthesized property but was released in 'dealloc'}} 35@synthesize K = _K; 36@synthesize N = _N; 37@synthesize M = _M; 38@synthesize V = _V; 39@synthesize W = _W; // expected-warning{{The '_W' instance variable was retained by a synthesized property but wasn't released in 'dealloc'}} 40 41- (void)dealloc 42{ 43 [_X release]; 44 [_Z release]; 45 [_N release]; 46 47 self.M = 0; // This will release '_M' 48 [self setV:0]; // This will release '_V' 49 [self setW:@"newW"]; // This will release '_W', but retain the new value 50 51 [super dealloc]; 52} 53 54@end 55 56