Skip to content

goto symex member cleanup #3221

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 6 commits into from
Nov 5, 2018

Conversation

karkhaz
Copy link
Collaborator

@karkhaz karkhaz commented Oct 23, 2018

This patch-set aims to const-ify every member of goto_symext and related classes that only serve as a cache for an optionst option, and to make those members protected if appropriate. The fact that they were public and/or non-const was rather confusing.

The first commit in the patch-set allows to set options of an optionst while it is being constructed, so that other classes can read from the optionst object while they are being constructed. This means that we no longer need to do many of the symex.member = options.get_option("member"); inside the bodies of a constructor, instead doing member(options.get_option("member")) inside the constructor for goto_symext and therefore making member const and protected.

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

@@ -43,16 +43,17 @@ class scratch_programt:public goto_programt
ns(symbol_table, symex_symbol_table),
equation(),
path_storage(),
options(),
options(
{{"propagation", true},
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the new propagation setting?

@smowton
Copy link
Contributor

smowton commented Oct 24, 2018

So symex currently has a weird mixture of directly querying the optionst it has stored by reference and querying it in the constructor and storing the results in fields (or previously, having its users do that for it). I suggest we should decide on one style and do that consistently -- personally I'd favour removing the const optionst &options from goto_symext entirely and querying and storing every option we're interested in during the constructor. That will lead to the more intuitive behaviour that the object is configured at construction time and subsequent changes to options will not affect it.

@smowton
Copy link
Contributor

smowton commented Oct 24, 2018

Also I'm not a fan of the new constructor for optionst because it's awkward to specify e.g. a single string option (optionst({}, {}, {}, {"hello", "world"})). Instead how about constructing the scratch_programt options using a static function, so the initializer looks something like options(get_default_options())?

@karkhaz karkhaz force-pushed the kk-goto-symex-member-cleanup branch from 0c909fd to 3a9711d Compare October 24, 2018 14:11
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: 56b4872).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/89037402

@karkhaz
Copy link
Collaborator Author

karkhaz commented Oct 24, 2018

@smowton thanks for the comments, agreed with all of them. I've reverted the optionst constructor and replaced it with a commit to construct scratch_programt's optionst with a static function. I've also added a new commit which introduces a bunch of members to goto_symext, caching the remaining options that it was using.

I notice that clang-format errors now cause the CI to fail. Is the preferred way to apply clang-format to have one single commit for the whole patch series as I've done above, or is it better to apply clang-format on each commit? CODING_STANDARD.md doesn't take a strong stance on the issue...

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.

Change the static default_options into a local, otherwise LGTM, thanks for the improvements! re: clang-format it's best to do it per commit if possible, since that results in a more accurate git blame

@@ -203,3 +203,10 @@ void scratch_programt::append_loop(
}
}
}

optionst scratch_programt::default_options;
Copy link
Contributor

Choose a reason for hiding this comment

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

Just declare this as a local in get_default_options

@karkhaz karkhaz force-pushed the kk-goto-symex-member-cleanup branch from 56b4872 to 2fc5dab Compare October 25, 2018 09:39
@karkhaz
Copy link
Collaborator Author

karkhaz commented Oct 25, 2018

Thanks, I did as you asked and applied the clang-format changes to the right commits. (I've also squashed the clang-format changes into its commit in #3220).

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

This is so that the optionst object that gets passed to
scratch_programt::symex has the right options for initializing the symex
object.
This member is never written to.
This member is never written to and serves merely as a cache for a
front-end option, so this commit makes it const and protected.
This goto_symext member is never written to and serves merely as a cache
for a front-end option, so this commit makes it const and protected.
This member is never written to and serves merely as a cache for a
front-end option, so this commit makes it const.
@karkhaz karkhaz force-pushed the kk-goto-symex-member-cleanup branch from 2fc5dab to 65e017d Compare October 30, 2018 08:53
goto_symext no longer has a reference to a optionst object. Instead, the
options that goto_symext needs to read from an optionst are read during
construction and cached in const members.
@karkhaz karkhaz force-pushed the kk-goto-symex-member-cleanup branch from 65e017d to 622940c Compare October 30, 2018 08:55
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: 65e017d).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/89630691
Status will be re-evaluated on next push.
Please contact @peterschrammel, @thk123, or @allredj for support.

Common spurious failures:

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

The incompatibility may have been introduced by an earlier PR. In that case merging this
PR should be avoided unless it fixes the current incompatibility.

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: 622940c).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/89632968
Status will be re-evaluated on next push.
Please contact @peterschrammel, @thk123, or @allredj for support.

Common spurious failures:

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

The incompatibility may have been introduced by an earlier PR. In that case merging this
PR should be avoided unless it fixes the current incompatibility.

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 looks good. Also, I have manually checked that this causes no trouble with test-gen. Compatibility warnings are due to some previous failure and can be disregarded.

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.

That looks a lot cleaner to me - and thanks for constructing an easy-to-review PR :-)

@chrisr-diffblue chrisr-diffblue removed their assignment Nov 5, 2018
@tautschnig tautschnig merged commit 51236f2 into diffblue:develop Nov 5, 2018
@karkhaz karkhaz deleted the kk-goto-symex-member-cleanup branch November 5, 2018 14:38
@karkhaz
Copy link
Collaborator Author

karkhaz commented Nov 5, 2018

@chrisr-diffblue I'm trying to accumulate good karma to cash in for a 4k line PR that is on the horizon...:upside_down_face:

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.

8 participants