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 @@ -79,9 +79,9 @@ static bool IsValueField(clang::ASTContext &ctx,
7979static bool IsArrayFieldPtr (clang::ASTContext &ctx, const clang::Expr *expr) {
8080 auto *member =
8181 clang::dyn_cast<clang::MemberExpr>(expr->IgnoreParenImpCasts ());
82- auto *field =
83- member ? clang::dyn_cast<clang::FieldDecl>(member->getMemberDecl ())
84- : nullptr ;
82+ auto *field = member
83+ ? clang::dyn_cast<clang::FieldDecl>(member->getMemberDecl ())
84+ : nullptr ;
8585 if (!field || field->getParent ()->isUnion () ||
8686 Mapper::Contains (ctx, member)) {
8787 return false ;
@@ -1567,8 +1567,8 @@ bool ConverterRefCount::VisitExplicitCastExpr(clang::ExplicitCastExpr *expr) {
15671567 PushConversionKind push (*this , ConversionKind::Unboxed);
15681568 StrCat (std::format (" ({} as Ptr<{}>)" , ToString (sub_expr),
15691569 ToString (element_type)));
1570- if (!ctx_.hasSameUnqualifiedType (
1571- element_type, expr->getType ()->getPointeeType ())) {
1570+ if (!ctx_.hasSameUnqualifiedType (element_type,
1571+ expr->getType ()->getPointeeType ())) {
15721572 StrCat (std::format (" .reinterpret_cast::<{}>()" ,
15731573 ConvertPointeeType (expr->getType ())));
15741574 }
Original file line number Diff line number Diff line change @@ -129,8 +129,8 @@ single object, which is why it needs no element index.
129129
130130` array_field_ptr!(p, arr) ` is a pointer to element 0 of the array field ` arr ` ,
131131and is how the elements of an array field are accessed. It is an ordinary array
132- pointer into the array's ` Value ` , except when ` p ` is a reinterpreted pointer: the
133- array then lives in the bytes of the original allocation, so the result is a
132+ pointer into the array's ` Value ` , except when ` p ` is a reinterpreted pointer:
133+ the array then lives in the bytes of the original allocation, so the result is a
134134reinterpreted pointer to those bytes, at the offset of the field. Writes to the
135135elements hence reach the original allocation, and the pointer can go past the
136136end of the struct, as C code does with a trailing ` char name[1] ` in an
You can’t perform that action at this time.
0 commit comments