diff --git a/clang-tools-extra/clangd/AST.cpp b/clang-tools-extra/clangd/AST.cpp --- a/clang-tools-extra/clangd/AST.cpp +++ b/clang-tools-extra/clangd/AST.cpp @@ -127,6 +127,8 @@ std::string Name; llvm::raw_string_ostream Out(Name); PrintingPolicy PP(Ctx.getLangOpts()); + // We don't consider a class template's args part of the constructor name. + PP.SuppressTemplateArgsInCXXConstructors = true; // Handle 'using namespace'. They all have the same name - . if (auto *UD = llvm::dyn_cast(&ND)) { diff --git a/clang-tools-extra/clangd/XRefs.cpp b/clang-tools-extra/clangd/XRefs.cpp --- a/clang-tools-extra/clangd/XRefs.cpp +++ b/clang-tools-extra/clangd/XRefs.cpp @@ -417,6 +417,7 @@ auto GetName = [](const Decl *D) { const NamedDecl *ND = dyn_cast(D); std::string Name = ND->getNameAsString(); + // FIXME(sammccall): include template params/specialization args?. if (!Name.empty()) return Name; if (auto RD = dyn_cast(D)) diff --git a/clang-tools-extra/clangd/unittests/XRefsTests.cpp b/clang-tools-extra/clangd/unittests/XRefsTests.cpp --- a/clang-tools-extra/clangd/unittests/XRefsTests.cpp +++ b/clang-tools-extra/clangd/unittests/XRefsTests.cpp @@ -897,7 +897,7 @@ HI.Definition = "int test"; HI.Type = "int"; }}, - // Partially-specialized class decl. (formerly type-parameter-0-0) + // Partially-specialized class template. (formerly type-parameter-0-0) {R"cpp( template class X; template class [[^X]] {}; @@ -908,6 +908,21 @@ HI.Kind = SymbolKind::Class; HI.Definition = "template class X {}"; }}, + // Constructor of partially-specialized class template + {R"cpp( + template struct X; + template struct X{ [[^X]](); }; + )cpp", + [](HoverInfo &HI) { + HI.NamespaceScope = ""; + HI.Name = "X"; + HI.LocalScope = "X::"; // FIXME: Should be X:: + HI.Kind = SymbolKind::Method; // FIXME: Should be Constructor + HI.Type = "void ()"; // FIXME: Should be None + HI.ReturnType = "void"; // FIXME: Should be None or X + HI.Definition = "X()"; // FIXME: --> X() + HI.Parameters.emplace(); + }}, // auto on lambda {R"cpp(