Commit Graph

7802 Commits

Author SHA1 Message Date
Eric Miotto
31536e9ee3 CMake: make the libswiftCompatibilitySpan symlink relative (#84200)
Currently we create an absolute one -- this prevents to use the partial
toolchain before the installation phase (namely for configurations that
run Swift tests on a different device than the builder).

Addresses rdar://160277259
2025-10-10 17:46:22 +01:00
Tim Kientzle
e5f9ffce12 Merge pull request #84024 from tbkka/tbkka-missing-embedded-allocators
Fill in two missing functions for Embedded Swift
2025-09-08 06:44:10 -07:00
David Smith
11adbdd707 Don't grow smol Strings to 16 characters when bridging out if tagged pointer formation fails (#84068)
Fixes rdar://159771498
2025-09-04 12:34:19 -07:00
Stephen Canon
f3da6b205e Try to clarify availability of Float16 and Float80 (#84011) 2025-09-04 10:22:18 -04:00
Stephen Canon
de8c4cd4d5 Mark U[M]BP.baseAddress transparent (#84097)
As well as a few other trivial API, since apparentely these do not reliably get inlined as-is.

Addresses rdar://159801610
2025-09-04 08:21:16 -04:00
Guillaume Lessard
cbcef93a54 Merge pull request #84002 from stephentyrone/pointer-comment-clarification
Remove "if and only if" language from [Raw]Span's _pointer field
2025-09-03 16:33:36 -07:00
Arnold Schwaighofer
f1b6de0de5 Merge pull request #83833 from aschwaighofer/mark_unsaferawpointer_withContiguousStorageIfAvailable_inline_always
stdlib: Mark UnsafeRawBufferPointer's withContiguousStorageIfAvailable as @inline(__always)
2025-09-02 10:17:59 -07:00
Tim Kientzle
ff50f8f2be Fill in two missing functions for Embedded Swift
`swift_coroFrameAlloc` is needed by `_read`/`_modify` accessors

`swift_deallocUninitializedObject` which I believe is needed for failable class initializers

Resolves rdar://157028375
Resolves rdar://157276375
2025-08-29 16:57:08 -07:00
Stephen Canon
567c619e3f Remove "if and only if" language from [Raw]Span's _pointer field
"can be nil" paired with "if and only if" lends itself to misreading, so let's clean this up a bit.
2025-08-29 09:36:12 -04:00
Doug Gregor
75b94d7a5b Merge pull request #83921 from DougGregor/with-unsafe-temporary-alloc-typed-throws
Adopt typed throws in withUnsafeTemporaryAllocation
2025-08-26 22:47:49 -07:00
Doug Gregor
45069a199b Merge pull request #82080 from jamieQ/patch-2
[docs][NFC]: minor formatting edits to SendableMetatype docs
2025-08-26 17:15:45 -07:00
Doug Gregor
3782db5ce1 Small fixes for typed throws in withUnsafeTemporaryAllocation 2025-08-26 17:09:07 -07:00
Doug Gregor
e96e1746bb Adopt typed throws in withUnsafeTemporaryAllocation
The interior wrapping in Result<T, U> is a little unfortunate, but is
currently necessary because we end up with extra stack allocations
along the error-handling path in a do..catch that aren't there when
using untyped throws. We can simplify the implementation if we can
eliminate the extraneous stack allocation.

Fixes rdar://134973620.
2025-08-26 13:06:48 -07:00
David Smith
0038b92e2b Speed up -isEqual:/isEqualToString: (#83894)
Fixes rdar://159058877
2025-08-25 18:03:54 -07:00
Arnold Schwaighofer
0b5233fa63 stdlib: Mark UnsafeRawBufferPointer's withContiguousStorageIfAvailable as @inline(__always)
The body seems to only reinterpret pointer types (`withMemoryRebound`).
Inlining it should not lead to code size gains and has shown to reduce code size.
2025-08-20 09:19:56 -07:00
Guillaume Lessard
c9a3fdf722 Merge pull request #83771 from glessard/rdar158440246 2025-08-16 02:40:16 -07:00
Guillaume Lessard
476491392b [stdlib] guard against underflow 2025-08-15 17:24:06 -07:00
Guillaume Lessard
709156b215 Merge pull request #83686 from glessard/legacy-abi-rethrows
[stdlib] apply the legacy ABI pattern to 3 functions
2025-08-14 15:53:17 -07:00
Guillaume Lessard
d1f7140357 [stdlib] apply the legacy ABI pattern to 3 functions 2025-08-12 16:15:13 -07:00
Erik Eckstein
e28125b106 stdlib: specialize OptionSet.insert for FixedWidthInteger raw-values
This lets the generated code boil down to a single or-instruction.

rdar://157958188
2025-08-12 08:05:49 +02:00
Karoy Lorentey
14b9b80746 Merge pull request #83314 from lorentey/pushing-word-boundaries
[stdlib] Fix implementation of Unicode text segmentation for word boundaries
2025-08-11 11:28:39 -07:00
Alex Martini
4b292b30f2 Merge pull request #83049 from amartini51/object_id_149961845
Update docs for ObjectIdentifier to mention actors

Fixes: rdar://149961845
2025-08-08 11:54:29 -07:00
Gábor Horváth
35b5c817b2 Merge pull request #83520 from Xazax-hun/check-safety-function-types 2025-08-08 06:39:39 +01:00
Karoy Lorentey
3e18a07187 [stdlib] Fix implementation of Unicode text segmentation for word boundaries
Carefully overhaul our word breaking implementation to follow the recommendations of Unicode Annex #29. Start exposing the core primitives (as well as `String`-level interfaces), so that folks can prototype proper API for these concepts.

- Fix `_wordIndex(after:)` to always advance forward. It now requires its input index to be on a word boundary. Remove the `@_spi` attribute, exposing it as a (hidden, but) public entry point.
- The old SPIs `_wordIndex(before:)` and `_nearestWordIndex(atOrBelow:)` were irredemably broken; follow the Unicode recommendation for implementing random-access text segmentation and replace them both with a new public `_wordIndex(somewhereAtOrBefore:)` entry pont.
- Expose handcrafted low-level state machines for detecting word boundaries (_WordRecognizer`, `_RandomAccessWordRecognizer`), following the design of `_CharacterRecognizer`.
- Add tests to reliably validate that the two state machine flavors always produce consistent results.

rdar://155482680
2025-08-05 20:04:46 -07:00
Gabor Horvath
402ad33463 [StrictMemorySafety] Check the safety of return types of calls
Previously, we skipped checking the return type of a function for safety
as we expected to warn at the use of the returned value:

  let x = returnsUnsafe()
  usesUnsafe(x) // warn here

Unfortunately, this resulted in missing some unsafe constructs that can
introduce memory safety issues when the use of the return value had a
different shape resulting in false negatives for cases like:

  return returnsUnsafe()

or

  usesUnsafe(returnsUnsafe())

This PR changes the analysis to always take return types of function
calls into account.

rdar://157237301
2025-08-05 12:16:44 +01:00
David Smith
051d0b68aa Override -_fastUTF8StringContents:utf8Length: to give bridged Strings O(1) access to their UTF8 contents (#83499)
Fixes rdar://157337605
2025-08-04 12:41:51 -07:00
eeckstein
8335ce577f Merge pull request #83474 from eeckstein/fix-address-of-property-feature
rename the feature AddressOfProperty to AddressOfProperty2
2025-08-01 17:38:19 +02:00
Ben Rimmington
b57b8368ac [stdlib] Update UTF8Span documentation (#83418)
Amend formatting of `Substring.utf8Span` example code.
Use DocC tables in `Unicode.UTF8.ValidationError` overview.

---------

Co-authored-by: Alex Martini <amartini@apple.com>
2025-08-01 06:56:19 -07:00
Erik Eckstein
ec8dcc98ad rename the feature AddressOfProperty to AddressOfProperty2
Fixes a build problem when using a mainline compiler with a 6.2 Swift.swiftinterface file.
This was caused by mistakenly cherry-picking the `#if $AddressOfProperty` conditions in the stdlib into 6.2 without the required compiler change.
2025-08-01 08:00:51 +02:00
Allan Shortlidge
71a5d9bd74 AST: Re-baseline ValueGenericsNameLookup feature. 2025-07-31 10:21:55 -07:00
Allan Shortlidge
6dd3e49954 AST: Re-baseline BuiltinEmplaceTypedThrows feature. 2025-07-31 10:21:55 -07:00
Guillaume Lessard
f6a7c61245 [stdlib] fix availability of Span.bytes 2025-07-29 17:19:34 -07:00
David Smith
cee927e2d5 Fix lengthOfBytes(using:) semantics (#83334)
Fixes rdar://156675395
2025-07-25 16:29:45 -07:00
Guillaume Lessard
bf80c2f90f Merge pull request #83160 from glessard/typedThrows-array-init
[stdlib] Generalize `Array(unsafeUninitializedCapacity:initializingWith:)` for typed throws
2025-07-25 14:54:45 -07:00
Guillaume Lessard
3a963a6957 [stdlib] generalize Array(unsafeUninitializedCapacity:initializingWith:) 2025-07-25 09:29:19 -07:00
Slava Pestov
b7766b6361 stdlib: Use the original === and !== operators on embedded
It seems that the restriction preventing these from working was
lifted.

The behavioral difference is that in Swift 5 mode, we don't
actually open AnyObject like this, so the old operator could
not be used with class-bound existentials.

I added a trivial test case just to ensure that calls to ===
type check correctly in both language modes.

Fixes rdar://156095800.
2025-07-24 15:25:30 -04:00
Erik Eckstein
b540204a64 stdlib: specify the count of Span and MutableSpan as _assumeNonNegative 2025-07-22 12:24:58 +02:00
Erik Eckstein
cf16c1b19f stdlib: revert workaround for Span bounds checking 2025-07-22 12:21:37 +02:00
Stephen Canon
ee9b38ca22 Use an explicit unsigned comparison for span index checks (#83150)
LLVM ought to be able to do this transformation for us, but it currently fails to do so. We can code around it easily enough. https://github.com/swiftlang/swift/pull/83172 has a better long-term fix.
2025-07-21 16:06:17 -04:00
Michael Ilseman
bed6408712 Better docs for UTF8Span (#83184)
Co-authored-by: Alex Martini <amartini@apple.com>
2025-07-21 11:02:29 -06:00
Stephen Canon
337b20e8ed Remove some redundant unsafe markings (#83192)
We were getting warnings about these; remove them to cut down on noise.
2025-07-21 11:22:13 -04:00
Guillaume Lessard
b72c4422b8 Merge pull request #81637 from glessard/rdar147780495-OutputSpan-updates
[SE-0485] OutputSpan and OutputRawSpan
2025-07-17 14:14:52 -07:00
Guillaume Lessard
31235db588 [stdlib] add OutputSpan to backdeployment library 2025-07-16 17:15:28 -07:00
Guillaume Lessard
2689ef31e1 Merge pull request #82959 from glessard/rdar155474776-extracting
[stdlib] Implementation for SE-0488
2025-07-15 13:59:00 -07:00
Valeriy Van
f85b2c5b97 Fix doc comment of DiscontiguousSlice.swift to make it match the code (#82220) 2025-07-15 13:16:49 -07:00
Guillaume Lessard
fa87b3b944 [stdlib] remove bulk-update from MutableRawSpan per SE-0485 2025-07-14 23:04:49 -07:00
Guillaume Lessard
923a6e5292 [stdlib] remove bulk-update from MutableSpan per SE-0485 2025-07-14 23:04:48 -07:00
Guillaume Lessard
97a0bd743a [stdlib] rename MutableRawSpan.extracting functions 2025-07-14 23:04:48 -07:00
Guillaume Lessard
6439a32997 [stdlib] rename MutableSpan.extracting functions 2025-07-14 23:04:48 -07:00
Guillaume Lessard
9e98783ec5 [stdlib] make OutputRawSpan changes from SE-0485 2025-07-14 23:04:48 -07:00