@@ -1171,7 +1171,6 @@ void Converter::EmitConstructorFieldInits(clang::CXXConstructorDecl *decl) {
11711171
11721172 for (const auto *field : record_decl->fields ()) {
11731173 auto field_name = GetNamedDeclAsString (field);
1174- auto field_type = field->getType ();
11751174 const clang::CXXCtorInitializer *ctor_initializer = nullptr ;
11761175 for (const auto *init : definition->inits ()) {
11771176 if (init->isMemberInitializer () && init->getMember () == field) {
@@ -1180,15 +1179,9 @@ void Converter::EmitConstructorFieldInits(clang::CXXConstructorDecl *decl) {
11801179 }
11811180 }
11821181
1183- if (ctor_initializer) {
1184- StrCat (field_name, token::kColon );
1185- ConvertVarInit (field_type, ctor_initializer->getInit ());
1186- } else if (auto *init = field->getInClassInitializer ()) {
1187- StrCat (field_name, token::kColon );
1188- ConvertVarInit (field_type, init);
1189- } else {
1190- StrCat (field_name, token::kColon , GetDefaultAsString (field_type));
1191- }
1182+ StrCat (field_name, token::kColon );
1183+ ConvertFieldInit (field, ctor_initializer ? ctor_initializer->getInit ()
1184+ : field->getInClassInitializer ());
11921185 StrCat (token::kComma );
11931186 }
11941187}
@@ -2444,7 +2437,10 @@ bool Converter::VisitImplicitCastExpr(clang::ImplicitCastExpr *expr) {
24442437 case clang::CastKind::CK_LValueToRValue: {
24452438 PushExprKind push (*this , ExprKind::RValue);
24462439 Convert (sub_expr);
2447- SetValueFreshness (type);
2440+ // The value may have been copied out already.
2441+ if (!isFresh ()) {
2442+ SetValueFreshness (type);
2443+ }
24482444 break ;
24492445 }
24502446 case clang::CastKind::CK_ArrayToPointerDecay: {
@@ -3398,7 +3394,7 @@ bool Converter::VisitInitListExpr(clang::InitListExpr *expr) {
33983394 int i = 0 ;
33993395 for (const auto *field : record->fields ()) {
34003396 StrCat (GetNamedDeclAsString (field), token::kColon );
3401- ConvertVarInit (field-> getType () , expr->getInit (i++));
3397+ ConvertFieldInit (field, expr->getInit (i++));
34023398 StrCat (token::kComma );
34033399 }
34043400 } else {
@@ -4665,15 +4661,20 @@ void Converter::EmitDefaultStructLiteral(const clang::RecordDecl *decl) {
46654661 PushBrace brace (*this );
46664662 for (auto *field : decl->fields ()) {
46674663 StrCat (GetNamedDeclAsString (field), token::kColon );
4668- if (auto *init = field->getInClassInitializer ()) {
4669- ConvertVarInit (field->getType (), init);
4670- } else {
4671- StrCat (GetDefaultAsString (field->getType ()));
4672- }
4664+ ConvertFieldInit (field, field->getInClassInitializer ());
46734665 StrCat (token::kComma );
46744666 }
46754667}
46764668
4669+ void Converter::ConvertFieldInit (const clang::FieldDecl *field,
4670+ clang::Expr *init) {
4671+ if (init) {
4672+ ConvertVarInit (field->getType (), init);
4673+ } else {
4674+ StrCat (GetDefaultAsString (field->getType ()));
4675+ }
4676+ }
4677+
46774678void Converter::AddByteReprTrait (const clang::RecordDecl *decl) {}
46784679
46794680void Converter::ConvertUnsignedArithBinaryOperator (clang::BinaryOperator *op,
0 commit comments