Commit Graph

3290 Commits

Author SHA1 Message Date
Ben Barham
c163e0fe5e [Tests] Make OS features consistent
lit.py currently allows any substring of `target_triple` to be used as a
feature in REQUIRES/UNSUPPORTED/XFAIL. This results in various forms of
the OS spread across the tests and is also somewhat confusing since they
aren't actually listed in the available features.

Modify all OS-related features to use the `OS=` version that Swift adds
instead. We can later remove `config.target_triple` so that these don't
the non-OS versions don't work in the first place.
2022-05-20 19:51:23 -07:00
Karoy Lorentey
07ffddebae Merge pull request #58954 from lorentey/string-bincompat-workarounds
[stdlib] Work around binary compatibility issues with String index validation fixes in 5.7
2022-05-18 11:09:44 -07:00
Karoy Lorentey
50c2399a94 [stdlib] Work around binary compatibility issues with String index validation fixes in 5.7
Swift 5.7 added stronger index validation for `String`, so some illegal cases that previously triggered inconsistently diagnosed out of bounds accesses now result in reliable runtime errors. Similarly, attempts at applying an index originally vended by a UTF-8 string on a UTF-16 string now result in a reliable runtime error.

As is usually the case, new traps to the stdlib exposes code that contains previously undiagnosed / unreliably diagnosed coding issues.

Allow invalid code in binaries built with earlier versions of the stdlib to continue running with the 5.7 library by disabling some of the new traps based on the version of Swift the binary was built with.

In the case of an index encoding mismatch, allow transcoding of string storage regardless of the direction of the mismatch. (Previously we only allowed transcoding a UTF-8 string to UTF-16.)

rdar://93379333
2022-05-17 19:25:10 -07:00
David Smith
9dd8d3ad1a Actually slice things in _StringGutsSlice 2022-05-17 14:31:11 -07:00
Josh Soref
624a54b9cf Spelling stdlib (#42544)
* spelling: abcdefghijklmnopqrstuvwxyz

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: clazz

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: collection

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: compressible

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: constituent

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: contiguous

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: convertibility

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: element

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: enforce

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: exhaustive

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: exhausts

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: existential

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: facilitate

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: ignored

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: incorporated

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: intersection

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: laziness

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: misaligned

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: overhaul

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: preamble

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: precondition

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: replacement

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: trailing

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: unambiguous

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: uncompressible

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: world

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

Co-authored-by: Josh Soref <jsoref@users.noreply.github.com>
2022-04-22 19:18:38 -07:00
Doug Gregor
c76a99ba02 [SE-0352] Enable implicit opening of existentials by default 2022-04-20 17:51:04 -07:00
Karoy Lorentey
2574d78d40 Merge pull request #42442 from lorentey/better-index-conversions 2022-04-19 20:22:06 -07:00
Karoy Lorentey
e21b846828 [test] Add new tests for String.Index(_:within:) 2022-04-18 20:57:54 -07:00
swift-ci
58c8e2ecd8 Merge pull request #41033 from glessard/se-unaligned
[SE-0349] Implementation for unaligned loads from raw memory
2022-04-18 15:29:52 -07:00
Guillaume Lessard
3971f28228 [test] make back-deployment testing possible 2022-04-18 16:27:08 -06:00
Guillaume Lessard
2e54373236 [test] Test new unaligned store behaviour 2022-04-18 10:44:06 -06:00
Karoy Lorentey
318277c3aa [test] stdlib/StringIndex: Spin off O(n^4) substring replacement test into a standalone long test
Also trim down its input a bit so that this doesn’t take 20 minutes.
2022-04-15 21:29:32 -07:00
Guillaume Lessard
18622f518c [test] new stdlib load/store behaviours 2022-04-15 16:31:49 -06:00
Guillaume Lessard
f42705b536 [gardening] remove unnecessary warnings from test 2022-04-15 13:39:22 -06:00
Karoy Lorentey
66a8ae07dc [test] Move string test helper methods to StdlibUnittest
This fixes a Windows regression triggered by
https://github.com/apple/swift/pull/41417.
2022-04-14 21:36:45 -07:00
Karoy Lorentey
57f0e67658 Merge pull request #41417 from lorentey/the-horror-of-se-0180
[stdlib] Fix String indexing edge cases, anomalies & validation bugs
2022-04-14 14:08:53 -07:00
Karoy Lorentey
cb2194c024 [stdlib] Fix ABI and portability issues 2022-04-13 19:15:30 -07:00
Daniel Duan
3dfc40898c [NFC] Remove Python 2 imports from __future__ (#42086)
The `__future__` we relied on is now,  where the 3 specific things are
all included [since Python 3.0](https://docs.python.org/3/library/__future__.html):

* absolute_import
* print_function
* unicode_literals
* division

These import statements are no-ops and are no longer necessary.
2022-04-13 14:01:30 -07:00
swift-ci
a7edd6065c Merge pull request #42287 from glessard/rdar90336023
[test] check for availability before testing
2022-04-10 16:45:50 -07:00
Guillaume Lessard
f4533d4a53 [test] check for availability before testing
- These tests verify updated behaviour of existing API, and should check for availability first.
2022-04-10 14:01:32 -06:00
Guillaume Lessard
622eb497a5 Merge pull request #42232 from glessard/rdar90336023
[test] expectCrashLater(withMessage:) reliability workaround
2022-04-07 14:43:06 -06:00
Guillaume Lessard
8e3a47682b [test] just don’t check for the crash message 2022-04-07 10:44:31 -06:00
Karoy Lorentey
71216009e3 [test] Move useful helpers into StdlibUnicodeUnittest 2022-04-06 20:11:05 -07:00
Guillaume Lessard
152353157c [stdlib] less assumingMemoryBound, rebind instead 2022-04-06 16:18:02 -06:00
Guillaume Lessard
8032a7c0c9 [test] work around a linux testing issue 2022-04-06 04:18:17 -06:00
Karoy Lorentey
42c823847e [test] stdlib/StringIndex: Simplify 2022-04-05 20:47:42 -07:00
Guillaume Lessard
b13377726f [stdlib] improve the new deprecation messages 2022-04-05 14:43:03 -06:00
Guillaume Lessard
cfdb44ee7e [test] check deprecation warnings for undesirable overloads 2022-04-04 20:26:40 -06:00
Guillaume Lessard
a76b6ae8d0 [test] add tests of String-from-C-string inout conversion overloads 2022-04-04 17:53:54 -06:00
Guillaume Lessard
a8e2463cc2 [test] add tests of String-from-C-string String overloads 2022-04-04 17:53:20 -06:00
Guillaume Lessard
32fc00ee0b [test] add tests of String-from-C-string Array overloads 2022-04-04 17:44:37 -06:00
Karoy Lorentey
1c9c5ccbf6 [test] test/StringIndex: Add some tests exercising replaceSubrange
The exhaustive substring.replaceSubrange test probably takes too long
to include in regular testing, but let’s enable it for now: it has
caught a bunch of problems already and it will probably catch more
before this lands.
2022-03-29 20:00:08 -07:00
Karoy Lorentey
06090ce7f2 [test] Add more String coverage 2022-03-29 20:00:08 -07:00
Karoy Lorentey
99f693e4ba [test] stdlib/StringIndex: Review & extend with more cases 2022-03-24 21:00:00 -07:00
Karoy Lorentey
683b9fa021 [stdlib] Adjust/fix String’s indexing operations to deal with the consequences of SE-0180 2022-03-24 20:59:59 -07:00
Alejandro Alonso
27e6241a41 Merge pull request #41389 from Azoy/fix-indic-sequences
[stdlib] Fix backwards count of Indic graphemes
2022-03-14 12:08:21 -07:00
Alsey Coleman Miller
0ab3eec987 Added PowerPC 32-bit support 2022-03-03 22:21:33 -05:00
Karoy Lorentey
33bb68c2f2 [test] stdlib/StringTraps: Add some coverage for foreign traps in UTF-8/16 views
These trigger Objective-C exceptions in Foundation, but the fact these operations reliably trap when applied to foreign strings is part of the String contract in the stdlib, and we should have regression tests for them.
2022-03-01 19:22:16 -08:00
Karoy Lorentey
1da581642c Merge pull request #41599 from lorentey/string-unicodescalarview-index-validation
[stdlib] String.UnicodeScalarView: Fix some index validation issues
2022-03-01 16:27:34 -08:00
Karoy Lorentey
20c293ee18 Merge pull request #41598 from lorentey/string-index-validation
[stdlib] String.index(before:): Fix index validation issues
2022-03-01 16:27:03 -08:00
Guillaume Lessard
577015f5be Merge pull request #39639 from glessard/se-pointer-convenience
SE-0334: Pointer API Usability Improvements
2022-03-01 13:24:25 -07:00
Karoy Lorentey
2757088edc [test] stdlib/StringTraps: Add some test coverage for String.UnicodeScalarView 2022-03-01 10:05:05 -08:00
Karoy Lorentey
f528db51c5 [test] stdlib/StringTraps: Add some test coverage for String.index(before:) traps 2022-02-28 18:20:52 -08:00
Guillaume Lessard
e83ccd33c0 [test] fix test of withMemoryRebound
- The test did not properly test the intent of the change from 82fa4b0ea8
2022-02-28 17:40:14 -07:00
Guillaume Lessard
dd4b646651 [test] test SE-0334 additions 2022-02-25 13:35:20 -07:00
Guillaume Lessard
9ead7d039d [stdlib] relax stride check in UnsafePointer.withMemoryRebound (#41553)
* [stdlib] relax stride check

- The stride check in `UnsafePointer.withMemoryRebound` makes less sense when rebinding memory for a single element.
- This skips the stride-matching portion of the `_debugPrecondition` in `withMemoryRebound` when `count == 1`.

* [test] UnsafePointer.withMemoryRebound with capacity 1
2022-02-25 09:54:32 -05:00
Guillaume Lessard
c9e86b4a93 [test] UnsafePointer.withMemoryRebound with capacity 1 2022-02-24 22:00:47 -07:00
Robert Widmann
496da9dda9 Merge pull request #40977 from buttaface/droid-test 2022-02-21 22:46:42 -08:00
Karoy Lorentey
5274295e3f [test] Update tests for new (conditional) _debugPrecondition behavior 2022-02-18 21:54:02 -08:00
Philippe Hausler
e675b310f8 [SE-0329] Clock/Instant/Duration (#40609)
* [WIP] Initial draft at v2 Clock/Instant/Duration

* Ensure the literal types for _DoubleWide are able to be at least 64 bits on 32 bit platforms

* static cast timespec members to long

* Remove runtime exports from clock functions

* Export clock functions in implementations as they are in headers

* Clean up internal properties by adding leading underscores, refine availability to a TBD marker macro, and break at 80 lines to match style

* Shift operators to concrete Instant types to avoid complexity in solver resolution

* Adjust diagnostic note and error expectation of ambiguities to reflect new potential solver (perhaps incorrect) solutions

* Update stdlib/public/Concurrency/TaskSleep.swift

Co-authored-by: Karoy Lorentey <klorentey@apple.com>

* [stdlib][NFC] Remove trailing whitespace

* [stdlib] Remove _DoubleWidth from stdlib's ABI

* [stdlib] Strip downd _DoubleWidth to _[U]Int128

* Additional adjustments to diagnostic notes and errors expectation of ambiguities to reflect new potential solver (perhaps incorrect) solutions

* Disable type checker performance validation for operator overload inferences (rdar://33958047)

* Decorate Duration, DurationProtocol, Instant and clocks with @available(SwiftStdlib 9999, *)

* Restore diagnostic ambiguity test assertion (due to availability)

* Add a rough attempt at implementing time accessors on win32

* Remove unused clock id, rename SPI for swift clock ids and correct a few more missing availabilities

* remove obsolete case of realtime clock for dispatch after callout

* Use the default implementation of ~ for Int128 and UInt128

* Ensure diagnostic ambiguitiy applies evenly to all platforms and their resolved types

* Restore the simd vector build modifications (merge damage)

* Update to latest naming results for Instant.Duration

* Updates to latest proposal initializers and accessors and adjust encoding/decoding to string based serialization

* Update availability for Clock/Instant/Duration methods and types to be 5.7

* Correct *Clock.now to report via the correct runtime API

* Ensure the hashing of Duration is based upon the attoseconds hashing

* Avoid string based encoding and resort back to high and low bit encoding/decoding but as unkeyed

* Adjust naming of component initializer to use suffixes on parameters

* Duration decoding should use a mutable container for decoding

* fix up components initializer and decode access

* Add platform base initializers for timespec and tiemval to and from Duration

* Add some first draft documentation for standard library types Duration, DurationProtocol and InstantProtocol

* Another round of documentation prose and some drive-by availability fixes

* InstantProtocol availability should be 5.7

* Correct linux timeval creation to be Int and not Int32

Co-authored-by: Karoy Lorentey <klorentey@apple.com>
2022-02-17 09:32:46 -08:00