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