summaryrefslogtreecommitdiffstats
path: root/unittests/ASTMatchers/ASTMatchersTest.h
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2012-12-02 13:20:44 +0000
committerdim <dim@FreeBSD.org>2012-12-02 13:20:44 +0000
commit056abd2059c65a3e908193aeae16fad98017437c (patch)
tree2732d02d7d51218d6eed98ac7fcfc5b8794896b5 /unittests/ASTMatchers/ASTMatchersTest.h
parentcc73504950eb7b5dff2dded9bedd67bc36d64641 (diff)
downloadFreeBSD-src-056abd2059c65a3e908193aeae16fad98017437c.zip
FreeBSD-src-056abd2059c65a3e908193aeae16fad98017437c.tar.gz
Vendor import of clang release_32 branch r168974 (effectively, 3.2 RC2):
http://llvm.org/svn/llvm-project/cfe/branches/release_32@168974
Diffstat (limited to 'unittests/ASTMatchers/ASTMatchersTest.h')
-rw-r--r--unittests/ASTMatchers/ASTMatchersTest.h20
1 files changed, 13 insertions, 7 deletions
diff --git a/unittests/ASTMatchers/ASTMatchersTest.h b/unittests/ASTMatchers/ASTMatchersTest.h
index 64816f5..3b23ada 100644
--- a/unittests/ASTMatchers/ASTMatchersTest.h
+++ b/unittests/ASTMatchers/ASTMatchersTest.h
@@ -18,13 +18,14 @@ namespace clang {
namespace ast_matchers {
using clang::tooling::newFrontendActionFactory;
-using clang::tooling::runToolOnCode;
+using clang::tooling::runToolOnCodeWithArgs;
using clang::tooling::FrontendActionFactory;
class BoundNodesCallback {
public:
virtual ~BoundNodesCallback() {}
virtual bool run(const BoundNodes *BoundNodes) = 0;
+ virtual bool run(const BoundNodes *BoundNodes, ASTContext *Context) = 0;
};
// If 'FindResultVerifier' is not NULL, sets *Verified to the result of
@@ -37,7 +38,7 @@ public:
virtual void run(const MatchFinder::MatchResult &Result) {
if (FindResultReviewer != NULL) {
- *Verified = FindResultReviewer->run(&Result.Nodes);
+ *Verified |= FindResultReviewer->run(&Result.Nodes, Result.Context);
} else {
*Verified = true;
}
@@ -51,12 +52,15 @@ private:
template <typename T>
testing::AssertionResult matchesConditionally(const std::string &Code,
const T &AMatcher,
- bool ExpectMatch) {
+ bool ExpectMatch,
+ llvm::StringRef CompileArg) {
bool Found = false;
MatchFinder Finder;
Finder.addMatcher(AMatcher, new VerifyMatch(0, &Found));
OwningPtr<FrontendActionFactory> Factory(newFrontendActionFactory(&Finder));
- if (!runToolOnCode(Factory->create(), Code)) {
+ // Some tests use typeof, which is a gnu extension.
+ std::vector<std::string> Args(1, CompileArg);
+ if (!runToolOnCodeWithArgs(Factory->create(), Code, Args)) {
return testing::AssertionFailure() << "Parsing error in \"" << Code << "\"";
}
if (!Found && ExpectMatch) {
@@ -71,13 +75,13 @@ testing::AssertionResult matchesConditionally(const std::string &Code,
template <typename T>
testing::AssertionResult matches(const std::string &Code, const T &AMatcher) {
- return matchesConditionally(Code, AMatcher, true);
+ return matchesConditionally(Code, AMatcher, true, "-std=c++11");
}
template <typename T>
testing::AssertionResult notMatches(const std::string &Code,
const T &AMatcher) {
- return matchesConditionally(Code, AMatcher, false);
+ return matchesConditionally(Code, AMatcher, false, "-std=c++11");
}
template <typename T>
@@ -91,7 +95,9 @@ matchAndVerifyResultConditionally(const std::string &Code, const T &AMatcher,
Finder.addMatcher(
AMatcher, new VerifyMatch(FindResultVerifier, &VerifiedResult));
OwningPtr<FrontendActionFactory> Factory(newFrontendActionFactory(&Finder));
- if (!runToolOnCode(Factory->create(), Code)) {
+ // Some tests use typeof, which is a gnu extension.
+ std::vector<std::string> Args(1, "-std=gnu++98");
+ if (!runToolOnCodeWithArgs(Factory->create(), Code, Args)) {
return testing::AssertionFailure() << "Parsing error in \"" << Code << "\"";
}
if (!VerifiedResult && ExpectResult) {
OpenPOWER on IntegriCloud