]> granicus.if.org Git - clang/commitdiff
Unused ivars checker: also check methods in categories that are defined in the same...
authorTed Kremenek <kremenek@apple.com>
Wed, 28 Oct 2009 22:18:22 +0000 (22:18 +0000)
committerTed Kremenek <kremenek@apple.com>
Wed, 28 Oct 2009 22:18:22 +0000 (22:18 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85442 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/CheckObjCUnusedIVars.cpp
test/Analysis/unused-ivars.m

index 6c942aaafc08682cb032597326178c3a9aac610c..2d9b53163f6adf220a0dd19d2aeca9b48c43546a 100644 (file)
@@ -74,6 +74,14 @@ static void Scan(IvarUsageMap& M, const ObjCContainerDecl* D) {
     for (ObjCImplementationDecl::propimpl_iterator I = ID->propimpl_begin(),
          E = ID->propimpl_end(); I!=E; ++I)
       Scan(M, *I);
+    
+    // Scan the associated categories as well.
+    for (const ObjCCategoryDecl *CD =
+          ID->getClassInterface()->getCategoryList(); CD ;
+          CD = CD->getNextClassCategory()) {
+      if (const ObjCCategoryImplDecl *CID = CD->getImplementation())
+        Scan(M, CID);
+    }
   }
 }
 
index aacd44e7e6777985450358100a83e9274563ae36..9e9360da50c6ee1c1f71637cc36514278bf6785a 100644 (file)
   b();
 }
 @end
+
+//===----------------------------------------------------------------------===//
+// <rdar://problem/6260004> Detect that ivar is in use, if used in category 
+//  in the same file as the implementation
+//===----------------------------------------------------------------------===//
+
+@protocol Protocol6260004
+- (id) getId;
+@end
+
+@interface RDar6260004 {
+@private
+  id x; // no-warning
+}
+@end
+@implementation RDar6260004 @end
+@implementation RDar6260004 (Protocol6260004)
+- (id) getId {
+  return x;
+}
+@end
+