aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-02-15 19:17:31 +0000
committerDouglas Gregor <dgregor@apple.com>2011-02-15 19:17:31 +0000
commit97d7ff0e514793cb305a1595914f3c91833b4d8f (patch)
treebcf816eecfd42d4bf1a382899d75ed786540902b
parentd6c9a0f06ce7e164024d8e4dbf2423a5c5035084 (diff)
When we encounter an Objective-C class name in an expression, followed
by the code completion token, treat this as a class message send where the opening square bracket is missing. Fixes <rdar://problem/6970911>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125587 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Parse/ParseExpr.cpp15
-rw-r--r--test/Index/complete-objc-message.m5
2 files changed, 15 insertions, 5 deletions
diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp
index 55d2ba222f..4113c4fac2 100644
--- a/lib/Parse/ParseExpr.cpp
+++ b/lib/Parse/ParseExpr.cpp
@@ -669,12 +669,17 @@ ExprResult Parser::ParseCastExpression(bool isUnaryExpression,
break;
}
- // If we have an Objective-C class name followed by an identifier and
- // either ':' or ']', this is an Objective-C class message send that's
- // missing the opening '['. Recovery appropriately.
- if (getLang().ObjC1 && Tok.is(tok::identifier) && !InMessageExpression) {
+ // If we have an Objective-C class name followed by an identifier
+ // and either ':' or ']', this is an Objective-C class message
+ // send that's missing the opening '['. Recovery
+ // appropriately. Also take this path if we're performing code
+ // completion after an Objective-C class name.
+ if (getLang().ObjC1 &&
+ ((Tok.is(tok::identifier) && !InMessageExpression) ||
+ Tok.is(tok::code_completion))) {
const Token& Next = NextToken();
- if (Next.is(tok::colon) || Next.is(tok::r_square))
+ if (Tok.is(tok::code_completion) ||
+ Next.is(tok::colon) || Next.is(tok::r_square))
if (ParsedType Typ = Actions.getTypeName(II, ILoc, getCurScope()))
if (Typ.get()->isObjCObjectOrInterfaceType()) {
// Fake up a Declarator to use with ActOnTypeName.
diff --git a/test/Index/complete-objc-message.m b/test/Index/complete-objc-message.m
index 4e662b32ec..0658d53c65 100644
--- a/test/Index/complete-objc-message.m
+++ b/test/Index/complete-objc-message.m
@@ -171,6 +171,10 @@ void test_redundancy(C *c) {
}
@end
+void test_missing_open_more() {
+ A *a = A class_method3];
+}
+
// RUN: c-index-test -code-completion-at=%s:23:19 %s | FileCheck -check-prefix=CHECK-CC1 %s
// CHECK-CC1: {TypedText categoryClassMethod}
// CHECK-CC1: {TypedText classMethod1:}{Placeholder (id)}{HorizontalSpace }{TypedText withKeyword:}{Placeholder (int)}
@@ -294,3 +298,4 @@ void test_redundancy(C *c) {
// RUN: c-index-test -code-completion-at=%s:141:23 %s | FileCheck -check-prefix=CHECK-CCD %s
// RUN: c-index-test -code-completion-at=%s:141:30 %s | FileCheck -check-prefix=CHECK-CCE %s
+// RUN: c-index-test -code-completion-at=%s:175:12 %s | FileCheck -check-prefix=CHECK-CLASS-RESULT %s