forked from OSchip/llvm-project
[C++11] Replacing ObjCInterfaceDecl iterators protocol_begin() and protocol_end() with iterator_range protocols(). Updating all of the usages of the iterators with range-based for loops.
Drive-by fixing some incorrect types where a for loop would be improperly using ObjCInterfaceDecl::protocol_iterator. No functional changes in these cases. llvm-svn: 203842
This commit is contained in:
parent
a8fb72428b
commit
a49c5064a1
|
@ -823,7 +823,11 @@ public:
|
|||
}
|
||||
|
||||
typedef ObjCProtocolList::iterator protocol_iterator;
|
||||
typedef llvm::iterator_range<protocol_iterator> protocol_range;
|
||||
|
||||
protocol_range protocols() const {
|
||||
return protocol_range(protocol_begin(), protocol_end());
|
||||
}
|
||||
protocol_iterator protocol_begin() const {
|
||||
// FIXME: Should make sure no callers ever do this.
|
||||
if (!hasDefinition())
|
||||
|
|
|
@ -555,10 +555,8 @@ ObjCMethodDecl *ObjCInterfaceDecl::lookupMethod(Selector Sel,
|
|||
return MethodDecl;
|
||||
|
||||
// Didn't find one yet - look through protocols.
|
||||
for (ObjCInterfaceDecl::protocol_iterator I = ClassDecl->protocol_begin(),
|
||||
E = ClassDecl->protocol_end();
|
||||
I != E; ++I)
|
||||
if ((MethodDecl = (*I)->lookupMethod(Sel, isInstance)))
|
||||
for (const auto *I : ClassDecl->protocols())
|
||||
if ((MethodDecl = I->lookupMethod(Sel, isInstance)))
|
||||
return MethodDecl;
|
||||
|
||||
// Didn't find one yet - now look through categories.
|
||||
|
@ -1004,10 +1002,8 @@ static void CollectOverriddenMethodsRecurse(const ObjCContainerDecl *Container,
|
|||
|
||||
if (const ObjCInterfaceDecl *
|
||||
Interface = dyn_cast<ObjCInterfaceDecl>(Container)) {
|
||||
for (ObjCInterfaceDecl::protocol_iterator P = Interface->protocol_begin(),
|
||||
PEnd = Interface->protocol_end();
|
||||
P != PEnd; ++P)
|
||||
CollectOverriddenMethodsRecurse(*P, Method, Methods, MovedToSuper);
|
||||
for (const auto *P : Interface->protocols())
|
||||
CollectOverriddenMethodsRecurse(P, Method, Methods, MovedToSuper);
|
||||
|
||||
for (ObjCInterfaceDecl::known_categories_iterator
|
||||
Cat = Interface->known_categories_begin(),
|
||||
|
@ -1381,9 +1377,8 @@ bool ObjCInterfaceDecl::ClassImplementsProtocol(ObjCProtocolDecl *lProto,
|
|||
|
||||
ObjCInterfaceDecl *IDecl = this;
|
||||
// 1st, look up the class.
|
||||
for (ObjCInterfaceDecl::protocol_iterator
|
||||
PI = IDecl->protocol_begin(), E = IDecl->protocol_end(); PI != E; ++PI){
|
||||
if (getASTContext().ProtocolCompatibleWithProtocol(lProto, *PI))
|
||||
for (auto *PI : IDecl->protocols()){
|
||||
if (getASTContext().ProtocolCompatibleWithProtocol(lProto, PI))
|
||||
return true;
|
||||
// This is dubious and is added to be compatible with gcc. In gcc, it is
|
||||
// also allowed assigning a protocol-qualified 'id' type to a LHS object
|
||||
|
@ -1392,7 +1387,7 @@ bool ObjCInterfaceDecl::ClassImplementsProtocol(ObjCProtocolDecl *lProto,
|
|||
// FIXME: Treat this as an extension, and flag this as an error when GCC
|
||||
// extensions are not enabled.
|
||||
if (RHSIsQualifiedID &&
|
||||
getASTContext().ProtocolCompatibleWithProtocol(*PI, lProto))
|
||||
getASTContext().ProtocolCompatibleWithProtocol(PI, lProto))
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -2252,12 +2252,8 @@ void CGObjCGNU::GenerateClass(const ObjCImplementationDecl *OID) {
|
|||
}
|
||||
// Collect the names of referenced protocols
|
||||
SmallVector<std::string, 16> Protocols;
|
||||
for (ObjCInterfaceDecl::protocol_iterator
|
||||
I = ClassDecl->protocol_begin(),
|
||||
E = ClassDecl->protocol_end(); I != E; ++I)
|
||||
Protocols.push_back((*I)->getNameAsString());
|
||||
|
||||
|
||||
for (const auto *I : ClassDecl->protocols())
|
||||
Protocols.push_back(I->getNameAsString());
|
||||
|
||||
// Get the superclass pointer.
|
||||
llvm::Constant *SuperClass;
|
||||
|
|
|
@ -7511,8 +7511,8 @@ void RewriteModernObjC::RewriteObjCCategoryImplDecl(ObjCCategoryImplDecl *IDecl,
|
|||
// Protocols referenced in class declaration?
|
||||
// Protocol's super protocol list
|
||||
std::vector<ObjCProtocolDecl *> RefedProtocols;
|
||||
for (ObjCInterfaceDecl::protocol_iterator I = CDecl->protocol_begin(),
|
||||
E = CDecl->protocol_end();
|
||||
for (ObjCCategoryDecl::protocol_iterator I = CDecl->protocol_begin(),
|
||||
E = CDecl->protocol_end();
|
||||
|
||||
I != E; ++I) {
|
||||
RefedProtocols.push_back(*I);
|
||||
|
|
|
@ -4852,10 +4852,8 @@ static void AddObjCMethods(ObjCContainerDecl *Container,
|
|||
return;
|
||||
|
||||
// Add methods in protocols.
|
||||
for (ObjCInterfaceDecl::protocol_iterator I = IFace->protocol_begin(),
|
||||
E = IFace->protocol_end();
|
||||
I != E; ++I)
|
||||
AddObjCMethods(*I, WantInstanceMethods, WantKind, SelIdents,
|
||||
for (auto *I : IFace->protocols())
|
||||
AddObjCMethods(I, WantInstanceMethods, WantKind, SelIdents,
|
||||
CurContext, Selectors, AllowSameLength, Results, false);
|
||||
|
||||
// Add methods in categories.
|
||||
|
|
|
@ -222,11 +222,8 @@ Decl *Sema::ActOnProperty(Scope *S, SourceLocation AtLoc,
|
|||
|
||||
if (FoundInSuper) {
|
||||
// Also compare the property against a property in our protocols.
|
||||
for (ObjCInterfaceDecl::protocol_iterator
|
||||
P = CurrentInterfaceDecl->protocol_begin(),
|
||||
PEnd = CurrentInterfaceDecl->protocol_end();
|
||||
P != PEnd; ++P) {
|
||||
CheckPropertyAgainstProtocol(*this, Res, *P, KnownProtos);
|
||||
for (auto *P : CurrentInterfaceDecl->protocols()) {
|
||||
CheckPropertyAgainstProtocol(*this, Res, P, KnownProtos);
|
||||
}
|
||||
} else {
|
||||
// Slower path: look in all protocols we referenced.
|
||||
|
|
|
@ -491,10 +491,8 @@ void ASTDeclWriter::VisitObjCInterfaceDecl(ObjCInterfaceDecl *D) {
|
|||
|
||||
// Write out the protocols that are directly referenced by the @interface.
|
||||
Record.push_back(Data.ReferencedProtocols.size());
|
||||
for (ObjCInterfaceDecl::protocol_iterator P = D->protocol_begin(),
|
||||
PEnd = D->protocol_end();
|
||||
P != PEnd; ++P)
|
||||
Writer.AddDeclRef(*P, Record);
|
||||
for (const auto *P : D->protocols())
|
||||
Writer.AddDeclRef(P, Record);
|
||||
for (ObjCInterfaceDecl::protocol_loc_iterator PL = D->protocol_loc_begin(),
|
||||
PLEnd = D->protocol_loc_end();
|
||||
PL != PLEnd; ++PL)
|
||||
|
|
|
@ -257,11 +257,8 @@ void IvarInvalidationCheckerImpl::containsInvalidationMethod(
|
|||
if (const ObjCInterfaceDecl *InterfD = dyn_cast<ObjCInterfaceDecl>(D)) {
|
||||
|
||||
// Visit all protocols.
|
||||
for (ObjCInterfaceDecl::protocol_iterator
|
||||
I = InterfD->protocol_begin(),
|
||||
E = InterfD->protocol_end(); I != E; ++I) {
|
||||
containsInvalidationMethod((*I)->getDefinition(), OutInfo, Partial);
|
||||
}
|
||||
for (const auto *I : InterfD->protocols())
|
||||
containsInvalidationMethod(I->getDefinition(), OutInfo, Partial);
|
||||
|
||||
// Visit all categories in case the invalidation method is declared in
|
||||
// a category.
|
||||
|
@ -278,9 +275,9 @@ void IvarInvalidationCheckerImpl::containsInvalidationMethod(
|
|||
|
||||
// If protocol, check all parent protocols.
|
||||
if (const ObjCProtocolDecl *ProtD = dyn_cast<ObjCProtocolDecl>(D)) {
|
||||
for (ObjCInterfaceDecl::protocol_iterator
|
||||
I = ProtD->protocol_begin(),
|
||||
E = ProtD->protocol_end(); I != E; ++I) {
|
||||
for (ObjCProtocolDecl::protocol_iterator I = ProtD->protocol_begin(),
|
||||
E = ProtD->protocol_end();
|
||||
I != E; ++I) {
|
||||
containsInvalidationMethod((*I)->getDefinition(), OutInfo, Partial);
|
||||
}
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue