r194494 - Add test for injecting diagnostic consumers into a ClangTool.
Manuel Klimek
klimek at google.com
Tue Nov 12 09:53:19 PST 2013
Author: klimek
Date: Tue Nov 12 11:53:18 2013
New Revision: 194494
URL: http://llvm.org/viewvc/llvm-project?rev=194494&view=rev
Log:
Add test for injecting diagnostic consumers into a ClangTool.
As suggested by pcc on 194226.
Modified:
cfe/trunk/unittests/Tooling/ToolingTest.cpp
Modified: cfe/trunk/unittests/Tooling/ToolingTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/ToolingTest.cpp?rev=194494&r1=194493&r2=194494&view=diff
==============================================================================
--- cfe/trunk/unittests/Tooling/ToolingTest.cpp (original)
+++ cfe/trunk/unittests/Tooling/ToolingTest.cpp Tue Nov 12 11:53:18 2013
@@ -321,5 +321,17 @@ TEST(ClangToolTest, InjectDiagnosticCons
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
More information about the cfe-commits
mailing list