Skip to content

Add description of return removal #4091

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

danpoe
Copy link
Contributor

@danpoe danpoe commented Feb 5, 2019

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

/// The types of function pointer expressions in the goto program are however
/// not changed. For example, in an assignment where `func` is assigned to a
/// function pointer, such as `int (*f)(void) = func`, the function types
/// appearing in the lhs and rhs both retain the integer return type.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This paragraph documents the current behavior which should probably be changed at some point. Not sure if there would be any pitfalls with it though.

/// program. The `restore_returns()` functions restore the returns in a goto
/// program in which they have been removed previously.
///
/// In a goto program in which returns have not beem removed, functions return
Copy link
Member

Choose a reason for hiding this comment

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

been

/// ```
///
/// As `return` instructions are removed, the return types of the function types
/// are set to void as well (represented by the type `empty_typet`). This
Copy link
Member

Choose a reason for hiding this comment

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

What's the difference between void_typet and empty_typet ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

At the moment void_typet is defined as class void_typet:public empty_typet {};. I think use of void_typet is deprecated now.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, I really think we should get rid of void_typet - we don't use it consistently and effectively rely on empty_typet() == void_typet(). I'll put up a PR.

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

@@ -9,7 +9,7 @@ Date: September 2009
\*******************************************************************/

/// \file
/// Remove function return values
/// Remove function returns
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe "Replace function returns by assignments to global variables"

/// r = func();
/// ```
///
/// The return removal pass introduces a global variable `func#return_value`
Copy link
Collaborator

Choose a reason for hiding this comment

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

thread-local global variable

/// ```
///
/// As `return` instructions are removed, the return types of the function types
/// are set to void as well (represented by the type `empty_typet`). This
Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, I really think we should get rid of void_typet - we don't use it consistently and effectively rely on empty_typet() == void_typet(). I'll put up a PR.

@danpoe danpoe force-pushed the doc/update-remove-returns-documentation branch from 36bff33 to 39b453a Compare February 6, 2019 11:14
@danpoe danpoe merged commit 33e1656 into diffblue:develop Feb 6, 2019
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: 39b453a).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/99918689

@danpoe danpoe deleted the doc/update-remove-returns-documentation branch June 2, 2020 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants