Skip to content

[AST] NFC: Try to static_assert that ExtInfo and TypeBase agree #13079

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 2 commits into from
Nov 28, 2017

Conversation

davezarzycki
Copy link
Contributor

@davezarzycki davezarzycki commented Nov 27, 2017

Ultimately, we cannot directly static_assert that the bit counts are equal, but we can try.

@davezarzycki
Copy link
Contributor Author

@swift-ci please smoke test

@davezarzycki
Copy link
Contributor Author

@swift-ci please test

@@ -289,7 +289,7 @@ class alignas(1 << TypeAlignInBits) TypeBase {

/// Extra information which affects how the function is called, like
/// regparm and the calling convention.
unsigned ExtInfo : 7;
unsigned ExtInfo : 7; enum { NumExtInfoBits = 7 };
Copy link
Contributor

@rjmccall rjmccall Nov 27, 2017

Choose a reason for hiding this comment

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

Could you actually use the constant instead of repeating the magic number here? :)

Otherwise this looks good, thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unless I'm missing something, that would require moving and renaming the two ExtInfo classes so that they could be declared and defined before TypeBase, right? Is that what you want done?

Copy link
Contributor

@rjmccall rjmccall Nov 27, 2017

Choose a reason for hiding this comment

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

I'm asking for something much more trivial than that; I am asking you to write:

  enum { NumExtInfoBits = 7 };
  unsigned ExtInfo : NumExtInfoBits;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, sure. Done. I'll push the change in a second. :-)

FWIW – I thought you might be asking for the two ExtInfo types to be more like RecursiveTypeProperties, where TypeBase uses a constant defined by RecursiveTypeProperties to allocate the number of reserved bits. That would have required moving and renaming the two ExtInfo types ahead of TypeBase.

@davezarzycki
Copy link
Contributor Author

@swift-ci please smoke test and merge

1 similar comment
@davezarzycki
Copy link
Contributor Author

@swift-ci please smoke test and merge

@swift-ci swift-ci merged commit e482bcb into swiftlang:master Nov 28, 2017
@davezarzycki davezarzycki deleted the nfc_ExtInfo_feedback branch November 28, 2017 15:33
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.

3 participants