summaryrefslogtreecommitdiffstats
path: root/clang/unittests/ASTMatchers/ASTMatchersTest.cpp
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2013-05-28 19:21:51 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2013-05-28 19:21:51 +0000
commit6a55bb23073a4642923db94f56d574261b0c53c8 (patch)
tree4c95c9d7b066ae7eb1194beda3cbec64b373beb7 /clang/unittests/ASTMatchers/ASTMatchersTest.cpp
parentd72b3ceb6b576abda52c5d07a602f546c351e67b (diff)
downloadbcm5719-llvm-6a55bb23073a4642923db94f56d574261b0c53c8.tar.gz
bcm5719-llvm-6a55bb23073a4642923db94f56d574261b0c53c8.zip
Add an overridable MatchCallback::onEndOfTranslationUnit() function.
Differential Revision: http://llvm-reviews.chandlerc.com/D745 llvm-svn: 182798
Diffstat (limited to 'clang/unittests/ASTMatchers/ASTMatchersTest.cpp')
-rw-r--r--clang/unittests/ASTMatchers/ASTMatchersTest.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersTest.cpp
index 8dd3b70d210..86b54acdebc 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -3934,5 +3934,26 @@ TEST(MatchFinder, InterceptsStartOfTranslationUnit) {
EXPECT_TRUE(VerifyCallback.Called);
}
+class VerifyEndOfTranslationUnit : public MatchFinder::MatchCallback {
+public:
+ VerifyEndOfTranslationUnit() : Called(false) {}
+ virtual void run(const MatchFinder::MatchResult &Result) {
+ EXPECT_FALSE(Called);
+ }
+ virtual void onEndOfTranslationUnit() {
+ Called = true;
+ }
+ bool Called;
+};
+
+TEST(MatchFinder, InterceptsEndOfTranslationUnit) {
+ MatchFinder Finder;
+ VerifyEndOfTranslationUnit VerifyCallback;
+ Finder.addMatcher(decl(), &VerifyCallback);
+ OwningPtr<FrontendActionFactory> Factory(newFrontendActionFactory(&Finder));
+ ASSERT_TRUE(tooling::runToolOnCode(Factory->create(), "int x;"));
+ EXPECT_TRUE(VerifyCallback.Called);
+}
+
} // end namespace ast_matchers
} // end namespace clang
OpenPOWER on IntegriCloud