-
Notifications
You must be signed in to change notification settings - Fork 78
[BoundsWidening] Adding all bounds widening analysis commits #1122
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
We separate out BoundsVars into BoundsVarsLower and BoundsVarsUpper that track the variables occurring in the lower and upper bounds expressions, respectively. This is needed for the bounds widenening analysis where we want to determine the variables that can potentially be widened in a given dereference expression.
In preparation for the new bounds widening analysis we rename some variables in the existing implementation because these variables will be defined in the new implementation.
Added a method called PreorderAST::GetExprIntDiff that computes the integer difference between two input expressions and returns true if the expressions are comparable. If the expressions are not comparable then it returns false. This method will be used in the updated bounds widening analysis. This method is meant to replace PreorderAST::GetDerefOffset after the updated bounds widening analysis merges. See #1078
This is an updated implementation of the dataflow analysis for bounds widening. In addition to the existing support for bounds widening on a conditional dereferencing a null-terminated array at its upper bound this implementation also supports bounds widening in presence of _Where clauses. For example: _Nt_array_ptr<char> p : bounds(p, p + 1); int x = strlen(p) _Where p : bounds(p, p + x); In the above example the bounds of p would be widened to bounds(p, p + x) after the call to strlen.
…ds.cpp We invoke the updated BoundsWideningAnalysis::WidenBounds() method from SemaBounds.cpp. We also add new test cases for bounds widening and delete the old test cases.
For each statement update the observed bounds in the BlockState with the widened bounds as computed by the updated bounds widening analysis. The bounds of variables whose bounds are killed are reset to the declared bounds. This PR also updates the method GetBoundsWidenedAndNotKilled that returns the bounds widened in a block before a given statement and not killed by that statement.
The updated implementation of the bounds widening analysis is now in committed. So we can remove the old implementation.
kkjeer
approved these changes
Jul 9, 2021
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!
sulekhark
approved these changes
Jul 9, 2021
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! Thank you!
This was referenced Jul 9, 2021
This was referenced Jan 17, 2022
[BoundsWidening] Implement the bounds widening dataflow analysis
checkedc/checkedc-llvm-project#1093
Closed
Closed
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains all commits required for the updated bounds widening analysis.