diff options
| author | Peter Collingbourne <peter@pcc.me.uk> | 2013-11-07 22:30:36 +0000 |
|---|---|---|
| committer | Peter Collingbourne <peter@pcc.me.uk> | 2013-11-07 22:30:36 +0000 |
| commit | a2334162cffc91f31898f79b0a286474e8365ce9 (patch) | |
| tree | b6663a0327d0ff955c358b05942453eae9a14559 /clang/unittests/ASTMatchers/ASTMatchersTest.h | |
| parent | 2b94713053aef3ca42e4e555ed6e04e41215762d (diff) | |
| download | bcm5719-llvm-a2334162cffc91f31898f79b0a286474e8365ce9.tar.gz bcm5719-llvm-a2334162cffc91f31898f79b0a286474e8365ce9.zip | |
Introduce MatchFinder::matchAST.
Differential Revision: http://llvm-reviews.chandlerc.com/D2115
llvm-svn: 194223
Diffstat (limited to 'clang/unittests/ASTMatchers/ASTMatchersTest.h')
| -rw-r--r-- | clang/unittests/ASTMatchers/ASTMatchersTest.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/clang/unittests/ASTMatchers/ASTMatchersTest.h b/clang/unittests/ASTMatchers/ASTMatchersTest.h index e65d8e792df..f5bcd37f112 100644 --- a/clang/unittests/ASTMatchers/ASTMatchersTest.h +++ b/clang/unittests/ASTMatchers/ASTMatchersTest.h @@ -11,12 +11,14 @@ #define LLVM_CLANG_UNITTESTS_AST_MATCHERS_AST_MATCHERS_TEST_H #include "clang/ASTMatchers/ASTMatchFinder.h" +#include "clang/Frontend/ASTUnit.h" #include "clang/Tooling/Tooling.h" #include "gtest/gtest.h" namespace clang { namespace ast_matchers { +using clang::tooling::buildASTFromCodeWithArgs; using clang::tooling::newFrontendActionFactory; using clang::tooling::runToolOnCodeWithArgs; using clang::tooling::FrontendActionFactory; @@ -121,6 +123,21 @@ matchAndVerifyResultConditionally(const std::string &Code, const T &AMatcher, return testing::AssertionFailure() << "Verified unexpected result in \"" << Code << "\""; } + + VerifiedResult = false; + OwningPtr<ASTUnit> AST(buildASTFromCodeWithArgs(Code, Args)); + if (!AST.get()) + return testing::AssertionFailure() << "Parsing error in \"" << Code + << "\" while building AST"; + Finder.matchAST(AST->getASTContext()); + if (!VerifiedResult && ExpectResult) { + return testing::AssertionFailure() + << "Could not verify result in \"" << Code << "\" with AST"; + } else if (VerifiedResult && !ExpectResult) { + return testing::AssertionFailure() + << "Verified unexpected result in \"" << Code << "\" with AST"; + } + return testing::AssertionSuccess(); } |

