-
Notifications
You must be signed in to change notification settings - Fork 123
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
fix: very simple constant propagation for obvious cases #1596
base: main
Are you sure you want to change the base?
Conversation
…cases of division by zero, null dereference and integer overflow. The analyzer does not do branch joining nor fixpoint computation. It attempts to evaluate a function code up to a point where two or more branches need to join.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tests cannot be deprecated: these are our specification, so when you switch to a proper implementation, tests should still pass
What will we need to change in the codebase to switch to a more advanced solution? |
Depending on what we want to do with constant propagation:
|
… own subfolder, because they were conflicting with the short-circuiting tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Issue
Closes #716.
This is a simplified version of the AST-based constant propagation algorithm in PR #852 in order to have a quick fix for the issue. It solves very obvious cases of division by zero, null de-reference and integer overflow. The analysis tries to execute expressions and statements until it reaches a join point of two or more branches. At that moment, it stops. The analysis does not carry out branch joining or fix-point computation.
For example, it is able to detect the division by zero in this:
But not in here:
If needed, we could get it closer to the code in PR #852 by later incremental additions. This PR replaces PR #852.
NOTE: This solution is intended to be temporary until proper constant propagation is implemented.
Checklist