Commit Graph

165 Commits

Author SHA1 Message Date
Alejandro Alonso
708d72d2c3 Update tests for 6.1 Unicode 16 stdlib 2025-01-15 14:09:57 -08:00
Becca Royal-Gordon
fd84e7273d Rename module.map -> module.modulemap in tests
The legacy `module.map` spelling of module map files was deprecated by llvm/llvm-project#75142 and clang expects to remove support for them in the future. Switch all tests to use the supported spelling.

Fixes rdar://128431478.
2024-08-12 17:47:26 -07:00
Tim Kientzle
48eb993349 Verify that hash/equality behavior is all consistent
It's not obvious that we can check that hash/equality behavior
is entirely correct, since there are two very different behaviors
which depend on environmental factors that are not easy to test for.

But we can do a quick probe to see whether the current environment
seems to be offering the legacy or non-legacy behavior and then
carefully verify that everything else is consistent with our initial
probe.

This gives us confidence that at least we're not getting inconsistent
behavior.
2024-07-09 13:30:13 -07:00
David Smith
b81aec5c1a rdar://127199021, fix compatibility with apps that accidentally do [[[aSwiftArray class] new] mutableCopy] to work (#73728) 2024-05-20 12:06:05 -07:00
Joe Groff
02e1f2ea15 IRGen: Fix key path generic environment marshalling for external property descriptors.
The layout of a computed key path component carries an argument buffer for captures, which has
the following layout:

```
---
captured values (subscript indices)
---
generic arguments
---
```

When we reference an externally-defined public property or subscript from a key path, and the
external declaration has a property descriptor, then the generic arguments for the external
declaration get appended to the end of this buffer, giving:

```
---
captured values (subscript indices)
---
generic arguments
---
external property's generic arguments
---
```

The convention for key path accessors to bind their generic environment is thus to unpack them
from the end of the argument buffer, so that the external keypath's accessors can find the
arguments to bind the external generic environment while still allowing the enclosing key path
to save the original captured generic environment (which may be necessary to capture the
appropriate conditional and/or retroactive `Equatable` and `Hashable` conformances for
subscript indices).

However, our code generation for binding the generic arguments out of the argument buffer
contained a flawed optimization: for a property, we know there are never any captured values,
so I had assumed that the generic parameters could always be bound from the beginning of the
argument buffer, assuming that the generic parameters make up the totality of the buffer. This
falls over for external property descriptor references when the key path itself captures a
generic environment, since the external property's expected generic environment appears after
the key path's original generic environment. We can fix this by removing the conditional
entirely, and always adjusting the offset we load the generic environment from to look at the
end of the buffer. Fixes rdar://125886333.
2024-04-25 10:36:13 -07:00
Tim Kientzle
6c173fe4b8 Fix up tests to deal with varying behaviors 2024-02-14 12:51:25 -08:00
Tim Kientzle
4e821f65ec Merge pull request #69464 from tbkka/tbkka-objc-equatable-hashable
Use Swift Equatable and Hashable conformances from ObjC
2023-11-10 13:46:19 -08:00
Tim Kientzle
5ba38e8527 Comment out a known-broken test case
This entire suite was copied wholesale from SwiftObjectNSObject.
Some of it may not apply, very little of it has been critically
evaluated.  But it should help avoid unexpected changes in SwiftValue behavior.
2023-11-03 17:06:49 -07:00
Tim Kientzle
2cbd70e531 Make SwiftValue hash/equality work the same as SwiftObject
Update PR #68720 with lessons learned in reviewing #69464

Background:

* SwiftValue can expose Swift value types (structs/enums)
  to ObjC by wrapping them in an Obj-C object on the heap

* SwiftObject is the Obj-C type that Swift class objects all
  inherit from (when viewed from Obj-C).  This allows arbitrary
  Swift class objects to be passed into Obj-C.

History:

* PR #4124 made Obj-C `-hash` and `-isEqual:` work for SwiftValue for Hashable Swift types

* PR #68720 extended SwiftValue to also support Equatable Swift types

* PR #69464 added similar support to SwiftObject

In the process of working through #69464, we found a better way
to handle an ObjC request for `-hash` for a type that is Swift
Equatable but not Hashable.  This PR updates SwiftValue to use
the same approach.  The approach considers three cases:

1. A Hashable type can forward both `-hash` and `-isEqual:` to
   the Swift object.

2. A type that is neither Equatable nor Hashable can implement
   `-isEqual:` as the identity check and `-hash` as returning
   the address of the object in memory.

3. A type is that Equatable but not Hashable is more complex.

