summaryrefslogtreecommitdiffstats
path: root/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
diff options
context:
space:
mode:
authorDmitri Gribenko <gribozavr@gmail.com>2019-05-03 12:50:00 +0000
committerDmitri Gribenko <gribozavr@gmail.com>2019-05-03 12:50:00 +0000
commitb641b914a36bbf1f35587b9f0bf652d691f97cee (patch)
tree3a7e4ed5002fce854d7d1036f9f90093edbb0246 /clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
parent6d08b8dbaef2a6795d76b617a88070ec9c815a2e (diff)
downloadbcm5719-llvm-b641b914a36bbf1f35587b9f0bf652d691f97cee.tar.gz
bcm5719-llvm-b641b914a36bbf1f35587b9f0bf652d691f97cee.zip
Added an AST matcher for declarations that are in the `std` namespace
Reviewers: alexfh Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61480 llvm-svn: 359876
Diffstat (limited to 'clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp')
-rw-r--r--clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
index 012ca117c29..01b168da2b7 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -2031,6 +2031,57 @@ TEST(NS, Anonymous) {
EXPECT_TRUE(matches("namespace {}", namespaceDecl(isAnonymous())));
}
+TEST(DeclarationMatcher, InStdNamespace) {
+ EXPECT_TRUE(notMatches("class vector {};"
+ "namespace foo {"
+ " class vector {};"
+ "}"
+ "namespace foo {"
+ " namespace std {"
+ " class vector {};"
+ " }"
+ "}",
+ cxxRecordDecl(hasName("vector"), isInStdNamespace())));
+
+ EXPECT_TRUE(matches("namespace std {"
+ " class vector {};"
+ "}",
+ cxxRecordDecl(hasName("vector"), isInStdNamespace())));
+ EXPECT_TRUE(matches("namespace std {"
+ " inline namespace __1 {"
+ " class vector {};"
+ " }"
+ "}",
+ cxxRecordDecl(hasName("vector"), isInStdNamespace())));
+ EXPECT_TRUE(notMatches("namespace std {"
+ " inline namespace __1 {"
+ " inline namespace __fs {"
+ " namespace filesystem {"
+ " inline namespace v1 {"
+ " class path {};"
+ " }"
+ " }"
+ " }"
+ " }"
+ "}",
+ cxxRecordDecl(hasName("path"), isInStdNamespace())));
+ EXPECT_TRUE(
+ matches("namespace std {"
+ " inline namespace __1 {"
+ " inline namespace __fs {"
+ " namespace filesystem {"
+ " inline namespace v1 {"
+ " class path {};"
+ " }"
+ " }"
+ " }"
+ " }"
+ "}",
+ cxxRecordDecl(hasName("path"),
+ hasAncestor(namespaceDecl(hasName("filesystem"),
+ isInStdNamespace())))));
+}
+
TEST(EqualsBoundNodeMatcher, QualType) {
EXPECT_TRUE(matches(
"int i = 1;", varDecl(hasType(qualType().bind("type")),
OpenPOWER on IntegriCloud