-
Notifications
You must be signed in to change notification settings - Fork 274
remove instances of to_unsigned_integer #3065
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
Conversation
kroening
commented
Sep 29, 2018
- Each commit message has a non-empty body, explaining why the change was made.
- My contribution is formatted in line with CODING_STANDARD.md.
- Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
- Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
- My commit message includes data points confirming performance improvements (if claimed).
- My PR is restricted to a single feature or bugfix.
- White-space or formatting changes outside the feature-related changed lines are in commits of their own.
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.
Before reviewing any further and copying the same comment several times: this can be simplified by using numeric_cast_v
DATA_INVARIANT(!ret, "target expected to be unsigned integer"); | ||
targets.insert(target); | ||
auto target=numeric_cast<unsigned>(to_constant_expr(i_it->args[0])); | ||
DATA_INVARIANT(target.has_value(), "target expected to be unsigned integer"); |
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.
Just use numeric_cast_v
instead of this convert+check step.
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: d9428eb).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/86369065
3a69957
to
183566b
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.
Approving to move this forward, but I'd appreciate if the below comment could be considered.
auto c = numeric_cast<unsigned>(to_constant_expr(arr.operands()[i])); | ||
INVARIANT(c.has_value(), "constant should be convertible to unsigned"); | ||
out[i] = c.value(); | ||
out[i] = numeric_cast_v<unsigned>(to_constant_expr(arr.operands()[i])); |
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 above PRECONDITION
is rather redundant.
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 do like it as it clarifies the contract here well; will move up.
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.
Having the two loops, esp. with different iteration control does seem a bit unnecessary.
76e8c1f
to
7903623
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: 76e8c1f).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/87886965
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: 7903623).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/87892779
@@ -482,16 +482,14 @@ std::pair<exprt, string_constraintst> add_axioms_for_format( | |||
std::string | |||
utf16_constant_array_to_java(const array_exprt &arr, std::size_t length) | |||
{ | |||
for(const auto &op : arr.operands()) | |||
PRECONDITION(op.id()==ID_constant); |
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.
clang-format
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: 7903623).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/88668373
7903623
to
0209196
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: 0209196).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/88690519