Commit Graph

7814 Commits

Author SHA1 Message Date
swift-ci
0f20b54db7 Merge remote-tracking branch 'origin/main' into rebranch 2025-09-19 10:14:16 -07:00
Nate Cook
80f052e251 [stdlib] Switch to a linear-space variant of Myers diffing (#83212)
This changes the implementation for `Collection.difference(from:)` to
use a linear-space complexity variation of the same Myers algorithm. The
new version is similar in execution time to the existing one, but should
alleviate memory pressure when diffing collections where the number of
differences approaches the size of the collection. While the new
algorithm returns a set of changes that is the same size as the previous
version, the specific changes are not guaranteed to be the same.

rdar://155829876
2025-09-19 10:03:26 -07:00
swift-ci
e7eb500826 Merge remote-tracking branch 'origin/main' into rebranch 2025-09-19 01:14:59 -07:00
Doug Gregor
844ba5f4f8 [Embedded] Diagnose non-final generic methods in class in the type checker
Move the diagnostic about non-final generic methods in classes up to
the type checker, so that it is available to `-Wwarning
EmbeddedRestrictions` and earlier in the pipeline. The SIL version of
this is still available as a backstop.

Yet another part of rdar://133874555.
2025-09-18 10:05:33 -07:00
swift-ci
27ad0fa578 Merge remote-tracking branch 'origin/main' into rebranch 2025-09-18 06:18:04 -07:00
Doug Gregor
5a46664954 Merge pull request #84359 from DougGregor/diagnose-untyped-throws-in-embedded 2025-09-18 06:11:55 -07:00
Doug Gregor
7088022eef [Standard library] Eliminate ABI-only rethrows versions from Embedded
Where we have rethrowing versions of functions that have typed-throws
counterparts that are only retained for ABI compatibility, wrap them
in `#if !$Embedded` so they aren't compiled into the Embedded version
of the standard library. This eliminates warnings about this code,
which cannot actually be used with arbitrary errors anyway.
2025-09-17 13:09:49 -07:00
Ebuka Ezike
c4cee76605 [Debug] Re-enable DebugDescription macro on linux 2025-09-17 12:42:54 +01:00
Andrew Trick
9007036d2e Merge pull request #84276 from atrick/remove-span-unsafenonescapable
Mutable[Raw]Span.init() does not need @_unsafeNonescapableResult
2025-09-16 15:30:21 -07:00
David Smith
2c02ba3189 Remove a retain-release pair from -count for bridged arrays (#84247) 2025-09-16 12:41:27 -04:00
Ebuka Ezike
b2fda7ffe6 [Debug] Renable DebugDescription macro on linux 2025-09-16 14:28:14 +01:00
Andrew Trick
20067350eb Mutable[Raw]Span.init() does not need @_unsafeNonescapableResult
It isn't clear why @_unsafeNonescapableResult was applied to
Mutable[Raw]Span.init(). It was either a mistake or temporary workaround for
some compiler bug.
2025-09-13 22:15:51 -07:00
Eric Miotto
db18a725d4 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-09-10 22:53:02 -07: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