diff options
author | Chris Lattner <sabre@nondot.org> | 2008-07-26 04:03:38 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-07-26 04:03:38 +0000 |
commit | e13b9595dc1e2f4288bec34f3412359f648e84a5 (patch) | |
tree | 187b55589c94501a9359e44de81663a2edffb6b0 /lib/Parse/ParseObjc.cpp | |
parent | eacc39212e5960b2680067c006384c2e4804873a (diff) |
pull protocol resolution out into ActOnStartProtocolInterface.
This temporarily duplicates ParseObjCProtocolReferences, but it
will be removed in the future.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54092 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseObjc.cpp')
-rw-r--r-- | lib/Parse/ParseObjc.cpp | 56 |
1 files changed, 49 insertions, 7 deletions
diff --git a/lib/Parse/ParseObjc.cpp b/lib/Parse/ParseObjc.cpp index d495e6f062..1bfc2a949b 100644 --- a/lib/Parse/ParseObjc.cpp +++ b/lib/Parse/ParseObjc.cpp @@ -746,6 +746,48 @@ ParseObjCProtocolReferences(llvm::SmallVectorImpl<IdentifierLocPair> &Protocols, return true; } +/// objc-protocol-refs: +/// '<' identifier-list '>' +/// +bool Parser:: +ParseObjCProtocolReferences(llvm::SmallVectorImpl<Action::DeclTy*> &Protocols, + bool WarnOnDeclarations, SourceLocation &EndLoc) { + assert(Tok.is(tok::less) && "expected <"); + + ConsumeToken(); // the "<" + + llvm::SmallVector<IdentifierLocPair, 8> ProtocolIdents; + + while (1) { + if (Tok.isNot(tok::identifier)) { + Diag(Tok, diag::err_expected_ident); + SkipUntil(tok::greater); + return true; + } + ProtocolIdents.push_back(std::make_pair(Tok.getIdentifierInfo(), + Tok.getLocation())); + ConsumeToken(); + + if (Tok.isNot(tok::comma)) + break; + ConsumeToken(); + } + + // Consume the '>'. + if (Tok.isNot(tok::greater)) { + Diag(Tok, diag::err_expected_greater); + return true; + } + + EndLoc = ConsumeAnyToken(); + + // Convert the list of protocols identifiers into a list of protocol decls. + Actions.FindProtocolDeclaration(WarnOnDeclarations, + &ProtocolIdents[0], ProtocolIdents.size(), + Protocols); + return false; +} + /// objc-class-instance-variables: /// '{' objc-instance-variable-decl-list[opt] '}' /// @@ -899,17 +941,17 @@ Parser::DeclTy *Parser::ParseObjCAtProtocolDeclaration(SourceLocation AtLoc) { } // Last, and definitely not least, parse a protocol declaration. - SourceLocation endProtoLoc; - llvm::SmallVector<IdentifierLocPair, 8> ProtocolRefs; + SourceLocation EndProtoLoc; + llvm::SmallVector<DeclTy *, 8> ProtocolRefs; if (Tok.is(tok::less) && - ParseObjCProtocolReferences(ProtocolRefs, endProtoLoc)) + ParseObjCProtocolReferences(ProtocolRefs, true, EndProtoLoc)) return 0; - DeclTy *ProtoType = Actions.ActOnStartProtocolInterface(AtLoc, - protocolName, nameLoc, - &ProtocolRefs[0], - ProtocolRefs.size(), endProtoLoc); + DeclTy *ProtoType = + Actions.ActOnStartProtocolInterface(AtLoc, protocolName, nameLoc, + &ProtocolRefs[0], ProtocolRefs.size(), + EndProtoLoc); ParseObjCInterfaceDeclList(ProtoType, tok::objc_protocol); // The @ sign was already consumed by ParseObjCInterfaceDeclList(). |