Commit Graph

7802 Commits

Author SHA1 Message Date
Kuba (Brecka) Mracek
3fdec2171f Merge pull request #77657 from kubamracek/embedded-more-stdlib
[embedded] Add back lazy collection operations, collection diffing and StaticBigInt to Embedded Stdlib
2024-11-19 15:03:31 -08:00
Meghana Gupta
92782a0e08 Add an initializer for Span without lifetime dependence
Without this, supported old compilers which don't recognize LifetimeDependence feature but
recognize the NonEscapableTypes feature will run into lifetime dependence inference errors
on the implicit initializer generated for the stdlib's swiftinterface
2024-11-18 18:09:19 -08:00
Meghana Gupta
5b5acc64e0 Promote Nonescapable types to a language feature 2024-11-18 18:09:17 -08:00
Guillaume Lessard
9084af187f [span] remove the _elementsEqual() functions
We should only add them once they reach their final form.
2024-11-18 16:18:17 -05:00
Guillaume Lessard
9936393183 [span] temporarily add a feature guard 2024-11-18 15:45:07 -05:00
Guillaume Lessard
9073576e84 [span] formulate Span.withUnsafeBytes() better 2024-11-18 15:14:16 -05:00
Guillaume Lessard
2b916a10b3 [gardening] improves some comments in Span and RawSpan 2024-11-18 14:24:56 -05:00
Kuba Mracek
0d4f91f271 [embedded] Add back lazy collection operations, collection diffing and StaticBigInt to Embedded Stdlib 2024-11-16 08:16:57 -08:00
Artem Chikin
9cd689816c Revert "[NFC][CMake] Disable use of in-process 'libSwiftScan' queries when building the Standard Library" 2024-11-14 12:47:32 -08:00
Artem Chikin
201edb83f6 Merge pull request #77606 from artemcm/MoveLibSwiftScanOutOfTools
[CMake] Establish a dependency from standard library variants onto 'libSwiftScan'
2024-11-14 12:31:12 -08:00
Kuba (Brecka) Mracek
a680211a4f Merge pull request #77594 from kubamracek/embedded-int-parsing
[embedded] Enable integer parsing in Embedded Swift
2024-11-14 10:23:01 -08:00
Artem Chikin
338b9141e3 Move libSwiftScan from 'tools' to 'lib/Tooling'
'tools' should be reserved for executable tools.
2024-11-14 08:44:32 -08:00
artemcm
4deff61e11 [NFC][CMake] Disable use of in-process 'libSwiftScan' queries when building the Standard Library
Due to the ordering of our build system, we may encounter a race when building standard library variants using tools produced by Swift's 'tools' CMake build.
As a workaround, for now, ensure that the compiler building standard library variants does not rely on libSwiftScan built as part of 'tools'.
2024-11-13 23:15:08 +00:00
Kuba Mracek
b370050dd0 [embedded] Enable integer parsing in Embedded Swift 2024-11-13 11:52:37 -08:00
Artem Chikin
e96fc88e58 Merge pull request #77541 from artemcm/AddSwiftScanDepToEmbeddedStdLib
[CMake] Add a dependency on 'libSwiftScan' for 'swiftCore'
2024-11-12 15:58:33 -08:00
Guillaume Lessard
4a909c7cc8 Merge pull request #77549 from glessard/buffer-update-fromContentsOf-null-check-removal
[stdlib] Elide some null-pointer checks in UM[R]BP bulk-copy functions
2024-11-12 15:51:20 -05:00
Nate Cook
e12e968570 Add contains(_:) methods to (Closed)Range (#76891)
The _StringProcessing module provides a generic, collection-based
`contains` method that performs poorly for ranges and closed ranges.
This addresses the primary issue by providing concrete overloads
for Range and ClosedRange which match the expected performance for
these operations.

This change also fixes an issue with the existing range overlap tests.
The generated `(Closed)Range.overlap` tests are ignoring the "other"
range type when generating ranges for testing, so all overlap tests
are only being run against ranges of the same type. This fixes things
so that heterogeneous testing is included.
2024-11-12 11:47:24 -08:00
Artem Chikin
58709e58e7 [CMake] Add a dependency on 'libSwiftScan' for 'swiftCore'
It appears that 'swiftCore' and following associated 'embedded-stdlib-*' targets may begin building before the libSwiftScan library has completed building, which may cause crashes if the compiler process building 'swiftCore' attempts to load it.

Resolves rdar://137674862
2024-11-12 10:05:47 -08:00
Guillaume Lessard
54066b2562 Merge pull request #77548 from glessard/rdar139668469-not-immortal-vincible
[span] express correct lifetimes for initializers
2024-11-12 07:40:41 -05:00
Guillaume Lessard
a50260b181 [stdlib] Avoid unnecessary null-pointer checks in UM[R]BP bulk-copy functions 2024-11-11 23:57:47 -05:00
Guillaume Lessard
76d22cc675 [span] correctly express lifetimes for initializers 2024-11-11 23:31:16 -05:00
Henrik G. Olsson
0678829cf7 Add @PointerBounds macro (#76969)
Add @PointerBounds macro

@PointerBounds is a macro intended to be applied by ClangImporter when
importing functions with pointer parameters from C headers. By
leveraging C attributes we can get insight into bounds, esapability, and
(eventually) lifetimes of pointers, allowing us to map them to safe(r)
and more ergonomic types than UnsafePointer.

This initial macro implementation supports CountedBy and Sizedby, but
not yet EndedBy. It can generate function overloads with and without an
explicit count parameter, as well as with UnsafeBufferPointer or Span
(if marked nonescaping), and any of their combinations. It supports
nullable/optional pointers, and both mutable and immutable pointers.
It supports arbitrary count expressions. These are passed to the macro
as a string literal since any parameters referred to in the count
expression will not have been declared yet when parsing the macro.

It does not support indirect pointers or inout parameters. It supports
functions with return values, but returned pointers can not be bounds
checked yet.

Bounds checked pointers must be of type Unsafe[Mutable]Pointer[?]<T>
or Unsafe[Mutable]RawPointer[?]. Count expressions must conform to
the BinaryInteger protocol, and have an initializer with signature
"init(exactly: Int) -> T?" (or be of type Int).

rdar://137628612

---------

Co-authored-by: Doug Gregor <dgregor@apple.com>
2024-11-11 14:54:25 -08:00
Guillaume Lessard
20b85ed59d Merge pull request #76406 from glessard/rdar96837923-span 2024-11-07 18:25:49 -08:00
Guillaume Lessard
4fe9328b65 [span] follow the leading underscore rule
Co-authored-by: Karoy Lorentey <klorentey@apple.com>
2024-11-07 12:40:16 -08:00
Guillaume Lessard
386f041aa8 [span] fix an argument label
Co-authored-by: Karoy Lorentey <klorentey@apple.com>
2024-11-07 12:39:12 -08:00
Guillaume Lessard
0922b6b622 [span] improve argument labels for safe initializers 2024-11-07 11:19:28 -08:00
Guillaume Lessard
9a8f5a7e9d [span] update more doc-comments 2024-11-07 11:18:40 -08:00
Guillaume Lessard
6272ad66a0 [span] address review feedback 2024-11-06 22:48:28 -08:00
Christian
023590a566 Improved Error._domain calculation (#77369) 2024-11-06 15:09:55 -08:00
Allan Shortlidge
26bd056852 stdlib: Add @_disfavoredOverload to various functions for Embedded.
Functions like `fatalError()` have overloads for Embedded Swift only that take
StaticString instead of String, since String is unavailable. Unfortunately,
many of these overloads create the opportunity for ambiguity in certain
contexts. The easiest way to avoid the ambiguities is to mark each of the
overloads taking `String` as `@_disfavoredOverload`. Another approach that
could work would be to remove the default arguments from the `String` variants
in Embedded Swift only, but that would create even more duplication of source
code so it doesn't seem worth it.
2024-11-02 10:41:08 -07:00
Kuba Mracek
db94dc7d36 [Concurrency] Fix memory leak around mismatched refcounting in Concurrency 2024-10-31 21:43:02 -07:00
Kuba (Brecka) Mracek
79d8de952f Merge pull request #77240 from kubamracek/embedded-printing-types
[embedded] Make Bool string-interpolatable in Embedded Swift, clarify support in docs
2024-10-26 07:56:36 -07:00
Kuba Mracek
68e01f2249 [embedded] Make Bool string-interpolatable in Embedded Swift, clarify support in docs 2024-10-25 22:05:58 -07:00
Guillaume Lessard
c2abbbf4f6 [span] annotate lifetimes that can’t be correct 2024-10-25 18:45:10 -07:00
Guillaume Lessard
2d65dc4f41 [span] lifetime argument tweaks 2024-10-25 18:45:10 -07:00
Guillaume Lessard
c4c9383658 [span] borrow pointer or buffer initializer parameters 2024-10-25 18:45:10 -07:00
Guillaume Lessard
eaf74acbcb [span] add missing RawSpan initializers 2024-10-25 18:45:10 -07:00
Guillaume Lessard
fafd9d3690 [span] readability improvements 2024-10-25 18:45:10 -07:00
Guillaume Lessard
e37475bace [span] small ABI tweaks 2024-10-25 18:45:10 -07:00
Guillaume Lessard
57345f7f6f [span] remove _shrink functions added for review purposes 2024-10-23 18:19:21 -07:00
Guillaume Lessard
b508206844 [span] improve indices(of:) and byteOffsets(of:) 2024-10-23 18:19:21 -07:00
Guillaume Lessard
5d49bd60b7 [span] allow start pointers of empty spans to be exposed 2024-10-23 14:59:07 -07:00
Guillaume Lessard
6fa9780bc5 [span] improve _elementsEqual 2024-10-23 14:48:25 -07:00
Guillaume Lessard
108034e4b0 [span] fix a bounds-checking mistake 2024-10-23 14:06:26 -07:00
Guillaume Lessard
e58e50d17c [span] add availability annotations 2024-10-23 13:14:26 -07:00
Guillaume Lessard
909409181a [gardening] add a relevant FIXME comment 2024-10-23 13:14:22 -07:00
Kuba Mracek
0048c1c624 [embedded] Document the details of the Embedded Swift's refcounting scheme 2024-10-21 08:56:22 -07:00
Guillaume Lessard
979523014c [span] update to match latest proposal tweaks 2024-10-19 23:46:54 -07:00
Kuba Mracek
8666aef39f [embedded] Fix a memory leak caused by incorrect refcounting logic around doNotFreeBit 2024-10-18 23:19:40 -07:00
Guillaume Lessard
7faf7bc634 [stdlib] add Span 2024-10-18 22:57:43 -07:00