Skip to content

[cxx-interop][libswift] Use std::string instead of BridgedStringRef 🚀 #39356

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 2 commits into from
Sep 23, 2021

Conversation

zoecarver
Copy link
Contributor

No description provided.

@zoecarver zoecarver added the c++ interop Feature: Interoperability with C++ label Sep 18, 2021
@zoecarver
Copy link
Contributor Author

Something we'll need to do here is guard on the Swift version so we don't try to build with a version of the Swift compiler that can't import the C++ stdlib.

Copy link
Contributor

@eeckstein eeckstein left a comment

Choose a reason for hiding this comment

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

Is there a reason why you would the *_debugDescription functions return a std::string and not a llvm::StringRef?

@zoecarver
Copy link
Contributor Author

Is there a reason why you would the *_debugDescription functions return a std::string and not a llvm::StringRef?

It's what's used in the swift compiler. Eventually we want to remove as much of this bridging as possible and just use .debugDescription, so we should match the APIs as closely as possible. Also, it would require us to allocate/convert the string, and it's nice to get rid of that.

@zoecarver
Copy link
Contributor Author

Oh, and another reason (not a very good one but still): this allows us to not pull in any extra header includes which makes this patch simpler. I think it would be good to not touch any of the LLVM or Swift headers on the first go (other than the bridging headers which we already import and are pretty simpler).

@eeckstein
Copy link
Contributor

Yes, sorry, I mixed that up with Function.name. For debugDescription it makes sense to pass it as a std::string.

Copy link
Contributor

@eeckstein eeckstein left a comment

Choose a reason for hiding this comment

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

lgtm!

@zoecarver zoecarver force-pushed the cxx-interop-lib-swift branch from a33f87a to f063701 Compare September 22, 2021 23:14
@@ -81,6 +81,15 @@ extension BridgedStringRef {
}
}

extension std.__1.string {
public var string: String {
// TODO: remove this once a new version of Swift is released (and call
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess Egor's patch for this didn't quite make it into 5.5 :(

@zoecarver
Copy link
Contributor Author

@swift-ci please smoke test.

@zoecarver
Copy link
Contributor Author

@swift-ci please smoke test macOS.

@zoecarver
Copy link
Contributor Author

@swift-ci please test Windows.

1 similar comment
@zoecarver
Copy link
Contributor Author

@swift-ci please test Windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ interop Feature: Interoperability with C++
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants