diff options
author | Samuel Benzaquen <sbenza@google.com> | 2016-02-22 21:13:02 +0000 |
---|---|---|
committer | Samuel Benzaquen <sbenza@google.com> | 2016-02-22 21:13:02 +0000 |
commit | dfad990d887c6c644b2e544fc6cd5aa1cca84d26 (patch) | |
tree | ae4e054bc2ccbbb1d411f538661584dc53ec3792 /unittests/ASTMatchers/ASTMatchersTest.cpp | |
parent | 4ca3ad678789018e7b37e9319b0da9f5f741eb6b (diff) | |
download | clang-dfad990d887c6c644b2e544fc6cd5aa1cca84d26.tar.gz |
[ASTMatchers] Add matcher hasAnyName.
Summary: Add matcher hasAnyName as an optimization over anyOf(hasName(),...)
Reviewers: alexfh
Subscribers: klimek, cfe-commits
Differential Revision: http://reviews.llvm.org/D17163
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@261574 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/ASTMatchers/ASTMatchersTest.cpp')
-rw-r--r-- | unittests/ASTMatchers/ASTMatchersTest.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/unittests/ASTMatchers/ASTMatchersTest.cpp b/unittests/ASTMatchers/ASTMatchersTest.cpp index eb871f91de..133dc70513 100644 --- a/unittests/ASTMatchers/ASTMatchersTest.cpp +++ b/unittests/ASTMatchers/ASTMatchersTest.cpp @@ -2881,6 +2881,19 @@ TEST(Matcher, HasNameSupportsFunctionScope) { EXPECT_TRUE(matches(code, fieldDecl(hasName("::a::F(int)::S::m")))); } +TEST(Matcher, HasAnyName) { + const std::string Code = "namespace a { namespace b { class C; } }"; + + EXPECT_TRUE(matches(Code, recordDecl(hasAnyName("XX", "a::b::C")))); + EXPECT_TRUE(matches(Code, recordDecl(hasAnyName("a::b::C", "XX")))); + EXPECT_TRUE(matches(Code, recordDecl(hasAnyName("XX::C", "a::b::C")))); + EXPECT_TRUE(matches(Code, recordDecl(hasAnyName("XX", "C")))); + + EXPECT_TRUE(notMatches(Code, recordDecl(hasAnyName("::C", "::b::C")))); + EXPECT_TRUE( + matches(Code, recordDecl(hasAnyName("::C", "::b::C", "::a::b::C")))); +} + TEST(Matcher, IsDefinition) { DeclarationMatcher DefinitionOfClassA = recordDecl(hasName("A"), isDefinition()); |