immunant / c2rust

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

analyze: add --rewrite-mode pointwise #1073

Closed spernsteiner closed 5 months ago

spernsteiner commented 6 months ago

This adds a new --rewrite-mode called "pointwise", which rewrites each function in isolation, with all other definitions marked FIXED. The static analysis runs only once, then we run multiple rewriting passes using the same analysis results, making this much more efficient than running the whole c2rust-analyze tool multiple times.

The rewritten code is output to a separate file for each function. For example, given foo.rs containing a function bar, this mode will write to foo.bar.rs the new code produced by rewriting only bar.

Pointwise mode is the basis for our new "pointwise success rate" metric.