@@ -402,6 +402,7 @@ bool ConverterRefCount::VisitArraySubscriptExpr(
402402 StrCat (GetPointerDerefPrefix (expr->getType ()));
403403 ConvertArraySubscript (base, expr->getIdx (), expr->getType ());
404404 StrCat (GetPointerDerefSuffix (expr->getType ()));
405+ SetValueFreshness (expr->getType ());
405406 } else {
406407 ConvertArraySubscript (base, expr->getIdx (), expr->getType ());
407408 }
@@ -788,6 +789,7 @@ bool ConverterRefCount::ConvertIncAndDec(clang::UnaryOperator *expr) {
788789 } else {
789790 StrCat (str, ' .' , method, " ()" );
790791 }
792+ SetFreshType (expr->getType ());
791793 return true ;
792794}
793795
@@ -1133,16 +1135,19 @@ bool ConverterRefCount::VisitStringLiteral(clang::StringLiteral *expr) {
11331135 uint64_t arr_size = arr_ty->getSize ().getZExtValue ();
11341136 if (expr->getString ().empty ()) {
11351137 StrCat (std::format (" vec![0u8; {}].into_boxed_slice()" , arr_size));
1138+ computed_expr_type_ = ComputedExprType::FreshValue;
11361139 return false ;
11371140 }
11381141 pad = arr_size > expr->getString ().size ()
11391142 ? arr_size - expr->getString ().size ()
11401143 : 0 ;
11411144 }
11421145 StrCat (std::format (" Box::from(*b{})" , GetEscapedStringLiteral (expr, pad)));
1146+ computed_expr_type_ = ComputedExprType::FreshValue;
11431147 return false ;
11441148 }
11451149 StrCat (std::format (" b{}" , GetEscapedStringLiteral (expr, 0 )));
1150+ computed_expr_type_ = ComputedExprType::FreshValue;
11461151 return false ;
11471152}
11481153
@@ -1270,6 +1275,7 @@ void ConverterRefCount::ConvertEqualsNullPtr(clang::Expr *expr) {
12701275 StrCat (' (' );
12711276 Convert (expr);
12721277 StrCat (" ).is_null()" );
1278+ computed_expr_type_ = ComputedExprType::FreshValue;
12731279}
12741280
12751281bool ConverterRefCount::VisitFunctionPointerCast (
@@ -1421,6 +1427,7 @@ void ConverterRefCount::EmitStmtExprTail(clang::Expr *tail) {
14211427 Convert (tail);
14221428 StrCat (token::kSemiColon );
14231429 StrCat (" __result" );
1430+ SetFreshType (tail->getType ());
14241431}
14251432
14261433void ConverterRefCount::ConvertBinaryOperator (clang::BinaryOperator *expr) {
@@ -1483,6 +1490,8 @@ void ConverterRefCount::ConvertBinaryOperator(clang::BinaryOperator *expr) {
14831490 if (expr->isCompoundAssignmentOp ()) {
14841491 StrCat (token::kSemiColon );
14851492 EmitSetOrAssign (lhs, " rhs_0" );
1493+ } else {
1494+ computed_expr_type_ = ComputedExprType::FreshValue;
14861495 }
14871496 return ;
14881497 }
@@ -1608,6 +1617,7 @@ void ConverterRefCount::ConvertUnionMemberAccessor(clang::MemberExpr *expr) {
16081617 return ;
16091618 }
16101619 StrCat (DerefPtrExpr (str, member->getType ()));
1620+ SetValueFreshness (member->getType ());
16111621}
16121622
16131623bool ConverterRefCount::VisitMemberExpr (clang::MemberExpr *expr) {
@@ -1882,6 +1892,7 @@ bool ConverterRefCount::VisitImplicitValueInitExpr(
18821892 StrCat (" Box::new(" );
18831893 Converter::VisitImplicitValueInitExpr (expr);
18841894 StrCat (' )' );
1895+ computed_expr_type_ = ComputedExprType::FreshValue;
18851896 return false ;
18861897 }
18871898 }
@@ -1909,6 +1920,7 @@ bool ConverterRefCount::VisitVAArgExpr(clang::VAArgExpr *expr) {
19091920 StrCat (ToString (expr->getType ()));
19101921 }
19111922 StrCat (" >()" );
1923+ SetFreshType (expr->getType ());
19121924 return false ;
19131925}
19141926
@@ -1936,10 +1948,12 @@ ConverterRefCount::GetArrayDefaultAsString(clang::QualType qual_type) {
19361948
19371949std::string ConverterRefCount::GetDefaultAsString (clang::QualType qual_type) {
19381950 if (IsVaListType (qual_type)) {
1951+ computed_expr_type_ = ComputedExprType::FreshValue;
19391952 return BoxValue (" VaList::default()" );
19401953 }
19411954
19421955 if (auto arr = GetArrayDefaultAsString (qual_type); !arr.empty ()) {
1956+ computed_expr_type_ = ComputedExprType::FreshValue;
19431957 return BoxValue (std::move (arr));
19441958 }
19451959
@@ -1964,6 +1978,7 @@ std::string ConverterRefCount::GetDefaultAsString(clang::QualType qual_type) {
19641978 } else {
19651979 return Converter::GetDefaultAsString (qual_type);
19661980 }
1981+ computed_expr_type_ = ComputedExprType::FreshPointer;
19671982 return BoxValue (std::move (ret));
19681983}
19691984
@@ -2103,13 +2118,15 @@ void ConverterRefCount::ConvertGenericBinaryOperator(
21032118 opcode,
21042119 ConvertFreshRValue (
21052120 rhs, GetOperandImplicitConversionTarget (expr, rhs, lhs))));
2121+ computed_expr_type_ = ComputedExprType::FreshValue;
21062122 return ;
21072123 }
21082124
21092125 PushParen outer (*this );
21102126 Convert (lhs, GetOperandImplicitConversionTarget (expr, lhs, rhs));
21112127 StrCat (opcode);
21122128 Convert (rhs, GetOperandImplicitConversionTarget (expr, rhs, lhs));
2129+ computed_expr_type_ = ComputedExprType::FreshValue;
21132130}
21142131
21152132void ConverterRefCount::ConvertUniquePtrDeref (
@@ -2394,6 +2411,7 @@ void ConverterRefCount::ConvertArrow(clang::Expr *expr) {
23942411 if (!is_overloaded_arrow) {
23952412 auto ptr = ToString (expr);
23962413 StrCat (DerefPtrExpr (ptr, expr->getType ()->getPointeeType ()));
2414+ SetValueFreshness (expr->getType ()->getPointeeType ());
23972415 return ;
23982416 }
23992417
0 commit comments