Commit Graph

3290 Commits

Author SHA1 Message Date
Guillaume Lessard
a27d9c426a Merge pull request #71912 from oscbyspro/better-joined-distance-from-to-int-min
FlattenSequence/distance(from:to:) untrapping Int.min
2024-05-17 16:17:01 -07:00
Alejandro Alonso
db9232f246 Merge pull request #73550 from Azoy/string-debugger-changes
[debug] Print strings using their description in the debugger
2024-05-16 11:40:00 -07:00
Alejandro Alonso
528160d1cd Update BridgedObjectDebuggerSupport.swift 2024-05-15 10:03:57 -07:00
Alejandro Alonso
b2f21bbfb3 Update DebuggerSupport.swift 2024-05-15 10:02:35 -07:00
Stephen Canon
8578a0e18d Add some additional test coverage for duration static methods (#73578)
The numerics of these operations is fairly subtle, and the overflow boundaries are somewhat surprising, so additional test coverage isn't a bad thing (also gives us an excuse to exercise Int128 more)
2024-05-11 18:13:11 -04:00
Tim Kientzle
da8a0872bf Update tests to match new expectations everywhere 2024-05-10 17:10:50 -07:00
Kavon Farvardin
0420310623 NCGenerics: it's no longer "experimental"
resolves rdar://127701059
2024-05-08 10:49:12 -07:00
Nate Chandler
c10d39e35f [AST] Remove Builtin.copy.
A vestigial remnant of it was left behind after
06921cfe84 in order to avoid a reverse
condfail when building old swiftinterfaces that define

```swift
func _copy<T>(_ value: T) -> T {
  #if $BuiltinCopy
    Builtin.copy(value)
  #else
    value
  #endif
}
```

If the language feature is removed, though, such interfaces should again
be buildable because the branch where the language feature isn't defined
should be expanded.

rdar://127516085
2024-05-04 11:35:17 -07:00
Nate Chandler
06921cfe84 [SIL] Hollow out Builtin.copy, deprecate _copy.
The copy operator has been implemented and doesn't use it.  Remove
`Builtin.copy` and `_copy` as much as currently possible.

Source compatibility requires that `_copy` remain in the stdlib.  It is
deprecated here and just uses the copy operator.

Handling old swiftinterfaces requires that `Builtin.copy` be defined.
Redefine it here as a passthrough--SILGen machinery will produce the
necessary copy_addr.

rdar://127502242
2024-05-03 15:56:25 -07:00
Kuba Mracek
1d48f28d84 [KeyPath] Fix regression in == on keypaths 2024-04-30 12:50:03 -07:00
Joe Groff
2f954ef5d7 Merge pull request #73259 from jckarter/external-key-path-generic-environment-binding
IRGen: Fix key path generic environment marshalling for external property descriptors.
2024-04-25 16:24:42 -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
Ben Barham
412c8321c3 [Test] Add symbols visible on Ubuntu 23.10
A couple more `basic_string`:
```
_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE15_M_replace_coldEPcmPKcmm
_ZSt12__str_concatINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEET_PKNS6_10value_typeENS6_9size_typeES9_SA_RKNS6_14allocator_typeE
```

Which are:
```
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_replace_cold(char*, unsigned long, char const*, unsigned long, unsigned long)
```
and
```
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > std::__str_concat<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::value_type const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::size_type, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::value_type const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::size_type, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::allocator_type const&)
```
2024-04-19 13:26:57 -07:00
Stephen Canon
8ca9e1bc59 Disable PrintFloat16 test with debug stdlib, it's slooooooow. (#73098) 2024-04-18 12:04:04 -04:00
Artem Chikin
01d891ad99 Merge pull request #72834 from artemcm/UpstreamVisionOS
Introduce visionOS Platform
2024-04-15 09:33:49 -07:00
Tim Kientzle
5251750999 Conditionalize tests to supported OSes only 2024-04-10 15:30:29 -07:00
Artem Chikin
1f14158a1d Introduce VisionOS Platform
This change introduces a new compilation target platform to the Swift compiler - visionOS.

- Changes to the compiler build infrastrucuture to support building compiler-adjacent artifacts and test suites for the new target.
- Addition of the new platform kind definition.
- Support for the new platform in language constructs such as compile-time availability annotations or runtime OS version queries.
- Utilities to read out Darwin platform SDK info containing platform mapping data.
- Utilities to support re-mapping availability annotations from iOS to visionOS (e.g. 'updateIntroducedPlatformForFallback', 'updateDeprecatedPlatformForFallback', 'updateObsoletedPlatformForFallback').
- Additional tests exercising platform-specific availability handling and availability re-mapping fallback code-path.
- Changes to existing test suite to accomodate the new platform.
2024-04-10 09:38:02 -07:00
Tim Kientzle
810792843b Fill in extended existential support for type(of:) and mirror
type(of:) now returns the dynamic type of the contents of
an extended existential (just like it does for a regular existential)

Mirror can now reflect fields of a value stored inside an extended
existential (just like it can with a regular existential).  This
requires type(of:) support, since Mirror internals use that to
determine how to reflect a value.

Resolves rdar://102906195
2024-04-09 17:37:57 -07:00
Yuta Saito
c32c7f55fe [wasm] Fix build failure due to lack of _Float16 support
WebAssembly does not support _Float16 type, so we need to guard the use
of the type. Unfortunately, Clang does not provide a good way to detect
the support of _Float16 type at compile time, so just disable for wasm
targets.
2024-04-07 16:34:11 +00:00
Stephen Canon
6ac852f3f4 Move Float16 print tests to their own file and test exhaustively (#72859)
We can easily test all 2**16 values, so let's do it. Also now _Float16 is properly supported in clang, so we can pass arguments to CPP that way, which lets us get snan right on more platforms.
2024-04-05 19:55:19 -04:00
Yuta Saito
c30ba69e4f [test] Fix Int128 test on 32-bit platforms
The test used Int.min and Int.max assuming that they are 64-bit integers.
Use 64-bit integers explicitly instead.
2024-04-03 00:44:46 +00:00
Stephen Canon
a381589524 SE-0425 implementation (#72139) 2024-04-02 16:24:41 -04:00
Kavon Farvardin
554fa49a1f Test: clean-up noncopyable_generics lit usage
There no longer is a lit feature called `noncopyable_generics`, it's
just always on now.
2024-04-01 12:28:08 -07:00
Karoy Lorentey
7fc54cab80 [stdlib] MemoryLayout: Add support for non-copyable type arguments
[stdlib] MemoryLayout: Update Swift version numbers

[stdlib] MemoryLayout: Actually hide legacy ABI
2024-03-18 11:03:48 -07:00
Alexis Laferrière
81e465971c Tests: un-xfail tests on the freestanding bot 2024-03-13 13:32:41 -07:00
Alexis Laferrière
841740e7ab Tests: XFAIL a few tests on freestanding
rdar://121121793
2024-03-11 13:29:49 -07:00
Oscar Byström Ericsson
7703ae4a3b FlattenSequence/distance(from:to:) untrapping Int.min (v5).
1. FlattenSequence/distance(from:to:) cleanup.
2. FlattenDistanceFromToTests cleanup.
3. FlattenDistanceFromToTests availability checks.
2024-03-01 11:11:54 +01:00
Guillaume Lessard
18a5fc6d95 Merge pull request #71981 from glessard/rdar123810713
[test] guard a behavioral change
2024-02-29 17:21:40 -08:00
Guillaume Lessard
d463723e15 [test] guard a behavioral change
These two edge cases were fixed in https://github.com/apple/swift/pull/71369, and fail when run against an older standard library. Ensure they run only against a Swift 6.0 or newer stdlib

Addresses rdar://123810713
2024-02-29 08:24:48 -08:00
Tim Kientzle
69ef3add66 Merge pull request #71852 from tbkka/tbkka-rdar123422591
Fix hash/isEqual interop conditionals, update tests
2024-02-28 17:16:57 -08:00
Tim Kientzle
eece2b024b Fix test build 2024-02-28 10:41:51 -08:00
Ben Barham
c4111e53ee [Test] Even more visible libstdc++
```
_ZNSt10_HashtableImSt4pairIKmSt8optionalISsEESaIS4_ENSt8__detail10_Select1stESt8equal_toImESt4hashImENS6_18_Mod_range_hashingENS6_20_Default_ranged_hashENS6_20_Prime_rehash_policyENS6_17_Hashtable_traitsILb0ELb0ELb1EEEE10_M_emplaceIJS0_ImS3_EEEES0_INS6_14_Node_iteratorIS4_Lb0ELb0EEEbESt17integral_constantIbLb1EEDpOT_
_ZNSt10_HashtableImSt4pairIKmSt8optionalISsEESaIS4_ENSt8__detail10_Select1stESt8equal_toImESt4hashImENS6_18_Mod_range_hashingENS6_20_Default_ranged_hashENS6_20_Prime_rehash_policyENS6_17_Hashtable_traitsILb0ELb0ELb1EEEE10_M_emplaceIJS0_ImSsEEEES0_INS6_14_Node_iteratorIS4_Lb0ELb0EEEbESt17integral_constantIbLb1EEDpOT_
_ZNSt10_HashtableImSt4pairIKmSt8optionalISsEESaIS4_ENSt8__detail10_Select1stESt8equal_toImESt4hashImENS6_18_Mod_range_hashingENS6_20_Default_ranged_hashENS6_20_Prime_rehash_policyENS6_17_Hashtable_traitsILb0ELb0ELb1EEEE13_M_rehash_auxEmSt17integral_constantIbLb1EE
```

Which corresponds to `_M_emplace` and `_M_rehash_aux`:
```
std::pair<std::__detail::_Node_iterator<std::pair<unsigned long const, std::optional<std::string> >, false, false>, bool> std::_Hashtable<unsigned long, std::pair<unsigned long const, std::optional<std::string> >, std::allocator<std::pair<unsigned long const, std::optional<std::string> > >, std::__detail::_Select1st, std::equal_to<unsigned long>, std::hash<unsigned long>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true> >::_M_emplace<std::pair<unsigned long, std::optional<std::string> > >(std::integral_constant<bool, true>, std::pair<unsigned long, std::optional<std::string> >&&)
std::pair<std::__detail::_Node_iterator<std::pair<unsigned long const, std::optional<std::string> >, false, false>, bool> std::_Hashtable<unsigned long, std::pair<unsigned long const, std::optional<std::string> >, std::allocator<std::pair<unsigned long const, std::optional<std::string> > >, std::__detail::_Select1st, std::equal_to<unsigned long>, std::hash<unsigned long>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true> >::_M_emplace<std::pair<unsigned long, std::string> >(std::integral_constant<bool, true>, std::pair<unsigned long, std::string>&&)
std::_Hashtable<unsigned long, std::pair<unsigned long const, std::optional<std::string> >, std::allocator<std::pair<unsigned long const, std::optional<std::string> > >, std::__detail::_Select1st, std::equal_to<unsigned long>, std::hash<unsigned long>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true> >::_M_rehash_aux(unsigned long, std::integral_constant<bool, true>)
```
2024-02-28 09:11:31 -08:00
Oscar Byström Ericsson
d5e8bdfa48 FlattenSequence/distance(from:to:) untrapping Int.min (v4).
1. I removed some command-like comments.
2. I added a test for Int.min and Int.max distances.
2024-02-28 13:46:22 +01:00
Oscar Byström Ericsson
e06f80a978 FlattenSequence/distance(from:to:) untrapping Int.min (v3).
1. I added a file with some tests [test/stdlib/FlattenDistanceFromTo.swift].
2. I used [test/stdlib/StaticBigInt.swift] as the template for the new file.
2024-02-28 11:22:19 +01:00
Tim Kientzle
804800447d Document the test hacks more clearly 2024-02-27 17:46:49 -08:00
Tim Kientzle
fac88221c5 Fix hash/isEqual interop conditionals, update tests
Github PR #71620 mixed up one of the bincompat conditionals.
It also had some errors in the tests for ObjC interop.

For now, this leaves the legacy behavior in place for
all Apple platforms.
2024-02-27 17:46:49 -08:00
Ben Barham
5efd8802b9 [Test] Add another C++ stdlib symbol to the Linux symbol visibility test
`_ZNSt6vectorISt8optionalISt4pairISsbEESaIS3_EE17_M_realloc_insertIJRKS3_EEEvN9__gnu_cxx17__normal_iteratorIPS3_S5_EEDpOT_`

```
void std::vector<std::optional<std::pair<std::string, bool> >, std::allocator<std::optional<std::pair<std::string, bool> > > >::_M_realloc_insert<std::optional<std::pair<std::string, bool> > const&>(__gnu_cxx::__normal_iterator<std::optional<std::pair<std::string, bool> >*, std::vector<std::optional<std::pair<std::string, bool> >, std::allocator<std::optional<std::pair<std::string, bool> > > > >, std::optional<std::pair<std::string, bool> > const&)
```
2024-02-26 18:13:24 -08:00
Mishal Shah
cb96ec2893 Merge remote-tracking branch 'origin/main' into bump-swift-version-to-6 2024-02-22 09:44:44 -08:00
Ben Barham
dea8e30d0f [Test] Add more C++ stdlib symbols on Linux
Two new symbols:
  `void std::__detail::__variant::__erased_ctor<std::monostate&, std::monostate&&>(void*, void*)`
  `void std::__detail::__variant::__erased_assign<std::monostate&, std::monostate&&>(void*, void*)`

Likely added from #71627.
2024-02-21 22:27:46 -08:00
Ben Barham
ef8825bfe6 Migrate llvm::Optional to std::optional
LLVM has removed llvm::Optional, move over to std::optional. Also
clang-format to fix up all the renamed #includes.
2024-02-21 11:20:06 -08:00
Mishal Shah
af112c1591 Update the Swift version to 6.0 from 5.11 2024-02-19 17:47:16 -08:00
Tim Kientzle
6c173fe4b8 Fix up tests to deal with varying behaviors 2024-02-14 12:51:25 -08:00
Alejandro Alonso
69370ec793 Update LockFreeSingleConsumerStack.swift 2024-02-06 14:54:16 -08:00
Doug Gregor
e4d6bee153 Merge pull request #71400 from DougGregor/will-throw-typed
Implement `swift_willThrow` variant for typed throws.
2024-02-06 03:22:22 -08:00
Doug Gregor
3fa07a0e7a Implement swift_willThrow variant for typed throws.
`swift_willThrow` is called with an error right before it is thrown.
This existing entrypoint requires an already-boxed error existential;
with typed errors, we don't have the error existential on hand, so we
would need to allocate the box to throw a typed error. That's not okay.

Introduce a new `swift_willThrowTypedImpl` entry point into the runtime
that will first check for the presence of an error handler and, if one
is present, box the error to provide to the error handler. This
maintains the no-allocations path for typed errors while still
allowing existing error handlers to work.

This new entrypoint isn't available on older Swift runtimes, so create
a back-deployable shim called by the compiler. On new-enough platforms,
this will call through to `swift_willThrowTypedImpl`. On older
platforms, we drop the error and don't call the registered will-throw
handler at all. This is a compromise that avoids boxing when throwing
typed errors, at the cost of a slightly different experience for this
new feature on older runtimes.

Fixes rdar://119828459.
2024-02-05 15:06:55 -08:00
Guillaume Lessard
a2df540cfa Merge pull request #71369 from oscbyspro/main
BinaryInteger advanced(by:) fixes
2024-02-05 14:42:38 -08:00
Holly Borla
93b68cd9df Merge pull request #71365 from hborla/lazy-trc-extension 2024-02-05 08:06:45 -08:00
Oscar Byström Ericsson
306eaefb5b Apply suggestions from code review
- Changed 128 integer literal to Int(Int8.max)+1 in unit tests (Int8.Stride is Int).

Co-authored-by: Guillaume Lessard <glessard@users.noreply.github.com>
2024-02-04 08:27:27 +01:00
Oscar Byström Ericsson
17187e38f5 This patch fixes two unnecessary traps in BinaryInteger's advanced(to:) method.
- `Int8.min.advanced(by: 128)`, etc.
- `UInt.max.advanced(by: Int.min)`, etc.
2024-02-03 13:56:33 +01:00
Holly Borla
48eb4b7714 [Availability] Lazily expand type refinement contexts for extensions. 2024-02-02 17:34:40 -08:00