Sonder is a static analysis tool for C, for determining the necessary sementics for converting the analyzed C programs to Rust.
-
Get list of all owned data
-
For each piece of owned data:
- Get list of all usages of all refs to it in each scope
- Iterate through scope to check if each one is mutable, or immutable
- this may include parsing called scopes
- some escape analysis may be will here
- whether full borrow-checking will be needed is still unclear
- we will need a way of checking branching
- this includes being passed mutably, or mutating
- Count to make sure at any given point, only a single mutable, or any number of immutable references are used (otherwise leave it as a raw pointer)
- If we have time, check for common Smart Pointer semantics
-
Generate a new AST with previously implicit pointer semantics made explicit
-
Try converting the new AST to semantically identical, idiomatic Rust.
- Branches are counted as their own scopes
- Exclusive branches can hold different references to an object
- But they all must consider the higher-scoped references to higher-scoped data
- Assume all non-exclusive branches occur