-
Notifications
You must be signed in to change notification settings - Fork 284
Fix skeleton in shift_indexed_access_to_lhs #4895
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 skeleton in shift_indexed_access_to_lhs #4895
Conversation
The function only has an effect if the byte_extract expression can be simplified. So there is no point for the caller to call it with do_simplify=false.
Since the type of expression to simplify is known, we avoid several intermediary calls by calling directly the function that would eventually be called.
If the expression e itself is nil then it would be incorrect to return a pointer to that, so we special case that and return nullptr to denote failure.
This makes it clear from the start of the function that this will only modify byte_update_expressions.
The name of the variable does not add any information to the reader.
tautschnig
left a comment
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.
Could I please ask for a an explanation why we shouldn't instead just revert #4841? If a bugfix requires +584/-94 changes then we've got a serious problem in our architecture. This doesn't scale.
a7a7542 to
a5971b2
Compare
This allows checking we are replacing the missing part by an appropriate one. This will also make some manipulation easier, like reverting a byte extract operation on a member_expr skeleton.
This is meant to revert the effect of a byte extract on a skeleton. This can be used in symex when assignments are transformed, by switching byte_update/extract operations from one side of the assignment to the other.
Function defined in the header should be marked inline (except for template which are inline by default).
Tests we function works as expected on skeleton containing member and index access.
If a byte_extract operation is added to the lhs, then the revert operation must be performed on the skeleton so that new_skeleton[new_lhs] is equivalent to skeleton[lhs].
This tests the case where a byte_extract expression is assigned.
Since we change the lhs it does not make sense to keep the same skeleton and we have to start from a fresh one.
a5971b2 to
504262b
Compare
The problem is not with #4841, this was a refactoring to makes things clearer. The bug was already there before. It was introduced when |
So which bug does it fix? I cannot seem to see a single regression test. I think this is the third PR on the |
src/goto-symex/symex_assign.cpp
Outdated
| byte_update.offset(), | ||
| byte_update.value().type()}, | ||
| ns); | ||
| exprt byte_extract = simplify_exprt{ns} |
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.
Let's not -- simplify can decide how to do whatever simplification seems appropriate; we shouldn't lift the lid in one place.
|
After staring at this for a while, thoughts:
To sum up: |
|
Here's my rival PR: #4917 Long story short: do all the LHS rvalue renaming and simplifying right at the start of |
|
#4917 makes this irrelevant |
If a byte_extract operation is added to the lhs, then the invert
operation must be performed on the skeleton so that
new_skeleton[new_lhs] is equivalent to skeleton[lhs].
This requires adding a method
revert_byte_extracton skeletont.Unit tests are added for this method and for convert assign symbol.