-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[cxx-interop] Estend _SwiftifyImport with basic std::span support #78352
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
Conversation
This is a preliminary PR to transform nonescaping std::span parameters to Swift's Span type in safe wrappers. To hook this up with ClangImporter, we will need generalize the noescape attribute to non-pointer types (PR is already in review). To transform potentially escaping spans and spans in the return position, a follow-up PR will add lifetime annotation support. This is a building block towards rdar://139074571.
d65bf9b
to
b0bb995
Compare
@swift-ci please smoke test |
for (idx, param) in signature.parameterClause.parameters.enumerated() { | ||
let typeName = try getTypeName(param.type).text; | ||
if let desugaredType = typeMappings[typeName] { | ||
if desugaredType.starts(with: "span") { |
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 cause an issue if any type alias from C/C++ where the desugared type starts with "span", right? It's probably a good idea to add a cxxSpan
option to the _SwiftifyInfo
enum.
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.
Oh, I wanted to update this code snippet. I don't think we need an enum for this, but I'll make the name matching more precise.
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.
In the meantime, I am working on a follow-up PR. The content of the string we are matching against depends on how we generate the typeMapping
in ClangImporter. Would you be OK if this part would stay as is and I only changed it in the follow up where this starts to work end to end? Alternatively, I can backport some code to this PR.
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.
The follow-up PR where this logic changes: #78422
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.
That works for me!
This is a preliminary PR to transform nonescaping std::span parameters to Swift's Span type in safe wrappers. To hook this up with ClangImporter, we will need generalize the noescape attribute to non-pointer types (PR is already in review). To transform potentially escaping spans and spans in the return position, a follow-up PR will add lifetime annotation support. This is a building block towards rdar://139074571.