diff options
author | Manuel Klimek <klimek@google.com> | 2013-11-12 17:53:18 +0000 |
---|---|---|
committer | Manuel Klimek <klimek@google.com> | 2013-11-12 17:53:18 +0000 |
commit | cb5a9ecef48756841652f00311215814746e1e3f (patch) | |
tree | cdcf8b4cf779a9cd4303499897cb46c727530d84 /unittests/Tooling | |
parent | a7462b8ce22a3f754bf51eeeb01adafc42b32cea (diff) | |
download | clang-cb5a9ecef48756841652f00311215814746e1e3f.tar.gz clang-cb5a9ecef48756841652f00311215814746e1e3f.tar.bz2 clang-cb5a9ecef48756841652f00311215814746e1e3f.tar.xz |
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
Diffstat (limited to 'unittests/Tooling')
-rw-r--r-- | unittests/Tooling/ToolingTest.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
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<std::string>()); + ClangTool Tool(Compilations, std::vector<std::string>(1, "/a.cc")); + Tool.mapVirtualFile("/a.cc", "int x = undeclared;"); + TestDiagnosticConsumer Consumer; + Tool.setDiagnosticConsumer(&Consumer); + std::vector<ASTUnit*> ASTs; + Tool.buildASTs(ASTs); + EXPECT_EQ(1u, ASTs.size()); + EXPECT_EQ(1u, Consumer.NumDiagnosticsSeen); +} + } // end namespace tooling } // end namespace clang |