Skip to content

Use CProverString.format as interface to the solver builtin function #4477

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

Conversation

romainbrenguier
Copy link
Contributor

The way String.format is implemented in the string preprocessing is hacky and buggy.
By adding a CProverString.format function as interface, the preprocessing becomes very simple, the complexity is then transfered to the java models, for which it is much easier to write clean code (than goto-program for java).
This should go together with an update of the models: diffblue/java-models-library#20

  • Each commit message has a non-empty body, explaining why the change was made.
  • Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • 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).
  • 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
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.

Seems sensible

@romainbrenguier romainbrenguier force-pushed the feature/cprover-string-format branch 3 times, most recently from fad62ee to e74d753 Compare April 2, 2019 07:49
@romainbrenguier romainbrenguier force-pushed the feature/cprover-string-format branch 2 times, most recently from 801c355 to 147a223 Compare April 2, 2019 09:29
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.

⚠️
This PR failed Diffblue compatibility checks (cbmc commit: e74d753).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/106699730
Status will be re-evaluated on next push.
Common spurious failures include: 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); compatibility was already broken by an earlier merge.

@romainbrenguier romainbrenguier force-pushed the feature/cprover-string-format branch 2 times, most recently from 660b193 to 1acddc7 Compare April 2, 2019 11:19
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.

⚠️
This PR failed Diffblue compatibility checks (cbmc commit: 660b193).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/106716601
Status will be re-evaluated on next push.
Common spurious failures include: 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); compatibility was already broken by an earlier merge.

@romainbrenguier romainbrenguier force-pushed the feature/cprover-string-format branch 2 times, most recently from 06785cc to fe27d99 Compare April 2, 2019 12:51
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: 211fd5e).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/106879072

@tautschnig tautschnig assigned peterschrammel and martin-cs and unassigned allredj Apr 3, 2019
@romainbrenguier romainbrenguier force-pushed the feature/cprover-string-format branch 3 times, most recently from 7a920a1 to e45a2d0 Compare April 3, 2019 12:40
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.

⚠️
This PR failed Diffblue compatibility checks (cbmc commit: 06e7e9f).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/106916333
Status will be re-evaluated on next push.
Common spurious failures include: 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); compatibility was already broken by an earlier merge.

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.

⚠️
This PR failed Diffblue compatibility checks (cbmc commit: 7a920a1).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/106919141
Status will be re-evaluated on next push.
Common spurious failures include: 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); compatibility was already broken by an earlier merge.

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

const exprt as_int = format_arg_from_string(string, ID_int);
return typecast_exprt{as_int, floatbv_typet{}};
}
UNHANDLED_CASE;
Copy link
Member

Choose a reason for hiding this comment

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

byte, short, double and long are not handled yet?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They are all handled by being cast to a long within the model. So ID_int does not need to make a distinction between byte, short, int and long.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Drive-by comment: so what about double?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's also cast to a long. ID_float handles both the cases where the formatting string except a float and a double (this was the same before my PR).

@peterschrammel peterschrammel removed their assignment Apr 3, 2019
This makes the link between the CProverString.format signature from java
and the ID_cprover_string_format_func from the solver.
This makes it accept a function as argument, which gives for possible
types the corresponding value of the argument.
This will allow us to adapt more easily to a change in the way the
arguments of format are given: they are now given as a struct but we
want to have the possibility to give them as a string.
Add the possibility to pass argument to the builtin format function as
strings instead of structs with fields.
add_axioms_from_int_hex is deprecated, we use
add_axioms_for_string_of_int_with_radix instead.
This should now be in the model, and the implementation of models can
use CProverString.format.
This tests the new implementation of String.format using the java models.
To use the builtin format function, the java entry point is now
CProverString.format, so we can remove the legacy code which was
handling String.format directly.
Reflects the new way the argument are passed to the format builtin function.
@romainbrenguier romainbrenguier force-pushed the feature/cprover-string-format branch from e45a2d0 to 7c34ea4 Compare April 3, 2019 16:00
@romainbrenguier
Copy link
Contributor Author

The java-models-library update is now pointing to master

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

@romainbrenguier romainbrenguier merged commit b2d0d2c into diffblue:develop Apr 4, 2019
@romainbrenguier romainbrenguier deleted the feature/cprover-string-format branch April 4, 2019 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants