summaryrefslogtreecommitdiffstats
path: root/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp')
-rw-r--r--clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
index 92678a30919..bb8aecfe8b8 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -1520,6 +1520,21 @@ TEST(Matcher, HasNameSupportsFunctionScope) {
EXPECT_TRUE(matches(code, fieldDecl(hasName("::a::F(int)::S::m"))));
}
+TEST(Matcher, HasNameQualifiedSupportsLinkage) {
+ // https://bugs.llvm.org/show_bug.cgi?id=42193
+ std::string code = R"cpp(namespace foo { extern "C" void test(); })cpp";
+ EXPECT_TRUE(matches(code, functionDecl(hasName("test"))));
+ EXPECT_TRUE(matches(code, functionDecl(hasName("foo::test"))));
+ EXPECT_TRUE(matches(code, functionDecl(hasName("::foo::test"))));
+ EXPECT_TRUE(notMatches(code, functionDecl(hasName("::test"))));
+
+ code = R"cpp(namespace foo { extern "C" { void test(); } })cpp";
+ EXPECT_TRUE(matches(code, functionDecl(hasName("test"))));
+ EXPECT_TRUE(matches(code, functionDecl(hasName("foo::test"))));
+ EXPECT_TRUE(matches(code, functionDecl(hasName("::foo::test"))));
+ EXPECT_TRUE(notMatches(code, functionDecl(hasName("::test"))));
+}
+
TEST(Matcher, HasAnyName) {
const std::string Code = "namespace a { namespace b { class C; } }";
OpenPOWER on IntegriCloud