Skip to content

Commit b56abf7

Browse files
committed
Use friend operators in ord trait
1 parent f04d580 commit b56abf7

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

‎cpp2rust/converter/converter.cpp‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4597,13 +4597,28 @@ void Converter::AddOrdTrait(const clang::CXXRecordDecl *decl) {
45974597
break;
45984598
}
45994599
};
4600+
auto consider_decl = [&](const clang::NamedDecl *found) {
4601+
if (const auto *tmpl =
4602+
clang::dyn_cast<clang::FunctionTemplateDecl>(found)) {
4603+
for (const auto *spec : tmpl->specializations()) {
4604+
consider(spec);
4605+
}
4606+
return;
4607+
}
4608+
consider(clang::dyn_cast<clang::FunctionDecl>(found));
4609+
};
46004610
for (const auto *method : decl->methods()) {
46014611
consider(method);
46024612
}
46034613
for (auto op : {clang::OO_EqualEqual, clang::OO_Less, clang::OO_Spaceship}) {
46044614
auto name = ctx_.DeclarationNames.getCXXOperatorName(op);
46054615
for (const auto *found : decl->getDeclContext()->lookup(name)) {
4606-
consider(clang::dyn_cast<clang::FunctionDecl>(found));
4616+
consider_decl(found);
4617+
}
4618+
}
4619+
for (const auto *friend_decl : decl->friends()) {
4620+
if (const auto *found = friend_decl->getFriendDecl()) {
4621+
consider_decl(found);
46074622
}
46084623
}
46094624

0 commit comments

Comments
 (0)