@@ -686,6 +686,10 @@ bool Converter::RecordDerivesDefault(const clang::RecordDecl *decl) {
686686 }
687687
688688 for (auto f : decl->fields ()) {
689+ if (f->hasInClassInitializer ()) {
690+ return false ;
691+ }
692+
689693 // Records that contain function pointer do not derive Default
690694 if (auto ptr_ty = f->getType ()->getAs <clang::PointerType>()) {
691695 if (ptr_ty->getPointeeType ()->isFunctionType ()) {
@@ -1096,6 +1100,10 @@ std::string Converter::GetMethodName(const clang::CXXMethodDecl *decl) {
10961100 if (clang::isa<clang::CXXDestructorDecl>(decl)) {
10971101 return kDestructorName ;
10981102 }
1103+ if (const char *name = GetCopyOrMoveName (decl);
1104+ name && CanUseCopyOrMoveName (decl, name)) {
1105+ return name;
1106+ }
10991107 if (IsOverloadedMethod (decl)) {
11001108 return GetOverloadedFunctionName (decl);
11011109 }
@@ -1145,6 +1153,10 @@ std::string Converter::GetSelfMaybeWithMut(const clang::CXXMethodDecl *decl) {
11451153
11461154std::string Converter::GetCtorName (clang::CXXConstructorDecl *decl) {
11471155 if (decl->isCopyOrMoveConstructor ()) {
1156+ if (const char *name = GetCopyOrMoveName (decl);
1157+ CanUseCopyOrMoveName (decl, name)) {
1158+ return name;
1159+ }
11481160 return GetOverloadedFunctionName (decl);
11491161 }
11501162 return GetNumberOfConvertingCtors (decl->getParent ()) != 1
@@ -3328,7 +3340,7 @@ void Converter::ConvertMemberExpr(clang::MemberExpr *expr) {
33283340 if (auto *method = clang::dyn_cast<clang::CXXMethodDecl>(member);
33293341 method && IsOverloadedMethod (method)) {
33303342 StrCat (token::kDot );
3331- StrCat (GetOverloadedFunctionName (method));
3343+ StrCat (GetMethodName (method));
33323344 } else if (!name_override.empty ()) {
33333345 StrCat (token::kDot , name_override);
33343346 } else if (member->getDeclName ().isIdentifier ()) {
@@ -3370,6 +3382,7 @@ bool Converter::VisitArrayInitLoopExpr(clang::ArrayInitLoopExpr *expr) {
33703382}
33713383
33723384bool Converter::VisitInitListExpr (clang::InitListExpr *expr) {
3385+ auto *syntactic = expr->isSyntacticForm () ? expr : expr->getSyntacticForm ();
33733386 if (auto form = expr->getSemanticForm ())
33743387 expr = form;
33753388
@@ -3395,6 +3408,12 @@ bool Converter::VisitInitListExpr(clang::InitListExpr *expr) {
33953408 return false ;
33963409 }
33973410
3411+ if (syntactic->getNumInits () == 0 ) {
3412+ StrCat (GetDefaultAsString (qual_type));
3413+ SetFreshType (qual_type);
3414+ return false ;
3415+ }
3416+
33983417 StrCat (GetUnsafeTypeAsString (qual_type));
33993418 PushBrace brace (*this );
34003419 int i = 0 ;
@@ -4038,18 +4057,6 @@ std::string Converter::GetDefaultAsStringFallback(clang::QualType qual_type) {
40384057 return getTypedLiteral (" 0.0" , ToString (qual_type));
40394058 }
40404059
4041- if (auto record = qual_type->getAsRecordDecl ();
4042- record && in_const_initializer_) {
4043- if (auto cxx = clang::dyn_cast<clang::CXXRecordDecl>(record)) {
4044- ENSURE (GetUserDefinedDefaultConstructor (cxx) == nullptr &&
4045- " Default initializing globals using default constructor is not "
4046- " supported" );
4047- }
4048- Buffer buf (*this );
4049- EmitDefaultStructLiteral (record);
4050- return std::move (buf).str ();
4051- }
4052-
40534060 if (auto record = qual_type->getAsRecordDecl ()) {
40544061 if (ctx_.getSourceManager ().isInSystemHeader (record->getLocation ()) &&
40554062 qual_type.isPODType (ctx_)) {
@@ -4708,8 +4715,13 @@ void Converter::EmitDefaultStructLiteral(const clang::RecordDecl *decl) {
47084715 StrCat (GetRecordName (decl));
47094716 PushBrace brace (*this );
47104717 for (auto *field : decl->fields ()) {
4711- StrCat (GetNamedDeclAsString (field), token::kColon ,
4712- GetDefaultAsString (field->getType ()), token::kComma );
4718+ StrCat (GetNamedDeclAsString (field), token::kColon );
4719+ if (auto *init = field->getInClassInitializer ()) {
4720+ ConvertVarInit (field->getType (), init);
4721+ } else {
4722+ StrCat (GetDefaultAsString (field->getType ()));
4723+ }
4724+ StrCat (token::kComma );
47134725 }
47144726}
47154727
0 commit comments