[cfe-commits] r161015 - in /cfe/trunk: lib/Parse/ParseExprCXX.cpp test/Index/complete-lambdas.mm

Jordan Rose jordan_rose at apple.com
Mon Jul 30 17:53:22 PDT 2012


I thought about this too when I was looking into this. It seems like this prefers message expansion for "[a,b" (arguable) and even "[&,b" (wrong). This is certainly strictly better than before, but maybe it's better to only prefer message expansion if there haven't been any commas yet?

(That's why I suggested doing it back in the lookahead stages of disambiguation.)
Jordan


On Jul 30, 2012, at 17:50 , Douglas Gregor <dgregor at apple.com> wrote:

> Author: dgregor
> Date: Mon Jul 30 19:50:07 2012
> New Revision: 161015
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=161015&view=rev
> Log:
> When we encounter a code-completion token while parsing an ill-formed
> lambda-introducer in Objective-C++11, fall back to treating the tokens
> as an Objective-C message send to provide those (more likely)
> completions. Fixes <rdar://problem/11980263>.
> 
> Added:
>    cfe/trunk/test/Index/complete-lambdas.mm
> Modified:
>    cfe/trunk/lib/Parse/ParseExprCXX.cpp
> 
> Modified: cfe/trunk/lib/Parse/ParseExprCXX.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExprCXX.cpp?rev=161015&r1=161014&r2=161015&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Parse/ParseExprCXX.cpp (original)
> +++ cfe/trunk/lib/Parse/ParseExprCXX.cpp Mon Jul 30 19:50:07 2012
> @@ -642,7 +642,11 @@
>   while (Tok.isNot(tok::r_square)) {
>     if (!first) {
>       if (Tok.isNot(tok::comma)) {
> -        if (Tok.is(tok::code_completion)) {
> +        // Provide a completion for a lambda introducer here. Except
> +        // 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) {
>           Actions.CodeCompleteLambdaIntroducer(getCurScope(), Intro, 
>                                                /*AfterAmpersand=*/false);
>           ConsumeCodeCompletionToken();
> 
> Added: cfe/trunk/test/Index/complete-lambdas.mm
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/complete-lambdas.mm?rev=161015&view=auto
> ==============================================================================
> --- cfe/trunk/test/Index/complete-lambdas.mm (added)
> +++ cfe/trunk/test/Index/complete-lambdas.mm Mon Jul 30 19:50:07 2012
> @@ -0,0 +1,40 @@
> +// This test is line- and column-sensitive. See below for run lines.
> +
> +
> + at interface A
> +- instanceMethod:(int)value withOther:(int)other;
> ++ classMethod;
> + at end
> +
> + at interface B : A
> + at end
> +
> + at implementation B
> +- someMethod:(A*)a {
> +  [a classMethod];
> +  [A classMethod];
> +  [a instanceMethod:0 withOther:1];
> +  [self someMethod:a];
> +  [super instanceMethod];
> +}
> +
> + at end
> +
> +// RUN: c-index-test -code-completion-at=%s:14:6 -std=c++11 %s | FileCheck -check-prefix=CHECK-CC1 %s
> +// CHECK-CC1: ObjCInstanceMethodDecl:{ResultType id}{TypedText instanceMethod:}{Placeholder (int)}{HorizontalSpace  }{TypedText withOther:}{Placeholder (int)} (35) (parent: ObjCInterfaceDecl 'A')
> +
> +// RUN: c-index-test -code-completion-at=%s:15:6 -std=c++11 %s | FileCheck -check-prefix=CHECK-CC2 %s
> +// CHECK-CC2: ObjCClassMethodDecl:{ResultType id}{TypedText classMethod} (35) (parent: ObjCInterfaceDecl 'A')
> +
> +// RUN: c-index-test -code-completion-at=%s:16:4 -std=c++11 %s | FileCheck -check-prefix=CHECK-CC3 %s
> +// CHECK-CC3: ObjCInterfaceDecl:{TypedText A} (50) (parent: TranslationUnit '(null)')
> +// CHECK-CC3: ParmDecl:{ResultType A *}{TypedText a} (34)
> +// CHECK-CC3: ObjCInterfaceDecl:{TypedText B} (50) (parent: TranslationUnit '(null)')
> +// CHECK-CC3: TypedefDecl:{TypedText Class} (50) (parent: TranslationUnit '(null)')
> +
> +
> +// RUN: c-index-test -code-completion-at=%s:16:21 -x objective-c++ -std=c++11 %s | FileCheck -check-prefix=CHECK-CC4 %s
> +// CHECK-CC4: NotImplemented:{ResultType B *}{TypedText self} (34)
> +// 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
> 
> 
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




More information about the cfe-commits mailing list