-
Notifications
You must be signed in to change notification settings - Fork 10.6k
stdlib: Add withUnsafeBytes(of:) and withUnsafePointer(to:) for immutable arguments. #15608
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
stdlib: Add withUnsafeBytes(of:) and withUnsafePointer(to:) for immutable arguments. #15608
Conversation
@swift-ci Please test |
Build failed |
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.
This is great, Joe!
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.
Lost the end of the sentence here…
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.
This parameter is named value
, and we've got lots of arg
s above—what do you think of standardizing on value
throughout? It's less jarg
ony.
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.
Can you add the parameters to the function name where this is mentioned? withUnsafeMutablePointer(to:_:)
Build failed |
Very nice. |
65457d3
to
670903b
Compare
@swift-ci Please test |
@natecook1000 Thanks for the feedback! How do the doc comments look now? |
Build failed |
Build failed |
The resilience model forces inlinable code to use resiliently conservative access paths for properties in the same module, but some stdlib methods by design escapes storage of a global variable. The additional `Builtin.addressof` validation introduced in swiftlang#15608 exposed the latent issue here.
The resilience model forces inlinable code to use resiliently conservative access paths for properties in the same module, but some stdlib methods by design escapes storage of a global variable. The additional `Builtin.addressof` validation introduced in swiftlang#15608 exposed the latent issue here.
This looks great, @jckarter — thanks! Good note on exclusivity concerns, too. 👍 |
@xedin Any idea why this change would have regressed diagnostics in this test in
I would've expected no impact, since the
|
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'm pretty sure that's no good either, because we want this to fold down to a single address reference. Did we ever implement the thing where _emptyStringStorage
was itself inlinable, meaning that you could rely on it being stored?
stdlib/public/core/VarArgs.swift
Outdated
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.
Same here. We're supposed to fold all the va_list-building down to primitive ops.
670903b
to
a3536a6
Compare
@swift-ci Please test |
@swift-ci Please test source compatibility |
Build failed |
Build failed |
a3536a6
to
262137d
Compare
…able arguments. Since the functions produce pointers with tightly-scoped lifetimes there's no formal reason these have to only work on `inout` things. Now that arguments can be +0, we can even do this without copying values that we already have at +0.
262137d
to
62771a0
Compare
@swift-ci Please test |
Build failed |
Build failed |
Since the functions produce pointers with tightly-scoped lifetimes there's no formal reason these have to only work on
inout
things. Now that arguments can be +0, we can even do this without copying values that we already have at +0.Proposal: swiftlang/swift-evolution#822