[cfe-commits] r85423 - /cfe/trunk/lib/Analysis/CheckObjCUnusedIVars.cpp
Ted Kremenek
kremenek at apple.com
Wed Oct 28 13:37:47 PDT 2009
Author: kremenek
Date: Wed Oct 28 15:37:47 2009
New Revision: 85423
URL: http://llvm.org/viewvc/llvm-project?rev=85423&view=rev
Log:
Pull ivar scanning logic into another utility function. This refactoring will enable scanning
categories as well (WIP). No functionality change yet.
Modified:
cfe/trunk/lib/Analysis/CheckObjCUnusedIVars.cpp
Modified: cfe/trunk/lib/Analysis/CheckObjCUnusedIVars.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CheckObjCUnusedIVars.cpp?rev=85423&r1=85422&r2=85423&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/CheckObjCUnusedIVars.cpp (original)
+++ cfe/trunk/lib/Analysis/CheckObjCUnusedIVars.cpp Wed Oct 28 15:37:47 2009
@@ -62,6 +62,21 @@
I->second = Used;
}
+static void Scan(IvarUsageMap& M, const ObjCContainerDecl* D) {
+ // Scan the methods for accesses.
+ for (ObjCContainerDecl::instmeth_iterator I = D->instmeth_begin(),
+ E = D->instmeth_end(); I!=E; ++I)
+ Scan(M, (*I)->getBody());
+
+ if (const ObjCImplementationDecl *ID = dyn_cast<ObjCImplementationDecl>(D)) {
+ // Scan for @synthesized property methods that act as setters/getters
+ // to an ivar.
+ for (ObjCImplementationDecl::propimpl_iterator I = ID->propimpl_begin(),
+ E = ID->propimpl_end(); I!=E; ++I)
+ Scan(M, *I);
+ }
+}
+
void clang::CheckObjCUnusedIvar(const ObjCImplementationDecl *D,
BugReporter &BR) {
@@ -88,16 +103,8 @@
if (M.empty())
return;
- // Now scan the methods for accesses.
- for (ObjCImplementationDecl::instmeth_iterator I = D->instmeth_begin(),
- E = D->instmeth_end(); I!=E; ++I)
- Scan(M, (*I)->getBody());
-
- // Scan for @synthesized property methods that act as setters/getters
- // to an ivar.
- for (ObjCImplementationDecl::propimpl_iterator I = D->propimpl_begin(),
- E = D->propimpl_end(); I!=E; ++I)
- Scan(M, *I);
+ // Now scan the implementation declaration.
+ Scan(M, D);
// Find ivars that are unused.
for (IvarUsageMap::iterator I = M.begin(), E = M.end(); I!=E; ++I)
More information about the cfe-commits
mailing list