Skip to content

[SILGen] Handle arbitrary ObjC-to-Swift bridging for globals #12603

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

Closed
wants to merge 1 commit into from

Conversation

jrose-apple
Copy link
Contributor

Possibly useful for rdar://problem/34913634, possibly not. Now that it's working in my little test cases I need to go back and examine whether we actually need it, per discussion on #10832. May still be useful in some form for the SIL folks, though.

@slavapestov
Copy link
Contributor

This looks good at first glance. It should obsolete my fix for dfdd3a7 -- can you try removing it and see if the test still passes?

@slavapestov
Copy link
Contributor

Actually my fix hits the code path for member VarDecls, but I think we should use the same bridging path component in both cases (the original bug was that NSString globals were bridged, but import-as-member globals were not).

Copy link
Contributor

@rjmccall rjmccall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@jrose-apple jrose-apple changed the title [WIP] Handle arbitrary ObjC-to-Swift bridging for globals [SILGen] Handle arbitrary ObjC-to-Swift bridging for globals Oct 25, 2017
@jrose-apple
Copy link
Contributor Author

Indeed, this obsoletes dfdd3a7. It doesn't seem to fix rdar://problem/34913634 after all, but now I feel comfortable committing it, since there's already a test case. I've folded in a revert of that change.

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 95f6f3fe7163a41047d1fb8827127cfd91701909

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 95f6f3fe7163a41047d1fb8827127cfd91701909

@jrose-apple
Copy link
Contributor Author

Uh, hm. I wonder if the Linux failure is a fluke.

@swift-ci Please test Linux

@@ -2219,6 +2280,12 @@ static LValue emitLValueForNonMemberVarDecl(SILGenFunction &SGF,

if (address.getType().is<ReferenceStorageType>())
lv.add<OwnershipComponent>(typeData);

AbstractionPattern pattern = SGF.SGM.Types.getAbstractionPattern(var);
if (pattern.isClangType()) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hang on, should this also check that the types are different? What's the best way to do that? If they happen to be the same we might as well leave the physical component in place.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You want to check whether the type-of-rvalue matches the target lowered type.

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 5e36a5f5b16727c006d384235e9e24b4df6a1bf2

@jrose-apple
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 5e36a5f5b16727c006d384235e9e24b4df6a1bf2

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 5e36a5f5b16727c006d384235e9e24b4df6a1bf2

Copy link
Contributor

@slavapestov slavapestov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for cleaning up my earlier fix too.

@DougGregor
Copy link
Member

@swift-ci please smoke test macOS

A more general fix for import-as-member NSStrings than Slava's
dfdd3a7. Reverts the SILGen change from that commit in favor of a
new PathComponent for lvalue access. In theory this will handle
mutable bridged import-as-member globals as well, but we don't have
any of those yet.
@jrose-apple
Copy link
Contributor Author

Had the wrong type for reverse bridging.

@swift-ci Please test

@swift-ci
Copy link
Contributor

swift-ci commented Nov 1, 2017

Build failed
Swift Test OS X Platform
Git Sha - 4b3e48c7d803181fc7bbcec56138eb6c026f9fd7

@swift-ci
Copy link
Contributor

swift-ci commented Nov 1, 2017

Build failed
Swift Test Linux Platform
Git Sha - 4b3e48c7d803181fc7bbcec56138eb6c026f9fd7

@jrose-apple
Copy link
Contributor Author

I've tried several variations and can't get this right. Going to have to shelve it for now.

@jrose-apple jrose-apple closed this Nov 3, 2017
@jrose-apple
Copy link
Contributor Author

Filed rdar://problem/35328468 to come back to this later.

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.

5 participants