1 // RUN: %clang_analyze_cc1 -analyzer-checker=core,osx.cocoa.RetainCount,osx.cocoa.SelfInit -analyzer-config ipa=dynamic-bifurcate -verify %s
3 typedef signed char BOOL;
4 typedef struct objc_class *Class;
5 typedef struct objc_object {
8 @protocol NSObject - (BOOL)isEqual:(id)object; @end
9 @interface NSObject <NSObject> {}
12 - (oneway void)release;
20 // We do not want to overhelm user with error messages in case they forgot to
21 // assign to self and check that the result of [super init] is non-nil. So
22 // stop tracking the receiver of init with respect to Retain Release checker.
24 @interface ParentOfCell : NSObject
25 - (id)initWithInt: (int)inInt;
27 @interface Cell : ParentOfCell{
38 self.x = 3; // no-warning
39 return self; // expected-warning {{Returning 'self' while it is not set to the result of '[(super or self)}}
41 - (id) initWithInt: (int)inInt {
42 [super initWithInt: inInt];
43 self.x = inInt; // no-warning
44 return self; // expected-warning {{Returning 'self' while it is not set to the result of '[(super or self)}}
47 [self init]; // The call [self init] is inlined. We will warn inside the inlined body.
48 self.x = 2; // no-warning
52 - (id) initWithIntGood: (int)inInt {
53 if (self = [super initWithInt: inInt]) {
59 Cell *sharedCell1 = [[Cell alloc] init];
60 [sharedCell1 release];
61 Cell *sharedCell2 = [[Cell alloc] initWithInt: 3];
62 [sharedCell2 release];
63 Cell *sharedCell3 = [[Cell alloc] initWithIntGood: 3];
64 [sharedCell3 release];