[cfe-commits] r85442 - in /cfe/trunk: lib/Analysis/CheckObjCUnusedIVars.cpp test/Analysis/unused-ivars.m
Ted Kremenek
kremenek at apple.com
Wed Oct 28 15:18:22 PDT 2009
Author: kremenek
Date: Wed Oct 28 17:18:22 2009
New Revision: 85442
URL: http://llvm.org/viewvc/llvm-project?rev=85442&view=rev
Log:
Unused ivars checker: also check methods in categories that are defined in the same translation unit. Fixes <rdar://problem/6260004>.
Modified:
cfe/trunk/lib/Analysis/CheckObjCUnusedIVars.cpp
cfe/trunk/test/Analysis/unused-ivars.m
Modified: cfe/trunk/lib/Analysis/CheckObjCUnusedIVars.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CheckObjCUnusedIVars.cpp?rev=85442&r1=85441&r2=85442&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/CheckObjCUnusedIVars.cpp (original)
+++ cfe/trunk/lib/Analysis/CheckObjCUnusedIVars.cpp Wed Oct 28 17:18:22 2009
@@ -74,6 +74,14 @@
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);
+ }
}
}
Modified: cfe/trunk/test/Analysis/unused-ivars.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/unused-ivars.m?rev=85442&r1=85441&r2=85442&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/unused-ivars.m (original)
+++ cfe/trunk/test/Analysis/unused-ivars.m Wed Oct 28 17:18:22 2009
@@ -43,3 +43,25 @@
b();
}
@end
+
+//===----------------------------------------------------------------------===//
+// <rdar://problem/6260004> Detect that ivar is in use, if used in category
+// in the same file as the implementation
+//===----------------------------------------------------------------------===//
+
+ at protocol Protocol6260004
+- (id) getId;
+ at end
+
+ at interface RDar6260004 {
+ at private
+ id x; // no-warning
+}
+ at end
+ at implementation RDar6260004 @end
+ at implementation RDar6260004 (Protocol6260004)
+- (id) getId {
+ return x;
+}
+ at end
+
More information about the cfe-commits
mailing list