Commit Graph

195786 Commits

Author SHA1 Message Date
Egor Zhdan
21440b3fa9 Merge pull request #85867 from egorzhdan/egorzhdan/iterator-invalidation
[cxx-interop] Fix iterator invalidation
2025-12-06 18:31:05 +00:00
Max Desiatov
fb0ec64b2d Merge pull request #85835 from MaxDesiatov/embedded-wasm-mutex 2025-12-06 13:35:39 +00:00
Jamie
87aab10541 [test]: update existing tests for SingleValueExpr fixit 2025-12-06 05:18:24 -06:00
Jamie
8b591aecc9 [Sema]: add no_async_in_await fixit for SingleValueExpr too 2025-12-06 04:39:32 -06:00
Jamie
2c4e26b94f [test]: update existing tests for new fixit 2025-12-06 04:05:44 -06:00
Tim Kientzle
ea6c81f17b Disable some tests on wasm32 for now 2025-12-06 09:07:08 +00:00
Tim Kientzle
827d0620b6 Test that legacy ABI still works 2025-12-06 09:04:16 +00:00
Tim Kientzle
02665c7f74 Expand NaN testing a little 2025-12-06 09:04:16 +00:00
Tim Kientzle
919bedb1d0 Enable test debugging 2025-12-06 09:04:16 +00:00
Tim Kientzle
4dcf2ce592 Don't expect Float16 functions on macOS
Because these support functions used to be implemented in C, they could
be present on macOS x86_64, even though Float16 isn't supported
there otherwise.  With the new Swift implementation, we can't define
these functions on x86_64 macOS, so remove them from the expected list.
2025-12-06 09:04:15 +00:00
Tim Kientzle
2c67a0b5d2 Float16 is unsupported on macOS x86_64, so disable tests there 2025-12-06 09:04:15 +00:00
Tim Kientzle
7084ab8e6e Express the core parser functions as initializers 2025-12-06 09:04:14 +00:00
Tim Kientzle
f48aa4a627 Make Float16 support conditional on Swift 5.3 2025-12-06 09:04:14 +00:00
Tim Kientzle
09cad0dbcd Disable this code on 16-bit platforms 2025-12-06 09:04:14 +00:00
Tim Kientzle
7d5fff34fc Fix 16-bit build 2025-12-06 09:04:13 +00:00
Tim Kientzle
c5ab343358 Fix the backwards-compatibility stubs 2025-12-06 09:04:13 +00:00
Tim Kientzle
c8f12e69e2 Fix up some comments 2025-12-06 09:04:13 +00:00
Tim Kientzle
93eb82c9a3 [Embedded] Reimplement Float16/32/64 parsing in Swift
This reimplements the underlying support for `Float16(_:StringSlice)`,
`Float32(_:StringSlice)`, and `Float64(_:StringSlice)` in pure Swift,
using the same core algorithm currently used by Apple's libc.  Those
`StringSlice` initializers are in turn used by `Float16(_:String)`,
`Float32(_:String)`, and `Float64(_:String)`.

**Supports Embedded**: This fully supports Embedded Swift and
insulates us from variations in libc implementations.

**Corrects bugs in Float16 parsing**: The previous version of
`Float16` parsing called libc `strtof()` to parse to a 32-bit float,
then rounded to `Float16`. (This was necessary because float16
parsing functions are not widely supported in C implementations.)
This double-rounding systematically corrupted NaN payloads and
resulted in 1 ULP errors for certain decimal and hexadecimal inputs.
The new version parses `Float16` directly, avoiding these errors.

