Skip to content

[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

Merged
merged 1 commit into from
Apr 28, 2018

Conversation

DougGregor
Copy link
Member

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.

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.
@DougGregor DougGregor requested a review from jrose-apple April 28, 2018 00:08
@DougGregor
Copy link
Member Author

@swift-ci please smoke test and merge

@DougGregor
Copy link
Member Author

Bah, the Clang automerge didn't happen yet.

@DougGregor
Copy link
Member Author

@swift-ci please smoke test

2 similar comments
@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor DougGregor merged commit 8ad1d76 into swiftlang:master Apr 28, 2018
@DougGregor DougGregor deleted the import-bridged-typedef branch April 28, 2018 21:15
Copy link
Contributor

@jrose-apple jrose-apple left a 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))
Copy link
Contributor

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?

Copy link
Member Author

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,
Copy link
Contributor

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));
Copy link
Contributor

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants