Skip to content

Commit 97c31ee

Browse files
committed
[clang][ssaf][NFC] Fix test for entity name of implicit declaration
1 parent 30ac699 commit 97c31ee

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

clang/unittests/Analysis/Scalable/ASTEntityMappingTest.cpp

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -96,27 +96,20 @@ TEST(ASTEntityMappingTest, NullDecl) {
9696
EXPECT_FALSE(EntityName.has_value());
9797
}
9898

99-
TEST(ASTEntityMappingTest, ImplicitDecl) {
99+
TEST(ASTEntityMappingTest, ImplicitDeclLambda) {
100100
auto AST = tooling::buildASTFromCode(R"(
101-
struct S {
102-
S() = default;
103-
};
101+
auto L = [](){};
104102
)", "test.cpp", std::make_shared<PCHContainerOperations>());
105103
auto &Ctx = AST->getASTContext();
106104

107-
const auto *RD = findDecl<CXXRecordDecl>(Ctx, "S");
108-
ASSERT_NE(RD, nullptr);
105+
auto Matcher = cxxRecordDecl(isImplicit()).bind("decl");
106+
auto Matches = match(Matcher, Ctx);
107+
ASSERT_GT(Matches.size(), 0u);
109108

110-
// Find the implicitly-declared copy constructor
111-
const CXXConstructorDecl * ImplCtor = nullptr;
112-
for (const auto *Ctor : RD->ctors()) {
113-
if (Ctor->isCopyConstructor() && Ctor->isImplicit()) {
114-
ImplCtor = Ctor;
115-
break;
116-
}
117-
}
109+
const auto * ImplCXXRD = Matches[0].getNodeAs<CXXRecordDecl>("decl");
110+
ASSERT_NE(ImplCXXRD, nullptr);
118111

119-
auto EntityName = getEntityName(ImplCtor);
112+
auto EntityName = getEntityName(ImplCXXRD);
120113
EXPECT_FALSE(EntityName.has_value());
121114
}
122115

0 commit comments

Comments
 (0)