diff --git a/clang-tools-extra/clangd/index/SymbolCollector.cpp b/clang-tools-extra/clangd/index/SymbolCollector.cpp index d9f8a6fa1aaf..c9d156ee1669 100644 --- a/clang-tools-extra/clangd/index/SymbolCollector.cpp +++ b/clang-tools-extra/clangd/index/SymbolCollector.cpp @@ -27,16 +27,11 @@ namespace clang { 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(&ND)) { - if (auto T = Cls->getDescribedTemplate()) - return *T; - } else if (auto Func = dyn_cast(&ND)) { - if (auto T = Func->getPrimaryTemplate()) - return *T; - } + if (auto T = ND.getDescribedTemplate()) + return *T; return ND; } diff --git a/clang-tools-extra/unittests/clangd/FileIndexTests.cpp b/clang-tools-extra/unittests/clangd/FileIndexTests.cpp index 1c14571a768c..afcfd5193e00 100644 --- a/clang-tools-extra/unittests/clangd/FileIndexTests.cpp +++ b/clang-tools-extra/unittests/clangd/FileIndexTests.cpp @@ -201,8 +201,8 @@ template class vector { }; -template -vector make_vector(Ty* begin, Ty* end) {} +template +vector make_vector(Arg A) {} )cpp"; FileIndex M; @@ -222,9 +222,9 @@ vector make_vector(Ty* begin, Ty* end) {} } if (Sym.Name == "make_vector") { - EXPECT_EQ(Sym.CompletionLabel, "make_vector(Ty *begin, Ty *end)"); + EXPECT_EQ(Sym.CompletionLabel, "make_vector(Arg A)"); EXPECT_EQ(Sym.CompletionSnippetInsertText, - "make_vector(${1:Ty *begin}, ${2:Ty *end})"); + "make_vector<${1:class Ty}>(${2:Arg A})"); EXPECT_EQ(Sym.CompletionPlainInsertText, "make_vector"); SeenMakeVector = true; }