forked from OSchip/llvm-project
[C++11] Replacing ObjCCategoryDecl iterators protocol_begin() and protocol_end() with iterator_range protocols(). Updating all of the usages of the iterators with range-based for loops.
llvm-svn: 203922
This commit is contained in:
parent
f445399870
commit
19a417699f
|
@ -1763,7 +1763,14 @@ public:
|
|||
}
|
||||
|
||||
typedef ObjCProtocolList::iterator protocol_iterator;
|
||||
protocol_iterator protocol_begin() const {return ReferencedProtocols.begin();}
|
||||
typedef llvm::iterator_range<protocol_iterator> protocol_range;
|
||||
|
||||
protocol_range protocols() const {
|
||||
return protocol_range(protocol_begin(), protocol_end());
|
||||
}
|
||||
protocol_iterator protocol_begin() const {
|
||||
return ReferencedProtocols.begin();
|
||||
}
|
||||
protocol_iterator protocol_end() const { return ReferencedProtocols.end(); }
|
||||
unsigned protocol_size() const { return ReferencedProtocols.size(); }
|
||||
typedef ObjCProtocolList::loc_iterator protocol_loc_iterator;
|
||||
|
|
|
@ -1827,9 +1827,7 @@ void ASTContext::CollectInheritedProtocols(const Decl *CDecl,
|
|||
SD = SD->getSuperClass();
|
||||
}
|
||||
} else if (const ObjCCategoryDecl *OC = dyn_cast<ObjCCategoryDecl>(CDecl)) {
|
||||
for (ObjCCategoryDecl::protocol_iterator P = OC->protocol_begin(),
|
||||
PE = OC->protocol_end(); P != PE; ++P) {
|
||||
ObjCProtocolDecl *Proto = (*P);
|
||||
for (auto *Proto : OC->protocols()) {
|
||||
Protocols.insert(Proto->getCanonicalDecl());
|
||||
for (const auto *P : Proto->protocols())
|
||||
CollectInheritedProtocols(P, Protocols);
|
||||
|
|
|
@ -227,11 +227,9 @@ ObjCContainerDecl::FindPropertyDeclaration(IdentifierInfo *PropertyId) const {
|
|||
const ObjCCategoryDecl *OCD = cast<ObjCCategoryDecl>(this);
|
||||
// Look through protocols.
|
||||
if (!OCD->IsClassExtension())
|
||||
for (ObjCCategoryDecl::protocol_iterator
|
||||
I = OCD->protocol_begin(), E = OCD->protocol_end(); I != E; ++I)
|
||||
if (ObjCPropertyDecl *P = (*I)->FindPropertyDeclaration(PropertyId))
|
||||
return P;
|
||||
|
||||
for (const auto *I : OCD->protocols())
|
||||
if (ObjCPropertyDecl *P = I->FindPropertyDeclaration(PropertyId))
|
||||
return P;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -943,10 +941,8 @@ static void CollectOverriddenMethodsRecurse(const ObjCContainerDecl *Container,
|
|||
return;
|
||||
}
|
||||
|
||||
for (ObjCCategoryDecl::protocol_iterator P = Category->protocol_begin(),
|
||||
PEnd = Category->protocol_end();
|
||||
P != PEnd; ++P)
|
||||
CollectOverriddenMethodsRecurse(*P, Method, Methods, MovedToSuper);
|
||||
for (const auto *P : Category->protocols())
|
||||
CollectOverriddenMethodsRecurse(P, Method, Methods, MovedToSuper);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1343,10 +1339,8 @@ bool ObjCInterfaceDecl::ClassImplementsProtocol(ObjCProtocolDecl *lProto,
|
|||
// 2nd, look up the category.
|
||||
if (lookupCategory)
|
||||
for (const auto *Cat : visible_categories()) {
|
||||
for (ObjCCategoryDecl::protocol_iterator PI = Cat->protocol_begin(),
|
||||
E = Cat->protocol_end();
|
||||
PI != E; ++PI)
|
||||
if (getASTContext().ProtocolCompatibleWithProtocol(lProto, *PI))
|
||||
for (auto *PI : Cat->protocols())
|
||||
if (getASTContext().ProtocolCompatibleWithProtocol(lProto, PI))
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -2816,10 +2816,8 @@ llvm::Constant *CGObjCCommonMac::EmitPropertyList(Twine Name,
|
|||
PushProtocolProperties(PropertySet, Properties, Container, P, ObjCTypes);
|
||||
}
|
||||
else if (const ObjCCategoryDecl *CD = dyn_cast<ObjCCategoryDecl>(OCD)) {
|
||||
for (ObjCCategoryDecl::protocol_iterator P = CD->protocol_begin(),
|
||||
E = CD->protocol_end(); P != E; ++P)
|
||||
PushProtocolProperties(PropertySet, Properties, Container, (*P),
|
||||
ObjCTypes);
|
||||
for (const auto *P : CD->protocols())
|
||||
PushProtocolProperties(PropertySet, Properties, Container, P, ObjCTypes);
|
||||
}
|
||||
|
||||
// Return null for empty list.
|
||||
|
|
|
@ -7505,16 +7505,11 @@ void RewriteModernObjC::RewriteObjCCategoryImplDecl(ObjCCategoryImplDecl *IDecl,
|
|||
|
||||
// Protocols referenced in class declaration?
|
||||
// Protocol's super protocol list
|
||||
std::vector<ObjCProtocolDecl *> RefedProtocols;
|
||||
for (ObjCCategoryDecl::protocol_iterator I = CDecl->protocol_begin(),
|
||||
E = CDecl->protocol_end();
|
||||
|
||||
I != E; ++I) {
|
||||
RefedProtocols.push_back(*I);
|
||||
SmallVector<ObjCProtocolDecl *, 8> RefedProtocols(CDecl->protocols());
|
||||
for (auto *I : CDecl->protocols())
|
||||
// Must write out all protocol definitions in current qualifier list,
|
||||
// and in their nested qualifiers before writing out current definition.
|
||||
RewriteObjCProtocolMetaData(*I, Result);
|
||||
}
|
||||
RewriteObjCProtocolMetaData(I, Result);
|
||||
|
||||
Write_protocol_list_initializer(Context, Result,
|
||||
RefedProtocols,
|
||||
|
|
|
@ -3511,10 +3511,8 @@ static void AddObjCProperties(ObjCContainerDecl *Container,
|
|||
} else if (const ObjCCategoryDecl *Category
|
||||
= dyn_cast<ObjCCategoryDecl>(Container)) {
|
||||
// Look through protocols.
|
||||
for (ObjCCategoryDecl::protocol_iterator P = Category->protocol_begin(),
|
||||
PEnd = Category->protocol_end();
|
||||
P != PEnd; ++P)
|
||||
AddObjCProperties(*P, AllowCategories, AllowNullaryMethods, CurContext,
|
||||
for (auto *P : Category->protocols())
|
||||
AddObjCProperties(P, AllowCategories, AllowNullaryMethods, CurContext,
|
||||
AddedProperties, Results);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1998,9 +1998,8 @@ void Sema::ImplMethodsVsClassMethods(Scope *S, ObjCImplDecl* IMPDecl,
|
|||
// For extended class, unimplemented methods in its protocols will
|
||||
// be reported in the primary class.
|
||||
if (!C->IsClassExtension()) {
|
||||
for (ObjCCategoryDecl::protocol_iterator PI = C->protocol_begin(),
|
||||
E = C->protocol_end(); PI != E; ++PI)
|
||||
CheckProtocolMethodDefs(*this, IMPDecl->getLocation(), *PI,
|
||||
for (auto *P : C->protocols())
|
||||
CheckProtocolMethodDefs(*this, IMPDecl->getLocation(), P,
|
||||
IncompleteImpl, InsMap, ClsMap, CDecl,
|
||||
ExplicitImplProtocols);
|
||||
DiagnoseUnimplementedProperties(S, IMPDecl, CDecl,
|
||||
|
|
|
@ -3167,10 +3167,9 @@ static void LookupVisibleDecls(DeclContext *Ctx, LookupResult &Result,
|
|||
Visited);
|
||||
}
|
||||
} else if (ObjCCategoryDecl *Category = dyn_cast<ObjCCategoryDecl>(Ctx)) {
|
||||
for (ObjCCategoryDecl::protocol_iterator I = Category->protocol_begin(),
|
||||
E = Category->protocol_end(); I != E; ++I) {
|
||||
for (auto *I : Category->protocols()) {
|
||||
ShadowContextRAII Shadow(Visited);
|
||||
LookupVisibleDecls(*I, Result, QualifiedNameLookup, false, Consumer,
|
||||
LookupVisibleDecls(I, Result, QualifiedNameLookup, false, Consumer,
|
||||
Visited);
|
||||
}
|
||||
|
||||
|
|
|
@ -229,11 +229,8 @@ Decl *Sema::ActOnProperty(Scope *S, SourceLocation AtLoc,
|
|||
}
|
||||
}
|
||||
} else if (ObjCCategoryDecl *Cat = dyn_cast<ObjCCategoryDecl>(ClassDecl)) {
|
||||
for (ObjCCategoryDecl::protocol_iterator P = Cat->protocol_begin(),
|
||||
PEnd = Cat->protocol_end();
|
||||
P != PEnd; ++P) {
|
||||
CheckPropertyAgainstProtocol(*this, Res, *P, KnownProtos);
|
||||
}
|
||||
for (auto *P : Cat->protocols())
|
||||
CheckPropertyAgainstProtocol(*this, Res, P, KnownProtos);
|
||||
} else {
|
||||
ObjCProtocolDecl *Proto = cast<ObjCProtocolDecl>(ClassDecl);
|
||||
for (auto *P : Proto->protocols())
|
||||
|
@ -1439,9 +1436,8 @@ static void CollectImmediateProperties(ObjCContainerDecl *CDecl,
|
|||
PropMap[Prop->getIdentifier()] = Prop;
|
||||
if (IncludeProtocols) {
|
||||
// Scan through class's protocols.
|
||||
for (ObjCCategoryDecl::protocol_iterator PI = CATDecl->protocol_begin(),
|
||||
E = CATDecl->protocol_end(); PI != E; ++PI)
|
||||
CollectImmediateProperties((*PI), PropMap, SuperPropMap);
|
||||
for (auto *PI : CATDecl->protocols())
|
||||
CollectImmediateProperties(PI, PropMap, SuperPropMap);
|
||||
}
|
||||
}
|
||||
else if (ObjCProtocolDecl *PDecl = dyn_cast<ObjCProtocolDecl>(CDecl)) {
|
||||
|
|
|
@ -566,9 +566,8 @@ void ASTDeclWriter::VisitObjCCategoryDecl(ObjCCategoryDecl *D) {
|
|||
Writer.AddSourceLocation(D->getIvarRBraceLoc(), Record);
|
||||
Writer.AddDeclRef(D->getClassInterface(), Record);
|
||||
Record.push_back(D->protocol_size());
|
||||
for (ObjCCategoryDecl::protocol_iterator
|
||||
I = D->protocol_begin(), IEnd = D->protocol_end(); I != IEnd; ++I)
|
||||
Writer.AddDeclRef(*I, Record);
|
||||
for (const auto *I : D->protocols())
|
||||
Writer.AddDeclRef(I, Record);
|
||||
for (ObjCCategoryDecl::protocol_loc_iterator
|
||||
PL = D->protocol_loc_begin(), PLEnd = D->protocol_loc_end();
|
||||
PL != PLEnd; ++PL)
|
||||
|
|
Loading…
Reference in New Issue