diff options
| author | Aaron Ballman <aaron@aaronballman.com> | 2015-03-12 13:21:19 +0000 |
|---|---|---|
| committer | Aaron Ballman <aaron@aaronballman.com> | 2015-03-12 13:21:19 +0000 |
| commit | 12865302b76c3b8b6282429d4adc9bd1c1ea84f8 (patch) | |
| tree | 906d2938beac56945856001f49d3766a21eb7810 /clang/unittests/ASTMatchers/ASTMatchersTest.h | |
| parent | 4952a0cba2f795ecf251c1140d9280b06d29954d (diff) | |
| download | bcm5719-llvm-12865302b76c3b8b6282429d4adc9bd1c1ea84f8.tar.gz bcm5719-llvm-12865302b76c3b8b6282429d4adc9bd1c1ea84f8.zip | |
Added some matchers for objective c selectors and messages to ASTMatchers.h. Minor mods to ASTMatchersTest.h to allow test files with ".m" extension in addition to ".cpp". New tests added to ASTMatchersTest.c.
Patch by Dean Sutherland, reviewed by Manuel Klimek. From http://reviews.llvm.org/D7710
llvm-svn: 232034
Diffstat (limited to 'clang/unittests/ASTMatchers/ASTMatchersTest.h')
| -rw-r--r-- | clang/unittests/ASTMatchers/ASTMatchersTest.h | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/clang/unittests/ASTMatchers/ASTMatchersTest.h b/clang/unittests/ASTMatchers/ASTMatchersTest.h index eb4cac5abc5..4befe4a129d 100644 --- a/clang/unittests/ASTMatchers/ASTMatchersTest.h +++ b/clang/unittests/ASTMatchers/ASTMatchersTest.h @@ -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); @@ -78,7 +79,7 @@ testing::AssertionResult matchesConditionally( // Some tests need rtti/exceptions on Args.push_back("-frtti"); Args.push_back("-fexceptions"); - if (!runToolOnCodeWithArgs(Factory->create(), Code, Args, "input.cc", + if (!runToolOnCodeWithArgs(Factory->create(), Code, Args, Filename, VirtualMappedFiles)) { return testing::AssertionFailure() << "Parsing error in \"" << Code << "\""; } @@ -109,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> |