**Modest perforamnce improvement**:  The old version had to copy
the Swift string to construct a C string.  For inputs longer than
15 characters, this typically required a heap allocation, which added
up to 20% to the runtime.  The new version parses directly from a Swift
string, avoiding this copy and heap allocation.
2025-12-06 09:04:12 +00:00
Mike Ash
b4dedb2d83 Merge pull request #85880 from AZero13/nonatomic
swift_nonatomic_unknownObjectRelease should use swift_nonatomic_release
2025-12-06 02:05:59 -05:00
Kavon Farvardin
a42d520656 Merge pull request #85850 from kavon/suppressed-assoc-types-with-defaults-2
Test: additional test coverage for SuppressedAssociatedTypesWithDefaults
2025-12-05 22:03:37 -08:00
AZero13
bef81c9ee5 swift_nonatomic_unknownObjectRelease should use swift_nonatomic_release
This appears to be a typo. Thankfully, it is not a correctness issue, as the atomic version does the same thing just slower.
2025-12-05 20:56:06 -05:00
Pavel Yaskevich
f0fd506745 [Diagnostics] TildeSendable: Suggest Sendable suppression in explicit Senable warning
Add a note to missing explicit `Sendable` conformance warning
(produced by `-Wwarning ExplicitSendable`) and a fix-it with
a suggestion to suppress `Senable` conformance  via `~Sendable`.
2025-12-05 17:20:55 -08:00
John Hui
6c80c68075 [ClangImporter] Do not import function decl if already imported via type signature (#85480)
This is a small incremental patch that is designed to address the issue
discovered by 9aa3c5d17c, which is that we
are importing various Decls multiple times.

rdar://164616956
2025-12-05 17:18:58 -08:00
Augusto Noronha
e3c67c905a [RemoteInspection] Read ContextDescriptor from symbol if available
If the MemoryReader can provide a symbol for the context descriptor, use
that instead of building the mangle tree from metadata. This shouldn't
hurt other clients, and would have a few benefits for LLDB:

- Small but numerous memory reads can be expensive for LLDB, building
  the mangle tree from a string should be much faster.

- For types with private discriminators, this allows LLDB to provide the
  same private discriminator that's in DWARF and in the swiftmodule (as
  opposed to using the memory address where the context descriptor lives
  at). This means that these private types would have the same mangled
  name in every run. LLDB persistently caches field descriptors by name,
  but since private discriminators aren't guaranteed to have the same
  mangled name over multiple runs, LLDB would often need to invalidate
  its entire cache and rebuild it. Using the stable UUID would solve
  that issue.

rdar://165950673
2025-12-05 17:14:30 -08:00
Alexis Laferrière
e3571eb833 Sema: Allow SPI references from implicitly public layouts 2025-12-05 17:13:52 -08:00
Kavon Farvardin
c3861247c4 Test: additional test coverage for SuppressedAssociatedTypesWithDefaults 2025-12-05 17:05:21 -08:00
Augusto Noronha
d468b5f017 Merge pull request #85823 from augusto2112/use-anonymous-address
[RemoteInspection] Use the address returned by resolveRemoteAddress
2025-12-05 16:56:20 -08:00
Ben Barham
b29a0a9b3d Fix up the userdocs index
A few docs weren't added to the index, re-run the generation and fix the
test to actually run in order to catch future issues.
2025-12-06 10:18:19 +10:00
Artem Chikin
3f0732f0d9 Merge pull request #85849 from artemcm/FixScanDepsPerfRegression
[Dependency Scanning] Do not re-query a given clang module identifier more than once
2025-12-05 14:33:49 -08:00
Pavel Yaskevich
7c32c2a21b [CSRanking] Disambiguate static vs. instance method that used to be supported by a performance hack
Handle the following situation:

```swift
struct S {
   func test() {}
   static func test(_: S) {}
}
```

Calling `S.test(s)` where `s` has a type `S` without any other context
should prefer a complete call to a static member over a partial
application of an instance once based on the choice of the base type.

The behavior is consistent for double-applies as well i.e.
`S.test(s)()` if static method produced a function type it would be
preferred.

Resolves: rdar://165862285
2025-12-05 13:27:53 -08:00
Slava Pestov
bf3170691e Merge pull request #85863 from slavapestov/fix-rdar165909327
Sema: Re-visit @specialize attribute where clause in interface resolution stage
2025-12-05 16:21:35 -05:00
Arnold Schwaighofer
4764ad70e7 Fix typos/needless whitespace 2025-12-05 13:10:54 -08:00
eeckstein
e987c925f7 Merge pull request #85855 from eeckstein/fix-silcombine
DeadCodeElimination,SILCombine: don't insert destroys for removed values in dead-end blocks
2025-12-05 22:04:07 +01:00
Arnold Schwaighofer
81dfb754ba [embedded] Apply shared linkage to metadata of public types in embedded with existential mode
We generate public metadata lazily which implies it could be emitted into a
different module. If we emit metadata for a public type into a module
other than its "home module" apply "shared" linkage.
2025-12-05 13:03:34 -08:00
Eric Miotto
817a890a67 CMake Android: ensure _Builtin_float is built before _math
_math would be able to build against either the Swift or the clang
module for _Builtin_float; however the build will fail if the Swift
module is present but does not contain the architectures we need, with errors
like

```
<unknown>:0: error: could not find module
'_Builtin_float' for target 'armv7-unknown-linux-android'; found:
aarch64-unknown-linux-android, x86_64-unknown-linux-android, at:
/home/build-user/build/swift-project/Ninja-Release/swift-linux-x86_64/lib/swift/android/_Builtin_float.swiftmodule/armv7-unknown-linux-android
```

In other words, in this situation we are not falling back to the clang
module.

