summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/ParseObjc.cpp
diff options
context:
space:
mode:
authorAlex Lorenz <arphaman@gmail.com>2016-12-01 12:14:38 +0000
committerAlex Lorenz <arphaman@gmail.com>2016-12-01 12:14:38 +0000
commita589abc35346747b10f55bcf6a839fab8d5f9e62 (patch)
treea3e912fd5338716d405d668fab5b38ccf9d4a5fd /clang/lib/Parse/ParseObjc.cpp
parent947650e99d60452259cc3b9601a11bca588972ec (diff)
downloadbcm5719-llvm-a589abc35346747b10f55bcf6a839fab8d5f9e62.tar.gz
bcm5719-llvm-a589abc35346747b10f55bcf6a839fab8d5f9e62.zip
[ObjC] Avoid a @try/@finally/@autoreleasepool fixit when parsing an expression
This patch ensures that the typo fixit for the @try/@finally/@autoreleasepool {} directive is shown only when we're parsing an actual statement where such directives can actually be present. rdar://19669565 Differential Revision: https://reviews.llvm.org/D26916 llvm-svn: 288334
Diffstat (limited to 'clang/lib/Parse/ParseObjc.cpp')
-rw-r--r--clang/lib/Parse/ParseObjc.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/clang/lib/Parse/ParseObjc.cpp b/clang/lib/Parse/ParseObjc.cpp
index 42081a29ad9..81761bf8d2d 100644
--- a/clang/lib/Parse/ParseObjc.cpp
+++ b/clang/lib/Parse/ParseObjc.cpp
@@ -2773,6 +2773,7 @@ StmtResult Parser::ParseObjCAtStatement(SourceLocation AtLoc) {
return Actions.ActOnNullStmt(Tok.getLocation());
}
+ ExprStatementTokLoc = AtLoc;
ExprResult Res(ParseExpressionWithLeadingAt(AtLoc));
if (Res.isInvalid()) {
// If the expression is invalid, skip ahead to the next semicolon. Not
@@ -2869,7 +2870,11 @@ ExprResult Parser::ParseObjCAtExpression(SourceLocation AtLoc) {
return ParseAvailabilityCheckExpr(AtLoc);
default: {
const char *str = nullptr;
- if (GetLookAheadToken(1).is(tok::l_brace)) {
+ // Only provide the @try/@finally/@autoreleasepool fixit when we're sure
+ // that this is a proper statement where such directives could actually
+ // occur.
+ if (GetLookAheadToken(1).is(tok::l_brace) &&
+ ExprStatementTokLoc == AtLoc) {
char ch = Tok.getIdentifierInfo()->getNameStart()[0];
str =
ch == 't' ? "try"
OpenPOWER on IntegriCloud