From: Chris Lattner Date: Sat, 26 Jul 2008 04:13:19 +0000 (+0000) Subject: Pull protocol resolution of out ActOnStartClassInterface, this is also the X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=06036d3709955a53297b4cbe14e20db88f321470;p=clang Pull protocol resolution of out ActOnStartClassInterface, this is also the last client of the old ParseObjCProtocolReferences, so it also removes it. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54094 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Parse/Action.h b/include/clang/Parse/Action.h index d2a653d239..b97aac1145 100644 --- a/include/clang/Parse/Action.h +++ b/include/clang/Parse/Action.h @@ -621,16 +621,15 @@ public: // ActOnStartClassInterface - this action is called immediately after parsing // the prologue for a class interface (before parsing the instance // variables). Instance variables are processed by ActOnFields(). - virtual DeclTy *ActOnStartClassInterface( - SourceLocation AtInterafceLoc, - IdentifierInfo *ClassName, - SourceLocation ClassLoc, - IdentifierInfo *SuperName, - SourceLocation SuperLoc, - const IdentifierLocPair *ProtocolNames, - unsigned NumProtocols, - SourceLocation EndProtoLoc, - AttributeList *AttrList) { + virtual DeclTy *ActOnStartClassInterface(SourceLocation AtInterfaceLoc, + IdentifierInfo *ClassName, + SourceLocation ClassLoc, + IdentifierInfo *SuperName, + SourceLocation SuperLoc, + DeclTy * const *ProtoRefs, + unsigned NumProtoRefs, + SourceLocation EndProtoLoc, + AttributeList *AttrList) { return 0; } @@ -847,11 +846,14 @@ public: unsigned NumElts); virtual DeclTy *ActOnStartClassInterface(SourceLocation interLoc, - IdentifierInfo *ClassName, SourceLocation ClassLoc, - IdentifierInfo *SuperName, SourceLocation SuperLoc, - const IdentifierLocPair *ProtocolNames, - unsigned NumProtocols, - SourceLocation EndProtoLoc, AttributeList *AttrList); + IdentifierInfo *ClassName, + SourceLocation ClassLoc, + IdentifierInfo *SuperName, + SourceLocation SuperLoc, + DeclTy * const *ProtoRefs, + unsigned NumProtoRefs, + SourceLocation EndProtoLoc, + AttributeList *AttrList); }; } // end namespace clang diff --git a/include/clang/Parse/Parser.h b/include/clang/Parse/Parser.h index 00f7822015..4cd9100867 100644 --- a/include/clang/Parse/Parser.h +++ b/include/clang/Parse/Parser.h @@ -326,8 +326,6 @@ private: AttributeList *prefixAttrs = 0); void ParseObjCClassInstanceVariables(DeclTy *interfaceDecl, SourceLocation atLoc); - bool ParseObjCProtocolReferences(llvm::SmallVectorImpl &, - SourceLocation &endProtoLoc); bool ParseObjCProtocolReferences(llvm::SmallVectorImpl &P, bool WarnOnDeclarations, SourceLocation &EndProtoLoc); diff --git a/lib/Parse/MinimalAction.cpp b/lib/Parse/MinimalAction.cpp index 91f3c6e4a4..aa886ab458 100644 --- a/lib/Parse/MinimalAction.cpp +++ b/lib/Parse/MinimalAction.cpp @@ -89,11 +89,14 @@ MinimalAction::ActOnDeclarator(Scope *S, Declarator &D, DeclTy *LastInGroup) { Action::DeclTy * MinimalAction::ActOnStartClassInterface(SourceLocation AtInterfaceLoc, - IdentifierInfo *ClassName, SourceLocation ClassLoc, - IdentifierInfo *SuperName, SourceLocation SuperLoc, - const IdentifierLocPair *ProtocolNames, - unsigned NumProtocols, - SourceLocation EndProtoLoc, AttributeList *AttrList) { + IdentifierInfo *ClassName, + SourceLocation ClassLoc, + IdentifierInfo *SuperName, + SourceLocation SuperLoc, + DeclTy * const *ProtoRefs, + unsigned NumProtocols, + SourceLocation EndProtoLoc, + AttributeList *AttrList) { TypeNameInfo *TI = new TypeNameInfo(1, ClassName->getFETokenInfo()); diff --git a/lib/Parse/ParseObjc.cpp b/lib/Parse/ParseObjc.cpp index cabb5bf69a..980105a02c 100644 --- a/lib/Parse/ParseObjc.cpp +++ b/lib/Parse/ParseObjc.cpp @@ -186,16 +186,17 @@ Parser::DeclTy *Parser::ParseObjCAtInterfaceDeclaration( superClassLoc = ConsumeToken(); } // Next, we need to check for any protocol references. - llvm::SmallVector ProtocolRefs; - SourceLocation endProtoLoc; - if (Tok.is(tok::less)) { - if (ParseObjCProtocolReferences(ProtocolRefs, endProtoLoc)) - return 0; - } - DeclTy *ClsType = Actions.ActOnStartClassInterface( - atLoc, nameId, nameLoc, - superClassId, superClassLoc, &ProtocolRefs[0], - ProtocolRefs.size(), endProtoLoc, attrList); + llvm::SmallVector ProtocolRefs; + SourceLocation EndProtoLoc; + if (Tok.is(tok::less) && + ParseObjCProtocolReferences(ProtocolRefs, true, EndProtoLoc)) + return 0; + + DeclTy *ClsType = + Actions.ActOnStartClassInterface(atLoc, nameId, nameLoc, + superClassId, superClassLoc, + &ProtocolRefs[0], ProtocolRefs.size(), + EndProtoLoc, attrList); if (Tok.is(tok::l_brace)) ParseObjCClassInstanceVariables(ClsType, atLoc); @@ -713,40 +714,6 @@ Parser::DeclTy *Parser::ParseObjCMethodDecl(SourceLocation mLoc, MethodImplKind, isVariadic); } -/// objc-protocol-refs: -/// '<' identifier-list '>' -/// -bool Parser:: -ParseObjCProtocolReferences(llvm::SmallVectorImpl &Protocols, - SourceLocation &endLoc) { - assert(Tok.is(tok::less) && "expected <"); - - ConsumeToken(); // the "<" - - while (1) { - if (Tok.isNot(tok::identifier)) { - Diag(Tok, diag::err_expected_ident); - SkipUntil(tok::greater); - return true; - } - Protocols.push_back(std::make_pair(Tok.getIdentifierInfo(), - Tok.getLocation())); - ConsumeToken(); - - if (Tok.isNot(tok::comma)) - break; - ConsumeToken(); - } - - // Consume the '>'. - if (Tok.is(tok::greater)) { - endLoc = ConsumeAnyToken(); - return false; - } - Diag(Tok, diag::err_expected_greater); - return true; -} - /// objc-protocol-refs: /// '<' identifier-list '>' /// diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h index 9584dcc468..09d8d793cb 100644 --- a/lib/Sema/Sema.h +++ b/lib/Sema/Sema.h @@ -605,13 +605,15 @@ public: // Objective-C declarations. - virtual DeclTy *ActOnStartClassInterface( - SourceLocation AtInterafceLoc, - IdentifierInfo *ClassName, SourceLocation ClassLoc, - IdentifierInfo *SuperName, SourceLocation SuperLoc, - const IdentifierLocPair *ProtocolNames, - unsigned NumProtocols, - SourceLocation EndProtoLoc, AttributeList *AttrList); + virtual DeclTy *ActOnStartClassInterface(SourceLocation AtInterfaceLoc, + IdentifierInfo *ClassName, + SourceLocation ClassLoc, + IdentifierInfo *SuperName, + SourceLocation SuperLoc, + DeclTy * const *ProtoRefs, + unsigned NumProtoRefs, + SourceLocation EndProtoLoc, + AttributeList *AttrList); virtual DeclTy *ActOnCompatiblityAlias( SourceLocation AtCompatibilityAliasLoc, diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index 570437d071..07cc890fde 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -75,8 +75,7 @@ Sema::DeclTy *Sema:: ActOnStartClassInterface(SourceLocation AtInterfaceLoc, IdentifierInfo *ClassName, SourceLocation ClassLoc, IdentifierInfo *SuperName, SourceLocation SuperLoc, - const IdentifierLocPair *ProtocolNames, - unsigned NumProtocols, + DeclTy * const *ProtoRefs, unsigned NumProtoRefs, SourceLocation EndProtoLoc, AttributeList *AttrList) { assert(ClassName && "Missing class identifier"); @@ -134,22 +133,8 @@ ActOnStartClassInterface(SourceLocation AtInterfaceLoc, } /// Check then save referenced protocols - if (NumProtocols) { - llvm::SmallVector RefProtos; - for (unsigned int i = 0; i != NumProtocols; i++) { - ObjCProtocolDecl* RefPDecl = ObjCProtocols[ProtocolNames[i].first]; - if (!RefPDecl) - Diag(ProtocolNames[i].second, diag::err_undeclared_protocol, - ProtocolNames[i].first->getName()); - else { - if (RefPDecl->isForwardDecl()) - Diag(ProtocolNames[i].second, diag::warn_undef_protocolref, - ProtocolNames[i].first->getName()); - RefProtos.push_back(RefPDecl); - } - } - if (!RefProtos.empty()) - IDecl->addReferencedProtocols(&RefProtos[0], RefProtos.size()); + if (NumProtoRefs) { + IDecl->addReferencedProtocols((ObjCProtocolDecl**)ProtoRefs, NumProtoRefs); IDecl->setLocEnd(EndProtoLoc); } return IDecl;