Skip to content

Cleanup types [DOC-12] #2815

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 4 commits into from
Sep 17, 2018
Merged

Conversation

majakusber
Copy link

This is a follow-up PR to #2771 (it is based on top of it so please ignore the Add documentation commits until it's merged and rebased).

@tautschnig
Copy link
Collaborator

It's a bit of a daring ask, but would you mind tackling #2780, #2808, and possibly even #2810 as well? The last one is likely taking it a bit too far, but the first two might be reasonable? Thank you!!!

Copy link
Collaborator

@tautschnig tautschnig left a comment

Choose a reason for hiding this comment

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

I think this is great cleanup work, though it may be better to do some of this in several small PRs for work not to be held up in case some of it turns out to be controversial.

@@ -12,7 +12,6 @@ Author: Daniel Kroening, [email protected]

#include "type.h"
#include "std_types.h"
#include "namespace.h"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think (and this would make me rather happy) std_types.h could go as well? That finally resolves a dependency that should not have existed in the first place...

@@ -16,6 +16,7 @@ Author: Chris Smowton, [email protected]
#include <set>
#include <unordered_set>
#include <util/symbol_table.h>
#include <util/namespace.h>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit pick: please sort lexicographically.

@@ -15,6 +15,7 @@ Author: Daniel Kroening, [email protected]
#include "string2int.h"
#include "arith_tools.h"
#include "std_expr.h"
#include "namespace.h"
Copy link
Collaborator

Choose a reason for hiding this comment

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

As above: please sort lexicographically, likely making a slightly bigger change than necessary (sort all of them).

@@ -20,7 +20,7 @@ Author: Daniel Kroening, [email protected]
#include "invariant.h"
#include "std_types.h"
#include "expr_cast.h"

#include "mathematical_types.h"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit pick: maintain/establish lexicographic sorting

@@ -11,6 +11,7 @@ Author: Daniel Kroening, [email protected]
#define CPROVER_UTIL_C_TYPES_H

#include "std_types.h"
#include "mathematical_types.h"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess that's really just for complex_typet? Maybe keep that in std_types.h?

Copy link
Author

Choose a reason for hiding this comment

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

It's a mathematical type so if we're moving some of them into a separate file, it only makes sense if we really move all of them. Is there any particular reason why this stands out for you?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I thought it was the one that's actually used by C/C++ front-ends, but maybe it's not even the only one.

Copy link
Author

Choose a reason for hiding this comment

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

You are right, there is std::complex type, moving back to std_types.

@majakusber majakusber force-pushed the cleanup_typet branch 2 times, most recently from f1a227f to 6fee370 Compare August 22, 2018 14:40
@majakusber
Copy link
Author

@tautschnig We only had one day booked for doc changes and I'm already out of time :) I'll make sure those issues are put on the next doc day to-do list.

@majakusber
Copy link
Author

I've split out two of the changes into separate PRs:

@majakusber majakusber force-pushed the cleanup_typet branch 2 times, most recently from 3a53602 to 3a29698 Compare August 22, 2018 15:07
@tautschnig
Copy link
Collaborator

We only had one day booked for doc changes and I'm already out of time :)

I know, I'm greedy :-) Thanks a lot for all the work!

@majakusber
Copy link
Author

Test-gen pointer bump: https://github.com/diffblue/test-gen/pull/2192

@kroening
Copy link
Member

I find the can_cast_type<symbol_typet>(type1) idiom to be hard to read, and it doesn't add value beyond the one-off. We should not do that.

@tautschnig
Copy link
Collaborator

In response to @kroening: see ba01589 from #2595, which in turn was a side track of #2205.

@majakusber
Copy link
Author

Yes, the comment in guidelines was exactly my motivation to add missing cast checks.

@majakusber
Copy link
Author

There is a failing test on the test-gen pointer bump, I will investigate it later. Until then I added do not merge label.

@kroening
Copy link
Member

@tautschnig Yes; I understand the motivation for can_cast. However, I'd still like to stick to the if(x.id() ==ID_Z) idiom. In particular, we can then eventually do switch(x.id()).

@majakusber
Copy link
Author

@kroening Introducing can_casts does not really prevent to access id directly. On top of the motivation that was already mentioned, I recently learned that can_cast is used by type/expr_try_dynamic_cast which can be quite handy as it can be used in if conditions and directly assign the result - thus replacing two lines of can_cast+cast by one (see the third commit in this 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.

This PR failed Diffblue compatibility checks (cbmc commit: 3ced6c7).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/84437357
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).

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

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

@majakusber majakusber merged commit 3e9b76d into diffblue:develop Sep 17, 2018
@majakusber majakusber deleted the cleanup_typet branch September 17, 2018 13:22
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.

6 participants