[PATCH] D60954: [clangd] Test case demonstrating variable template issue
Nathan Ridge via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Apr 21 14:14:24 PDT 2019
nridge created this revision.
Herald added subscribers: cfe-commits, kadircet, arphaman, jkorous, MaskRay, ioeric, ilya-biryukov.
Herald added a project: clang.
This is not meant to be committed, it's meant to demonstrate an
issue with using RecursiveASTVisitor with TestTU on code that contains a
top-level variable template.
The variable template declaration is never visited, for reasons I don't
fully understand.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D60954
Files:
clang-tools-extra/unittests/clangd/TestTU.cpp
Index: clang-tools-extra/unittests/clangd/TestTU.cpp
===================================================================
--- clang-tools-extra/unittests/clangd/TestTU.cpp
+++ clang-tools-extra/unittests/clangd/TestTU.cpp
@@ -141,5 +141,24 @@
});
}
+class TestVisitor : public RecursiveASTVisitor<TestVisitor> {
+public:
+ bool VisitVarTemplateDecl(VarTemplateDecl *VTD) {
+ seenVarTemplateDecl = true;
+ return true;
+ }
+
+ bool seenVarTemplateDecl = false;
+};
+
+TEST(TestTU, VariableTemplate) {
+ TestTU TU = TestTU::withCode("template <typename T> 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60954.196017.patch
Type: text/x-patch
Size: 815 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190421/b3f1e695/attachment-0001.bin>
More information about the cfe-commits
mailing list