blob: aa5d173807b2d6f2767bcf10eaa6aae8cb6ec9fe [file] [log] [blame]
Ted Kremenek997c1552008-10-30 15:19:43 +00001// 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;
Steve Naroff87d3ef02008-11-17 22:29:32 +00008- dealloc;
Ted Kremenek997c1552008-10-30 15:19:43 +00009@end
10
11@interface MyClass : NSObject {
12@private
13 id _X;
14 id _Y;
15 id _Z;
16 id _K;
17 id _N;
18 id _M;
19 id _V;
20 id _W;
21}
22@property(retain) id X;
23@property(retain) id Y;
24@property(assign) id Z;
25@property(assign) id K;
26@property(assign, readonly) id N;
27@property(retain) id M;
28@property(retain) id V;
29@property(retain) id W;
Ted Kremenekccb55e32008-10-30 23:00:13 +000030-(id) O;
31-(void) setO: (id) arg;
Ted Kremenek997c1552008-10-30 15:19:43 +000032@end
33
34@implementation MyClass
35@synthesize X = _X;
36@synthesize Y = _Y; // expected-warning{{The '_Y' instance variable was retained by a synthesized property but wasn't released in 'dealloc'}}
37@synthesize Z = _Z; // expected-warning{{The '_Z' instance variable was not retained by a synthesized property but was released in 'dealloc'}}
38@synthesize K = _K;
39@synthesize N = _N;
40@synthesize M = _M;
41@synthesize V = _V;
42@synthesize W = _W; // expected-warning{{The '_W' instance variable was retained by a synthesized property but wasn't released in 'dealloc'}}
43
Ted Kremenekccb55e32008-10-30 23:00:13 +000044-(id) O{ return 0; }
45-(void) setO:(id)arg { }
46
Ted Kremenek997c1552008-10-30 15:19:43 +000047- (void)dealloc
48{
49 [_X release];
50 [_Z release];
51 [_N release];
52
53 self.M = 0; // This will release '_M'
54 [self setV:0]; // This will release '_V'
55 [self setW:@"newW"]; // This will release '_W', but retain the new value
Ted Kremenekccb55e32008-10-30 23:00:13 +000056 self.O = 0; // no-warning
Ted Kremenek997c1552008-10-30 15:19:43 +000057 [super dealloc];
58}
59
60@end
61