]> granicus.if.org Git - clang/commitdiff
Pull ivar scanning logic into another utility function. This refactoring will enable...
authorTed Kremenek <kremenek@apple.com>
Wed, 28 Oct 2009 20:37:47 +0000 (20:37 +0000)
committerTed Kremenek <kremenek@apple.com>
Wed, 28 Oct 2009 20:37:47 +0000 (20:37 +0000)
categories as well (WIP). No functionality change yet.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85423 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/CheckObjCUnusedIVars.cpp

index 1a900f8976783ac68b4122ace5f277f82df8377f..6c942aaafc08682cb032597326178c3a9aac610c 100644 (file)
@@ -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)