926 lines · plain
1// RUN: %clang_analyze_cc1 -analyzer-checker=osx.cocoa.Dealloc -fblocks -triple x86_64-apple-ios4.0 -DMACOS=0 -verify %s2// RUN: %clang_analyze_cc1 -analyzer-checker=osx.cocoa.Dealloc -fblocks -triple x86_64-apple-macosx10.6.0 -DMACOS=1 -verify %s3// RUN: %clang_analyze_cc1 -analyzer-checker=osx.cocoa.Dealloc -fblocks -triple x86_64-apple-darwin10 -fobjc-arc -fobjc-runtime-has-weak -verify %s4 5#include "Inputs/system-header-simulator-for-objc-dealloc.h"6 7#define NON_ARC !__has_feature(objc_arc)8 9#if NON_ARC10#define WEAK_ON_ARC11#else12#define WEAK_ON_ARC __weak13#endif14 15// No diagnostics expected under ARC.16#if !NON_ARC17 // expected-no-diagnostics18#endif19 20// Do not warn about missing release in -dealloc for ivars.21 22@interface MyIvarClass1 : NSObject {23 NSObject *_ivar;24}25@end26 27@implementation MyIvarClass128- (instancetype)initWithIvar:(NSObject *)ivar29{30 self = [super init];31 if (!self)32 return nil;33#if NON_ARC34 _ivar = [ivar retain];35#endif36 return self;37}38- (void)dealloc39{40#if NON_ARC41 [super dealloc];42#endif43}44@end45 46@interface MyIvarClass2 : NSObject {47 NSObject *_ivar;48}49- (NSObject *)ivar;50- (void)setIvar:(NSObject *)ivar;51@end52 53@implementation MyIvarClass254- (instancetype)init55{56 self = [super init];57 return self;58}59- (void)dealloc60{61#if NON_ARC62 [super dealloc];63#endif64}65- (NSObject *)ivar66{67 return _ivar;68}69- (void)setIvar:(NSObject *)ivar70{71#if NON_ARC72 [_ivar release];73 _ivar = [ivar retain];74#else75 _ivar = ivar;76#endif77}78@end79 80// Warn about missing release in -dealloc for properties.81 82@interface MyPropertyClass1 : NSObject83@property (copy) NSObject *ivar;84@end85 86@implementation MyPropertyClass187- (void)dealloc88{89#if NON_ARC90 [super dealloc]; // expected-warning {{The '_ivar' ivar in 'MyPropertyClass1' was copied by a synthesized property but not released before '[super dealloc]'}}91#endif92}93@end94 95@interface MyPropertyClass2 : NSObject96@property (retain) NSObject *ivar;97@end98 99@implementation MyPropertyClass2100- (void)dealloc101{102#if NON_ARC103 [super dealloc]; // expected-warning {{The '_ivar' ivar in 'MyPropertyClass2' was retained by a synthesized property but not released before '[super dealloc]'}}104#endif105}106@end107 108@interface MyPropertyClass3 : NSObject {109 NSObject *_ivar;110}111@property (retain) NSObject *ivar;112@end113 114@implementation MyPropertyClass3115@synthesize ivar = _ivar;116- (void)dealloc117{118#if NON_ARC119 [super dealloc]; // expected-warning {{The '_ivar' ivar in 'MyPropertyClass3' was retained by a synthesized property but not released before '[super dealloc]'}}120#endif121}122 123@end124 125@interface MyPropertyClass4 : NSObject {126 void (^_blockPropertyIvar)(void);127}128@property (copy) void (^blockProperty)(void);129@property (copy) void (^blockProperty2)(void);130@property (copy) void (^blockProperty3)(void);131 132@end133 134@implementation MyPropertyClass4135@synthesize blockProperty = _blockPropertyIvar;136- (void)dealloc137{138#if NON_ARC139 [_blockProperty2 release];140 Block_release(_blockProperty3);141 142 [super dealloc]; // expected-warning {{The '_blockPropertyIvar' ivar in 'MyPropertyClass4' was copied by a synthesized property but not released before '[super dealloc]'}}143#endif144}145@end146 147@interface MyPropertyClass5 : NSObject {148 WEAK_ON_ARC NSObject *_ivar;149}150@property (weak) NSObject *ivar;151@end152 153@implementation MyPropertyClass5154@synthesize ivar = _ivar;155- (void)dealloc156{157#if NON_ARC158 [super dealloc]; // no-warning because it is a weak property159#endif160}161@end162 163@interface MyPropertyClassWithReturnInDealloc : NSObject {164 NSObject *_ivar;165}166@property (retain) NSObject *ivar;167@end168 169@implementation MyPropertyClassWithReturnInDealloc170@synthesize ivar = _ivar;171- (void)dealloc172{173 return;174#if NON_ARC175 // expected-warning@-2{{The '_ivar' ivar in 'MyPropertyClassWithReturnInDealloc' was retained by a synthesized property but not released before '[super dealloc]'}}176 [super dealloc];177#endif178}179@end180 181@interface MyPropertyClassWithReleaseInOtherInstance : NSObject {182 NSObject *_ivar;183 MyPropertyClassWithReleaseInOtherInstance *_other;184}185@property (retain) NSObject *ivar;186 187-(void)releaseIvars;188@end189 190@implementation MyPropertyClassWithReleaseInOtherInstance191@synthesize ivar = _ivar;192 193-(void)releaseIvars; {194#if NON_ARC195 [_ivar release];196#endif197}198 199- (void)dealloc200{201 [_other releaseIvars];202#if NON_ARC203 [super dealloc]; // expected-warning {{The '_ivar' ivar in 'MyPropertyClassWithReleaseInOtherInstance' was retained by a synthesized property but not released before '[super dealloc]'}}204#endif205}206@end207 208@interface MyPropertyClassWithNeitherReturnNorSuperDealloc : NSObject {209 NSObject *_ivar;210}211@property (retain) NSObject *ivar;212@end213 214@implementation MyPropertyClassWithNeitherReturnNorSuperDealloc215@synthesize ivar = _ivar;216- (void)dealloc217{218}219#if NON_ARC220 // expected-warning@-2 {{method possibly missing a [super dealloc] call}} (From Sema)221 // expected-warning@-3{{The '_ivar' ivar in 'MyPropertyClassWithNeitherReturnNorSuperDealloc' was retained by a synthesized property but not released before '[super dealloc]'}}222#endif223@end224 225// 'myproperty' has kind 'assign' and thus the assignment through the setter226// does not perform a release.227 228@interface MyObject : NSObject {229 id __unsafe_unretained _myproperty;230}231@property(assign) id myproperty;232@end233 234@implementation MyObject235@synthesize myproperty=_myproperty; // no-warning236- (void)dealloc {237 // Don't claim that myproperty is released since it the property238 // has the 'assign' attribute.239 self.myproperty = 0; // no-warning240#if NON_ARC241 [super dealloc];242#endif243}244@end245 246@interface ClassWithControlFlowInRelease : NSObject {247 BOOL _ivar1;248}249@property (retain) NSObject *ivar2;250@end251 252@implementation ClassWithControlFlowInRelease253- (void)dealloc; {254 if (_ivar1) {255 // We really should warn because there is a path through -dealloc on which256 // _ivar2 is not released.257#if NON_ARC258 [_ivar2 release];259#endif260 }261 262#if NON_ARC263 [super dealloc]; // expected-warning {{The '_ivar2' ivar in 'ClassWithControlFlowInRelease' was retained by a synthesized property but not released before '[super dealloc]'}}264#endif265}266@end267 268// Don't warn when the property is nil'd out in -dealloc269 270@interface ClassWithNildOutProperty : NSObject271@property (retain) NSObject *ivar;272@property (assign) int *intPtrProp;273@end274 275@implementation ClassWithNildOutProperty276- (void)dealloc; {277 self.ivar = nil;278 279 // Make sure to handle setting a non-retainable property to 0.280 self.intPtrProp = 0;281#if NON_ARC282 [super dealloc]; // no-warning283#endif284}285@end286 287// Do warn when the ivar but not the property is nil'd out in -dealloc288 289@interface ClassWithNildOutIvar : NSObject290@property (retain) NSObject *ivar;291@end292 293@implementation ClassWithNildOutIvar294- (void)dealloc; {295 // Oops. Meant self.ivar = nil296 _ivar = nil;297 298#if NON_ARC299 [super dealloc]; // expected-warning {{The '_ivar' ivar in 'ClassWithNildOutIvar' was retained by a synthesized property but not released before '[super dealloc]'}}300#endif301}302@end303 304// Do warn when the ivar is updated to a different value that is then305// released.306 307@interface ClassWithUpdatedIvar : NSObject308@property (retain) NSObject *ivar;309@end310 311@implementation ClassWithUpdatedIvar312- (void)dealloc; {313 _ivar = [[NSObject alloc] init];314 315#if NON_ARC316 [_ivar release];317#endif318 319#if NON_ARC320 [super dealloc]; // expected-warning {{The '_ivar' ivar in 'ClassWithUpdatedIvar' was retained by a synthesized property but not released before '[super dealloc]'}}321#endif322}323@end324 325 326// Don't warn when the property is nil'd out with a setter in -dealloc327 328@interface ClassWithNildOutPropertyViaSetter : NSObject329@property (retain) NSObject *ivar;330@end331 332@implementation ClassWithNildOutPropertyViaSetter333- (void)dealloc; {334 [self setIvar:nil];335 336#if NON_ARC337 [super dealloc]; // no-warning338#endif339}340@end341 342 343// Don't warn about missing releases when -dealloc helpers are called.344 345@interface ClassWithDeallocHelpers : NSObject346@property (retain) NSObject *ivarReleasedInMethod;347@property (retain) NSObject *propNilledOutInMethod;348 349@property (retain) NSObject *ivarReleasedInFunction;350@property (retain) NSObject *propNilledOutInFunction;351 352@property (retain) NSObject *ivarNeverReleased;353- (void)invalidateInMethod;354@end355 356void ReleaseValueHelper(NSObject *iv) {357#if NON_ARC358 [iv release];359#endif360}361 362void NilOutPropertyHelper(ClassWithDeallocHelpers *o) {363 o.propNilledOutInFunction = nil;364}365 366@implementation ClassWithDeallocHelpers367- (void)invalidateInMethod {368#if NON_ARC369 [_ivarReleasedInMethod release];370#endif371 self.propNilledOutInMethod = nil;372}373 374- (void)dealloc; {375 ReleaseValueHelper(_ivarReleasedInFunction);376 NilOutPropertyHelper(self);377 378 [self invalidateInMethod];379#if NON_ARC380 [super dealloc]; // expected-warning {{The '_ivarNeverReleased' ivar in 'ClassWithDeallocHelpers' was retained by a synthesized property but not released before '[super dealloc]'}}381#endif382}383@end384 385 386// Don't warn when self in -dealloc escapes.387 388@interface ClassWhereSelfEscapesViaMethodCall : NSObject389@property (retain) NSObject *ivar; // no-warning390@end391 392@interface ClassWhereSelfEscapesViaMethodCall (Other)393- (void)invalidate; // In other translation unit.394@end395 396@implementation ClassWhereSelfEscapesViaMethodCall397- (void)dealloc; {398 [self invalidate];399#if NON_ARC400 [super dealloc];401#endif402} // no-warning403@end404 405@interface ClassWhereSelfEscapesViaPropertyAccess : NSObject406@property (retain) NSObject *ivar;407@end408 409@interface ClassWhereSelfEscapesViaPropertyAccess (Other)410// The implementation of this property is unknown and therefore could411// release ivar.412@property (retain) NSObject *otherIvar;413@end414 415@implementation ClassWhereSelfEscapesViaPropertyAccess416- (void)dealloc; {417 self.otherIvar = nil;418#if NON_ARC419 [super dealloc];420#endif421} // no-warning422@end423 424// Don't treat self as escaping when setter called on *synthesized*425// property.426 427@interface ClassWhereSelfEscapesViaSynthesizedPropertyAccess : NSObject428@property (retain) NSObject *ivar;429@property (retain) NSObject *otherIvar;430@end431 432@implementation ClassWhereSelfEscapesViaSynthesizedPropertyAccess433- (void)dealloc; {434 self.otherIvar = nil;435#if NON_ARC436 [super dealloc]; // expected-warning {{The '_ivar' ivar in 'ClassWhereSelfEscapesViaSynthesizedPropertyAccess' was retained by a synthesized property but not released before '[super dealloc]'}}437#endif438}439@end440 441 442// Don't treat calls to system headers as escapes443 444@interface ClassWhereSelfEscapesViaCallToSystem : NSObject445@property (retain) NSObject *ivar1;446@property (retain) NSObject *ivar2;447@property (retain) NSObject *ivar3;448@property (retain) NSObject *ivar4;449@property (retain) NSObject *ivar5;450@property (retain) NSObject *ivar6;451@end452 453@implementation ClassWhereSelfEscapesViaCallToSystem454- (void)dealloc; {455#if NON_ARC456 [_ivar2 release];457 if (_ivar3) {458 [_ivar3 release];459 }460#endif461 462 [[NSRunLoop currentRunLoop] cancelPerformSelectorsWithTarget:self];463 [[NSNotificationCenter defaultCenter] removeObserver:self];464 465#if NON_ARC466 [_ivar4 release];467 468 if (_ivar5) {469 [_ivar5 release];470 }471#endif472 473 [[NSNotificationCenter defaultCenter] removeObserver:self];474 475#if NON_ARC476 if (_ivar6) {477 [_ivar6 release];478 }479 480 [super dealloc]; // expected-warning {{The '_ivar1' ivar in 'ClassWhereSelfEscapesViaCallToSystem' was retained by a synthesized property but not released before '[super dealloc]'}}481#endif482}483@end484 485// Don't warn when value escapes.486 487@interface ClassWhereIvarValueEscapes : NSObject488@property (retain) NSObject *ivar;489@end490 491void ReleaseMe(id arg);492 493@implementation ClassWhereIvarValueEscapes494- (void)dealloc; {495 496 ReleaseMe(_ivar);497 498#if NON_ARC499 [super dealloc];500#endif501} // no-warning502@end503 504// Don't warn when value is known to be nil.505 506@interface ClassWhereIvarIsNil : NSObject507@property (retain) NSObject *ivarIsNil;508@end509 510@implementation ClassWhereIvarIsNil511- (void)dealloc; {512 513#if NON_ARC514 if (_ivarIsNil)515 [_ivarIsNil release];516 517 [super dealloc];518#endif519} // no-warning520@end521 522 523// Don't warn for non-retainable properties.524 525@interface ClassWithNonRetainableProperty : NSObject526@property (assign) int *ivar; // no-warning527@end528 529@implementation ClassWithNonRetainableProperty530- (void)dealloc; {531#if NON_ARC532 [super dealloc];533#endif534} // no-warning535@end536 537 538@interface SuperClassOfClassWithInlinedSuperDealloc : NSObject539@property (retain) NSObject *propInSuper;540@end541 542@implementation SuperClassOfClassWithInlinedSuperDealloc543- (void)dealloc {544#if NON_ARC545 [super dealloc]; // expected-warning {{The '_propInSuper' ivar in 'SuperClassOfClassWithInlinedSuperDealloc' was retained by a synthesized property but not released before '[super dealloc]'}}546#endif547}548@end549 550@interface ClassWithInlinedSuperDealloc : SuperClassOfClassWithInlinedSuperDealloc551@property (retain) NSObject *propInSub;552@end553 554@implementation ClassWithInlinedSuperDealloc555- (void)dealloc {556#if NON_ARC557 [super dealloc]; // expected-warning {{The '_propInSub' ivar in 'ClassWithInlinedSuperDealloc' was retained by a synthesized property but not released before '[super dealloc]'}}558#endif559}560@end561 562 563@interface SuperClassOfClassWithInlinedSuperDeallocAndInvalidation : NSObject564@property (retain) NSObject *propInSuper;565 566- (void)invalidate;567@end568 569@implementation SuperClassOfClassWithInlinedSuperDeallocAndInvalidation570 571- (void)invalidate {572#if NON_ARC573 [_propInSuper release];574#endif575 _propInSuper = nil;576}577 578- (void)dealloc {579 [self invalidate];580#if NON_ARC581 [super dealloc]; // no-warning582#endif583}584@end585 586@interface ClassWithInlinedSuperDeallocAndInvalidation : SuperClassOfClassWithInlinedSuperDeallocAndInvalidation587@property (retain) NSObject *propInSub;588@end589 590@implementation ClassWithInlinedSuperDeallocAndInvalidation591 592- (void)invalidate {593#if NON_ARC594 [_propInSub release];595#endif596 [super invalidate];597}598 599- (void)dealloc {600#if NON_ARC601 [super dealloc]; // no-warning602#endif603}604@end605 606 607@interface SuperClassOfClassThatEscapesBeforeInliningSuper : NSObject608@property (retain) NSObject *propInSuper;609@end610 611@implementation SuperClassOfClassThatEscapesBeforeInliningSuper612 613- (void)dealloc {614 615#if NON_ARC616 [super dealloc]; // expected-warning {{The '_propInSuper' ivar in 'SuperClassOfClassThatEscapesBeforeInliningSuper' was retained by a synthesized property but not released before '[super dealloc]'}}617#endif618}619@end620 621@interface ClassThatEscapesBeforeInliningSuper : SuperClassOfClassThatEscapesBeforeInliningSuper622@property (retain) NSObject *propInSub;623@end624 625@interface ClassThatEscapesBeforeInliningSuper (Other)626- (void)invalidate; // No implementation in translation unit.627@end628 629@implementation ClassThatEscapesBeforeInliningSuper630- (void)dealloc {631 [self invalidate];632 633#if NON_ARC634 [super dealloc]; // no-warning635#endif636}637@end638 639 640#if NON_ARC641@interface ReleaseIvarInField : NSObject {642 int _tag;643 union {644 NSObject *field1;645 NSObject *field2;646 } _someUnion;647 648 struct {649 NSObject *field1;650 } _someStruct;651}652@end653 654@implementation ReleaseIvarInField655- (void)dealloc {656 if (_tag) {657 [_someUnion.field1 release];658 } else {659 [_someUnion.field2 release];660 }661 662 [_someStruct.field1 release];663 [super dealloc];664}665@end666#endif667 668struct SomeStruct {669 int f;670};671@interface ZeroOutStructWithSetter : NSObject672 @property(assign) struct SomeStruct s;673@end674 675@implementation ZeroOutStructWithSetter676- (void)dealloc {677 struct SomeStruct zeroedS;678 zeroedS.f = 0;679 680 self.s = zeroedS;681#if NON_ARC682 [super dealloc];683#endif684}685@end686 687#if NON_ARC688@interface ReleaseIvarInArray : NSObject {689 NSObject *_array[3];690}691@end692 693@implementation ReleaseIvarInArray694- (void)dealloc {695 for (int i = 0; i < 3; i++) {696 [_array[i] release];697 }698 [super dealloc];699}700@end701#endif702 703// Don't warn about missing releases for subclasses of SenTestCase or704// for classes that are not subclasses of NSObject.705 706@interface SenTestCase : NSObject {}707@end708 709@interface MyClassTest : SenTestCase710@property (retain) NSObject *ivar;711@end712 713@implementation MyClassTest714-(void)tearDown {715#if NON_ARC716 [_ivar release];717#endif718}719 720-(void)dealloc; {721#if NON_ARC722 [super dealloc]; // no-warning723#endif724}725@end726 727@interface XCTestCase : NSObject {}728@end729 730@interface MyClassXCTest : XCTestCase731@property (retain) NSObject *ivar;732@end733 734@implementation MyClassXCTest735-(void)tearDown {736#if NON_ARC737 [_ivar release];738#endif739}740 741-(void)dealloc; {742#if NON_ARC743 [super dealloc]; // no-warning744#endif745}746@end747 748 749__attribute__((objc_root_class))750@interface NonNSObjectMissingDealloc751@property (retain) NSObject *ivar;752@end753@implementation NonNSObjectMissingDealloc754-(void)dealloc; {755 756}757@end758 759// Warn about calling -dealloc rather than release by mistake.760 761@interface CallDeallocOnRetainPropIvar : NSObject {762 NSObject *okToDeallocDirectly;763}764 765@property (retain) NSObject *ivar;766@end767 768@implementation CallDeallocOnRetainPropIvar769- (void)dealloc770{771#if NON_ARC772 // Only warn for synthesized ivars.773 [okToDeallocDirectly dealloc]; // no-warning774 [_ivar dealloc]; // expected-warning {{'_ivar' should be released rather than deallocated}}775 776 [super dealloc];777#endif778}779@end780 781// CIFilter special cases.782// By design, -[CIFilter dealloc] releases (by calling -setValue: forKey: with783// 'nil') all ivars (even in its *subclasses*) with names starting with784// 'input' or that are backed by properties with names starting with 'input'.785// The Dealloc checker needs to take particular care to not warn about missing786// releases in this case -- if the user adds a release quiet the787// warning it may result in an over release.788 789@interface ImmediateSubCIFilter : CIFilter {790 NSObject *inputIvar;791 NSObject *nonInputIvar;792 NSObject *notPrefixedButBackingPrefixedProperty;793 NSObject *inputPrefixedButBackingNonPrefixedProperty;794}795 796@property(retain) NSObject *inputIvar;797@property(retain) NSObject *nonInputIvar;798@property(retain) NSObject *inputAutoSynthesizedIvar;799@property(retain) NSObject *inputExplicitlySynthesizedToNonPrefixedIvar;800@property(retain) NSObject *nonPrefixedPropertyBackedByExplicitlySynthesizedPrefixedIvar;801 802@end803 804@implementation ImmediateSubCIFilter805@synthesize inputIvar = inputIvar;806@synthesize nonInputIvar = nonInputIvar;807@synthesize inputExplicitlySynthesizedToNonPrefixedIvar = notPrefixedButBackingPrefixedProperty;808@synthesize nonPrefixedPropertyBackedByExplicitlySynthesizedPrefixedIvar = inputPrefixedButBackingNonPrefixedProperty;809 810- (void)dealloc {811#if NON_ARC812 // We don't want warnings here for:813 // inputIvar814 // inputAutoSynthesizedIvar815 // inputExplicitlySynthesizedToNonPrefixedIvar816 // inputPrefixedButBackingNonPrefixedProperty817 [super dealloc];818 // expected-warning@-1 {{The 'nonInputIvar' ivar in 'ImmediateSubCIFilter' was retained by a synthesized property but not released before '[super dealloc]'}}819#endif820}821@end822 823@interface SubSubCIFilter : CIFilter {824 NSObject *inputIvarInSub;825}826 827@property(retain) NSObject *inputIvarInSub;828@end829 830@implementation SubSubCIFilter831@synthesize inputIvarInSub = inputIvarInSub;832 833- (void)dealloc {834// Don't warn about inputIvarInSub.835#if NON_ARC836 [super dealloc];837#endif838}839@end840@interface OverreleasingCIFilter : CIFilter {841 NSObject *inputIvar;842}843 844@property(retain) NSObject *inputIvar;845@end846 847@implementation OverreleasingCIFilter848@synthesize inputIvar = inputIvar;849 850- (void)dealloc {851#if NON_ARC852 // This is an over release because CIFilter's dealloc will also release it.853 [inputIvar release]; // expected-warning {{The 'inputIvar' ivar in 'OverreleasingCIFilter' will be released by '-[CIFilter dealloc]' but also released here}}854 [super dealloc]; // no-warning855 #endif856}857@end858 859 860@interface NotMissingDeallocCIFilter : CIFilter {861 NSObject *inputIvar;862}863 864@property(retain) NSObject *inputIvar;865@end866 867@implementation NotMissingDeallocCIFilter // no-warning868@synthesize inputIvar = inputIvar;869@end870 871 872@interface ClassWithRetainPropWithIBOutletIvarButNoSetter : NSObject {873 // On macOS, the nib-loading code will set the ivar directly without874 // retaining value (unike iOS, where it is retained). This means that875 // on macOS we should not warn about a missing release for a property backed876 // by an IBOutlet ivar when that property does not have a setter.877 IBOutlet NSObject *ivarForOutlet;878}879 880@property (readonly, retain) NSObject *ivarForOutlet;881@end882 883@implementation ClassWithRetainPropWithIBOutletIvarButNoSetter884 885@synthesize ivarForOutlet;886- (void)dealloc {887 888#if NON_ARC889 [super dealloc];890#if !MACOS891// expected-warning@-2{{The 'ivarForOutlet' ivar in 'ClassWithRetainPropWithIBOutletIvarButNoSetter' was retained by a synthesized property but not released before '[super dealloc]'}}892#endif893#endif894}895 896@end897 898@interface ClassWithRetainPropWithIBOutletIvarAndShadowingReadWrite : NSObject {899 IBOutlet NSObject *ivarForOutlet;900}901 902@property (readonly, retain) NSObject *ivarForOutlet;903 904@end905 906@interface ClassWithRetainPropWithIBOutletIvarAndShadowingReadWrite ()907 908// Since there is a shadowing readwrite property, there will be a retaining909// setter and so the ivar will be retained by nib-loading code even on910// macOS and therefore must be released.911@property (readwrite, retain) NSObject *ivarForOutlet;912@end913 914@implementation ClassWithRetainPropWithIBOutletIvarAndShadowingReadWrite915 916@synthesize ivarForOutlet;917- (void)dealloc {918 919#if NON_ARC920 [super dealloc];921// expected-warning@-1{{The 'ivarForOutlet' ivar in 'ClassWithRetainPropWithIBOutletIvarAndShadowingReadWrite' was retained by a synthesized property but not released before '[super dealloc]'}}922#endif923}924 925@end926