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 | 31cd3fc08897206ef0ed8df5b4d835d71847393b (patch) | |
| tree | 9db8ab9b4f35d6c5561b78f32ec8fe875c5dfbf4 /clang/unittests/Tooling/ToolingTest.cpp | |
| parent | 875395f9f88aec48006f39aa02e1226208300230 (diff) | |
| download | bcm5719-llvm-31cd3fc08897206ef0ed8df5b4d835d71847393b.tar.gz bcm5719-llvm-31cd3fc08897206ef0ed8df5b4d835d71847393b.zip | |
Add test for injecting diagnostic consumers into a ClangTool.
As suggested by pcc on 194226.
llvm-svn: 194494
Diffstat (limited to 'clang/unittests/Tooling/ToolingTest.cpp')
| -rw-r--r-- | clang/unittests/Tooling/ToolingTest.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/clang/unittests/Tooling/ToolingTest.cpp b/clang/unittests/Tooling/ToolingTest.cpp index 40360fb45e1..2afe9292f5f 100644 --- a/clang/unittests/Tooling/ToolingTest.cpp +++ b/clang/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 |

