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 @@ -36,6 +36,10 @@ llvm::dyn_cast(&ND)) { if (auto *Args = Cls->getTemplateArgsAsWritten()) return Args->arguments(); + } else if (auto *Var = + llvm::dyn_cast(&ND)) { + if (auto *Args = Var->getTemplateArgsAsWritten()) + return Args->arguments(); } else if (auto *Var = llvm::dyn_cast(&ND)) return Var->getTemplateArgsInfo().arguments(); // We return None for ClassTemplateSpecializationDecls because it does not diff --git a/clang-tools-extra/clangd/unittests/ClangdUnitTests.cpp b/clang-tools-extra/clangd/unittests/ClangdUnitTests.cpp --- a/clang-tools-extra/clangd/unittests/ClangdUnitTests.cpp +++ b/clang-tools-extra/clangd/unittests/ClangdUnitTests.cpp @@ -188,7 +188,7 @@ AllOf(DeclNamed("foo"), WithTemplateArgs("")), AllOf(DeclNamed("i"), WithTemplateArgs("")), AllOf(DeclNamed("d"), WithTemplateArgs("")), - AllOf(DeclNamed("foo"), WithTemplateArgs("<>")), + AllOf(DeclNamed("foo"), WithTemplateArgs("")), AllOf(DeclNamed("foo"), WithTemplateArgs(""))})); } diff --git a/clang-tools-extra/clangd/unittests/PrintASTTests.cpp b/clang-tools-extra/clangd/unittests/PrintASTTests.cpp --- a/clang-tools-extra/clangd/unittests/PrintASTTests.cpp +++ b/clang-tools-extra/clangd/unittests/PrintASTTests.cpp @@ -96,6 +96,15 @@ struct Bar { friend class Foo; }; template <> struct ^Foo {};)cpp", {""}}, + { + R"cpp( + template + T S = T(10); + template + int ^S = 0; + template <> + int ^S = 0;)cpp", + {"", ""}}, })),); } // namespace } // namespace clangd