1 // RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core,osx.cocoa.Dealloc %s -verify
3 // Tests for the checker which checks missing/extra ivar 'release' calls
11 @interface MyClass : NSObject {
31 @property(retain) id X;
32 @property(retain) id Y;
33 @property(assign) id Z;
34 @property(assign) id K;
36 @property(readonly) id N;
37 @property(retain) id M;
40 @property(retain) id R;
41 @property(weak, readonly) id S;
43 @property(assign, readonly) id T; // Shadowed in class extension
44 @property(assign) id U;
46 @property(retain) id V;
47 @property(retain) id W;
49 -(void) setO: (id) arg;
53 // Shadows T to make it readwrite internally but readonly externally.
54 @property(assign, readwrite) id T;
57 @implementation MyClass
71 -(void) setO:(id)arg { }
74 -(void) releaseInHelper {
75 [_R release]; // no-warning
83 [_Z release]; // expected-warning{{The '_Z' ivar in 'MyClass' was synthesized for an assign, readwrite property but was released in 'dealloc'}}
84 [_T release]; // no-warning
86 [_other->_Z release]; // no-warning
89 self.M = 0; // This will release '_M'
90 [self setV:0]; // This will release '_V'
91 [self setW:@"newW"]; // This will release '_W', but retain the new value
93 [_S release]; // expected-warning {{The '_S' ivar in 'MyClass' was synthesized for a weak property but was released in 'dealloc'}}
95 self.O = 0; // no-warning
97 [_Q release]; // expected-warning {{The '_Q' ivar in 'MyClass' was synthesized for a weak property but was released in 'dealloc'}}
101 [self releaseInHelper];
103 [_nonPropertyIvar release]; // no-warning
105 // Silly, but not an error.
110 // expected-warning@-1{{The '_Y' ivar in 'MyClass' was retained by a synthesized property but not released before '[super dealloc]'}}
111 // expected-warning@-2{{The '_W' ivar in 'MyClass' was retained by a synthesized property but not released before '[super dealloc]'}}