Skip to content

exprt::opX cleanup #3465

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 1 commit into from
Nov 27, 2018
Merged

exprt::opX cleanup #3465

merged 1 commit into from
Nov 27, 2018

Conversation

kroening
Copy link
Member

  • Each commit message has a non-empty body, explaining why the change was made.
  • n/a Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • n/a The feature or user visible behaviour I have added or modified has been documented in the User Guide in doc/cprover-manual/
  • 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).
  • n/a My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • n/a White-space or formatting changes outside the feature-related changed lines are in commits of their own.

u_rhs.copy_to_operands(guard);
u_rhs.copy_to_operands(merge[j]);
u_rhs.op0().make_not();
u_rhs.add_to_operands(not_exprt(guard), merge[j]);
Copy link
Collaborator

Choose a reason for hiding this comment

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

make_not is slightly different to this one - maybe use boolean_negate instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

done

if(
to_bitvector_type(typecast_expr.type()).get_width() >=
to_bitvector_type(typecast_expr.op().type()).get_width())
return build_string(typecast_expr.op());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit pick: please add braces for readability

Copy link
Member Author

Choose a reason for hiding this comment

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

done

if(expr.type().id()==ID_signedbv ||
expr.type().id()==ID_unsignedbv)
if(
typecast_expr.type().id() == ID_signedbv ||
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggestion that I shouldn't be making because out-of-scope for this PR: we use typecast_expr.type().id() and typecast_expr.op().type().id() several times in here, maybe add some temporaries?

@@ -137,8 +140,8 @@ std::string inv_object_storet::build_string(const exprt &expr) const

if(expr.id()==ID_member)
{
assert(expr.operands().size()==1);
return build_string(expr.op0())+"."+expr.get_string(ID_component_name);
return build_string(to_member_expr(expr).struct_op()) + "." +
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe .struct_op() is deprecated in favour of .compound() (here and below).

Copy link
Member Author

Choose a reason for hiding this comment

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

done

{
assert(expr.op1().operands().size()==1);
add_type_bounds(expr.op0(), expr.op1().op0().type());
assert(equal_expr.op1().operands().size() == 1);
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can safely get rid of this by using to_typecast_expr below. Repeats once more below.

Copy link
Contributor

Choose a reason for hiding this comment

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

That would also get rid of the use of assert rather than INVARIANT too....

Copy link
Member Author

Choose a reason for hiding this comment

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

done

get_object(expr.op1(), p.second))
if(
get_object(equal_expr.op0(), p.first) ||
get_object(equal_expr.op1(), p.second))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit pick: please add braces for readability.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

get_object(expr.op1(), p.second))
if(
get_object(notequal_expr.op0(), p.first) ||
get_object(notequal_expr.op1(), p.second))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit pick: please add braces for readability.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor

@chrisr-diffblue chrisr-diffblue left a comment

Choose a reason for hiding this comment

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

I agree with the comments Michael made, but otherwise looks like a nice cleanup to me.

{
assert(expr.op1().operands().size()==1);
add_type_bounds(expr.op0(), expr.op1().op0().type());
assert(equal_expr.op1().operands().size() == 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

That would also get rid of the use of assert rather than INVARIANT too....

@kroening kroening force-pushed the expr-op-cleanup branch 3 times, most recently from 133bdb3 to 480544c Compare November 26, 2018 23:53
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: 480544c).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/92626177

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: 0942e1f).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/92649557

@tautschnig tautschnig merged commit d314770 into develop Nov 27, 2018
@tautschnig tautschnig deleted the expr-op-cleanup branch November 27, 2018 08:28
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.

4 participants