Skip to content

Commit 203317b

Browse files
committed
code review
1 parent e08005e commit 203317b

File tree

2 files changed

+30
-20
lines changed

2 files changed

+30
-20
lines changed

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

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3307,12 +3307,12 @@ TEST(SignatureHelpTest, SkipExplicitObjectParameter) {
33073307
EXPECT_THAT(Result.signatures[0], AllOf(sig("([[A]], [[int]]) -> void")));
33083308
}
33093309
{
3310+
// TODO: llvm/llvm-project/146649
33103311
const auto Result = signatureHelp(testPath(TU.Filename), Code.point("c3"),
33113312
*Preamble, Inputs, MarkupKind::PlainText);
3312-
// TODO: We expect 1 signature here
3313-
// EXPECT_EQ(1U, Result.signatures.size());
3314-
3315-
// EXPECT_THAT(Result.signatures[0], AllOf(sig("([[A]], [[int]]) ->
3313+
// TODO: We expect 1 signature here, with this signature
3314+
EXPECT_EQ(0U, Result.signatures.size());
3315+
// EXPECT_THAT(Result.signatures[0], AllOf(sig("([[A&&]], [[int]]) ->
33163316
// void")));
33173317
}
33183318
}
@@ -4424,12 +4424,19 @@ TEST(CompletionTest, SkipExplicitObjectParameter) {
44244424
44254425
int main() {
44264426
A a {};
4427-
a.$c1^
4428-
(&A::ba$c2^;
4429-
(&A::fo$c3^;
4427+
a.$c1^;
4428+
(&A::fo$c2^;
4429+
(&A::ba$c3^;
44304430
}
44314431
)cpp");
44324432

4433+
// TODO: llvm/llvm-project/146649
4434+
// This is incorrect behavior. Correct Result should be a variant of,
4435+
// c2: signature = (A&& self, int arg)
4436+
// snippet = (${1: A&& self}, ${2: int arg})
4437+
// c3: signature = (A self, int arg)
4438+
// snippet = (${1: A self}, ${2: int arg})
4439+
44334440
auto TU = TestTU::withCode(Code.code());
44344441
TU.ExtraArgs = {"-std=c++23"};
44354442

@@ -4444,28 +4451,27 @@ TEST(CompletionTest, SkipExplicitObjectParameter) {
44444451
auto Result = codeComplete(testPath(TU.Filename), Code.point("c1"),
44454452
Preamble.get(), Inputs, Opts);
44464453

4447-
EXPECT_THAT(
4448-
Result.Completions,
4449-
UnorderedElementsAre(
4450-
AllOf(named("foo"), signature("(int arg)"), snippetSuffix("")),
4451-
AllOf(named("bar"), signature("(int arg)"), snippetSuffix(""))));
4452-
}
4453-
{
4454-
auto Result = codeComplete(testPath(TU.Filename), Code.point("c2"),
4455-
Preamble.get(), Inputs, Opts);
4456-
// TODO: snippet suffix is empty for c2
44574454
EXPECT_THAT(Result.Completions,
4458-
ElementsAre(AllOf(named("bar"), signature("(int arg)"),
4459-
snippetSuffix(""))));
4455+
UnorderedElementsAre(AllOf(named("foo"), signature("(int arg)"),
4456+
snippetSuffix("(${1:int arg})")),
4457+
AllOf(named("bar"), signature("(int arg)"),
4458+
snippetSuffix("(${1:int arg})"))));
44604459
}
44614460
{
4462-
auto Result = codeComplete(testPath(TU.Filename), Code.point("c3"),
4461+
auto Result = codeComplete(testPath(TU.Filename), Code.point("c2"),
44634462
Preamble.get(), Inputs, Opts);
44644463
EXPECT_THAT(
44654464
Result.Completions,
44664465
ElementsAre(AllOf(named("foo"), signature("<class self:auto>(int arg)"),
44674466
snippetSuffix("<${1:class self:auto}>"))));
44684467
}
4468+
{
4469+
auto Result = codeComplete(testPath(TU.Filename), Code.point("c3"),
4470+
Preamble.get(), Inputs, Opts);
4471+
EXPECT_THAT(Result.Completions,
4472+
ElementsAre(AllOf(named("bar"), signature("(int arg)"),
4473+
snippetSuffix(""))));
4474+
}
44694475
}
44704476
} // namespace
44714477
} // namespace clangd

clang/test/CodeCompletion/skip-explicit-object-parameter.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ int func2() {
2727
// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-2):9 -std=c++23 %s | FileCheck -check-prefix=CHECK-CC2 %s
2828
// CHECK-CC2: OVERLOAD: [#void#]foo(int arg)
2929

30+
// TODO: llvm/llvm-project/146649
31+
// This is incorrect behavior. Correct Result should be a variant of,
32+
// CC3: should be something like [#void#]foo(<#A self#>, <#int arg#>)
33+
// CC4: should be something like [#void#]bar(<#A self#>, <#int arg#>)
3034
int func3() {
3135
(&A::foo)
3236
(&A::bar)

0 commit comments

Comments
 (0)