In this last case, we can easily forward `-isEqual:` to the
Equatable conformance but ObjC also requires us to
always provide a compatible `-hash` implementation.
The only way to do this is to have `-hash` return a constant,
but that is a very bad idea in general, so we're also including
a log message whenever we see a request for `-hash` on
a Swift value that is Equatable but not Hashable.
To limit performance problems from the logging itself, we
emit the log message only once for each type.
2023-11-02 11:24:04 -07:00
Tim Kientzle
716b58e956 Handle ObjC -hash differently for Equatable and non-Equatable types
For an Equatable type, we need a hash implementation that
is compatible with any possible definition of `==`.
Conservatively, that means `-hash` must return a constant.

For non-Equatable types, we know that `==` is identity based,
so we can get better hash behavior by using the object address.

Caveat:  This means that non-Equatable types will do two
protocol conformance checks on every call to `hash`.
2023-10-31 14:26:20 -07:00
Tim Kientzle
6fd39741d6 Fix a number of issues (review feedback)
* Fix how we were looking for common parent class
* Use a constant hashValue for types that are Equatable but not Hashable
2023-10-30 15:57:47 -07:00
Tim Kientzle
a840c69392 Use Swift Equatable and Hashable conformances from ObjC
If a Swift type implements Equatable and/or Hashable and
we then pass that object into ObjC, we want ObjC
`isEqual:` and `hashValue` to use that.  This allows
ObjC code to build ObjC collections of Swift objects.

* Support for Hashable struct/enum types was implemented in #4124
* Support for Equatable struct/enum types was implemented in #68720
* This implements support for Hashable and Equatable _class_ types

Caveats:
1. This does a lot of dynamic lookup work for each operation, so is
   inherently rather slow.  Unlike the struct/enum case, there is no convenient
   place to cache the conformance information, so it's not clear that there is a
   viable way to make it significantly faster.
2. This is a behavioral change to low-level support code.  There is a
   risk of breaking code that may be relying on the old behavior.
2023-10-27 12:01:44 -07:00
Michael Spencer
b2640e15e4 [test] Rename all module.map files to module.modulemap
`module.map` as a module map name has been discouraged since 2014, and
Clang will soon warn on its usage. This patch renames all instances of
`module.map` in the Swift tests to `module.modulemap` in preparation
for this change to Clang.

rdar://106123303
2023-08-21 15:58:59 -07:00
Karoy Lorentey
b82ce9c3be [stdlib] Adopt _pointerBitWidth conditional 2023-04-27 13:33:24 -07:00
nate-chandler
5e0267b9b7 Merge pull request #64553 from nate-chandler/eagermove_collections
[stdlib] Collection types are eagerMove.
2023-03-30 16:16:26 -07:00
Nate Chandler
cda365ca8d [stdlib] Collection types are eagerMove.
Types that have "value semantics" should not have lexical lifetimes.
Value types are not expected to have custom deinits. Are not expected to
expose unsafe interior pointers. And cannot have weak references because
they are structs. Therefore, deinitialization barriers are irrelevant.

