Skip to content

Commit a7c5aa7

Browse files
committed
[clang][ssaf][NFC] Improve redeclaration entity name test
1 parent f7d033b commit a7c5aa7

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

clang/unittests/Analysis/Scalable/ASTEntityMappingTest.cpp

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -225,19 +225,22 @@ TEST(ASTEntityMappingTest, FunctionRedeclaration) {
225225

226226
auto Matcher = functionDecl(hasName("foo")).bind("decl");
227227
auto Matches = match(Matcher, Ctx);
228-
ASSERT_EQ(Matches.size(), 2u);
228+
ASSERT_GE(Matches.size(), 2u);
229229

230-
const auto *Decl1 = Matches[0].getNodeAs<FunctionDecl>("decl");
231-
const auto *Decl2 = Matches[1].getNodeAs<FunctionDecl>("decl");
232-
ASSERT_NE(Decl1, nullptr);
233-
ASSERT_NE(Decl2, nullptr);
230+
const auto *FirstDecl = Matches[0].getNodeAs<FunctionDecl>("decl");
231+
ASSERT_NE(FirstDecl, nullptr);
234232

235-
auto Name1 = getLocalEntityNameForDecl(Decl1);
236-
auto Name2 = getLocalEntityNameForDecl(Decl2);
237-
ASSERT_TRUE(Name1.has_value());
238-
ASSERT_TRUE(Name2.has_value());
233+
auto FirstName = getLocalEntityNameForDecl(FirstDecl);
234+
ASSERT_TRUE(FirstName.has_value());
239235

240-
EXPECT_EQ(*Name1, *Name2);
236+
for (size_t I = 1; I < Matches.size(); ++I) {
237+
const auto *Decl = Matches[I].getNodeAs<FunctionDecl>("decl");
238+
ASSERT_NE(Decl, nullptr);
239+
240+
auto Name = getLocalEntityNameForDecl(Decl);
241+
ASSERT_TRUE(Name.has_value());
242+
EXPECT_EQ(*FirstName, *Name);
243+
}
241244
}
242245

243246
TEST(ASTEntityMappingTest, VarRedeclaration) {

0 commit comments

Comments
 (0)