This branch updates the rewriter to add casts around function calls and their arguments. We mainly need this so we can add casts to and from raw pointers around calls to non-rewritten functions.
More specifically, this branch does the following:
Updates rewrite::expr::mir_op to emit casts around function calls. Given the MIR statement _2 = f(_1), we now generate a cast from the type (LTy) of _1 to the argument type of f and a cast from the return type of f to the type of _2.
Updates rewrite::expr::distribute to handle rewrites from multiple MIR locations being applied to the same HIR node. For example, the HIR code f(x) compiles down to _tmp = _x; f(_tmp); in some test cases, code like this resulted in a cast on the rvalue _x of the first assignment and another cast on the argument _tmp of the call. But both MIR locations originate from the same HIR expression, x, so having rewrites on both locations was rejected because it's ambiguous which set of rewrites should be applied first to the HIR. On this branch, distribute now properly prioritizes these rewrites and allows this case.
Adds support for casts between TyKind::Refs and TyKind::RawPtrs and between different RawPtr types. This consists of some cleanup and expansion of emit_cast_desc_desc in rewrite::expr::mir_op and the addition of a few new Rewrite variants.
Adds some new function attributes #[c2rust_analyze_test::fixed_signature], #[c2rust_analyze_test::skip_rewrite], and #[c2rust_analyze_test::fail_analysis] for use in test cases.
This branch updates the rewriter to add casts around function calls and their arguments. We mainly need this so we can add casts to and from raw pointers around calls to non-rewritten functions.
More specifically, this branch does the following:
rewrite::expr::mir_op
to emit casts around function calls. Given the MIR statement_2 = f(_1)
, we now generate a cast from the type (LTy
) of_1
to the argument type off
and a cast from the return type off
to the type of_2
.rewrite::expr::distribute
to handle rewrites from multiple MIR locations being applied to the same HIR node. For example, the HIR codef(x)
compiles down to_tmp = _x; f(_tmp)
; in some test cases, code like this resulted in a cast on the rvalue_x
of the first assignment and another cast on the argument_tmp
of the call. But both MIR locations originate from the same HIR expression,x
, so having rewrites on both locations was rejected because it's ambiguous which set of rewrites should be applied first to the HIR. On this branch,distribute
now properly prioritizes these rewrites and allows this case.TyKind::Ref
s andTyKind::RawPtr
s and between differentRawPtr
types. This consists of some cleanup and expansion ofemit_cast_desc_desc
inrewrite::expr::mir_op
and the addition of a few newRewrite
variants.#[c2rust_analyze_test::fixed_signature]
,#[c2rust_analyze_test::skip_rewrite]
, and#[c2rust_analyze_test::fail_analysis]
for use in test cases.