[PATCH] D72119: [clangd] Handle DeducedTemplateSpecializationType in TargetFinder
Nathan Ridge via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 2 17:19:21 PST 2020
nridge created this revision.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, MaskRay, ilya-biryukov.
Herald added a project: clang.
This is mostly a workaround for
https://bugs.llvm.org/show_bug.cgi?id=42914. Once that is fixed, the
handling in VisitDeducedTyped() should be sufficient.
Fixes https://github.com/clangd/clangd/issues/242
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D72119
Files:
clang-tools-extra/clangd/FindTarget.cpp
clang-tools-extra/clangd/unittests/XRefsTests.cpp
Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -495,6 +495,16 @@
void test(unique_ptr<S<T>>& V) {
V->fo^o();
}
+ )cpp",
+
+ R"cpp(// Class template argument deduction
+ template <typename T>
+ struct [[Test]] {
+ Test(T);
+ };
+ void foo() {
+ T^est a(5);
+ }
)cpp"};
for (const char *Test : Tests) {
Annotations T(Test);
@@ -513,6 +523,7 @@
// FIXME: Auto-completion in a template requires disabling delayed template
// parsing.
TU.ExtraArgs.push_back("-fno-delayed-template-parsing");
+ TU.ExtraArgs.push_back("-std=c++17");
auto AST = TU.build();
ASSERT_TRUE(AST.getDiagnostics().empty())
Index: clang-tools-extra/clangd/FindTarget.cpp
===================================================================
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -315,6 +315,12 @@
// TypeLoc never has a deduced type. https://llvm.org/PR42914
Outer.add(DT->getDeducedType(), Flags | Rel::Underlying);
}
+ void VisitDeducedTemplateSpecializationType(
+ const DeducedTemplateSpecializationType *DTST) {
+ if (auto *TD = DTST->getTemplateName().getAsTemplateDecl()) {
+ Outer.add(TD->getTemplatedDecl(), Flags | Rel::TemplatePattern);
+ }
+ }
void VisitTypedefType(const TypedefType *TT) {
Outer.add(TT->getDecl(), Flags);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72119.235975.patch
Type: text/x-patch
Size: 1673 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200103/43411a0e/attachment.bin>
More information about the cfe-commits
mailing list