Skip to content

Commit 639da07

Browse files
committed
Update tests
1 parent aa2c6fe commit 639da07

File tree

2 files changed

+83
-0
lines changed

2 files changed

+83
-0
lines changed

clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4538,6 +4538,7 @@ TEST(CompletionTest, ListExplicitObjectOverloads) {
45384538
struct S {
45394539
void foo1(int a);
45404540
void foo2(int a) const;
4541+
void foo2(this const S& self, float a);
45414542
void foo3(this const S& self, int a);
45424543
void foo4(this S& self, int a);
45434544
};
@@ -4587,6 +4588,8 @@ TEST(CompletionTest, ListExplicitObjectOverloads) {
45874588
snippetSuffix("(${1:int a})")),
45884589
AllOf(named("foo2"), signature("(int a) const"),
45894590
snippetSuffix("(${1:int a})")),
4591+
AllOf(named("foo2"), signature("(float a) const"),
4592+
snippetSuffix("(${1:float a})")),
45904593
AllOf(named("foo3"), signature("(int a) const"),
45914594
snippetSuffix("(${1:int a})")),
45924595
AllOf(named("foo4"), signature("(int a)"),
@@ -4599,6 +4602,8 @@ TEST(CompletionTest, ListExplicitObjectOverloads) {
45994602
Result.Completions,
46004603
UnorderedElementsAre(AllOf(named("foo2"), signature("(int a) const"),
46014604
snippetSuffix("(${1:int a})")),
4605+
AllOf(named("foo2"), signature("(float a) const"),
4606+
snippetSuffix("(${1:float a})")),
46024607
AllOf(named("foo3"), signature("(int a) const"),
46034608
snippetSuffix("(${1:int a})"))));
46044609
}
@@ -4609,6 +4614,8 @@ TEST(CompletionTest, ListExplicitObjectOverloads) {
46094614
Result.Completions,
46104615
UnorderedElementsAre(AllOf(named("foo2"), signature("(int a) const"),
46114616
snippetSuffix("(${1:int a})")),
4617+
AllOf(named("foo2"), signature("(float a) const"),
4618+
snippetSuffix("(${1:float a})")),
46124619
AllOf(named("foo3"), signature("(int a) const"),
46134620
snippetSuffix("(${1:int a})"))));
46144621
}
@@ -4621,6 +4628,8 @@ TEST(CompletionTest, ListExplicitObjectOverloads) {
46214628
snippetSuffix("(${1:int a})")),
46224629
AllOf(named("foo2"), signature("(int a) const"),
46234630
snippetSuffix("(${1:int a})")),
4631+
AllOf(named("foo2"), signature("(float a) const"),
4632+
snippetSuffix("(${1:float a})")),
46244633
AllOf(named("foo3"), signature("(int a) const"),
46254634
snippetSuffix("(${1:int a})")),
46264635
AllOf(named("foo4"), signature("(int a)"),
@@ -4635,6 +4644,8 @@ TEST(CompletionTest, ListExplicitObjectOverloads) {
46354644
snippetSuffix("(${1:int a})")),
46364645
AllOf(named("foo2"), signature("(int a) const"),
46374646
snippetSuffix("(${1:int a})")),
4647+
AllOf(named("foo2"), signature("(float a) const"),
4648+
snippetSuffix("(${1:float a})")),
46384649
AllOf(named("foo3"), signature("(int a) const"),
46394650
snippetSuffix("(${1:int a})")),
46404651
AllOf(named("foo4"), signature("(int a)"),
@@ -4647,6 +4658,8 @@ TEST(CompletionTest, ListExplicitObjectOverloads) {
46474658
Result.Completions,
46484659
UnorderedElementsAre(AllOf(named("foo2"), signature("(int a) const"),
46494660
snippetSuffix("(${1:int a})")),
4661+
AllOf(named("foo2"), signature("(float a) const"),
4662+
snippetSuffix("(${1:float a})")),
46504663
AllOf(named("foo3"), signature("(int a) const"),
46514664
snippetSuffix("(${1:int a})"))));
46524665
}

clang/test/CodeCompletion/cpp23-explicit-object.cpp

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,73 @@ struct C {
8181
}
8282
};
8383

