aboutsummaryrefslogtreecommitdiff
path: root/lib/Parse/ParseExpr.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-05-31 18:18:22 +0000
committerChris Lattner <sabre@nondot.org>2010-05-31 18:18:22 +0000
commitc59cb38810c63a806270385f79ea84e0203754ea (patch)
tree610b846d11888eb4365f2b4eef33c91915508bc8 /lib/Parse/ParseExpr.cpp
parent61ecf35dcb18f53ea4b41ce9b8152f8046616be6 (diff)
Minor tweaks on doug's objc recovery patch: the caller
of isSimpleObjCMessageExpression checks the language, so change a dynamic check into an assert. isSimpleObjCMessageExpression is expensive, so only do it in the common case when it is likely to matter: when the [ of the postfix expr starts on a new line. This should avoid doing lookahead for every array expression. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105229 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseExpr.cpp')
-rw-r--r--lib/Parse/ParseExpr.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp
index 093f9738ca..cc69bdc065 100644
--- a/lib/Parse/ParseExpr.cpp
+++ b/lib/Parse/ParseExpr.cpp
@@ -961,7 +961,14 @@ Parser::ParsePostfixExpressionSuffix(OwningExprResult LHS) {
default: // Not a postfix-expression suffix.
return move(LHS);
case tok::l_square: { // postfix-expression: p-e '[' expression ']'
- if (getLang().ObjC1 && isSimpleObjCMessageExpression())
+ // If we have a array postfix expression that starts on a new line and
+ // Objective-C is enabled, it is highly likely that the user forgot a
+ // semicolon after the base expression and that the array postfix-expr is
+ // actually another message send. In this case, do some look-ahead to see
+ // if the contents of the square brackets are obviously not a valid
+ // expression and recover by pretending there is no suffix.
+ if (getLang().ObjC1 && Tok.isAtStartOfLine() &&
+ isSimpleObjCMessageExpression())
return move(LHS);
Loc = ConsumeBracket();