[clang] [clang-tools-extra] [clang][CodeComplete] skip explicit obj param in SignatureHelp (PR #146649)

Mythreya Kuricheti via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 29 03:07:56 PDT 2025


================
@@ -4386,12 +4430,24 @@ TEST(CompletionTest, SkipExplicitObjectParameter) {
 
   MockFS FS;
   auto Inputs = TU.inputs(FS);
-  auto Result = codeComplete(testPath(TU.Filename), Code.point(),
-                             Preamble.get(), Inputs, Opts);
-
-  EXPECT_THAT(Result.Completions,
-              ElementsAre(AllOf(named("foo"), signature("(int arg)"),
-                                snippetSuffix("(${1:int arg})"))));
+  {
+    auto Result = codeComplete(testPath(TU.Filename), Code.point("c1"),
+                               Preamble.get(), Inputs, Opts);
+
+    EXPECT_THAT(Result.Completions,
+                UnorderedElementsAre(AllOf(named("foo"), signature("(int arg)"),
+                                           snippetSuffix("(${1:int arg})")),
+                                     AllOf(named("bar"), signature("(int arg)"),
+                                           snippetSuffix("(${1:int arg})"))));
+  }
+  {
+    auto Result = codeComplete(testPath(TU.Filename), Code.point("c2"),
+                               Preamble.get(), Inputs, Opts);
+    // TODO: snippet suffix is empty for c2
+    EXPECT_THAT(Result.Completions,
+                ElementsAre(AllOf(named("bar"), signature("(int arg)"),
+                                  snippetSuffix(""))));
----------------
MythreyaK wrote:

> We will want snippetSuffix to be (${1:A self}, ${2: int arg})
> signature being (int arg) is also wrong

Yep, the snippet suffix is missing, I wasn't sure how to handle this--in this PR, or a new one?

I updated the tests to "pass", to sync up with a more recent `main`, but there seems to be a regression (I had to update my test in the latest commit, [here](https://github.com/llvm/llvm-project/pull/146649/commits/e08005e3a6fbd42e7063cffe27ce1ccdf0c36d1a#diff-4864eebf0abf8b29afb79cfde58b196f40c6baa36e8ad05676325edb08cd577dR4447-R4451), [comment here](https://github.com/llvm/llvm-project/pull/146649#discussion_r2239265645)). Snippet suffix that existed previously is now missing. 

https://github.com/llvm/llvm-project/pull/146649


More information about the cfe-commits mailing list