Skip to content

fix exprt::opX accesses in java_bytecode #5018

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
Aug 15, 2019
Merged

Conversation

kroening
Copy link
Member

This improves type safety.

  • 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).
  • n/a 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.

Copy link
Contributor

@smowton smowton left a comment

Choose a reason for hiding this comment

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

Mostly good, I don't see that we're improving anything by using an unchecked cast to multi_ary_exprt and then using the similarly unguarded op0 etc though, I think we should introduce appropriate containers for these

@@ -916,8 +916,9 @@ void add_java_array_types(symbol_tablet &symbol_table)

side_effect_exprt inc(ID_assign, typet(), location);
inc.operands().resize(2);
inc.op0()=index_symexpr;
inc.op1()=plus_exprt(index_symexpr, from_integer(1, index_symexpr.type()));
to_binary_expr(inc).op0() = index_symexpr;
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's introduce side_effect_expr_assignt 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

@@ -494,20 +493,23 @@ optionalt<codet> java_bytecode_instrumentt::instrument_expr(const exprt &expr)
{
// this corresponds to a throw and so we check that
// we don't throw null
result.add(check_null_dereference(expr.op0(), expr.source_location()));
result.add(check_null_dereference(
to_unary_expr(expr).op(), expr.source_location()));
Copy link
Contributor

Choose a reason for hiding this comment

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

We have side_effect_expr_throwt

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, but that doesn't have operands -- will make that a separate PR.

}
else if(statement==ID_java_new_array)
{
// this corresponds to new array so we check that
// length is >=0
result.add(check_array_length(expr.op0(), expr.source_location()));
result.add(check_array_length(
to_multi_ary_expr(expr).op0(), expr.source_location()));
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a container for java_new_array?

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

@kroening kroening self-assigned this Aug 14, 2019
This improves type safety.
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: 185a3c3).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/123355159

@kroening kroening merged commit 20a2055 into develop Aug 15, 2019
@kroening kroening deleted the java_bytecode-opX branch August 15, 2019 13:06
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