[clangd] Fix label and snippet for funcs in the index
This is a follow-up to r330004 to fix functions with required template args,
e.g. std::make_shared.
llvm-svn: 330087
diff --git a/clang-tools-extra/clangd/index/SymbolCollector.cpp b/clang-tools-extra/clangd/index/SymbolCollector.cpp
index d9f8a6f..c9d156e 100644
--- a/clang-tools-extra/clangd/index/SymbolCollector.cpp
+++ b/clang-tools-extra/clangd/index/SymbolCollector.cpp
@@ -27,16 +27,11 @@
namespace clangd {
namespace {
-/// If \p ND is a template specialization, returns the primary template.
+/// If \p ND is a template specialization, returns the described template.
/// Otherwise, returns \p ND.
const NamedDecl &getTemplateOrThis(const NamedDecl &ND) {
- if (auto Cls = dyn_cast<CXXRecordDecl>(&ND)) {
- if (auto T = Cls->getDescribedTemplate())
- return *T;
- } else if (auto Func = dyn_cast<FunctionDecl>(&ND)) {
- if (auto T = Func->getPrimaryTemplate())
- return *T;
- }
+ if (auto T = ND.getDescribedTemplate())
+ return *T;
return ND;
}