diff options
Diffstat (limited to 'clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp')
| -rw-r--r-- | clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp | 51 |
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")), |

