diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-10-28 20:37:47 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-10-28 20:37:47 +0000 |
commit | faba9fe5e49727f7d95526543f54589bf97eb05e (patch) | |
tree | bc5479907203d1912e0ed5d90a1111368e3b54e2 | |
parent | a0c0d88ba8b088aa6551f8f64fdf8cbb51c4df15 (diff) | |
download | bcm5719-llvm-faba9fe5e49727f7d95526543f54589bf97eb05e.tar.gz bcm5719-llvm-faba9fe5e49727f7d95526543f54589bf97eb05e.zip |
Pull ivar scanning logic into another utility function. This refactoring will enable scanning
categories as well (WIP). No functionality change yet.
llvm-svn: 85423
-rw-r--r-- | clang/lib/Analysis/CheckObjCUnusedIVars.cpp | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/clang/lib/Analysis/CheckObjCUnusedIVars.cpp b/clang/lib/Analysis/CheckObjCUnusedIVars.cpp index 1a900f89767..6c942aaafc0 100644 --- a/clang/lib/Analysis/CheckObjCUnusedIVars.cpp +++ b/clang/lib/Analysis/CheckObjCUnusedIVars.cpp @@ -62,6 +62,21 @@ static void Scan(IvarUsageMap& M, const ObjCPropertyImplDecl* D) { 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 @@ void clang::CheckObjCUnusedIvar(const ObjCImplementationDecl *D, 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) |