Skip to content

Commit

Permalink
analyze: mir_op: trace! reasons for not rewriting malloc/calloc
Browse files Browse the repository at this point in the history
  • Loading branch information
spernsteiner committed Oct 10, 2024
1 parent abc496f commit 922735f
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions c2rust-analyze/src/rewrite/expr/mir_op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,10 @@ impl<'a, 'tcx> ExprRewriteVisitor<'a, 'tcx> {
let pointee_lty = match dest_pointee {
Some(x) => x,
// TODO: emit void* cast before bailing out
None => return,
None => {
trace!("{callee:?}: no pointee type for dest");
return;
}
};

let orig_pointee_ty = pointee_lty.ty;
Expand All @@ -687,7 +690,13 @@ impl<'a, 'tcx> ExprRewriteVisitor<'a, 'tcx> {
let zero_ty = match ZeroizeType::from_ty(tcx, orig_pointee_ty) {
Some(x) => x,
// TODO: emit void* cast before bailing out
None => return,
None => {
trace!(
"{callee:?}: failed to compute ZeroizeType \
for {orig_pointee_ty:?}"
);
return;
}
};

let rw = match *callee {
Expand Down Expand Up @@ -757,7 +766,7 @@ impl<'a, 'tcx> ExprRewriteVisitor<'a, 'tcx> {
});
}

Callee::Realloc => {
ref callee @ Callee::Realloc => {
self.enter_rvalue(|v| {
let src_lty = v.acx.type_of(&args[0]);
let src_pointee = v.pointee_lty(src_lty);
Expand All @@ -767,7 +776,13 @@ impl<'a, 'tcx> ExprRewriteVisitor<'a, 'tcx> {
let pointee_lty = match common_pointee {
Some(x) => x,
// TODO: emit void* cast before bailing out
None => return,
None => {
trace!(
"{callee:?}: no common pointee type \
between {src_pointee:?} and {dest_pointee:?}"
);
return;
}
};

let orig_pointee_ty = pointee_lty.ty;
Expand All @@ -785,7 +800,13 @@ impl<'a, 'tcx> ExprRewriteVisitor<'a, 'tcx> {
let zero_ty = match ZeroizeType::from_ty(tcx, orig_pointee_ty) {
Some(x) => x,
// TODO: emit void* cast before bailing out
None => return,
None => {
trace!(
"{callee:?}: failed to compute ZeroizeType \
for {orig_pointee_ty:?}"
);
return;
}
};

// Cast input to either `Box<T>` or `Box<[T]>`, as in `free`.
Expand Down

0 comments on commit 922735f

Please sign in to comment.