Constify some pointers. No functionality change.

llvm-svn: 78407
This commit is contained in:
Ted Kremenek 2009-08-07 20:55:20 +00:00
parent bfdd58e103
commit d99f2866ac
1 changed files with 16 additions and 15 deletions

View File

@ -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)
@ -104,4 +106,3 @@ void clang::CheckObjCUnusedIvar(ObjCImplementationDecl* D, BugReporter& BR) {
os.str().c_str(), I->first->getLocation());
}
}