@@ -1095,6 +1095,10 @@ std::string Converter::GetMethodName(const clang::CXXMethodDecl *decl) {
10951095 if (clang::isa<clang::CXXDestructorDecl>(decl)) {
10961096 return kDestructorName ;
10971097 }
1098+ if (const char *name = GetCopyOrMoveName (decl);
1099+ name && CanUseCopyOrMoveName (decl, name)) {
1100+ return name;
1101+ }
10981102 if (IsOverloadedMethod (decl)) {
10991103 return GetOverloadedFunctionName (decl);
11001104 }
@@ -1138,30 +1142,10 @@ std::string Converter::GetSelfMaybeWithMut(const clang::CXXMethodDecl *decl) {
11381142 return MethodNeedsMutableReceiver (decl) ? " &mut self" : " &self" ;
11391143}
11401144
1141- static bool CanUseShortCopyOrMoveCtorName (clang::CXXConstructorDecl *decl,
1142- const std::string &name) {
1143- const auto *record = decl->getParent ();
1144- bool is_unique_ctor =
1145- std::count_if (record->ctor_begin (), record->ctor_end (),
1146- [decl](const clang::CXXConstructorDecl *ctor) {
1147- return !ctor->isDeleted () &&
1148- (decl->isCopyConstructor ()
1149- ? ctor->isCopyConstructor ()
1150- : ctor->isMoveConstructor ());
1151- }) == 1 ;
1152- bool is_unique_name =
1153- std::none_of (record->method_begin (), record->method_end (),
1154- [&name](const clang::CXXMethodDecl *method) {
1155- return method->getDeclName ().isIdentifier () &&
1156- method->getName () == name;
1157- });
1158- return is_unique_ctor && is_unique_name;
1159- }
1160-
11611145std::string Converter::GetCtorName (clang::CXXConstructorDecl *decl) {
11621146 if (decl->isCopyOrMoveConstructor ()) {
1163- std::string name = decl-> isCopyConstructor () ? " copy_from " : " move_from " ;
1164- if ( CanUseShortCopyOrMoveCtorName (decl, name)) {
1147+ if ( const char * name = GetCopyOrMoveName (decl) ;
1148+ CanUseCopyOrMoveName (decl, name)) {
11651149 return name;
11661150 }
11671151 return GetOverloadedFunctionName (decl);
@@ -3358,7 +3342,7 @@ void Converter::ConvertMemberExpr(clang::MemberExpr *expr) {
33583342 if (auto *method = clang::dyn_cast<clang::CXXMethodDecl>(member);
33593343 method && IsOverloadedMethod (method)) {
33603344 StrCat (token::kDot );
3361- StrCat (GetOverloadedFunctionName (method));
3345+ StrCat (GetMethodName (method));
33623346 } else if (!name_override.empty ()) {
33633347 StrCat (token::kDot , name_override);
33643348 } else if (member->getDeclName ().isIdentifier ()) {
0 commit comments