xref: /netbsd-src/external/apache2/llvm/dist/clang/docs/analyzer/checkers/dealloc_example.m (revision 7330f729ccf0bd976a06f95fad452fe774fc7fd1)
1*7330f729Sjoerg
2*7330f729Sjoerg
3*7330f729Sjoerg@interface MyObject : NSObject {
4*7330f729Sjoerg  id _myproperty;
5*7330f729Sjoerg}
6*7330f729Sjoerg@end
7*7330f729Sjoerg
8*7330f729Sjoerg@implementation MyObject // warn: lacks 'dealloc'
9*7330f729Sjoerg@end
10*7330f729Sjoerg
11*7330f729Sjoerg@interface MyObject : NSObject {}
12*7330f729Sjoerg@property(assign) id myproperty;
13*7330f729Sjoerg@end
14*7330f729Sjoerg
15*7330f729Sjoerg@implementation MyObject // warn: does not send 'dealloc' to super
16*7330f729Sjoerg- (void)dealloc {
17*7330f729Sjoerg  self.myproperty = 0;
18*7330f729Sjoerg}
19*7330f729Sjoerg@end
20*7330f729Sjoerg
21*7330f729Sjoerg@interface MyObject : NSObject {
22*7330f729Sjoerg  id _myproperty;
23*7330f729Sjoerg}
24*7330f729Sjoerg@property(retain) id myproperty;
25*7330f729Sjoerg@end
26*7330f729Sjoerg
27*7330f729Sjoerg@implementation MyObject
28*7330f729Sjoerg@synthesize myproperty = _myproperty;
29*7330f729Sjoerg  // warn: var was retained but wasn't released
30*7330f729Sjoerg- (void)dealloc {
31*7330f729Sjoerg  [super dealloc];
32*7330f729Sjoerg}
33*7330f729Sjoerg@end
34*7330f729Sjoerg
35*7330f729Sjoerg@interface MyObject : NSObject {
36*7330f729Sjoerg  id _myproperty;
37*7330f729Sjoerg}
38*7330f729Sjoerg@property(assign) id myproperty;
39*7330f729Sjoerg@end
40*7330f729Sjoerg
41*7330f729Sjoerg@implementation MyObject
42*7330f729Sjoerg@synthesize myproperty = _myproperty;
43*7330f729Sjoerg  // warn: var wasn't retained but was released
44*7330f729Sjoerg- (void)dealloc {
45*7330f729Sjoerg  [_myproperty release];
46*7330f729Sjoerg  [super dealloc];
47*7330f729Sjoerg}
48*7330f729Sjoerg@end
49*7330f729Sjoerg
50