aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnna Zaks <ganna@apple.com>2012-10-16 19:36:37 +0000
committerAnna Zaks <ganna@apple.com>2012-10-16 19:36:37 +0000
commite0c50fa01d59749e9392ccff50ee6fb90a61725b (patch)
treee9a5d2151e72ad6f80611b96dc3f25790c93668d
parent97f81573636068fb9536436188caadf030584e58 (diff)
[analyzer] Ivar Invalidation: track ivars in continuations and
@implementation. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166047 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp10
-rw-r--r--test/Analysis/objc_invalidation.m11
2 files changed, 15 insertions, 6 deletions
diff --git a/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp b/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp
index 462066af57..e52e3d42e2 100644
--- a/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp
+++ b/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp
@@ -314,12 +314,12 @@ void IvarInvalidationChecker::checkASTDecl(const ObjCMethodDecl *D,
// Collect all ivars that need cleanup.
IvarSet Ivars;
const ObjCInterfaceDecl *InterfaceD = D->getClassInterface();
- for (ObjCInterfaceDecl::ivar_iterator
- II = InterfaceD->ivar_begin(),
- IE = InterfaceD->ivar_end(); II != IE; ++II) {
- const ObjCIvarDecl *Iv = *II;
+
+ // Collect ivars declared in this class, its extensions and its implementation
+ ObjCInterfaceDecl *IDecl = const_cast<ObjCInterfaceDecl *>(InterfaceD);
+ for (const ObjCIvarDecl *Iv = IDecl->all_declared_ivar_begin(); Iv;
+ Iv= Iv->getNextIvar())
trackIvar(Iv, Ivars);
- }
// Construct Property/Property Accessor to Ivar maps to assist checking if an
// ivar which is backing a property has been reset.
diff --git a/test/Analysis/objc_invalidation.m b/test/Analysis/objc_invalidation.m
index adcbbd62af..17b74e90c5 100644
--- a/test/Analysis/objc_invalidation.m
+++ b/test/Analysis/objc_invalidation.m
@@ -93,7 +93,14 @@ extern void NSLog(NSString *format, ...) __attribute__((format(__NSString__, 1,
@end
-@implementation SomeSubclassInvalidatableObject
+@interface SomeSubclassInvalidatableObject()
+@property (assign) SomeInvalidationImplementingObject* Prop8;
+@end
+
+@implementation SomeSubclassInvalidatableObject{
+ @private
+ SomeInvalidationImplementingObject *Ivar5;
+}
@synthesize Prop7 = _propIvar;
@synthesize Prop3 = _Prop3;
@@ -139,4 +146,6 @@ extern void NSLog(NSString *format, ...) __attribute__((format(__NSString__, 1,
// expected-warning@-4 {{Property SynthIvarProp needs to be invalidated}}
// 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