Author: ctopper Date: Wed Oct 21 23:59:56 2015 New Revision: 250988 URL: http://llvm.org/viewvc/llvm-project?rev=250988&view=rev Log: Change FindProtocolDeclaration to take an ArrayRef and use a range-based for loop. NFC
Modified: cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/lib/Parse/ParseObjc.cpp cfe/trunk/lib/Sema/SemaDeclObjC.cpp Modified: cfe/trunk/include/clang/Sema/Sema.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=250988&r1=250987&r2=250988&view=diff ============================================================================== --- cfe/trunk/include/clang/Sema/Sema.h (original) +++ cfe/trunk/include/clang/Sema/Sema.h Wed Oct 21 23:59:56 2015 @@ -7207,8 +7207,7 @@ public: AttributeList *attrList); void FindProtocolDeclaration(bool WarnOnDeclarations, bool ForObjCContainer, - const IdentifierLocPair *ProtocolId, - unsigned NumProtocols, + ArrayRef<IdentifierLocPair> ProtocolId, SmallVectorImpl<Decl *> &Protocols); /// Given a list of identifiers (and their locations), resolve the Modified: cfe/trunk/lib/Parse/ParseObjc.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=250988&r1=250987&r2=250988&view=diff ============================================================================== --- cfe/trunk/lib/Parse/ParseObjc.cpp (original) +++ cfe/trunk/lib/Parse/ParseObjc.cpp Wed Oct 21 23:59:56 2015 @@ -342,8 +342,7 @@ Decl *Parser::ParseObjCAtInterfaceDeclar } 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(SmallVectorI // 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; } Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=250988&r1=250987&r2=250988&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original) +++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Wed Oct 21 23:59:56 2015 @@ -1208,26 +1208,23 @@ static bool NestedProtocolHasNoDefinitio /// protocol declarations in its 'Protocols' argument. void Sema::FindProtocolDeclaration(bool WarnOnDeclarations, bool ForObjCContainer, - const IdentifierLocPair *ProtocolId, - unsigned NumProtocols, + ArrayRef<IdentifierLocPair> ProtocolId, SmallVectorImpl<Decl *> &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<DeclFilterCCC<ObjCProtocolDecl>>(), CTK_ErrorRecovery); if ((PDecl = Corrected.getCorrectionDeclAs<ObjCProtocolDecl>())) 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 WarnO // 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 WarnO 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; } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits