Author: zaks Date: Thu Oct 18 14:17:57 2012 New Revision: 166211 URL: http://llvm.org/viewvc/llvm-project?rev=166211&view=rev Log: [analyzer] Ivar invalidation: identify properties declared in protocols.
Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp cfe/trunk/test/Analysis/objc_invalidation.m Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp?rev=166211&r1=166210&r2=166211&view=diff ============================================================================== --- cfe/trunk/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp Thu Oct 18 14:17:57 2012 @@ -327,10 +327,13 @@ MethToIvarMapTy PropGetterToIvarMap; PropToIvarMapTy PropertyToIvarMap; IvarToPropMapTy IvarToPopertyMap; - for (ObjCInterfaceDecl::prop_iterator - I = InterfaceD->prop_begin(), - E = InterfaceD->prop_end(); I != E; ++I) { - const ObjCPropertyDecl *PD = *I; + + ObjCInterfaceDecl::PropertyMap PropMap; + InterfaceD->collectPropertiesToImplement(PropMap); + + for (ObjCInterfaceDecl::PropertyMap::iterator + I = PropMap.begin(), E = PropMap.end(); I != E; ++I) { + const ObjCPropertyDecl *PD = I->second; const ObjCIvarDecl *ID = findPropertyBackingIvar(PD, InterfaceD, Ivars); if (!ID) { @@ -386,7 +389,8 @@ const ObjCPropertyDecl *PD = IvarToPopertyMap[IvarDecl]; assert(PD && "Do we synthesize ivars for something other than properties?"); - os << "Property "<< PD->getName() << " needs to be invalidated"; + os << "Property "<< PD->getName() << + " needs to be invalidated or set to nil"; } else { os << "Instance variable "<< IvarDecl->getName() << " needs to be invalidated or set to nil"; Modified: cfe/trunk/test/Analysis/objc_invalidation.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/objc_invalidation.m?rev=166211&r1=166210&r2=166211&view=diff ============================================================================== --- cfe/trunk/test/Analysis/objc_invalidation.m (original) +++ cfe/trunk/test/Analysis/objc_invalidation.m Thu Oct 18 14:17:57 2012 @@ -63,6 +63,7 @@ SomeInvalidationImplementingObject *_Prop3; // property, invalidate via sending a message to a getter method SomeInvalidationImplementingObject *_Prop4; // property with @synthesize, invalidate via property SomeInvalidationImplementingObject *_Prop5; // property with @synthesize, invalidate via getter method + SomeInvalidationImplementingObject *_Prop8; // No warnings on these as they are not invalidatable. NSObject *NIvar1; @@ -106,6 +107,7 @@ @synthesize Prop3 = _Prop3; @synthesize Prop5 = _Prop5; @synthesize Prop4 = _Prop4; +@synthesize Prop8 = _Prop8; - (void) setProp1: (SomeInvalidationImplementingObject*) InObj { @@ -133,6 +135,7 @@ [self setProp3:0]; [[self Prop5] invalidate2]; [self.Prop4 invalidate]; + [self.Prop8 invalidate]; self.Prop6 = 0; [[self Prop7] invalidate]; @@ -143,9 +146,8 @@ // expected-warning@-1 {{Instance variable Ivar1 needs to be invalidated}} // expected-warning@-2 {{Instance variable MultipleProtocols needs to be invalidated}} // expected-warning@-3 {{Instance variable MultInheritance needs to be invalidated}} - // expected-warning@-4 {{Property SynthIvarProp needs to be invalidated}} + // expected-warning@-4 {{Property SynthIvarProp needs to be invalidated or set to nil}} // expected-warning@-5 {{Instance variable _Ivar3 needs to be invalidated}} // expected-warning@-6 {{Instance variable _Ivar4 needs to be invalidated}} // expected-warning@-7 {{Instance variable Ivar5 needs to be invalidated or set to nil}} - // expected-warning@-8 {{Property Prop8 needs to be invalidated}} @end _______________________________________________ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits