@@ -1099,6 +1099,10 @@ std::string Converter::GetMethodName(const clang::CXXMethodDecl *decl) {
10991099 if (IsOverloadedMethod (decl)) {
11001100 return GetOverloadedFunctionName (decl);
11011101 }
1102+ if (auto *conversion = clang::dyn_cast<clang::CXXConversionDecl>(decl)) {
1103+ return GetConversionName (
1104+ conversion, GetUnsafeTypeAsString (conversion->getConversionType ()));
1105+ }
11021106 return GetNamedDeclAsString (decl);
11031107}
11041108
@@ -1143,10 +1147,9 @@ std::string Converter::GetCtorName(clang::CXXConstructorDecl *decl) {
11431147 if (decl->isCopyOrMoveConstructor ()) {
11441148 return GetOverloadedFunctionName (decl);
11451149 }
1146- return GetRecordName (decl->getParent ()) +
1147- (GetNumberOfConvertingCtors (decl->getParent ()) != 1
1148- ? std::to_string (GetCtorIndex (decl))
1149- : " " );
1150+ return GetNumberOfConvertingCtors (decl->getParent ()) != 1
1151+ ? std::format (" new_{}" , GetCtorIndex (decl))
1152+ : " new" ;
11501153}
11511154
11521155bool Converter::VisitCXXConstructorDecl (clang::CXXConstructorDecl *decl) {
@@ -4068,6 +4071,10 @@ std::string Converter::ConvertVarDefaultInit(clang::QualType qual_type) {
40684071std::string
40694072Converter::GetOverloadedFunctionName (const clang::FunctionDecl *decl) {
40704073 auto name = GetFunctionBaseName (decl);
4074+ if (auto *conversion = clang::dyn_cast<clang::CXXConversionDecl>(decl)) {
4075+ name = GetConversionName (
4076+ conversion, GetUnsafeTypeAsString (conversion->getConversionType ()));
4077+ }
40714078 if (auto *ctor = clang::dyn_cast<clang::CXXConstructorDecl>(decl);
40724079 ctor && !ctor->getParent ()->getIdentifier ()) {
40734080 name = GetRecordName (ctor->getParent ());
@@ -4137,19 +4144,7 @@ Converter::GetOverloadedFunctionName(const clang::FunctionDecl *decl) {
41374144 }
41384145 }
41394146
4140- ReplaceAll (name, " [" , " arr" );
4141- ReplaceAll (name, " ]" , " arr" );
4142- ReplaceAll (name, " ;" , " _" );
4143- ReplaceAll (name, " ," , " _" );
4144- name.erase (std::remove_if (name.begin (), name.end (),
4145- [](char c) {
4146- return c == ' <' || c == ' >' || c == ' ' ||
4147- c == ' :' || c == ' (' || c == ' )' ||
4148- c == ' -' ;
4149- }),
4150- name.end ());
4151- std::replace (name.begin (), name.end (), ' *' , ' p' );
4152-
4147+ ToIdentifier (name);
41534148 return name;
41544149}
41554150
0 commit comments