xref: /llvm-project/clang/test/ARCMT/remove-dealloc-zerouts.m (revision 9b0a7cea0f5bb2d3197ff33734cc5411ea793e10)
1*9b0a7ceaSJohn McCall// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result
2*9b0a7ceaSJohn McCall// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t
3d70fb981SJohn McCall// RUN: diff %t %s.result
4d70fb981SJohn McCall
5d70fb981SJohn McCall@interface Foo
6d70fb981SJohn McCall@property (retain) id x;
7d70fb981SJohn McCall@property (retain) id y;
8d70fb981SJohn McCall@property (retain) id w;
9d70fb981SJohn McCall@property (retain) id z;
10d70fb981SJohn McCall@property (strong) id q;
11d70fb981SJohn McCall@end
12d70fb981SJohn McCall
13d70fb981SJohn McCall@implementation Foo
14d70fb981SJohn McCall@synthesize x;
15d70fb981SJohn McCall@synthesize y;
16d70fb981SJohn McCall@synthesize w;
17d70fb981SJohn McCall@synthesize q;
18d70fb981SJohn McCall@dynamic z;
19d70fb981SJohn McCall
20d70fb981SJohn McCall- (void) dealloc {
21d70fb981SJohn McCall  self.x = self.y = self.w = 0;
22d70fb981SJohn McCall  self.x = 0, w = 0, y = 0;
23d70fb981SJohn McCall  [self setY:0];
24d70fb981SJohn McCall  w = 0;
25d70fb981SJohn McCall  q = 0;
26d70fb981SJohn McCall  self.z = 0;
27d70fb981SJohn McCall}
28d70fb981SJohn McCall@end
29d70fb981SJohn McCall
30d70fb981SJohn McCall@interface Bar
31d70fb981SJohn McCall@property (retain) Foo *a;
32d70fb981SJohn McCall- (void) setA:(Foo*) val;
33d70fb981SJohn McCall- (id) a;
34d70fb981SJohn McCall@end
35d70fb981SJohn McCall
36d70fb981SJohn McCall@implementation Bar
37d70fb981SJohn McCall- (void) dealloc {
38d70fb981SJohn McCall  [self setA:0];  // This is user-defined setter overriding synthesize, don't touch it.
39d70fb981SJohn McCall  self.a.x = 0;  // every dealloc must zero out its own ivar. This patter is not recognized.
40d70fb981SJohn McCall}
41e1506cbfSFariborz Jahanian@synthesize a;
42d70fb981SJohn McCall- (void) setA:(Foo*) val { }
43d70fb981SJohn McCall- (id) a {return 0;}
44d70fb981SJohn McCall@end
45