diff options
author | Chris Lattner <sabre@nondot.org> | 2010-04-11 08:28:14 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-04-11 08:28:14 +0000 |
commit | a36ec4243bea51afe39c9d25206fe26dd30d748c (patch) | |
tree | 2ecb63e698763bc8137a6defde656d1ba0f4fcaf /clang/lib/Parse/ParseObjc.cpp | |
parent | 90c58faea6559a237ea26900a2494936b50eaa5a (diff) | |
download | bcm5719-llvm-a36ec4243bea51afe39c9d25206fe26dd30d748c.tar.gz bcm5719-llvm-a36ec4243bea51afe39c9d25206fe26dd30d748c.zip |
fix PR6811 by not parsing 'super' as a magic expression in
LookupInObjCMethod. Doing so allows all sorts of invalid code
to slip through to codegen. This patch does not change the
AST representation of super, though that would now be a natural
thing to do since it can only be in the receiver position and
in the base of a ObjCPropertyRefExpr.
There are still several ugly areas handling super in the parser,
but this is definitely a step in the right direction.
llvm-svn: 100959
Diffstat (limited to 'clang/lib/Parse/ParseObjc.cpp')
-rw-r--r-- | clang/lib/Parse/ParseObjc.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/clang/lib/Parse/ParseObjc.cpp b/clang/lib/Parse/ParseObjc.cpp index cd42aee255c..6e31f0f63c3 100644 --- a/clang/lib/Parse/ParseObjc.cpp +++ b/clang/lib/Parse/ParseObjc.cpp @@ -1709,6 +1709,7 @@ Parser::OwningExprResult Parser::ParseObjCAtExpression(SourceLocation AtLoc) { /// '[' objc-receiver objc-message-args ']' /// /// objc-receiver: +/// 'super' /// expression /// class-name /// type-name @@ -1716,16 +1717,22 @@ Parser::OwningExprResult Parser::ParseObjCMessageExpression() { assert(Tok.is(tok::l_square) && "'[' expected"); SourceLocation LBracLoc = ConsumeBracket(); // consume '[' - // Parse receiver - if (isTokObjCMessageIdentifierReceiver()) { - IdentifierInfo *ReceiverName = Tok.getIdentifierInfo(); - if (ReceiverName != Ident_super || GetLookAheadToken(1).isNot(tok::period)) { + if (Tok.is(tok::identifier)) { + IdentifierInfo *II = Tok.getIdentifierInfo(); + + // If this is '[' 'super', then this is a magic superclass message. + // We parse '[' 'super' '.' 'foo' as an expression? + // FIXME: Not in ParseInit.cpp? + if ((II == Ident_super && GetLookAheadToken(1).isNot(tok::period)) || + // Check to see if this is a typename. If so, it is a class message. + Actions.getTypeName(*II, Tok.getLocation(), CurScope)) { SourceLocation NameLoc = ConsumeToken(); - return ParseObjCMessageExpressionBody(LBracLoc, NameLoc, ReceiverName, + return ParseObjCMessageExpressionBody(LBracLoc, NameLoc, II, ExprArg(Actions)); } } - + + // Otherwise, an arbitrary expression can be the receiver of a send. OwningExprResult Res(ParseExpression()); if (Res.isInvalid()) { SkipUntil(tok::r_square); |