]> granicus.if.org Git - clang/commitdiff
Tweak code-completion heuristics deciding between a lambda
authorDouglas Gregor <dgregor@apple.com>
Tue, 31 Jul 2012 15:27:48 +0000 (15:27 +0000)
committerDouglas Gregor <dgregor@apple.com>
Tue, 31 Jul 2012 15:27:48 +0000 (15:27 +0000)
code-completion and an Objective-C message send, based on Jordan's
feedback.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161049 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseExprCXX.cpp
test/Index/complete-lambdas.mm

index b1ce59f28c778b88b93f5f363e553a1d9e95c0e7..592a3cc160bcd15a959a812da634abb638e0f23a 100644 (file)
@@ -646,7 +646,9 @@ llvm::Optional<unsigned> Parser::ParseLambdaIntroducer(LambdaIntroducer &Intro){
         // in Objective-C, where this is Almost Surely meant to be a message
         // send. In that case, fail here and let the ObjC message
         // expression parser perform the completion.
-        if (Tok.is(tok::code_completion) && !getLangOpts().ObjC1) {
+        if (Tok.is(tok::code_completion) &&
+            !(getLangOpts().ObjC1 && Intro.Default == LCD_None &&
+              !Intro.Captures.empty())) {
           Actions.CodeCompleteLambdaIntroducer(getCurScope(), Intro, 
                                                /*AfterAmpersand=*/false);
           ConsumeCodeCompletionToken();
index 5f33906471d0ea323e2bc154f70035cf15d32aa6..3f77dd2069229857e3815c3974c90cbaf9ceaaee 100644 (file)
@@ -16,6 +16,8 @@
   [a instanceMethod:0 withOther:1];
   [self someMethod:a];
   [super instanceMethod];
+  [&,a ]{};
+  [a,self instanceMethod:0 withOther:1]{};  
 }
 
 @end
 // CHECK-CC4: NotImplemented:{ResultType A *}{TypedText super} (40)
 
 // RUN: c-index-test -code-completion-at=%s:18:10 -x objective-c++ -std=c++11 %s | FileCheck -check-prefix=CHECK-CC1 %s
+
+// RUN: c-index-test -code-completion-at=%s:19:8 -x objective-c++ -std=c++11 %s | FileCheck -check-prefix=CHECK-CC5 %s
+// CHECK-CC5: NotImplemented:{ResultType SEL}{TypedText _cmd} (80)
+// CHECK-CC5-NEXT: NotImplemented:{ResultType B *}{TypedText self} (34)
+
+// RUN: c-index-test -code-completion-at=%s:20:11 -x objective-c++ -std=c++11 %s | FileCheck -check-prefix=CHECK-CC6 %s
+// CHECK-CC6: ObjCInstanceMethodDecl:{ResultType id}{TypedText instanceMethod:}{Placeholder (int)}{HorizontalSpace  }{TypedText withOther:}{Placeholder (int)} (37) (parent: ObjCInterfaceDecl 'A')
+// CHECK-CC6-NEXT: ObjCInstanceMethodDecl:{ResultType id}{TypedText someMethod:}{Placeholder (A *)} (32) (parent: ObjCImplementationDecl 'B')
+