Skip to content

Add a version of get_or_create_string_literal_symbol that takes a string parameter #4509

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

antlechner
Copy link
Contributor

No functional change, only refactoring.

  • 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.
  • n/a The feature or user visible behaviour I have added or modified has been documented in the User Guide in doc/cprover-manual/
  • n/a 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.

Following the new coding standard.
/// global symbols will be added.
/// \param string_refinement_enabled: if true, string refinement's string data
/// structure will also be initialised and added to the symbol table.
/// \return a symbol_expr corresponding to the new or existing literal symbol.
symbol_exprt get_or_create_string_literal_symbol(
const exprt &string_expr,
Copy link
Contributor

Choose a reason for hiding this comment

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

Are there any users of this overload left?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only one:

get_or_create_string_literal_symbol(

Copy link
Contributor

Choose a reason for hiding this comment

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

In that case it would be a very welcome addition to this PR to make java_string_literal_exprt rather than directly twiddling operands / named subexpressions -- fair enough though if you think that's out of scope.

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 looks like there aren't any java[\w_]+exprt types yet. Should such a type go into jbmc/src/java_bytecode/java_types.h or a new file, e.g. something like jbmc/src/java_bytecode/java_expressions.h or similar?
Or does it make more sense to create a new folder jbmc/src/util? In that case I would definitely make a new PR for that.

Copy link
Contributor

Choose a reason for hiding this comment

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

Does symex have to handle these expressions in a specific way? If it's the case then they shouldn't be defined in a jbmc subdirectory. Otherwise java_expr.h would be clearer for showing the class inherits from exprt and I'd prefer one class per file, so java_string_literal_expr.h would be better.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hearing about language-specific expressions makes me panic a bit. You will need to make sure all of these are gone by the time the code leaves the Java front-end.

Copy link
Contributor

Choose a reason for hiding this comment

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

They are; these are just descriptions of the exprts produced by the bytecode parser. The only other example I'm aware of now, and which I suggest we emulate, is fieldref_exprt, which is defined in java_bytecode_parse_tree.h.

Copy link
Contributor

Choose a reason for hiding this comment

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

(that expression is also local to the parser and becomes member_exprt later once we have more information about what it's referring to)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added the new class as you suggested, in a new commit.

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

@antlechner antlechner force-pushed the antonia/refactor-constant-string-symbol branch 2 times, most recently from bcc3f91 to 50ee969 Compare April 11, 2019 18:40
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.

Great, thanks a lot for this!

@antlechner antlechner force-pushed the antonia/refactor-constant-string-symbol branch from 50ee969 to f6db991 Compare April 12, 2019 09:49
@antlechner antlechner force-pushed the antonia/refactor-constant-string-symbol branch from f6db991 to ef2e5fe Compare April 12, 2019 10:41
This simplifies the code in a few places, since we don't have to repeat
the same lines of constructing the string literal exprt every time.
With this new class, we can avoid directly accessing named
subexpressions of exprts with id() == ID_java_string_literal.
@antlechner antlechner force-pushed the antonia/refactor-constant-string-symbol branch from ef2e5fe to 9e499d5 Compare April 12, 2019 12: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: 9e499d5).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/108126079

@antlechner antlechner merged commit 157f567 into diffblue:develop Apr 12, 2019
@antlechner antlechner deleted the antonia/refactor-constant-string-symbol branch April 12, 2019 14:07
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.

5 participants