Adapts the FrontendAction convenience functions so that it can be
used with classes that generate ASTConsumers; this allows decoupling
the ASTConsumer generation from the Frontend library (like, for example,
the MatchFinder in the upcoming ASTMatcher patch).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159760 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/unittests/Tooling/TestVisitor.h b/unittests/Tooling/TestVisitor.h
index f73d2e0..d439d81 100644
--- a/unittests/Tooling/TestVisitor.h
+++ b/unittests/Tooling/TestVisitor.h
@@ -56,6 +56,7 @@
FindConsumer(TestVisitor *Visitor) : Visitor(Visitor) {}
virtual void HandleTranslationUnit(clang::ASTContext &Context) {
+ Visitor->Context = &Context;
Visitor->TraverseDecl(Context.getTranslationUnitDecl());
}
@@ -68,8 +69,7 @@
TestAction(TestVisitor *Visitor) : Visitor(Visitor) {}
virtual clang::ASTConsumer* CreateASTConsumer(
- CompilerInstance& compiler, llvm::StringRef dummy) {
- Visitor->Context = &compiler.getASTContext();
+ CompilerInstance&, llvm::StringRef dummy) {
/// TestConsumer will be deleted by the framework calling us.
return new FindConsumer(Visitor);
}
diff --git a/unittests/Tooling/ToolingTest.cpp b/unittests/Tooling/ToolingTest.cpp
index f6681f8..fb3af26 100644
--- a/unittests/Tooling/ToolingTest.cpp
+++ b/unittests/Tooling/ToolingTest.cpp
@@ -104,7 +104,9 @@
}
struct IndependentFrontendActionCreator {
- FrontendAction *newFrontendAction() { return new SyntaxOnlyAction; }
+ ASTConsumer *newASTConsumer() {
+ return new FindTopLevelDeclConsumer(NULL);
+ }
};
TEST(newFrontendActionFactory, CreatesFrontendActionFactoryFromFactoryType) {