84+
85+
struct S {
86+
void foo1(int a);
87+
void foo2(int a) const;
88+
void foo2(this const S& self, float a);
89+
void foo3(this const S& self, int a);
90+
void foo4(this S& self, int a);
91+
};
92+
93+
void S::foo1(int a) {
94+
this->;
95+
// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):9 -std=c++23 %s | FileCheck -check-prefix=CHECK-CC7 %s
96+
// CHECK-CC7: COMPLETION: foo1 : [#void#]foo1(<#int a#>)
97+
// CHECK-CC7: COMPLETION: foo2 : [#void#]foo2(<#int a#>)[# const#]
98+
// CHECK-CC7: COMPLETION: foo2 : [#void#]foo2(<#float a#>)[# const#]
99+
// CHECK-CC7: COMPLETION: foo3 : [#void#]foo3(<#int a#>)[# const#]
100+
// CHECK-CC7: COMPLETION: foo4 : [#void#]foo4(<#int a#>)
101+
}
102+
103+
void S::foo2(int a) const {
104+
this->;
105+
// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):9 -std=c++23 %s | FileCheck -check-prefix=CHECK-CC8 %s
106+
// CHECK-CC8: COMPLETION: foo2 : [#void#]foo2(<#int a#>)[# const#]
107+
// CHECK-CC8: COMPLETION: foo2 : [#void#]foo2(<#float a#>)[# const#]
108+
// CHECK-CC8: COMPLETION: foo3 : [#void#]foo3(<#int a#>)[# const#]
109+
}
110+
111+
void S::foo3(this const S& self, int a) {
112+
self.;
113+
// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):8 -std=c++23 %s | FileCheck -check-prefix=CHECK-CC9 %s
114+
// CHECK-CC9: COMPLETION: foo2 : [#void#]foo2(<#int a#>)[# const#]
115+
// CHECK-CC9: COMPLETION: foo2 : [#void#]foo2(<#float a#>)[# const#]
116+
// CHECK-CC9: COMPLETION: foo3 : [#void#]foo3(<#int a#>)[# const#]
117+
}
118+
119+
void S::foo4(this S& self, int a) {
120+
self.;
121+
// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):8 -std=c++23 %s | FileCheck -check-prefix=CHECK-CC10 %s
122+
// CHECK-CC10: COMPLETION: foo1 : [#void#]foo1(<#int a#>)
123+
// CHECK-CC10: COMPLETION: foo2 : [#void#]foo2(<#int a#>)[# const#]
124+
// CHECK-CC10: COMPLETION: foo2 : [#void#]foo2(<#float a#>)[# const#]
125+
// CHECK-CC10: COMPLETION: foo3 : [#void#]foo3(<#int a#>)[# const#]
126+
// CHECK-CC10: COMPLETION: foo4 : [#void#]foo4(<#int a#>)
127+
}
128+
129+
void test1(S s) {
130+
s.;
131+
// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):5 -std=c++23 %s | FileCheck -check-prefix=CHECK-CC11 %s
132+
// CHECK-CC11: COMPLETION: foo1 : [#void#]foo1(<#int a#>)
133+
// CHECK-CC11: COMPLETION: foo2 : [#void#]foo2(<#int a#>)[# const#]
134+
// CHECK-CC11: COMPLETION: foo2 : [#void#]foo2(<#float a#>)[# const#]
135+
// CHECK-CC11: COMPLETION: foo3 : [#void#]foo3(<#int a#>)[# const#]
136+
// CHECK-CC11: COMPLETION: foo4 : [#void#]foo4(<#int a#>)
137+
}
138+
139+
void test2(const S s) {
140+
s.;
141+
// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):5 -std=c++23 %s | FileCheck -check-prefix=CHECK-CC12 %s
142+
// CHECK-CC12: COMPLETION: foo2 : [#void#]foo2(<#int a#>)[# const#]
143+
// CHECK-CC12: COMPLETION: foo2 : [#void#]foo2(<#float a#>)[# const#]
144+
// CHECK-CC12: COMPLETION: foo3 : [#void#]foo3(<#int a#>)[# const#]
145+
}
146+
147+
void test3(S s) {
148+
s.foo2();
149+
// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):10 -std=c++23 %s | FileCheck -check-prefix=CHECK-CC13 %s
150+
// CHECK-CC13: OVERLOAD: [#void#]foo2(<#int a#>)
151+
// CHECK-CC13: OVERLOAD: [#void#]foo2(float a)
152+
// TODO: foo2 should be OVERLOAD: [#void#]foo2(<#float a#>)
153+
}

0 commit comments

Comments
 (0)