diff options
Diffstat (limited to 'unittests/ASTMatchers/ASTMatchersTest.h')
-rw-r--r-- | unittests/ASTMatchers/ASTMatchersTest.h | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/unittests/ASTMatchers/ASTMatchersTest.h b/unittests/ASTMatchers/ASTMatchersTest.h index a2ab9feee2a2..e555e6318d58 100644 --- a/unittests/ASTMatchers/ASTMatchersTest.h +++ b/unittests/ASTMatchers/ASTMatchersTest.h @@ -40,7 +40,7 @@ public: VerifyMatch(BoundNodesCallback *FindResultVerifier, bool *Verified) : Verified(Verified), FindResultReviewer(FindResultVerifier) {} - virtual void run(const MatchFinder::MatchResult &Result) override { + void run(const MatchFinder::MatchResult &Result) override { if (FindResultReviewer != nullptr) { *Verified |= FindResultReviewer->run(&Result.Nodes, Result.Context); } else { @@ -62,7 +62,8 @@ template <typename T> testing::AssertionResult matchesConditionally( const std::string &Code, const T &AMatcher, bool ExpectMatch, llvm::StringRef CompileArg, - const FileContentMappings &VirtualMappedFiles = FileContentMappings()) { + const FileContentMappings &VirtualMappedFiles = FileContentMappings(), + const std::string &Filename = "input.cc") { bool Found = false, DynamicFound = false; MatchFinder Finder; VerifyMatch VerifyFound(nullptr, &Found); @@ -73,8 +74,12 @@ testing::AssertionResult matchesConditionally( std::unique_ptr<FrontendActionFactory> Factory( newFrontendActionFactory(&Finder)); // Some tests use typeof, which is a gnu extension. - std::vector<std::string> Args(1, CompileArg); - if (!runToolOnCodeWithArgs(Factory->create(), Code, Args, "input.cc", + std::vector<std::string> Args; + Args.push_back(CompileArg); + // Some tests need rtti/exceptions on + Args.push_back("-frtti"); + Args.push_back("-fexceptions"); + if (!runToolOnCodeWithArgs(Factory->create(), Code, Args, Filename, VirtualMappedFiles)) { return testing::AssertionFailure() << "Parsing error in \"" << Code << "\""; } @@ -105,6 +110,23 @@ testing::AssertionResult notMatches(const std::string &Code, return matchesConditionally(Code, AMatcher, false, "-std=c++11"); } +template <typename T> +testing::AssertionResult matchesObjC(const std::string &Code, + const T &AMatcher) { + return matchesConditionally( + Code, AMatcher, true, + "", FileContentMappings(), "input.m"); +} + +template <typename T> +testing::AssertionResult notMatchesObjC(const std::string &Code, + const T &AMatcher) { + return matchesConditionally( + Code, AMatcher, false, + "", FileContentMappings(), "input.m"); +} + + // Function based on matchesConditionally with "-x cuda" argument added and // small CUDA header prepended to the code string. template <typename T> |