immunant / c2rust

Migrate C code to Rust
https://c2rust.com/
Other
3.91k stars 229 forks source link

analyze: refactor MIR rewrite generation #919

Closed spernsteiner closed 1 year ago

spernsteiner commented 1 year ago

This branch refactors mir_op to make the generation of conversions more uniform. Ideally, we should call emit_cast_* in roughly every place where dataflow::type_check adds a dataflow edge. This branch doesn't fully implement that, but gets us a little closer.

This also adds a new TypeDesc type, which bundles up Ownership, Quantity, and a pointee Ty into a complete description of a rewritten pointer type. This is used for some of the new emit_cast_* machinery.

Based on #918 for now; once this is approved, I'll rebase onto master

spernsteiner commented 1 year ago

I rebased this onto master, but a test is now failing

spernsteiner commented 1 year ago

Fixed the test failure by skipping rewrite generation for void* casts. We can do something more intelligent with those later when we add proper rewriting of malloc/free/memcpy/etc.