-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[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
Conversation
@swift-ci please smoke test |
@swift-ci please test |
include/swift/AST/Types.h
Outdated
@@ -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 }; |
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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;
There was a problem hiding this comment.
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
.
@swift-ci please smoke test and merge |
1 similar comment
@swift-ci please smoke test and merge |
Ultimately, we cannot directly
static_assert
that the bit counts are equal, but we can try.