]> granicus.if.org Git - clang/commitdiff
Add test for injecting diagnostic consumers into a ClangTool.
authorManuel Klimek <klimek@google.com>
Tue, 12 Nov 2013 17:53:18 +0000 (17:53 +0000)
committerManuel Klimek <klimek@google.com>
Tue, 12 Nov 2013 17:53:18 +0000 (17:53 +0000)
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

index 40360fb45e1ca996615ec5fa610a7cf3c302ae59..2afe9292f5fed0faaa4c1b23307bf8942f1d0f4f 100644 (file)
@@ -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