From: Craig Topper Date: Thu, 22 Oct 2015 04:59:56 +0000 (+0000) Subject: Change FindProtocolDeclaration to take an ArrayRef and use a range-based for loop... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8d3237f3021097cadf8dda862caadd6371011b6d;p=clang Change FindProtocolDeclaration to take an ArrayRef and use a range-based for loop. NFC git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@250988 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index cce5405a1e..957d9fa93b 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -7207,8 +7207,7 @@ public: AttributeList *attrList); void FindProtocolDeclaration(bool WarnOnDeclarations, bool ForObjCContainer, - const IdentifierLocPair *ProtocolId, - unsigned NumProtocols, + ArrayRef ProtocolId, SmallVectorImpl &Protocols); /// Given a list of identifiers (and their locations), resolve the diff --git a/lib/Parse/ParseObjc.cpp b/lib/Parse/ParseObjc.cpp index ab097661f8..a4e499cf64 100644 --- a/lib/Parse/ParseObjc.cpp +++ b/lib/Parse/ParseObjc.cpp @@ -342,8 +342,7 @@ Decl *Parser::ParseObjCAtInterfaceDeclaration(SourceLocation AtLoc, } Actions.FindProtocolDeclaration(/*WarnOnDeclarations=*/true, /*ForObjCContainer=*/true, - &ProtocolIdents[0], ProtocolIdents.size(), - protocols); + ProtocolIdents, protocols); } } else if (protocols.empty() && Tok.is(tok::less) && ParseObjCProtocolReferences(protocols, protocolLocs, true, true, @@ -1584,8 +1583,7 @@ ParseObjCProtocolReferences(SmallVectorImpl &Protocols, // Convert the list of protocols identifiers into a list of protocol decls. Actions.FindProtocolDeclaration(WarnOnDeclarations, ForObjCContainer, - &ProtocolIdents[0], ProtocolIdents.size(), - Protocols); + ProtocolIdents, Protocols); return false; } diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index 8217ba811e..163976bd1e 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -1208,26 +1208,23 @@ static bool NestedProtocolHasNoDefinition(ObjCProtocolDecl *PDecl, /// protocol declarations in its 'Protocols' argument. void Sema::FindProtocolDeclaration(bool WarnOnDeclarations, bool ForObjCContainer, - const IdentifierLocPair *ProtocolId, - unsigned NumProtocols, + ArrayRef ProtocolId, SmallVectorImpl &Protocols) { - for (unsigned i = 0; i != NumProtocols; ++i) { - ObjCProtocolDecl *PDecl = LookupProtocol(ProtocolId[i].first, - ProtocolId[i].second); + for (const IdentifierLocPair &Pair : ProtocolId) { + ObjCProtocolDecl *PDecl = LookupProtocol(Pair.first, Pair.second); if (!PDecl) { TypoCorrection Corrected = CorrectTypo( - DeclarationNameInfo(ProtocolId[i].first, ProtocolId[i].second), + DeclarationNameInfo(Pair.first, Pair.second), LookupObjCProtocolName, TUScope, nullptr, llvm::make_unique>(), CTK_ErrorRecovery); if ((PDecl = Corrected.getCorrectionDeclAs())) diagnoseTypo(Corrected, PDiag(diag::err_undeclared_protocol_suggest) - << ProtocolId[i].first); + << Pair.first); } if (!PDecl) { - Diag(ProtocolId[i].second, diag::err_undeclared_protocol) - << ProtocolId[i].first; + Diag(Pair.second, diag::err_undeclared_protocol) << Pair.first; continue; } // If this is a forward protocol declaration, get its definition. @@ -1237,7 +1234,7 @@ Sema::FindProtocolDeclaration(bool WarnOnDeclarations, bool ForObjCContainer, // For an objc container, delay protocol reference checking until after we // can set the objc decl as the availability context, otherwise check now. if (!ForObjCContainer) { - (void)DiagnoseUseOfDecl(PDecl, ProtocolId[i].second); + (void)DiagnoseUseOfDecl(PDecl, Pair.second); } // If this is a forward declaration and we are supposed to warn in this @@ -1247,8 +1244,7 @@ Sema::FindProtocolDeclaration(bool WarnOnDeclarations, bool ForObjCContainer, if (WarnOnDeclarations && NestedProtocolHasNoDefinition(PDecl, UndefinedProtocol)) { - Diag(ProtocolId[i].second, diag::warn_undef_protocolref) - << ProtocolId[i].first; + Diag(Pair.second, diag::warn_undef_protocolref) << Pair.first; Diag(UndefinedProtocol->getLocation(), diag::note_protocol_decl_undefined) << UndefinedProtocol; }