Skip to content

Commit 8978032

Browse files
committed
Fix test for the hasExternalFormalLinkage matcher
Summary: Names of local variables have no linkage (see C++20 [basic.link] p8). Names of variables in unnamed namespace have internal linkage (see C++20 [basic.link] p4). Reviewers: aaron.ballman, rsmith, ymandel Reviewed By: ymandel Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D83700
1 parent 8eb8c92 commit 8978032

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2534,19 +2534,16 @@ TEST(NullPointerConstants, Basic) {
25342534
}
25352535

25362536
TEST(HasExternalFormalLinkage, Basic) {
2537-
EXPECT_TRUE(matches("int a = 0;", namedDecl(hasExternalFormalLinkage())));
2538-
EXPECT_TRUE(
2539-
notMatches("static int a = 0;", namedDecl(hasExternalFormalLinkage())));
2537+
EXPECT_TRUE(matches("int a = 0;",
2538+
namedDecl(hasName("a"), hasExternalFormalLinkage())));
2539+
EXPECT_TRUE(notMatches("static int a = 0;",
2540+
namedDecl(hasName("a"), hasExternalFormalLinkage())));
25402541
EXPECT_TRUE(notMatches("static void f(void) { int a = 0; }",
2541-
namedDecl(hasExternalFormalLinkage())));
2542-
EXPECT_TRUE(matches("void f(void) { int a = 0; }",
2543-
namedDecl(hasExternalFormalLinkage())));
2544-
2545-
// Despite having internal semantic linkage, the anonymous namespace member
2546-
// has external linkage because the member has a unique name in all
2547-
// translation units.
2548-
EXPECT_TRUE(matches("namespace { int a = 0; }",
2549-
namedDecl(hasExternalFormalLinkage())));
2542+
namedDecl(hasName("a"), hasExternalFormalLinkage())));
2543+
EXPECT_TRUE(notMatches("void f(void) { int a = 0; }",
2544+
namedDecl(hasName("a"), hasExternalFormalLinkage())));
2545+
EXPECT_TRUE(notMatches("namespace { int a = 0; }",
2546+
namedDecl(hasName("a"), hasExternalFormalLinkage())));
25502547
}
25512548

25522549
TEST(HasDefaultArgument, Basic) {

0 commit comments

Comments
 (0)