Patch to parse objective-c's @try-statement and @throw-statement.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42148 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Parse/ParseExpr.cpp b/Parse/ParseExpr.cpp
index 2e2a64e..1a7c403 100644
--- a/Parse/ParseExpr.cpp
+++ b/Parse/ParseExpr.cpp
@@ -172,6 +172,18 @@
return ParseRHSOfBinaryExpression(LHS, prec::Comma);
}
+/// This routine is called when the '@' is seen and consumed.
+/// Current token is an Identifier and is not a 'try'. This
+/// routine is necessary to disambiguate @try-statement from
+/// ,for example, @encode-expression.
+///
+Parser::ExprResult Parser::ParseExpressionWithLeadingAt(SourceLocation &AtLoc) {
+ ExprResult LHS = ParseObjCExpression(AtLoc);
+ if (LHS.isInvalid) return LHS;
+
+ return ParseRHSOfBinaryExpression(LHS, prec::Comma);
+}
+
/// ParseAssignmentExpression - Parse an expr that doesn't include commas.
///
Parser::ExprResult Parser::ParseAssignmentExpression() {
@@ -589,7 +601,10 @@
case tok::kw_static_cast:
return ParseCXXCasts();
case tok::at:
- return ParseObjCExpression();
+ {
+ SourceLocation AtLoc = ConsumeToken();
+ return ParseObjCExpression(AtLoc);
+ }
case tok::l_square:
return ParseObjCMessageExpression ();
default: