From cb5a9ecef48756841652f00311215814746e1e3f Mon Sep 17 00:00:00 2001 From: Manuel Klimek Date: Tue, 12 Nov 2013 17:53:18 +0000 Subject: [PATCH] Add test for injecting diagnostic consumers into a ClangTool. As suggested by pcc on 194226. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194494 91177308-0d34-0410-b5e6-96231b3b80d8 --- unittests/Tooling/ToolingTest.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/unittests/Tooling/ToolingTest.cpp b/unittests/Tooling/ToolingTest.cpp index 40360fb45e..2afe9292f5 100644 --- a/unittests/Tooling/ToolingTest.cpp +++ b/unittests/Tooling/ToolingTest.cpp @@ -321,5 +321,17 @@ TEST(ClangToolTest, InjectDiagnosticConsumer) { EXPECT_EQ(1u, Consumer.NumDiagnosticsSeen); } +TEST(ClangToolTest, InjectDiagnosticConsumerInBuildASTs) { + FixedCompilationDatabase Compilations("/", std::vector()); + ClangTool Tool(Compilations, std::vector(1, "/a.cc")); + Tool.mapVirtualFile("/a.cc", "int x = undeclared;"); + TestDiagnosticConsumer Consumer; + Tool.setDiagnosticConsumer(&Consumer); + std::vector ASTs; + Tool.buildASTs(ASTs); + EXPECT_EQ(1u, ASTs.size()); + EXPECT_EQ(1u, Consumer.NumDiagnosticsSeen); +} + } // end namespace tooling } // end namespace clang -- 2.40.0