summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnna Zaks <ganna@apple.com>2012-10-18 19:17:57 +0000
committerAnna Zaks <ganna@apple.com>2012-10-18 19:17:57 +0000
commit92898a79ebd327cce331e002d2940b402de85a92 (patch)
treeab67573dfb4abe2c6828f7db87f10f1545a981e5
parent673d76b0bc31cddc357cf071aa55d21d32fb3f40 (diff)
downloadbcm5719-llvm-92898a79ebd327cce331e002d2940b402de85a92.tar.gz
bcm5719-llvm-92898a79ebd327cce331e002d2940b402de85a92.zip
[analyzer] Ivar invalidation: identify properties declared in protocols.
llvm-svn: 166211
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp14
-rw-r--r--clang/test/Analysis/objc_invalidation.m6
2 files changed, 13 insertions, 7 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp
index e52e3d42e25..bf256cd9fa4 100644
--- a/clang/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp
@@ -327,10 +327,13 @@ void IvarInvalidationChecker::checkASTDecl(const ObjCMethodDecl *D,
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 @@ void IvarInvalidationChecker::checkASTDecl(const ObjCMethodDecl *D,
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";
diff --git a/clang/test/Analysis/objc_invalidation.m b/clang/test/Analysis/objc_invalidation.m
index 17b74e90c50..357c5e8f607 100644
--- a/clang/test/Analysis/objc_invalidation.m
+++ b/clang/test/Analysis/objc_invalidation.m
@@ -63,6 +63,7 @@ extern void NSLog(NSString *format, ...) __attribute__((format(__NSString__, 1,
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 @@ extern void NSLog(NSString *format, ...) __attribute__((format(__NSString__, 1,
@synthesize Prop3 = _Prop3;
@synthesize Prop5 = _Prop5;
@synthesize Prop4 = _Prop4;
+@synthesize Prop8 = _Prop8;
- (void) setProp1: (SomeInvalidationImplementingObject*) InObj {
@@ -133,6 +135,7 @@ extern void NSLog(NSString *format, ...) __attribute__((format(__NSString__, 1,
[self setProp3:0];
[[self Prop5] invalidate2];
[self.Prop4 invalidate];
+ [self.Prop8 invalidate];
self.Prop6 = 0;
[[self Prop7] invalidate];
@@ -143,9 +146,8 @@ extern void NSLog(NSString *format, ...) __attribute__((format(__NSString__, 1,
// 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
OpenPOWER on IntegriCloud