Addresses rdar://165768601
2025-12-05 12:58:06 -08:00
Henrik G. Olsson
4419ce5bbd Merge pull request #85528 from hnrklssn/diag-verify-fixes
[DiagnosticVerifier] improve output for expansions in clang attributes
2025-12-05 12:51:29 -08:00
Slava Pestov
d57a38be0a Sema: Fix latent bug due to unhandled cases in constraints::simplifyLocator() 2025-12-05 15:05:58 -05:00
eeckstein
d0f8ccef28 Merge pull request #85857 from eeckstein/fix-vtable-specialization
Embedded: allow generic class constructors
2025-12-05 20:17:52 +01:00
Andrew Trick
8cdef92334 Add a FIXME to CopyPropagation to highlight an incomplete fix. 2025-12-05 11:16:08 -08:00
Gabor Horvath
77187a04ab [cxx-interop] Introduce SWIFT_REFCOUNTED_PTR
This attribute introduces some conversions between the annotated smart
pointer type and the native swift reference type. In the future we plan
to introduce bridging so the smart pointer type can be hidden in the
signature and we can automatically convert it to the native Swift
reference type on the ABI boundaries.

This PR is using a new way to use swift_attr attributes. Instead of
doing the parsing in the clang importer it falls back to Swift's
attribute parsing and makes sure that the annotation has valid Swift
attribute syntax.

rdar://156521316
2025-12-05 18:19:10 +00:00
Egor Zhdan
69be33d3ba [cxx-interop] Remove compatibility versions
This removes the C++ interop compat version mechanism. It was added in mid-2023 and was never used. It complicates the testing story, and makes it harder to reason about the compiler's behavior. It also isn't compatible with explicit module builds.

The flag `-cxx-interoperability-mode` is preserved, so projects that use the flag will continue to build normally.

rdar://165919353
2025-12-05 18:01:09 +00:00
Egor Zhdan
b0ec567c0e [cxx-interop] Remove dead code: isCxxInteropCompatVersionAtLeast
rdar://165919353
2025-12-05 17:48:02 +00:00
Egor Zhdan
3015c39cae [cxx-interop] Fix iterator invalidation
This fixes an assertion failure in ClangImporter that was blocking bootstrapping of the FreeBSD toolchain.

Iterators pointing into `Impl.GetterSetterMap[result]` were being invalidated inside of the for-each loop.

I was unable to minimize the reproducer, so this doesn't include a test case.

rdar://164518108
2025-12-05 17:36:35 +00:00
Alexis Laferrière
8e04430498 Sema: Differentiate the reason for implictly public memory layouts 2025-12-05 09:25:37 -08:00
Pavel Yaskevich
767c569f89 Merge pull request #85847 from xedin/issue-84509-test-case
[Tests] NFC: Add a test-case for https://github.com/swiftlang/swift/i…
2025-12-05 09:24:17 -08:00
Arnold Schwaighofer
93ab16283b [embedded] Lazily emit class metadata in embedded mode 2025-12-05 09:03:16 -08:00
Ben Cohen
0f99458900 Allow Comparable: ~Copyable (#85747)
Builds on #85746 which covers Equatable
2025-12-05 08:37:36 -08:00
Erik Eckstein
c0017a2701 DeadCodeElimination: don't insert destroys for removed values in dead-end blocks
When an owned value has no lifetime ending uses it means that it is in a dead-end region.
We must not remove and inserting compensating destroys for it because that would potentially destroy the value too early.
Initialization of an object might be cut off and removed after a dead-end loop or an `unreachable`.
In this case a class destructor would see uninitialized fields.

Fixes a mis-compile
https://github.com/swiftlang/swift/issues/85851
rdar://165876726
2025-12-05 17:08:51 +01:00
Erik Eckstein
953d692e53 SILCombine: don't remove dead Array adoptStorage call
If followed by a dead infinite loop, the array initialization might have beed removed.
Therefore when inserting a compensating destroy of the array buffer can lead to a crash.

https://github.com/swiftlang/swift/issues/85851
rdar://165876726
2025-12-05 17:08:51 +01:00
Egor Zhdan
7fc815e383 [cxx-interop] Allow initializing std::function from Swift capturing closures
This introduces support for converting a Swift closure that captures variables from its surrounding context into an instance of `std::function`, which is useful for working with C++ APIs that use callbacks.

Each instantiation of `std::function` gets a synthesized Swift constructor that takes a Swift closure. Unlike the previous implementation, the closure is _not_ marked as `@convention(c)`. The body of the constructor is created lazily.

Under the hood, the closure is bitcast to a pair of a function pointer and a context pointer, which are then wrapped in a C++ object, `__SwiftFunctionWrapper`, that manages the lifetime of the context object via calls to `swift_retain`/`swift_release` from the copy constructor and the destructor. The `__SwiftFunctionWrapper` class is templated, and is instantiated by ClangImporter.

rdar://133777029
2025-12-05 15:41:59 +00:00