[PATCH] D73177: [clang][CodeComplete] Make completion work after initializer lists
Kadir Cetinkaya via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 22 05:20:04 PST 2020
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
CodeCompletion was not being triggered after successfully parsed
initializer lists, e.g.
cpp
void foo(int, bool);
void bar() {
foo({1}^, false);
}
CodeCompletion would suggest the function foo as an overload candidate up until
the point marked with `^` but after that point we do not trigger signature help
since parsing succeeds.
This patch handles that case by failing in parsing expression lists whenever we
see a codecompletion token, in addition to getting an invalid subexpression.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D73177
Files:
clang/lib/Parse/ParseExpr.cpp
clang/test/CodeCompletion/call.cpp
Index: clang/test/CodeCompletion/call.cpp
===================================================================
--- clang/test/CodeCompletion/call.cpp
+++ clang/test/CodeCompletion/call.cpp
@@ -25,4 +25,10 @@
// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:19:13 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
// CHECK-CC2-NOT: f(Y y, int ZZ)
// CHECK-CC2: f(int i, int j, <#int k#>)
+ f({}, 0, 0);
+ // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:28:7 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
+ // CHECK-CC3: OVERLOAD: [#void#]f()
+ // CHECK-CC3-NEXT: OVERLOAD: [#void#]f(<#X#>)
+ // CHECK-CC3-NEXT: OVERLOAD: [#void#]f(<#int i#>, int j, int k)
+ // CHECK-CC3-NEXT: OVERLOAD: [#void#]f(<#float x#>, float y)
}
Index: clang/lib/Parse/ParseExpr.cpp
===================================================================
--- clang/lib/Parse/ParseExpr.cpp
+++ clang/lib/Parse/ParseExpr.cpp
@@ -3128,6 +3128,11 @@
if (Tok.is(tok::ellipsis))
Expr = Actions.ActOnPackExpansion(Expr.get(), ConsumeToken());
+ else if (Tok.is(tok::code_completion)) {
+ SawError = true;
+ cutOffParsing();
+ break;
+ }
if (Expr.isInvalid()) {
SkipUntil(tok::comma, tok::r_paren, StopBeforeMatch);
SawError = true;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73177.239551.patch
Type: text/x-patch
Size: 1303 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200122/4cbb6253/attachment.bin>
More information about the cfe-commits
mailing list