-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -196,8 +196,14 @@ enum class Bridgeability { | |
/// | ||
/// In either case we end up losing sugar at some uses sites, so this is more | ||
/// about what the right default is. | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. Nitpick: LLVM style prefers double-indenting here rather than max-indenting. |
||
clang::QualType type) { | ||
return decl->hasAttr<clang::SwiftBridgedTypedefAttr>() | ||
? Bridgeability::Full | ||
: type->isBlockPointerType() | ||
? Bridgeability::Full | ||
: Bridgeability::None; | ||
} | ||
|
||
/// \brief Describes the kind of the C type that can be mapped to a stdlib | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#ifndef BRIDGED_TYPEDEF_H | ||
#define BRIDGED_TYPEDEF_H | ||
|
||
@import Foundation; | ||
|
||
|
||
typedef NSString *NSMyAmazingStringAlias __attribute__((swift_bridged_typedef)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
|
||
void acceptNSMyAmazingStringAlias(NSMyAmazingStringAlias _Nullable param); | ||
void acceptNSMyAmazingStringAliasArray(NSArray<NSMyAmazingStringAlias> * _Nonnull param); | ||
void acceptIndirectedAmazingAlias(NSMyAmazingStringAlias _Nonnull * _Nullable param); | ||
|
||
#endif |
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 ofimportedType
, in which case we want to keep that sugar.