diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2012-07-09 20:00:35 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2012-07-09 20:00:35 +0000 |
commit | 6749ae1dbcc9e45ade21b05c6542a6354903ad77 (patch) | |
tree | 0ccb0e24ae8e2196d17ee53e4262174e4ab91031 | |
parent | 5047024845d0825fc8ab0a67ac4e096d981912ad (diff) |
objective-c: provide fixit hint for @autoreleasepool
and similar other keywords. // rdar://10723084
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159956 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Parse/ParseObjc.cpp | 19 | ||||
-rw-r--r-- | test/FixIt/fixit-autoreleasepool.m | 9 |
2 files changed, 26 insertions, 2 deletions
diff --git a/lib/Parse/ParseObjc.cpp b/lib/Parse/ParseObjc.cpp index 35e4222c52..857040f265 100644 --- a/lib/Parse/ParseObjc.cpp +++ b/lib/Parse/ParseObjc.cpp @@ -2094,8 +2094,23 @@ ExprResult Parser::ParseObjCAtExpression(SourceLocation AtLoc) { return ParsePostfixExpressionSuffix(ParseObjCProtocolExpression(AtLoc)); case tok::objc_selector: return ParsePostfixExpressionSuffix(ParseObjCSelectorExpression(AtLoc)); - default: - return ExprError(Diag(AtLoc, diag::err_unexpected_at)); + default: { + const char *str = 0; + if (GetLookAheadToken(1).is(tok::l_brace)) { + char ch = Tok.getIdentifierInfo()->getNameStart()[0]; + str = + ch == 't' ? "try" + : (ch == 'f' ? "finally" + : (ch == 'a' ? "autoreleasepool" : 0)); + } + if (str) { + SourceLocation kwLoc = Tok.getLocation(); + return ExprError(Diag(AtLoc, diag::err_unexpected_at) << + FixItHint::CreateReplacement(kwLoc, str)); + } + else + return ExprError(Diag(AtLoc, diag::err_unexpected_at)); + } } } } diff --git a/test/FixIt/fixit-autoreleasepool.m b/test/FixIt/fixit-autoreleasepool.m new file mode 100644 index 0000000000..ba1ad130f2 --- /dev/null +++ b/test/FixIt/fixit-autoreleasepool.m @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fdiagnostics-parseable-fixits -x objective-c %s 2>&1 | FileCheck %s +// rdar://10723084 + +void f0() { + @autorelease { + } +} + +// CHECK: {5:4-5:15}:"autoreleasepool" |