File tree Expand file tree Collapse file tree 3 files changed +54
-6
lines changed Expand file tree Collapse file tree 3 files changed +54
-6
lines changed Original file line number Diff line number Diff line change @@ -3267,6 +3267,34 @@ TEST(SignatureHelpTest, VariadicType) {
32673267 }
32683268}
32693269
3270+ TEST (SignatureHelpTest, SkipExplicitObjectParameter) {
3271+ Annotations Code (R"cpp(
3272+ struct A {
3273+ void foo(this auto&& self, int arg);
3274+ };
3275+ int main() {
3276+ A a {};
3277+ a.foo(^);
3278+ }
3279+ )cpp" );
3280+
3281+ auto TU = TestTU::withCode (Code.code ());
3282+ TU.ExtraArgs = {" -std=c++23" };
3283+
3284+ MockFS FS;
3285+ auto Inputs = TU.inputs (FS);
3286+
3287+ auto Preamble = TU.preamble ();
3288+ ASSERT_TRUE (Preamble);
3289+
3290+ const auto Result = signatureHelp (testPath (TU.Filename ), Code.point (),
3291+ *Preamble, Inputs, MarkupKind::PlainText);
3292+
3293+ EXPECT_EQ (1 , Result.signatures .size ());
3294+
3295+ EXPECT_THAT (Result.signatures [0 ], AllOf (sig (" foo([[int arg]]) -> void" )));
3296+ }
3297+
32703298TEST (CompletionTest, IncludedCompletionKinds) {
32713299 Annotations Test (R"cpp( #include "^)cpp" );
32723300 auto TU = TestTU::withCode (Test.code ());
Original file line number Diff line number Diff line change @@ -4034,6 +4034,14 @@ static void AddOverloadParameterChunks(
40344034 return ;
40354035 }
40364036
4037+ // C++23 introduces an explicit object parameter, a.k.a. "deducing this"
4038+ // Skip it for autocomplete and treat the next parameter as the first
4039+ // parameter
4040+ if (Function && FirstParameter &&
4041+ Function->getParamDecl (P)->isExplicitObjectParameter ()) {
4042+ continue ;
4043+ }
4044+
40374045 if (FirstParameter)
40384046 FirstParameter = false ;
40394047 else
Original file line number Diff line number Diff line change @@ -6,9 +6,21 @@ int main() {
66 A a {};
77 a.
88}
9- // RUN: %clang_cc1 -cc1 -fsyntax-only -code-completion-at=%s:%(line-2):5 -std=c++23 %s | FileCheck %s
10- // CHECK: COMPLETION: A : A::
11- // CHECK-NEXT: COMPLETION: foo : [#void#]foo(<#int arg#>)
12- // CHECK-NEXT: COMPLETION: operator= : [#A &#]operator=(<#const A &#>)
13- // CHECK-NEXT: COMPLETION: operator= : [#A &#]operator=(<#A &&#>)
14- // CHECK-NEXT: COMPLETION: ~A : [#void#]~A()
9+ // RUN: %clang_cc1 -cc1 -fsyntax-only -code-completion-at=%s:%(line-2):5 -std=c++23 %s | FileCheck -check-prefix=CHECK-CC1 %s
10+ // CHECK-CC1: COMPLETION: A : A::
11+ // CHECK-NEXT-CC1: COMPLETION: foo : [#void#]foo(<#int arg#>)
12+ // CHECK-NEXT-CC1: COMPLETION: operator= : [#A &#]operator=(<#const A &#>)
13+ // CHECK-NEXT-CC1: COMPLETION: operator= : [#A &#]operator=(<#A &&#>)
14+ // CHECK-NEXT-CC1: COMPLETION: ~A : [#void#]~A()
15+
16+ struct B {
17+ template <typename T>
18+ void foo (this T&& self, int arg);
19+ };
20+
21+ int main2 () {
22+ B b {};
23+ b.foo ();
24+ }
25+ // RUN: %clang_cc1 -cc1 -fsyntax-only -code-completion-at=%s:%(line-2):9 -std=c++23 %s | FileCheck -check-prefix=CHECK-CC2 %s
26+ // CHECK-CC2: OVERLOAD: [#void#]foo(int arg)
You can’t perform that action at this time.
0 commit comments