[PATCH] D70308: [clangd] Don't consider class template params part of constructor name.
Sam McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 15 08:36:33 PST 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rG713c30b38960: [clangd] Don't consider class template params part of constructor name. (authored by sammccall).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D70308/new/
https://reviews.llvm.org/D70308
Files:
clang-tools-extra/clangd/AST.cpp
clang-tools-extra/clangd/XRefs.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
@@ -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 <typename T> class X;
template <typename T> class [[^X]]<T*> {};
@@ -908,6 +908,21 @@
HI.Kind = SymbolKind::Class;
HI.Definition = "template <typename T> class X<T *> {}";
}},
+ // Constructor of partially-specialized class template
+ {R"cpp(
+ template<typename> struct X;
+ template<typename T> struct X<T*>{ [[^X]](); };
+ )cpp",
+ [](HoverInfo &HI) {
+ HI.NamespaceScope = "";
+ HI.Name = "X";
+ HI.LocalScope = "X::"; // FIXME: Should be X<T *>::
+ HI.Kind = SymbolKind::Method; // FIXME: Should be Constructor
+ HI.Type = "void ()"; // FIXME: Should be None
+ HI.ReturnType = "void"; // FIXME: Should be None or X<T*>
+ HI.Definition = "X<type - parameter - 0 - 0 *>()"; // FIXME: --> X()
+ HI.Parameters.emplace();
+ }},
// auto on lambda
{R"cpp(
Index: clang-tools-extra/clangd/XRefs.cpp
===================================================================
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -417,6 +417,7 @@
auto GetName = [](const Decl *D) {
const NamedDecl *ND = dyn_cast<NamedDecl>(D);
std::string Name = ND->getNameAsString();
+ // FIXME(sammccall): include template params/specialization args?.
if (!Name.empty())
return Name;
if (auto RD = dyn_cast<RecordDecl>(D))
Index: clang-tools-extra/clangd/AST.cpp
===================================================================
--- clang-tools-extra/clangd/AST.cpp
+++ 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 - <using-directive>.
if (auto *UD = llvm::dyn_cast<UsingDirectiveDecl>(&ND)) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70308.229563.patch
Type: text/x-patch
Size: 2538 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191115/86a075e8/attachment-0001.bin>
More information about the cfe-commits
mailing list