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 @@ -1310,9 +1310,17 @@ bool ConverterRefCount::VisitExplicitCastExpr(clang::ExplicitCastExpr *expr) {
13101310 } else if (expr->getSubExpr ()->getType ()->isPointerType () &&
13111311 !expr->getSubExpr ()->isNullPointerConstant (
13121312 ctx_, clang::Expr::NPC_ValueDependentIsNull)) {
1313- StrCat (std::format (" ({}.to_strong().as_pointer() as {})" ,
1314- ToString (expr->getSubExpr ()),
1315- ToString (expr->getType ())));
1313+ auto src_pointee = expr->getSubExpr ()->getType ()->getPointeeType ();
1314+ auto dst_pointee = expr->getType ()->getPointeeType ();
1315+ if (ctx_.hasSameUnqualifiedType (src_pointee, dst_pointee)) {
1316+ StrCat (std::format (" ({}.to_strong().as_pointer() as {})" ,
1317+ ToString (expr->getSubExpr ()),
1318+ ToString (expr->getType ())));
1319+ } else {
1320+ StrCat (std::format (" {}.reinterpret_cast::<{}>()" ,
1321+ ToString (expr->getSubExpr ()),
1322+ ConvertPointeeType (expr->getType ())));
1323+ }
13161324 return false ;
13171325 }
13181326 return Converter::VisitExplicitCastExpr (expr);
You can’t perform that action at this time.
0 commit comments