[cfe-commits] r159956 - in /cfe/trunk: lib/Parse/ParseObjc.cpp test/FixIt/fixit-autoreleasepool.m
Fariborz Jahanian
fjahanian at apple.com
Mon Jul 9 13:00:35 PDT 2012
Author: fjahanian
Date: Mon Jul 9 15:00:35 2012
New Revision: 159956
URL: http://llvm.org/viewvc/llvm-project?rev=159956&view=rev
Log:
objective-c: provide fixit hint for @autoreleasepool
and similar other keywords. // rdar://10723084
Added:
cfe/trunk/test/FixIt/fixit-autoreleasepool.m
Modified:
cfe/trunk/lib/Parse/ParseObjc.cpp
Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=159956&r1=159955&r2=159956&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Mon Jul 9 15:00:35 2012
@@ -2094,8 +2094,23 @@
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));
+ }
}
}
}
Added: cfe/trunk/test/FixIt/fixit-autoreleasepool.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/FixIt/fixit-autoreleasepool.m?rev=159956&view=auto
==============================================================================
--- cfe/trunk/test/FixIt/fixit-autoreleasepool.m (added)
+++ cfe/trunk/test/FixIt/fixit-autoreleasepool.m Mon Jul 9 15:00:35 2012
@@ -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"
More information about the cfe-commits
mailing list