[PATCH] D72715: [clang][CodeComplete] Propogate printing policy to FunctionDecl
Kadir Cetinkaya via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 14 09:18:09 PST 2020
kadircet created this revision.
kadircet added a reviewer: ilya-biryukov.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous.
Herald added a project: clang.
Printing policy was not propogated to functiondecls when creating a
completion string which resulted in canonical template parameters like
`foo<type-parameter-0-0>`. This patch propogates printing policy to those as
well.
Fixes https://github.com/clangd/clangd/issues/76
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D72715
Files:
clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
clang/test/CodeCompletion/ctor-signature.cpp
Index: clang/test/CodeCompletion/ctor-signature.cpp
===================================================================
--- /dev/null
+++ clang/test/CodeCompletion/ctor-signature.cpp
@@ -0,0 +1,17 @@
+template <typename T>
+struct Foo {};
+template <typename T>
+struct Foo<T *> { Foo(T); };
+
+void foo() {
+ Foo<int>();
+ // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:7:12 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+ // CHECK-CC1: OVERLOAD: Foo()
+ // CHECK-CC1: OVERLOAD: Foo(<#const Foo<int> &#>)
+ // CHECK-CC1: OVERLOAD: Foo(<#Foo<int> &&#>
+ Foo<int *>(3);
+ // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:12:14 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
+ // CHECK-CC2: OVERLOAD: Foo(<#int#>)
+ // CHECK-CC2: OVERLOAD: Foo(<#const Foo<int *> &#>)
+ // CHECK-CC2: OVERLOAD: Foo(<#Foo<int *> &&#>
+}
Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -2297,6 +2297,16 @@
AllOf(Named("TestClangc"), Deprecated())));
}
+TEST(SignatureHelpTest, PartialSpec) {
+ const auto Results = signatures(R"cpp(
+ template <typename T> struct Foo {};
+ template <typename T> struct Foo<T*> { Foo(T); };
+ Foo<int*> F(^);
+ )cpp");
+ EXPECT_THAT(Results.signatures, Contains(Sig("Foo([[T]])")));
+ EXPECT_EQ(0, Results.activeParameter);
+}
+
TEST(SignatureHelpTest, InsideArgument) {
{
const auto Results = signatures(R"cpp(
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72715.238000.patch
Type: text/x-patch
Size: 1621 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200114/9c62a91f/attachment.bin>
More information about the cfe-commits
mailing list