-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Add a flag to track null termination of Strings #80075
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
Open
Catfish-Man
wants to merge
21
commits into
main
Choose a base branch
from
come-with-me-if-you-want-to-live-forever
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
76d48b9
WIP: add a flag to track null termination of string literals
Catfish-Man 8715633
Remove unnecessary ABI
Catfish-Man 79e8358
Add new ABI
Catfish-Man da98c52
Merge branch 'main' into come-with-me-if-you-want-to-live-forever
Catfish-Man 0c8fb4c
Rename as requested
Catfish-Man b1f4e1f
Merge remote-tracking branch 'refs/remotes/origin/come-with-me-if-you…
Catfish-Man f8522f4
Sidestep the question of whether isNullTerminated should say yes or n…
Catfish-Man 6c53a52
Make non-terminated shared strings bridging-safe
Catfish-Man 1fc7b0f
Leave old symbol in place
Catfish-Man bc212c5
Apparently @_aEIC vars still have symbols in some cases
Catfish-Man a9d5370
Merge remote-tracking branch 'origin/main' into come-with-me-if-you-w…
Catfish-Man 69385a2
Add a test for bridging the new SPI
Catfish-Man 37b1770
Add symbols on x86 too
Catfish-Man 344f41a
Fix availability and fix up test
Catfish-Man eaced32
Plumb flags through bridging properly, and check them in shared, not …
Catfish-Man 1f8e86a
Set null terminated to true for non-shared strings and for bridged st…
Catfish-Man 093135c
Merge branch 'main' into come-with-me-if-you-want-to-live-forever
Catfish-Man a34dfc8
Fix withCString in the presence of old binaries, and optimize it for …
Catfish-Man 0eed4cc
Remove now-redundant thing
Catfish-Man f33b8ad
Fix a warning
Catfish-Man 8025cc0
Merge branch 'main' into come-with-me-if-you-want-to-live-forever
Catfish-Man File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -82,9 +82,9 @@ extension _AbstractStringStorage { | |
| @inline(__always) | ||
| @_effects(readonly) | ||
| internal func _cString(encoding: UInt) -> UnsafePointer<UInt8>? { | ||
| switch (encoding, isASCII) { | ||
| case (_cocoaASCIIEncoding, true), | ||
| (_cocoaUTF8Encoding, _): | ||
| switch (encoding, isASCII, asString._guts._object.isFastZeroTerminated) { | ||
| case (_cocoaASCIIEncoding, true, true), | ||
| (_cocoaUTF8Encoding, _, true): | ||
| return unsafe start | ||
| default: | ||
| return unsafe _cocoaCStringUsingEncodingTrampoline(self, encoding) | ||
|
|
@@ -303,16 +303,21 @@ extension __SharedStringStorage { | |
| final internal func _fastCStringContents( | ||
| _ requiresNulTermination: Int8 | ||
| ) -> UnsafePointer<CChar>? { | ||
| if isASCII { | ||
| return unsafe start._asCChar | ||
| if 0 == requiresNulTermination || asString._guts._object.isFastZeroTerminated { | ||
| if isASCII { | ||
| return unsafe start._asCChar | ||
| } | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| @objc(UTF8String) | ||
| @_effects(readonly) | ||
| final internal func _utf8String() -> UnsafePointer<UInt8>? { | ||
| return start | ||
| if asString._guts._object.isFastZeroTerminated { | ||
| return start | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not entirely clear on why this doesn't need an |
||
| } | ||
| return unsafe _cocoaUTF8StringTrampoline(self) | ||
| } | ||
|
|
||
| @objc(cStringUsingEncoding:) | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
My kingdom for a way to force swiftc to generate an objc_msgSend_super call so I don't have to do this ridiculous hoop jumping