[clang-tools-extra] [clangd] Handle variables templates consistently with class templates in code completion (PR #85740)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 18 23:29:41 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clangd
Author: Nathan Ridge (HighCommander4)
<details>
<summary>Changes</summary>
The option --function-arg-placeholders=0 results in placeholders being omitted for class template argument lists. This patch extends the same treatment to variable template argument lists.
Fixes https://github.com/clangd/clangd/issues/1976
---
Full diff: https://github.com/llvm/llvm-project/pull/85740.diff
2 Files Affected:
- (modified) clang-tools-extra/clangd/CodeComplete.cpp (+2-1)
- (modified) clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp (+4-1)
``````````diff
diff --git a/clang-tools-extra/clangd/CodeComplete.cpp b/clang-tools-extra/clangd/CodeComplete.cpp
index 0e5f08cec440ce..72544b3c70aac5 100644
--- a/clang-tools-extra/clangd/CodeComplete.cpp
+++ b/clang-tools-extra/clangd/CodeComplete.cpp
@@ -619,7 +619,8 @@ struct CodeCompletionBuilder {
}
// 'CompletionItemKind::Interface' matches template type aliases.
if (Completion.Kind == CompletionItemKind::Interface ||
- Completion.Kind == CompletionItemKind::Class) {
+ Completion.Kind == CompletionItemKind::Class ||
+ Completion.Kind == CompletionItemKind::Variable) {
if (Snippet->front() != '<')
return *Snippet; // Not an arg snippet?
diff --git a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
index 6d387fec9b3851..49e91843aeec81 100644
--- a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -2631,12 +2631,15 @@ TEST(CompletionTest, CompletionFunctionArgsDisabled) {
class foo_class{};
template <class T>
using foo_alias = T**;
+ template <class T>
+ T foo_var = T{};
void f() { foo_^ })cpp",
{}, Opts);
EXPECT_THAT(
Results.Completions,
UnorderedElementsAre(AllOf(named("foo_class"), snippetSuffix("<$0>")),
- AllOf(named("foo_alias"), snippetSuffix("<$0>"))));
+ AllOf(named("foo_alias"), snippetSuffix("<$0>")),
+ AllOf(named("foo_var"), snippetSuffix("<$0>"))));
}
{
auto Results = completions(
``````````
</details>
https://github.com/llvm/llvm-project/pull/85740
More information about the cfe-commits
mailing list