-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Reorganize TypeContextDescriptorFlags to be a bit more semantic #18253
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
Reorganize TypeContextDescriptorFlags to be a bit more semantic #18253
Conversation
@jrose-apple, I'd like your opinion about the right thing to do with
Also, I've left importer-synthesized related declarations as a bit independent from the imported namespace kind. It looks like we don't actually set an imported declaration on related imports. We honor the original name but don't have any way of recording whether it was in a special namespace. |
@swift-ci Please test. |
We already encode all that information in the mangled name now, so I'm not sure how important it is to have additional flags in the type descriptor. Does anything actually query for this? |
Type descriptors don't store a mangled name. There are uses of |
I see, these are the flags used to determine how to interact with manglings. Tracking these as "namespaces" kind of works, I guess. (The mangling side of this is best captured by the
This is handled in the mangling but I guess not in the metadata? That does seem like a problem for |
The idea is that there's a foreign declaration which caused this type to exist. The context, name, and special namespace kind identify that declaration; the namespace is required because you could have different foreign declarations with the same name in different namespaces, depending on how the source language works. (e.g. C lets you write At least, that's the design that makes sense to me and which justifies mangling |
Okay, that makes sense. It's probably worth including that in the doc comment for |
Leave space for new kinds of non-generic metadata initialization (one of which I'm about to claim for "foreign") and non-default type namespaces.
65dff02
to
374f08f
Compare
@swift-ci Please smoke test. |
@jrose-apple Comment changed. I'm going to leave tags and typedefs alone for now, but there's a comment in |
// ObjC classes are in the ordinary namespace in C. | ||
// - Protocols are assumed to come from Objective-C by default. | ||
// ObjC protocols are in their own namespace in C. | ||
// - Structs and enums seem to always get either CTag or CTypedef. |
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.
This is not correct. Structs, enums, and unions always get CTag. CTypedef is only for typedefs with the swift_wrapper
attribute.
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.
Oops, and for CF types.
// ObjC protocols are in their own namespace in C. | ||
// - Structs and enums seem to always get either CTag or CTypedef. | ||
// It would probably make more sense to assume they come from the | ||
// tag namespace in C and then just use CTypedef as an override. |
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.
(This part is still fine, though. We would never map a class or protocol to a struct.)
Leave space for new kinds of non-generic metadata initialization (one of which I'm about to claim for "foreign") and non-default type namespaces.