File tree Expand file tree Collapse file tree
cpp2rust/converter/models Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1299,9 +1299,17 @@ bool ConverterRefCount::VisitExplicitCastExpr(clang::ExplicitCastExpr *expr) {
12991299 } else if (expr->getSubExpr ()->getType ()->isPointerType () &&
13001300 !expr->getSubExpr ()->isNullPointerConstant (
13011301 ctx_, clang::Expr::NPC_ValueDependentIsNull)) {
1302- StrCat (std::format (" ({}.to_strong().as_pointer() as {})" ,
1303- ToString (expr->getSubExpr ()),
1304- ToString (expr->getType ())));
1302+ auto src_pointee = expr->getSubExpr ()->getType ()->getPointeeType ();
1303+ auto dst_pointee = expr->getType ()->getPointeeType ();
1304+ if (ctx_.hasSameUnqualifiedType (src_pointee, dst_pointee)) {
1305+ StrCat (std::format (" ({}.to_strong().as_pointer() as {})" ,
1306+ ToString (expr->getSubExpr ()),
1307+ ToString (expr->getType ())));
1308+ } else {
1309+ StrCat (std::format (" {}.reinterpret_cast::<{}>()" ,
1310+ ToString (expr->getSubExpr ()),
1311+ ConvertPointeeType (expr->getType ())));
1312+ }
13051313 return false ;
13061314 }
13071315 return Converter::VisitExplicitCastExpr (expr);
You can’t perform that action at this time.
0 commit comments