Constify some pointers. No functionality change.
llvm-svn: 78407
This commit is contained in:
parent
bfdd58e103
commit
d99f2866ac
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue