summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Tooling/ToolingTest.cpp
diff options
context:
space:
mode:
authorEdwin Vane <edwin.vane@intel.com>2013-05-29 16:01:10 +0000
committerEdwin Vane <edwin.vane@intel.com>2013-05-29 16:01:10 +0000
commit20c6f54b85f6097be4e9a28a905fe59b8724bcb3 (patch)
tree87378c7ed866efaedc3dc50694a885c0f1693001 /clang/unittests/Tooling/ToolingTest.cpp
parent13969d0ab6a2016416c4429993403f373440e93f (diff)
downloadbcm5719-llvm-20c6f54b85f6097be4e9a28a905fe59b8724bcb3.tar.gz
bcm5719-llvm-20c6f54b85f6097be4e9a28a905fe59b8724bcb3.zip
Tooling: Call back for both begin and end of sources
newFrontendActionFactory() took a pointer to a callback to call when a source file was done being processed by an action. This revision updates the callback to include an ante-processing callback as well. Callback-providing class renamed and callback functions themselves renamed. Functions are no longer pure-virtual so users aren't forced to implement both callbacks if one isn't needed. llvm-svn: 182864
Diffstat (limited to 'clang/unittests/Tooling/ToolingTest.cpp')
-rw-r--r--clang/unittests/Tooling/ToolingTest.cpp21
1 files changed, 14 insertions, 7 deletions
diff --git a/clang/unittests/Tooling/ToolingTest.cpp b/clang/unittests/Tooling/ToolingTest.cpp
index a9319f29612..a7b94319184 100644
--- a/clang/unittests/Tooling/ToolingTest.cpp
+++ b/clang/unittests/Tooling/ToolingTest.cpp
@@ -131,20 +131,26 @@ TEST(ToolInvocation, TestMapVirtualFile) {
EXPECT_TRUE(Invocation.run());
}
-struct VerifyEndCallback : public EndOfSourceFileCallback {
- VerifyEndCallback() : Called(0), Matched(false) {}
- virtual void run() {
- ++Called;
+struct VerifyEndCallback : public SourceFileCallbacks {
+ VerifyEndCallback() : BeginCalled(0), EndCalled(0), Matched(false) {}
+ virtual bool BeginSource(CompilerInstance &CI,
+ StringRef Filename) LLVM_OVERRIDE {
+ ++BeginCalled;
+ return true;
+ }
+ virtual void EndSource() {
+ ++EndCalled;
}
ASTConsumer *newASTConsumer() {
return new FindTopLevelDeclConsumer(&Matched);
}
- unsigned Called;
+ unsigned BeginCalled;
+ unsigned EndCalled;
bool Matched;
};
#if !defined(_WIN32)
-TEST(newFrontendActionFactory, InjectsEndOfSourceFileCallback) {
+TEST(newFrontendActionFactory, InjectsSourceFileCallbacks) {
VerifyEndCallback EndCallback;
FixedCompilationDatabase Compilations("/", std::vector<std::string>());
@@ -159,7 +165,8 @@ TEST(newFrontendActionFactory, InjectsEndOfSourceFileCallback) {
Tool.run(newFrontendActionFactory(&EndCallback, &EndCallback));
EXPECT_TRUE(EndCallback.Matched);
- EXPECT_EQ(2u, EndCallback.Called);
+ EXPECT_EQ(2u, EndCallback.BeginCalled);
+ EXPECT_EQ(2u, EndCallback.EndCalled);
}
#endif
OpenPOWER on IntegriCloud