[cfe-commits] r78407 - /cfe/trunk/lib/Analysis/CheckObjCUnusedIVars.cpp

Ted Kremenek kremenek at apple.com
Fri Aug 7 13:55:21 PDT 2009


Author: kremenek
Date: Fri Aug  7 15:55:20 2009
New Revision: 78407

URL: http://llvm.org/viewvc/llvm-project?rev=78407&view=rev
Log:
Constify some pointers.  No functionality change.

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=78407&r1=78406&r2=78407&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/CheckObjCUnusedIVars.cpp (original)
+++ cfe/trunk/lib/Analysis/CheckObjCUnusedIVars.cpp Fri Aug  7 15:55:20 2009
@@ -24,46 +24,48 @@
 using namespace clang;
 
 enum IVarState { Unused, Used };
-typedef llvm::DenseMap<ObjCIvarDecl*,IVarState> IvarUsageMap;
+typedef llvm::DenseMap<const ObjCIvarDecl*,IVarState> IvarUsageMap;
 
-static void Scan(IvarUsageMap& M, Stmt* S) {
+static void Scan(IvarUsageMap& M, const Stmt* S) {
   if (!S)
     return;
   
-  if (ObjCIvarRefExpr* Ex = dyn_cast<ObjCIvarRefExpr>(S)) {
-    ObjCIvarDecl* D = Ex->getDecl();
+  if (const ObjCIvarRefExpr* Ex = dyn_cast<ObjCIvarRefExpr>(S)) {
+    const ObjCIvarDecl* D = Ex->getDecl();
     IvarUsageMap::iterator I = M.find(D);
-    if (I != M.end()) I->second = Used;
+    if (I != M.end())
+      I->second = Used;
     return;
   }
   
-  for (Stmt::child_iterator I=S->child_begin(), E=S->child_end(); I!=E;++I)
+  for (Stmt::const_child_iterator I=S->child_begin(),E=S->child_end(); I!=E;++I)
     Scan(M, *I);
 }
 
-static void Scan(IvarUsageMap& M, ObjCPropertyImplDecl* D) {
+static void Scan(IvarUsageMap& M, const ObjCPropertyImplDecl* D) {
   if (!D)
     return;
   
-  ObjCIvarDecl* ID = D->getPropertyIvarDecl();
+  const ObjCIvarDecl* ID = D->getPropertyIvarDecl();
 
   if (!ID)
     return;
   
   IvarUsageMap::iterator I = M.find(ID);
-  if (I != M.end()) I->second = Used;
+  if (I != M.end())
+    I->second = Used;
 }
 
 void clang::CheckObjCUnusedIvar(ObjCImplementationDecl* D, BugReporter& BR) {
 
-  ObjCInterfaceDecl* ID = D->getClassInterface();
+  const ObjCInterfaceDecl* ID = D->getClassInterface();
   IvarUsageMap M;
 
   // Iterate over the ivars.
-  for (ObjCInterfaceDecl::ivar_iterator I=ID->ivar_begin(), E=ID->ivar_end();
-       I!=E; ++I) {
+  for (ObjCInterfaceDecl::ivar_iterator I=ID->ivar_begin(),
+        E=ID->ivar_end(); I!=E; ++I) {
     
-    ObjCIvarDecl* ID = *I;
+    const ObjCIvarDecl* ID = *I;
     
     // Ignore ivars that aren't private.
     if (ID->getAccessControl() != ObjCIvarDecl::Private)
@@ -81,7 +83,7 @@
   
   // Now scan the methods for accesses.
   for (ObjCImplementationDecl::instmeth_iterator I = D->instmeth_begin(),
-       E = D->instmeth_end(); I!=E; ++I)
+        E = D->instmeth_end(); I!=E; ++I)
     Scan(M, (*I)->getBody());
   
   // Scan for @synthesized property methods that act as setters/getters
@@ -104,4 +106,3 @@
                          os.str().c_str(), I->first->getLocation());
     }
 }
-





More information about the cfe-commits mailing list