summaryrefslogtreecommitdiffstats
path: root/clang/unittests/ASTMatchers/ASTMatchersTest.cpp
diff options
context:
space:
mode:
authorSamuel Benzaquen <sbenza@google.com>2016-02-22 21:13:02 +0000
committerSamuel Benzaquen <sbenza@google.com>2016-02-22 21:13:02 +0000
commit922bef4f380c015ed370776a33a92b50c41ac04d (patch)
treecba6904082f100ccabf52693a6c910e8b9942792 /clang/unittests/ASTMatchers/ASTMatchersTest.cpp
parent2ec4717c2c99ffe53863d0d5eaedcf0f16d29074 (diff)
downloadbcm5719-llvm-922bef4f380c015ed370776a33a92b50c41ac04d.tar.gz
bcm5719-llvm-922bef4f380c015ed370776a33a92b50c41ac04d.zip
[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 llvm-svn: 261574
Diffstat (limited to 'clang/unittests/ASTMatchers/ASTMatchersTest.cpp')
-rw-r--r--clang/unittests/ASTMatchers/ASTMatchersTest.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersTest.cpp
index eb871f91def..133dc70513c 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp
+++ b/clang/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());
OpenPOWER on IntegriCloud