diff --git a/clang-tools-extra/unittests/clangd/TestTU.cpp b/clang-tools-extra/unittests/clangd/TestTU.cpp --- a/clang-tools-extra/unittests/clangd/TestTU.cpp +++ b/clang-tools-extra/unittests/clangd/TestTU.cpp @@ -141,5 +141,24 @@ }); } +class TestVisitor : public RecursiveASTVisitor { +public: + bool VisitVarTemplateDecl(VarTemplateDecl *VTD) { + seenVarTemplateDecl = true; + return true; + } + + bool seenVarTemplateDecl = false; +}; + +TEST(TestTU, VariableTemplate) { + TestTU TU = TestTU::withCode("template int x;"); + auto AST = TU.build(); + EXPECT_TRUE(AST.getDiagnostics().empty()); + TestVisitor Visitor; + Visitor.TraverseAST(AST.getASTContext()); + EXPECT_TRUE(Visitor.seenVarTemplateDecl); +} + } // namespace clangd } // namespace clang