Skip to content

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

Merged
merged 3 commits into from
Oct 22, 2018
Merged

Conversation

kroening
Copy link
Member

  • 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.

Copy link
Collaborator

@tautschnig tautschnig left a 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");
Copy link
Collaborator

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.

Copy link
Contributor

@allredj allredj left a 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

@kroening kroening force-pushed the to_unsigned_integer branch 2 times, most recently from 3a69957 to 183566b Compare October 14, 2018 14:08
@kroening kroening assigned tautschnig and unassigned kroening Oct 14, 2018
Copy link
Collaborator

@tautschnig tautschnig left a 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]));
Copy link
Collaborator

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.

Copy link
Member Author

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.

Copy link
Collaborator

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.

Copy link
Contributor

@allredj allredj left a 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

@kroening kroening removed their assignment Oct 14, 2018
Copy link
Contributor

@allredj allredj left a 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);
Copy link
Member

Choose a reason for hiding this comment

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

clang-format

Copy link
Contributor

@allredj allredj left a 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

@tautschnig tautschnig assigned kroening and unassigned smowton and peterschrammel Oct 22, 2018
@kroening kroening force-pushed the to_unsigned_integer branch from 7903623 to 0209196 Compare October 22, 2018 08:26
Copy link
Contributor

@allredj allredj left a 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

@kroening kroening merged commit db7bff3 into develop Oct 22, 2018
@kroening kroening deleted the to_unsigned_integer branch October 22, 2018 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants