From e5798dcb413e2cacfcf00452fb7fe14ba51bef6d Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Wed, 21 Apr 2010 20:38:13 +0000 Subject: Migrate the responsibility for turning the receiver name in an Objective-C class message expression into a type from the parser (which was doing so in two places) to Action::getObjCMessageKind() which, in the case of Sema, reduces the number of name lookups we need to perform. llvm-svn: 102026 --- clang/lib/Parse/ParseObjc.cpp | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) (limited to 'clang/lib/Parse/ParseObjc.cpp') diff --git a/clang/lib/Parse/ParseObjc.cpp b/clang/lib/Parse/ParseObjc.cpp index 56937a66cdc..2a71bf024bf 100644 --- a/clang/lib/Parse/ParseObjc.cpp +++ b/clang/lib/Parse/ParseObjc.cpp @@ -1726,40 +1726,26 @@ Parser::OwningExprResult Parser::ParseObjCMessageExpression() { if (Tok.is(tok::identifier)) { IdentifierInfo *Name = Tok.getIdentifierInfo(); SourceLocation NameLoc = Tok.getLocation(); + TypeTy *ReceiverType; switch (Actions.getObjCMessageKind(CurScope, Name, NameLoc, Name == Ident_super, - NextToken().is(tok::period))) { + NextToken().is(tok::period), + ReceiverType)) { case Action::ObjCSuperMessage: return ParseObjCMessageExpressionBody(LBracLoc, ConsumeToken(), 0, ExprArg(Actions)); - case Action::ObjCClassMessage: { - // Create the type that corresponds to the identifier (which - // names an Objective-C class). - TypeTy *Type = 0; - if (TypeTy *TyName = Actions.getTypeName(*Name, NameLoc, CurScope)) { - DeclSpec DS; - const char *PrevSpec = 0; - unsigned DiagID = 0; - if (!DS.SetTypeSpecType(DeclSpec::TST_typename, NameLoc, PrevSpec, - DiagID, TyName)) { - DS.SetRangeEnd(NameLoc); - Declarator DeclaratorInfo(DS, Declarator::TypeNameContext); - TypeResult Ty = Actions.ActOnTypeName(CurScope, DeclaratorInfo); - if (!Ty.isInvalid()) - Type = Ty.get(); - } - } - - ConsumeToken(); // The identifier. - if (!Type) { + case Action::ObjCClassMessage: + if (!ReceiverType) { SkipUntil(tok::r_square); return ExprError(); } - return ParseObjCMessageExpressionBody(LBracLoc, SourceLocation(), Type, + ConsumeToken(); // the type name + + return ParseObjCMessageExpressionBody(LBracLoc, SourceLocation(), + ReceiverType, ExprArg(Actions)); - } case Action::ObjCInstanceMessage: // Fall through to parse an expression. -- cgit v1.2.3