rdar://107076869
2023-03-30 11:04:47 -07:00
Alejandro Alonso
f16f0c3c23 Update the stdlib to use Unicode 15 data 2023-03-29 10:18:16 -07:00
Alsey Coleman Miller
62b7be4e9c [stdlib] Add RISCV64 support 2022-11-01 23:59:42 -07:00
David Smith
27a27fe034 Fix test 2022-08-09 14:35:10 -07:00
David Smith
ad00633cf1 Fix assert 2022-08-09 14:12:20 -07:00
David Smith
f966017c9c Review feedback 2022-08-08 17:27:23 -07:00
David Smith
b3d8875834 Iterate on the long tagged string test 2022-08-08 16:23:54 -07:00
David Smith
e0dd80fe3b Handle long tagged NSStrings 2022-08-05 19:02:37 -07:00
Anthony Latsis
087eba83a2 Merge pull request #59757 from AnthonyLatsis/close-issues-2
Add regression tests to close several issues p. 2
2022-06-29 02:48:54 +03:00
Anthony Latsis
7732306fa9 Add regression test to close #43135 2022-06-25 00:48:02 +03:00
Alejandro Alonso
95da55b182 [stdlib] Implement String.WordView (#42414)
* Implement String.WordView

* Add isWordAligned bit

* Hide WordView for now (also separate Index type)

add bidirectional conformance

Fix tests

* Address comments from Karoy and Michael

* Remove word view, use index methods

* Address Karoy's comments

aaa
2022-06-22 09:10:09 -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
Alejandro Alonso
657c17fa39 Setup grapheme breaking tests 2022-02-15 17:16:36 -08:00
Alejandro Alonso
98feb5e6ec Add availability to a few new tests (#40048)
its available, not availabile
2021-11-05 16:01:19 -07:00
Karoy Lorentey
e2cfab4f28 [stdlib][test] Adopt availability macros in tests 2021-10-31 15:00:58 -07:00
Alejandro Alonso
014e822cb2 Address Michael's comments
fix infinite recursion bug

NFC: Remove early ccc check

remember that false is turned on
2021-09-29 14:20:22 -07:00
Erik Eckstein
6f4192927e tests: refactor Array test files.
* move all ObjC array tests into a separate file ArraysObjc.swift.gyb
* merge the remaining Arrays.swift.gyb and ArrayNew.swift.gyb files
* move the utilities from ArrayTypesAndHelpers.swift into its only use into ArraysObjc.swift.gyb
2021-06-17 11:30:59 +02:00
Robert Widmann
0149ccd0ca Add arm64_32 support for Swift
Commit the platform definition and build script work necessary to
cross-compile for arm64_32.

arm64_32 is a variant of AARCH64 that supports an ILP32 architecture.
2021-04-20 14:59:04 -07:00
Ben Rimmington
d2495f87f0 [stdlib] Reinstate the FixedPointConversion tests (#36205)
* [stdlib] Reinstate the FixedPointConversion tests

* [stdlib] Update the FixedPointConversion tests

* [stdlib] Generate the FixedPointConversion tests

* [stdlib] FixedPointConversion_Release32: long_test
2021-03-09 22:24:03 -05:00
Michael Gottesman
8f1b353568 [mandatory-combine] Just like SILCombine, perform SIL canonicialization while performing mandatory combining. 2020-12-04 16:47:40 -08:00
Max Desiatov
0c8b86601c test: Replace _silgen_name w/ _cdecl in CommandLineStressTest
This test abuses @_silgen_name unnecessarily according to https://forums.swift.org/t/how-can-my-c-main-function-call-swift/40244/2
2020-09-14 09:23:22 +01:00
Stephen Canon
103961a7d5 Make Float16 unavailable on macOS and macCatalyst, mirroring Xcode's Swift. (#32868)
LLVM doesn't have a stable ABI for Float16 on x86 yet; we're working with Intel to get that fixed, but we don't want to make the type available on macOS until a stable ABI is actually available, because we'd break binaries compiled before any calling convention changes if we do.
2020-07-14 20:42:12 -04:00
Karoy Lorentey
da242bd2d4 [SDK] Remove obsolete overlay code 2020-06-22 15:43:39 -07:00
Mishal Shah
272c466e47 Update master to build with Xcode 12 beta 2020-06-22 15:43:20 -07:00
Stephen Canon
248c554524 Add Float16 to stdlib (#30130)
Add Float16 (IEEE 754 binary16) to the standard library, plus assorted runtime support operations.

Swift Evolution thread: https://forums.swift.org/t/se-0277-float16/33546
2020-04-06 17:57:44 -04:00
Erik Eckstein
66852e2bb7 tests: fix Array test
The Array/removeNonUnique test is not working with an old runtime.

rdar://problem/58471030
2020-01-10 09:50:34 +01:00
Erik Eckstein
88a9ebb9f8 stdlib: Don't request additional capacity in Array/ContiguousArray's remove.
Just copy the buffer if it's not unique.
This also implies that if there is a copy-on-write in remove, "shrink" the capacity of the new buffer to the required amount of elements (instead of copying the capacity of the original buffer).
2020-01-09 16:17:38 +01:00
Mike Ash
7d4bf753f4 [Test] Don't test demangling of SwiftObject's name, as it's subject to change.
rdar://problem/57163094
2019-11-15 12:56:24 -05:00
Arnold Schwaighofer
7a54927b03 IRGen: Fix MemoryLayout::offset(of:) for tail allocated C arrays
There is no storage but an offset.

rdar://51194713
2019-10-15 14:04:31 -07:00
David Smith
1cce12f20c Add an Array-based NSMutableArray subclass 2019-09-24 18:15:33 -07:00
David Smith
92eaeca0b2 Fix test to ignore two unused classes still present on old runtimes 2019-08-27 13:52:25 -07:00
David Smith
0887299d9e Fix sub-scalar index distances in foreign UTF8 views 2019-08-02 16:45:42 -07:00
David Smith
e7b1107212 Merge pull request #26374 from Catfish-Man/unindex-set
Remove unused Foundation subclasses
2019-07-26 17:09:45 -07:00
David Smith
48266a6f56 Remove unused Foundation subclasses 2019-07-26 14:47:43 -07:00