Commit Graph

75 Commits

Author SHA1 Message Date
Gabor Horvath
8c03a31d65 [cxx-interop] Support transforming lifetimebound spans
This PR adds basic support for storing lifetime dependence information,
transform Span return types, and generate lifetime annotations.

rdar://139074571
2025-01-21 10:51:04 +00:00
Henrik G. Olsson
d7bd76e9f1 [Swiftify] Add return pointer support (#78571)
* Import __counted_by for function return values

Instead of simply passing a parameter index to _SwiftifyInfo, the
_SwiftifyExpr enum is introduced. It currently has two cases:
 - .param(index: Int), corresponding to the previous parameter index
 - .return, corresponding to the function's return value.

ClangImporter is also updated to pass this new information along to
_SwiftifyImport, allowing overloads with buffer pointer return types to
be generated. The swiftified return values currently return Span when
the return value is marked as nonescaping, despite this not being sound.
This is a bug that will be fixed in the next commit, as the issue is
greater than just for return values.

* Fix Span variant selection

There was an assumption that all converted pointers were either
converted to Span-family pointers, or UnsafeBufferPointer-family
pointers. This was not consistently handled, resulting in violating the
`assert(nonescaping)` assert when the two were mixed. This patch removes
the Variant struct, and instead each swiftified pointer separately
tracks whether it should map to Span or UnsafeBufferPointer.
This also fixes return pointers being incorrectly mapped to Span when
marked as nonescaping.
2025-01-13 08:08:36 -08:00
Henrik G. Olsson
ef9d2b744d Rename pointer bounds (#78210)
* Make pointer bounds non-experimental

* Rename @PointerBounds to @_SwiftifyImport

* Rename filenames containing PointerBounds

* Add _PointerParam exception to stdlib ABI test

* Add _PointerParam to stdlib API changes

* Rename _PointerParam to _SwiftifyInfo
2024-12-20 11:36:01 +01:00
Doug Gregor
62d8659b15 Update API/ABI stability checker output for correctly-printed ''rethrows'
We used to treat 'rethrows' like an attribute, printing it as
'@rethrows', which was incorrect. That's fixed now, so update the
API/ABI checker tests to account for that.
2024-12-15 08:21:10 -08:00
Guillaume Lessard
5e819aeea6 [stdlib] generalize isPOD() over suppressible protocols 2024-10-18 22:57:43 -07:00
Karoy Lorentey
0cb576773f [api-digester] Update classic ABI checker exception list 2024-10-08 11:11:04 -07:00
Doug Gregor
2e9ab88c4a Genereralize standard library ABI stability test for arm64 macOS
... and now that it is fixed for the platform I'm developing odd, add the
missing entries for typed throws on withUnsafe(Mutable)BufferPointer.
2024-08-16 21:28:30 -07:00
Allan Shortlidge
20d97556ae stdlib: Remove #if $TypedThrows guards.
https://github.com/swiftlang/swift/pull/72612 can be reverted because it is no
longer necessary for the interface of the stdlib to be compatible with
compilers without `$TypedThrows` support.
2024-07-08 16:52:52 -07:00
Nate Chandler
746cf2ff5b [BitwiseCopyable] Drop req from SIMD/Storage.
There are conformers to SIMDStorage (like that in the added test case)
which involve an Array (a type that can't conform to BitwiseCopyable).
So lift the constraint on SIMDStorage.  This in turn requires lifting
the constraint on SIMD (otherwise, e.g. `SIMD8<Scalar>` would fail to
conform since it has as a member some SIMD8Storage which is only
constrained to conform to `SIMDStorage`; the `SIMD8Storage`
associatedtype also cannot be constrained to `BitwiseCopyable` because
that storage may again not conform as in the test example).

rdar://128661878
2024-05-24 12:32:10 -07:00
Nate Chandler
b1fbe4ea91 [BitwiseCopyable] Remove underscore. 2024-04-25 11:44:15 -07:00
Karoy Lorentey
a681a3d45e [api-digester] Ritually confess our sins 2024-04-16 11:21:08 -07:00
Stephen Canon
a381589524 SE-0425 implementation (#72139) 2024-04-02 16:24:41 -04:00
Allan Shortlidge
a1dacc12d7 stdlib: Make typed throws ABI placeholders properly @usableFromInline.
Functions that are used in public `@inlinable` function bodies can't be marked
`@_spi` nor can they be made obsolete. Also, they must retain `rethrows` so
that use of these entry points from other `rethrows` functions is accepted.

Builds on https://github.com/apple/swift/pull/72365. Once we no longer have to
support pre-`$TypedThrows` compilers, all of this can be reverted.

Part of rdar://125138945
2024-03-27 14:57:56 -07:00
Karoy Lorentey
c2f8d733dc [test] Update api-digester false positives lists 2024-03-21 13:53:58 -07:00
Karoy Lorentey
74bd1e385c [test] Fix mismerge in old ABI checker’s expectation list 2024-03-18 15:27:29 -07:00
Karoy Lorentey
6e77f85f92 [abi] Update false positives list for api-digester based ABI/source stability tests 2024-03-18 11:09:07 -07:00
Kavon Farvardin
11220bb3d0 ABI Tests: include Copyable/Escapable in baseline 2024-03-14 23:10:44 -07:00
Guillaume Lessard
78273b2390 Merge pull request #72089 from glessard/toplevel-withUMP-typed-throws
[stdlib] convert `withUnsafeMutablePointer()` to typed throws
2024-03-08 13:52:23 -08:00
Guillaume Lessard
3f9d93df76 [api-digester] fix exception omission
Update test/api-digester/stability-stdlib-abi-without-asserts.test
2024-03-08 09:01:11 -08:00
Guillaume Lessard
805dd70cfe Merge pull request #72074 from glessard/toplevel-withbytes-typed-throws
[stdlib] convert `withUnsafeBytes()` to typed throws
2024-03-08 08:55:08 -08:00
Guillaume Lessard
578a058797 Merge pull request #72052 from glessard/toplevel-withpointer-typed-throws
[stdlib] convert `withUnsafePointer()` to typed throws
2024-03-06 15:01:45 -08:00
Nate Chandler
73231b185b [BitwiseCopyable] Don't apply to FixedWidthInteger.
Per LWG feedback.

This reverts commit c8119e3c01.
2024-03-06 08:12:54 -08:00
Guillaume Lessard
fd726ccac3 [abi-digester] fix an exception
Update test/api-digester/stability-stdlib-abi-without-asserts.test
2024-03-05 09:24:13 -08:00
Guillaume Lessard
72e26f2d87 [api-digester] add more exceptions for typed throws 2024-03-05 03:06:42 -08:00
Guillaume Lessard
95c07e4688 [api-digester] add more exceptions for typed throws 2024-03-05 02:31:23 -08:00
Guillaume Lessard
e02d8ab799 [api-digester] add more exceptions for typed throws 2024-03-05 02:25:52 -08:00
Karoy Lorentey
a35741f4eb [test] Expect the phantom removal of _get*RetainCount functions 2024-02-27 13:18:28 -08:00
Guillaume Lessard
71640be109 Merge pull request #71363 from glessard/rdar115296219
[stdlib] properly rename validatingUTF8 to validatingCString
2024-02-07 14:37:23 -08:00
Guillaume Lessard
16af5e6a28 [test] silence api-digester false alarm 2024-02-03 16:19:05 -08:00
Nate Chandler
c8119e3c01 [stdlib] FixedWidthInteger is BitwiseCopyable. 2024-01-30 14:38:07 -08:00
Kuba Mracek
53ddf9bdf2 [embedded] Adjust stdlib stability test expectations after typed throws adoption 2024-01-18 20:56:20 -08:00
nate-chandler
7dd1d3f7c1 Merge pull request #70872 from nate-chandler/rdar19519745
[BitwiseCopyable] Infer and check constraint.
2024-01-16 07:01:31 -08:00
Nate Chandler
63de79c91e [stdlib] Pointers and SIMDs are bitwise copyable. 2024-01-15 17:08:32 -08:00
Doug Gregor
a30b623ee6 Implement typed throws support in _openExistential. 2024-01-14 14:32:49 -08:00
Doug Gregor
8912d4aa71 [SE-0413] Adopt typed throws in withoutActuallyEscaping(_:do:)
There is a small bug fix here in the identification of the catch node,
where the leading `{` of a closure was considered to be "inside" the
closure for code like

    { ... }()

causing us to assume that the call to the closure would catch the error
within the closure.

Other than that, introduce the thrown error type into the type checker's
modeling of `withoutActuallyEscaping(_:do:)`, and mirror that in the
library declaration.
2024-01-13 21:57:24 -08:00
Doug Gregor
7d74b3ba5c [SE-0413] Adopt typed throws in Result
Make `init(catching:)` and `get()` use typed throws. The former infers
the `Failure` type from the closure provided (once full type inference
is in place) and the latter only throws errors of the `Failure` type.
2024-01-13 06:45:08 -08:00
Doug Gregor
9bfca45432 Update ABI test for typed-throws map 2024-01-12 14:04:31 -08:00
Doug Gregor
f316c5fcfe Update tests for map switching to typed throws 2024-01-12 10:17:59 -08:00
Jeremy Schonfeld
2404013f78 [SE-0270] Add Collection Operations on Noncontiguous Elements (#69766)
* Adds RangeSet/DiscontiguousSlice to the stdlib

* Remove redundant DiscontiguousSlice.Index: Comparable conformance

* Attempt to fix embedded build

* Attempt to fix macOS test failures

* Fix Constaints/members.swift failure on linux

* Add exceptions to ABI/source checker to fix macOS tests

* Fix incremental dependency test failure

* Remove inlining/unfreeze implementation for future improvements

* Simplify indices(where:) implementation

* Address review feedback

* Add test for underscored, public slice members

* Address feedback on inlining, hashing, and initializing with unordered arrays

* Fix ABI checker issues

* Remove MutableCollection extension for DiscontiguousSlice

* Make insertion return a discardable Bool

* Fix ABI checker tests

* Fix other ABI checker tests due to dropping MutableCollection subscript
2024-01-09 14:02:19 -08:00
Doug Gregor
3baf6ac31a Revert "[Typed throws] Support overrides that are contravariant in the thrown error" 2023-11-16 10:40:23 -08:00
Doug Gregor
b93e228f9d Update tests for map switching to typed throws 2023-11-13 14:13:44 -08:00
Yuta Saito
7df19b86ea [stdlib] Fix calling convention mismatch for debugger utility functions (#69352)
This is the 3rd attempt to fix the mismatch, where the actual definition
(e.g. `swift_retainCount`) are defined with C calling-convention and the
callers wrongly expect Swift calling-convention.

The 1st fix broke ABI compatibility by introducing new symbol references
from app-side without any availability checks.
The 2nd fix broke lldb's retain counting feature due to new x-ref to
Clang module in serialized function body by `@_alwaysEmitIntoClient`.

This attemps to avoid introducing serialized x-ref to Clang module by
using new `@_extern(c)` attribute.

Resolves rdar://113910821

Co-authored-by: Karoy Lorentey <klorentey@apple.com>
2023-11-08 10:45:28 -08:00
Dario Rexin
29ce7a341d [Stdlib] Add some prespecializations to the stdlib (#66446)
* [Stdlib] Add some prespecializations to the stdlib

This adds prespecializations for commonly used types to the stdlib

* Add false positives to ABI checker ignore list

* Update multithread_module.swift

* Update multithread_module.swift

* Update multithread_module.swift
2023-07-06 15:27:09 -07:00
Nate Cook
89b9e48eae [stdlib] Implement Never conformance to Codable (#64899)
Proposed as SE-0396: Conform Never to Codable;
approved on 5/5/2023.
2023-05-09 13:10:10 -05:00
Allan Shortlidge
ba7472606d Tests: Update stability-stdlib-abi-without-asserts. 2023-05-05 18:26:59 -07:00
Guillaume Lessard
2689b6044b Merge pull request #41608 from glessard/se-pointer-family-initialization 2022-09-13 22:00:59 -06:00
Ben Pious
57d82317c1 Add CustomDebugDescription conformance to AnyKeyPath (#60133)
* initial

* it works

demangling mostly works

fix dots

printing works

add tests

add conformance to AnyKeyPath

implement SPI

subscripts fully work

comments

use cross platform image inspection

remove unnecessary comment

fix

fix issues

add conditional conformance

add types

try to fix the api-digester test

cr feedback: move impls behind flag, remove addChain(), switch statement, fallthrough instead of if-elses, move import

cr feedback: refactor switch statement

fix #ifdef

reindent, cr feedback: removes manual memory management

fix missing whitespace

fix typo

fix indentation issues

switch to regexes

checks should test in on all platforms

print types in subscripts

add test for empty subscript

Update test/api-digester/stability-stdlib-abi-without-asserts.test

Co-authored-by: Xiaodi Wu <13952+xwu@users.noreply.github.com>

add commas

fix failing test

fix stdlib annotation

cr feedback: remove global, refactor ifdef

cr feedback: switch back to manual memory management

switch to 5.8 macro

add new weakly linked functions to the allowlist

fix one more failing test

more cr feedback

more cr feedback

* fix invisible unicode
2022-09-13 09:23:32 -07:00
Guillaume Lessard
dfda525ae3 [abi] override the judgment of the abi stability test 2022-09-12 14:18:47 -06:00
Guillaume Lessard
8ed1fc739f [abi] override the judgment of the abi stability test 2022-08-26 17:36:40 -06:00
Guillaume Lessard
b0832cb13a [abi] override the judgment of the abi stability test 2022-08-26 17:36:40 -06:00