-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Clang importer] Honor swift_bridged_typedef attribute. #16229
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
[Clang importer] Honor swift_bridged_typedef attribute. #16229
Conversation
When the swift_bridged_typedef attribute is present on a typedef, import the underlying type as bridged (e.g., String) rather than as its unbridged type (e.g., NSString). Fixes rdar://problem/39497900.
@swift-ci please smoke test and merge |
Bah, the Clang automerge didn't happen yet. |
@swift-ci please smoke test |
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 think this will work but it is a bit tricky.
importedType = hint.BridgedType; | ||
|
||
// Set the bridged type if it wasn't done already. | ||
if (!importedType->isEqual(hint.BridgedType)) |
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.
Why do we need this check?
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.
hint.BridgedType
might be a sugared version of importedType
, in which case we want to keep that sugar.
static inline Bridgeability getTypedefBridgeability(clang::QualType type) { | ||
return type->isBlockPointerType() ? Bridgeability::Full : Bridgeability::None; | ||
static inline Bridgeability getTypedefBridgeability( | ||
const clang::TypedefNameDecl *decl, |
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.
Nitpick: LLVM style prefers double-indenting here rather than max-indenting.
@import Foundation; | ||
|
||
|
||
typedef NSString *NSMyAmazingStringAlias __attribute__((swift_bridged_typedef)); |
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.
Can you test a typedef that uses this typedef as well? If that typedef doesn't have the swift_bridged_typedef
attribute, what behavior should it have?
When the
swift_bridged_typedef
attribute is present on a typedef,import the underlying type as bridged (e.g., String) rather than as
its unbridged type (e.g., NSString).
Fixes rdar://problem/39497900.