[cfe-commits] r172168 - in /cfe/trunk: lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp test/Analysis/objc_invalidation.m
Anna Zaks
ganna at apple.com
Thu Jan 10 19:52:37 PST 2013
Author: zaks
Date: Thu Jan 10 21:52:37 2013
New Revision: 172168
URL: http://llvm.org/viewvc/llvm-project?rev=172168&view=rev
Log:
[analyzer] Ivar invalidation: track ivars declared in categories.
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=172168&r1=172167&r2=172168&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp Thu Jan 10 21:52:37 2013
@@ -227,15 +227,23 @@
}
// If interface, check all parent protocols and super.
- // TODO: Visit all categories in case the invalidation method is declared in
- // a category.
- if (const ObjCInterfaceDecl *InterfaceD = dyn_cast<ObjCInterfaceDecl>(D)) {
+ if (const ObjCInterfaceDecl *InterfD = dyn_cast<ObjCInterfaceDecl>(D)) {
+
+ // Visit all protocols.
for (ObjCInterfaceDecl::protocol_iterator
- I = InterfaceD->protocol_begin(),
- E = InterfaceD->protocol_end(); I != E; ++I) {
+ I = InterfD->protocol_begin(),
+ E = InterfD->protocol_end(); I != E; ++I) {
containsInvalidationMethod(*I, OutInfo);
}
- containsInvalidationMethod(InterfaceD->getSuperClass(), OutInfo);
+
+ // Visit all categories in case the invalidation method is declared in
+ // a category.
+ for (const ObjCCategoryDecl *I = InterfD->getFirstClassExtension(); I;
+ I = I->getNextClassExtension()) {
+ containsInvalidationMethod(I, OutInfo);
+ }
+
+ containsInvalidationMethod(InterfD->getSuperClass(), OutInfo);
return;
}
@@ -249,7 +257,7 @@
return;
}
- llvm_unreachable("One of the casts above should have succeeded.");
+ return;
}
bool IvarInvalidationChecker::trackIvar(const ObjCIvarDecl *Iv,
Modified: cfe/trunk/test/Analysis/objc_invalidation.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/objc_invalidation.m?rev=172168&r1=172167&r2=172168&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/objc_invalidation.m (original)
+++ cfe/trunk/test/Analysis/objc_invalidation.m Thu Jan 10 21:52:37 2013
@@ -41,6 +41,13 @@
@interface Invalidation1Class <Invalidation1>
@end
+ at interface ClassWithInvalidationMethodInCategory <NSObject>
+ at end
+
+ at interface ClassWithInvalidationMethodInCategory ()
+- (void) invalidate __attribute__((annotate("objc_instance_variable_invalidator")));
+ at end
+
@interface SomeInvalidationImplementingObject: NSObject <Invalidation3, Invalidation2> {
SomeInvalidationImplementingObject *ObjA; // invalidation in the parent
}
@@ -107,6 +114,7 @@
@implementation SomeSubclassInvalidatableObject{
@private
SomeInvalidationImplementingObject *Ivar5;
+ ClassWithInvalidationMethodInCategory *Ivar13;
}
@synthesize Prop7 = _propIvar;
@@ -156,6 +164,7 @@
// expected-warning at -5 {{Instance variable _Ivar3 needs to be invalidated}}
// expected-warning at -6 {{Instance variable _Ivar4 needs to be invalidated}}
// expected-warning at -7 {{Instance variable Ivar5 needs to be invalidated or set to nil}}
+// expected-warning at -8 {{Instance variable Ivar13 needs to be invalidated or set to nil}}
@end
// Example, where the same property is inherited through
More information about the cfe-commits
mailing list