-
Notifications
You must be signed in to change notification settings - Fork 10.6k
use RespectOriginallyDefinedIn when mangling extension contexts #82348
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
17f37a4 to
f4385de
Compare
|
@swift-ci Please test |
|
@etcwilde @edymtt This is the PR with the lit updates i was talking about. I wanted to expose |
edymtt
left a comment
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.
LGTM for the lit.cfg changes
|
@swift-ci Please test macOS |
|
@swift-ci Please clean test macOS |
1 similar comment
|
@swift-ci Please clean test macOS |
rdar://152598492
f4385de to
5e3e9d6
Compare
|
@swift-ci Please clean test macOS |
5e3e9d6 to
de80e21
Compare
|
@swift-ci Please test |
1 similar comment
|
@swift-ci Please test |
Resolves rdar://152598492 Consider the following Swift, adapted from a real-world framework: ```swift @available(macOS 10.8, *) @_originallyDefinedIn(module: "another", macOS 11.0) public struct SimpleStruct {} @available(macOS 12.0, iOS 13.0, *) public extension SimpleStruct { struct InnerStruct {} } ``` In this scenario, `SimpleStruct` was originally in a module called `another`, but was migrated to this module around the time of macOS 11.0. Since then, the module was ported to iOS and gained a nested type `SimpleStruct.InnerStruct`. When mangling USRs for this nested type, the result differs depending on whether we're targeting macOS or iOS. They're mostly the same, but the macOS build yields a USR with an `AAE` infix, designating that the `InnerStruct` was defined in an extension from a module with the name of the base module. On iOS, this infix does not exist. The reason this is happening is because of the implementation of `getAlternateModuleName` checking the availability spec in the `@_originallyDefinedIn` attribute against the currently active target. If the target matches the spec, then the alternate module name is reported, otherwise the real module name is. Since the iOS build reports the real module name, the mangling code doesn't bother including the extension-context infix, instead just opting to include the parent type's name and moving on. This PR routes around this issue by passing the `RespectOriginallyDefinedIn` variable to the `ExtensionDecl::isInSameDefiningModule` method, and using that to skip the alternate module name entirely. It also sets `RespectOriginallyDefinedIn` to `false` in more places when mangling USRs, but i'm not 100% confident that it was all necessary. The goal was to make USRs more consistent across platforms, regardless of the surrounding context.
…#82657) - **Explanation**: USR mangling can include an extension context infix (`AAE`) when an extended type uses `@_originallyDefinedIn` on platforms other than the active one. This adds a check for the `RespectOriginallyDefinedIn` flag when checking extension decls against their extended type. - **Scope**: Changes USR mangling in these situations so that USRs are the same for the same code regardless of platform. - **Issues**: rdar://152598492 - **Original PRs**: #82348 - **Risk**: Low. The change is limited to situations where the name mangler is already disrespecting the alternate module name, and only additionally turns on that flag for any USR mangling. - **Testing**: Automated tests - **Reviewers**: @edymtt @augusto2112
Resolves rdar://152598492
Consider the following Swift, adapted from a real-world framework:
In this scenario,
SimpleStructwas originally in a module calledanother, but was migrated to this module around the time of macOS 11.0. Since then, the module was ported to iOS and gained a nested typeSimpleStruct.InnerStruct. When mangling USRs for this nested type, the result differs depending on whether we're targeting macOS or iOS. They're mostly the same, but the macOS build yields a USR with anAAEinfix, designating that theInnerStructwas defined in an extension from a module with the name of the base module. On iOS, this infix does not exist.The reason this is happening is because of the implementation of
getAlternateModuleNamechecking the availability spec in the@_originallyDefinedInattribute against the currently active target. If the target matches the spec, then the alternate module name is reported, otherwise the real module name is. Since the iOS build reports the real module name, the mangling code doesn't bother including the extension-context infix, instead just opting to include the parent type's name and moving on.This PR routes around this issue by passing the
RespectOriginallyDefinedInvariable to theExtensionDecl::isInSameDefiningModulemethod, and using that to skip the alternate module name entirely. It also setsRespectOriginallyDefinedIntofalsein more places when mangling USRs, but i'm not 100% confident that it was all necessary. The goal was to make USRs more consistent across platforms, regardless of the surrounding context.