-
Notifications
You must be signed in to change notification settings - Fork 274
Construct array_exprt in a non-deprecated way [blocks: #3768] #3771
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
Construct array_exprt in a non-deprecated way [blocks: #3768] #3771
Conversation
6e047a8
to
8f46d4b
Compare
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.
🚫
This PR failed Diffblue compatibility checks (cbmc commit: 6e047a8).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/97138270
Status will be re-evaluated on next push.
Please contact @peterschrammel, @thk123, or @allredj for support.
Common spurious failures:
- the cbmc commit has disappeared in the mean time (e.g. in a force-push)
- the author is not in the list of contributors (e.g. first-time contributors).
The incompatibility may have been introduced by an earlier PR. In that case merging this
PR should be avoided unless it fixes the current incompatibility.
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.
✔️
Passed Diffblue compatibility checks (cbmc commit: 8f46d4b).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/97139411
8f46d4b
to
eedd686
Compare
} | ||
return std::move(values); | ||
return array_exprt(std::move(values), array_typet(typet(), exprt())); |
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.
Not sure about this one -- somehow an empty array with a correct type (seen many times below) seems considerably safer than this partially-constructed thing. If we're going to partially construct something, we should probably use a constructor with that express purpose, rather than pretending we're doing it safely?
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.
The language front-ends will always remain a bit weird. I'm not sure what the best option is - we could also do exprt values(ID_array);
to make very clear we are not building anything like a complete expression here.
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.
✔️
Passed Diffblue compatibility checks (cbmc commit: eedd686).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/97282088
case1.copy_to_operands(low_surrogate); | ||
case2.move_to_operands(low_surrogate); | ||
array_exprt case1({low_surrogate}, array_type); | ||
array_exprt case2({std::move(low_surrogate)}, array_type); | ||
exprt high_surrogate=expr_of_high_surrogate(chr, char_type); | ||
case2.move_to_operands(high_surrogate); |
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.
It maybe better to fully construct case2 in one step, and declare both cases const
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.
Makes sense, just in a race of whether I get this one or #3691 (getting rid of move_to_operands
) approved first.
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.
That's now all done.
@@ -122,7 +122,7 @@ exprt expr_initializert<nondet>::expr_initializer_rec( | |||
{ | |||
// we initialize this with an empty array | |||
|
|||
array_exprt value(array_type); | |||
array_exprt value({}, array_type); | |||
value.type().id(ID_array); |
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.
I don't see why this is necessary
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.
We could arguably make the no-operands-constructor non-deprecated. Would that seem better?
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.
So I'm still in two minds about this. I see the following options:
- De-deprecate the no-operands-constructor so that such a change isn't necessary. Reduces the amount of noise in this PR.
- Require the above syntax. Adds some noise, but has the following advantages: a) smaller API as fewer constructors are provided and b) encouraging efficient bottom-up construction.
Comments would be appreciated.
array_exprt(operandst &&_operands, const array_typet &_type) | ||
: multi_ary_exprt(ID_array, std::move(_operands), _type) | ||
{ | ||
} |
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.
This could have been a separate first commit
The existing array_exprt constructor relies on other deprecated constructors; instead introduce a non-deprecated one and use it across the codebase.
eedd686
to
475a7b9
Compare
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.
✔️
Passed Diffblue compatibility checks (cbmc commit: 475a7b9).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/98017728
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.
Never mind the partial construction question, it's definitely better this way than at present
The existing array_exprt constructor relies on other deprecated constructors;
instead introduce a non-deprecated one and use it across the codebase.