Skip to content

Conversation

mgrang
Copy link

@mgrang mgrang commented Jul 7, 2021

This PR contains all commits required for the updated bounds widening analysis.

Mandeep Singh Grang added 8 commits July 6, 2021 10:28
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.
@mgrang mgrang changed the base branch from bounds_widening_master2 to master July 8, 2021 22:21
Copy link
Contributor

@kkjeer kkjeer left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@sulekhark sulekhark left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you!

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.

3 participants