forked from OSchip/llvm-project
[C++11] Replacing ObjCInterfaceDecl iterators ivar_begin() and ivar_end() with iterator_range ivars(). Updating all of the usages of the iterators with range-based for loops.
llvm-svn: 203849
This commit is contained in:
parent
a9f49e394c
commit
59abbd4d9b
|
@ -910,7 +910,9 @@ public:
|
|||
}
|
||||
|
||||
typedef specific_decl_iterator<ObjCIvarDecl> ivar_iterator;
|
||||
typedef llvm::iterator_range<specific_decl_iterator<ObjCIvarDecl>> ivar_range;
|
||||
|
||||
ivar_range ivars() const { return ivar_range(ivar_begin(), ivar_end()); }
|
||||
ivar_iterator ivar_begin() const {
|
||||
if (const ObjCInterfaceDecl *Def = getDefinition())
|
||||
return ivar_iterator(Def->decls_begin());
|
||||
|
|
|
@ -1795,9 +1795,8 @@ void ASTContext::DeepCollectObjCIvars(const ObjCInterfaceDecl *OI,
|
|||
if (const ObjCInterfaceDecl *SuperClass = OI->getSuperClass())
|
||||
DeepCollectObjCIvars(SuperClass, false, Ivars);
|
||||
if (!leafClass) {
|
||||
for (ObjCInterfaceDecl::ivar_iterator I = OI->ivar_begin(),
|
||||
E = OI->ivar_end(); I != E; ++I)
|
||||
Ivars.push_back(*I);
|
||||
for (const auto *I : OI->ivars())
|
||||
Ivars.push_back(I);
|
||||
} else {
|
||||
ObjCInterfaceDecl *IDecl = const_cast<ObjCInterfaceDecl *>(OI);
|
||||
for (const ObjCIvarDecl *Iv = IDecl->all_declared_ivar_begin(); Iv;
|
||||
|
|
|
@ -1000,10 +1000,10 @@ void DeclPrinter::VisitObjCInterfaceDecl(ObjCInterfaceDecl *OID) {
|
|||
Out << "{\n";
|
||||
eolnOut = true;
|
||||
Indentation += Policy.Indentation;
|
||||
for (ObjCInterfaceDecl::ivar_iterator I = OID->ivar_begin(),
|
||||
E = OID->ivar_end(); I != E; ++I) {
|
||||
Indent() << I->getASTContext().getUnqualifiedObjCPointerType(I->getType()).
|
||||
getAsString(Policy) << ' ' << **I << ";\n";
|
||||
for (const auto *I : OID->ivars()) {
|
||||
Indent() << I->getASTContext()
|
||||
.getUnqualifiedObjCPointerType(I->getType())
|
||||
.getAsString(Policy) << ' ' << *I << ";\n";
|
||||
}
|
||||
Indentation -= Policy.Indentation;
|
||||
Out << "}\n";
|
||||
|
|
|
@ -2520,9 +2520,7 @@ Sema::SelectorsForTypoCorrection(Selector Sel,
|
|||
/// class's \@implementation is seen.
|
||||
void Sema::DiagnoseDuplicateIvars(ObjCInterfaceDecl *ID,
|
||||
ObjCInterfaceDecl *SID) {
|
||||
for (ObjCInterfaceDecl::ivar_iterator IVI = ID->ivar_begin(),
|
||||
IVE = ID->ivar_end(); IVI != IVE; ++IVI) {
|
||||
ObjCIvarDecl* Ivar = *IVI;
|
||||
for (auto *Ivar : ID->ivars()) {
|
||||
if (Ivar->isInvalidDecl())
|
||||
continue;
|
||||
if (IdentifierInfo *II = Ivar->getIdentifier()) {
|
||||
|
|
|
@ -113,15 +113,12 @@ static void checkObjCDealloc(const CheckerBase *Checker,
|
|||
|
||||
bool containsPointerIvar = false;
|
||||
|
||||
for (ObjCInterfaceDecl::ivar_iterator I=ID->ivar_begin(), E=ID->ivar_end();
|
||||
I!=E; ++I) {
|
||||
|
||||
ObjCIvarDecl *ID = *I;
|
||||
QualType T = ID->getType();
|
||||
for (const auto *Ivar : ID->ivars()) {
|
||||
QualType T = Ivar->getType();
|
||||
|
||||
if (!T->isObjCObjectPointerType() ||
|
||||
ID->hasAttr<IBOutletAttr>() || // Skip IBOutlets.
|
||||
ID->hasAttr<IBOutletCollectionAttr>()) // Skip IBOutletCollections.
|
||||
Ivar->hasAttr<IBOutletAttr>() || // Skip IBOutlets.
|
||||
Ivar->hasAttr<IBOutletCollectionAttr>()) // Skip IBOutletCollections.
|
||||
continue;
|
||||
|
||||
containsPointerIvar = true;
|
||||
|
|
|
@ -116,23 +116,19 @@ static void checkObjCUnusedIvar(const ObjCImplementationDecl *D,
|
|||
IvarUsageMap M;
|
||||
|
||||
// Iterate over the ivars.
|
||||
for (ObjCInterfaceDecl::ivar_iterator I=ID->ivar_begin(),
|
||||
E=ID->ivar_end(); I!=E; ++I) {
|
||||
|
||||
const ObjCIvarDecl *ID = *I;
|
||||
|
||||
for (const auto *Ivar : ID->ivars()) {
|
||||
// Ignore ivars that...
|
||||
// (a) aren't private
|
||||
// (b) explicitly marked unused
|
||||
// (c) are iboutlets
|
||||
// (d) are unnamed bitfields
|
||||
if (ID->getAccessControl() != ObjCIvarDecl::Private ||
|
||||
ID->hasAttr<UnusedAttr>() || ID->hasAttr<IBOutletAttr>() ||
|
||||
ID->hasAttr<IBOutletCollectionAttr>() ||
|
||||
ID->isUnnamedBitfield())
|
||||
if (Ivar->getAccessControl() != ObjCIvarDecl::Private ||
|
||||
Ivar->hasAttr<UnusedAttr>() || Ivar->hasAttr<IBOutletAttr>() ||
|
||||
Ivar->hasAttr<IBOutletCollectionAttr>() ||
|
||||
Ivar->isUnnamedBitfield())
|
||||
continue;
|
||||
|
||||
M[ID] = Unused;
|
||||
M[Ivar] = Unused;
|
||||
}
|
||||
|
||||
if (M.empty())
|
||||
|
|
Loading…
Reference in New Issue