Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

analyze: initial implementation of NON_NULL static analysis #1081

Merged
merged 6 commits into from
Apr 22, 2024

Conversation

spernsteiner
Copy link
Collaborator

This adds a very basic static analysis for NON_NULL within the current dataflow framework. It starts by optimistically assuming that all pointers are NON_NULL, and removes the permission from pointers into which a ptr::null() or equivalent might flow. This branch just implements the static analysis, not rewriting.

I'm actually not a huge fan of this design - I think we'd probably get much better results with a path-sensitive analysis that can handle common patterns from C like if !p.is_null() { let q = (&p).field; /* use q... */ } by detecting null checks in the CFG. But the simple path-insensitive version is sufficient for now, and gives us somewhere to plug in the dynamic analysis results.

Copy link
Contributor

@fw-immunant fw-immunant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One comment fix needed as mentioned inline, otherwise LGTM.

c2rust-analyze/src/borrowck/type_check.rs Outdated Show resolved Hide resolved
c2rust-analyze/src/util.rs Outdated Show resolved Hide resolved
@spernsteiner spernsteiner merged commit d85b4d0 into master Apr 22, 2024
7 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants