blob: c326eab300af22b79ab86a5117efb2ccd3077d25 [file] [log] [blame]
Daniel Dunbard4270232009-01-20 23:17:32 +00001// RUN: clang -analyze -warn-objc-missing-dealloc '-DIBOutlet=__attribute__((iboutlet))' %s --verify
Ted Kremeneke0bb8042008-12-08 21:59:21 +00002typedef signed char BOOL;
3@protocol NSObject - (BOOL)isEqual:(id)object; @end
4@interface NSObject <NSObject> {}
5- (void)dealloc;
Ted Kremenek63de7362008-12-08 22:01:50 +00006- (id)init;
Ted Kremeneke0bb8042008-12-08 21:59:21 +00007@end
8
Ted Kremenek63de7362008-12-08 22:01:50 +00009typedef struct objc_selector *SEL;
10
Ted Kremeneke0bb8042008-12-08 21:59:21 +000011// <rdar://problem/6380411>: 'myproperty' has kind 'assign' and thus the
12// assignment through the setter does not perform a release.
13
14@interface MyObject : NSObject {
15 id _myproperty;
16}
17@property(assign) id myproperty;
18@end
19
20@implementation MyObject
21@synthesize myproperty=_myproperty; // no-warning
22- (void)dealloc {
23 self.myproperty = 0;
24 [super dealloc];
25}
26@end
Ted Kremenek63de7362008-12-08 22:01:50 +000027
28//===------------------------------------------------------------------------===
29// Don't warn about iVars that are selectors.
30
31@interface TestSELs : NSObject {
32 SEL a;
33 SEL b;
34}
35
36@end
37
38@implementation TestSELs // no-warning
39- (id)init {
40 if( (self = [super init]) ) {
41 a = @selector(a);
42 b = @selector(b);
43 }
44
45 return self;
46}
47@end
Ted Kremenek26b58cd2008-12-08 22:05:43 +000048
49//===------------------------------------------------------------------------===
50// Don't warn about iVars that are IBOutlets.
51
52#ifndef IBOutlet
53#define IBOutlet
54#endif
55
56@class NSWindow;
57
58@interface HasOutlet : NSObject {
59IBOutlet NSWindow *window;
60}
61@end
62
63@implementation HasOutlet // no-warning
64@end
65
Ted Kremenek183c6f22009-02-10 23:41:52 +000066//===------------------------------------------------------------------------===
67// <rdar://problem/6380411>
68// Was bogus warning: "The '_myproperty' instance variable was not retained by a
69// synthesized property but was released in 'dealloc'"
70
71@interface MyObject_rdar6380411 : NSObject {
72 id _myproperty;
73}
74@property(assign) id myproperty;
75@end
76
77@implementation MyObject_rdar6380411
78@synthesize myproperty=_myproperty;
79- (void)dealloc {
80 // Don't claim that myproperty is released since it the property
81 // has the 'assign' attribute.
82 self.myproperty = 0; // no-warning
83 [super dealloc];
84}
85@end