Commit Graph

1927 Commits

Author SHA1 Message Date
Qiongsi Wu
070a6f0973 Disable TestModuleCycle while we investigate the extra diagnostics. 2025-11-19 18:40:23 -08:00
Slava Pestov
b7e0083478 Sema: Handle leading dot before calling isViableForRanking() 2025-11-17 11:16:37 -05:00
Slava Pestov
403a11f79d Sema: Infer key path bindings before calling isViableForRanking()
This allows us to remove the key path check from isViableForRanking().
2025-11-17 11:16:37 -05:00
Slava Pestov
c0238dbb4c Sema: Split up BindingSet::inferTransitiveBindings() into three methods 2025-11-17 11:16:37 -05:00
Slava Pestov
45d03e152c Sema: Split up BindingSet::finalize() into finalizeKeyPathBindings() and finalizeUnresolvedMemberChain() 2025-11-17 11:16:33 -05:00
Slava Pestov
02129f2b1f Sema: Pull call to inferTransitiveBindings() out of BindingSet::finalize() 2025-11-17 11:16:32 -05:00
Slava Pestov
5f2db0c96c Sema: Pull call to determineLiteralCoverage() out of BindingSet::finalize() 2025-11-17 11:15:52 -05:00
Saleem Abdulrasool
c0d286c79e build: use the correct driver for building the unit tests
We would use `clang++` to build the tests rather than `clang-cl` which
should be preferred when building with the MSVC-like command line.
2025-11-10 13:17:49 -08:00
Mike Ash
a62f08e050 [Concurrency] Add environment variable for disabling async stack slab allocator.
Add SWIFT_DEBUG_ENABLE_TASK_SLAB_ALLOCATOR, which is on by default. When turned off, async stack allocations call through to malloc/free. This allows memory debugging tools to be used on async stack allocations.
2025-11-07 22:48:41 -05:00
John McCall
13937fdb4e Merge pull request #84528 from rjmccall/async-let-runtime-realism
Model async let begin/finish as builtins in SIL
2025-11-05 10:24:46 -08:00
Kavon Farvardin
c06c72a510 unittests: skip some tests on AL2 due to rdar://163604876
It's blocking the Swift CI job https://ci.swift.org/job/oss-swift-package-amazon-linux-2-aarch64/
2025-11-03 15:14:09 -08:00
Kavon Farvardin
3351b936d3 NFC: add explainer on how to disable unit tests 2025-11-03 14:46:04 -08:00
John McCall
3cfda35b7c Remove the unused swift_asyncLet_{start,end,wait,wait_throwing} runtime
functions.

These were introduced in an early draft implementation of async let, but
never used by a released compiler. They are not used as symbols by any
app binaries. There's no reason to keep carrying them.

While I'm at it, dramatically improve the documentation of the remaining
async let API functions.
2025-11-03 13:45:18 -08:00
Alastair Houghton
237a7d53a7 Merge pull request #85234 from al45tair/eng/PR-163661576
[Tests][Threading] Allow 1‰ error in wait times.
2025-11-03 10:30:12 +00:00
Alastair Houghton
7206dfadbf [Tests][Threading] Allow 1‰ error in wait times.
Ideally this should not be an issue and we should always return
strictly *after* the time we waited for.  In practice it can
happen, for mathematics related reasons, that the time isn't
entirely precise, so allow a one thou error.

rdar://163661576
2025-10-31 09:55:39 +00:00
Guillaume Lessard
d4a9b3f14c Merge pull request #85080 from KushalP/stack-use-after-scope-TaskQueueTest
Fix ASAN stack-use-after-scope errors `Basic/TaskQueueTest.cpp`
2025-10-24 09:38:04 -07:00
Guillaume Lessard
4bc3d6a695 Merge pull request #85083 from KushalP/TaskQueueTest-fix-race
TaskQueue(Test): Add destructor to close FDs, preventing resource leak, fix race in TaskSignalHandling test
2025-10-24 09:31:51 -07:00
Hamish Knight
8397a7a61d Merge pull request #84907 from hamishknight/fixed-point
[CS] Penalize implicit pointer conversions to generic parameter types
2025-10-24 15:56:07 +01:00
Kushal Pisavadia
3dcfdaf531 TaskQueueTest: Fix race condition in TaskSignalHandling test
Replace `sleep` with `condition_variable` synchronization to ensure the child
PID is captured before attempting to kill it. This eliminates timing
dependencies.
2025-10-23 12:57:20 +01:00
Kushal Pisavadia
c2a1a20cac Fix ASAN stack-use-after-scope errors Basic/TaskQueueTest.cpp
The issue was that in three tests, the `Args` arrays were being declared inside
for loops.

When `TQ.addTask()` was called, it stored a pointer to the `Args` array. As the
`Args` array was declared in the loop, it would go out of scope at the end of
each iteration whilst `TaskQueue` held a pointer to it.
2025-10-23 11:00:27 +01:00
Michael Gottesman
828bf45e4e [rbi] Ensure that we error when two 'inout sending' parameters are in the same region at end of function.
The caller is allowed to assume that the 'inout sending' parameters are not in
the same region on return so can be sent to different isolation domains safely.
To enforce that we have to ensure on return that the two are /actually/ not in
the same region.

rdar://138519484
2025-10-17 12:07:09 -07:00
Hamish Knight
77a59383f7 [CS] Penalize implicit pointer conversions to generic parameter types
We ought to consider outright banning these conversions if the
destination is a generic parameter type, but for now let's penalize
them such that we don't end up with ambiguities if you're doing an
implicit pointer conversion through an identity generic function.

rdar://161205293
2025-10-16 14:14:53 +01:00
Artem Chikin
5e77606173 Merge pull request #84633 from KushalP/TaskQueueTest
Add tests for `lib/Basic/TaskQueue.cpp`
2025-10-13 11:52:58 -04:00
Allan Shortlidge
4e9a883824 AST: Rename SwiftLanguage availability domain kind to SwiftLanguageMode. 2025-10-08 15:46:34 -07:00
Kushal Pisavadia
1075d8c957 Add tests for lib/Basic/TaskQueue.cpp
Validates scenarios like single task execution, parallel task execution,
execution failure handling, and covers the `DummyTaskQueue` fall back.
2025-10-01 21:51:22 +01:00
Erik Eckstein
2f124cf564 Remove the -enable-ossa-modules option.
OSSA modules are enabled by default.
The compiler still accepts this option but it has no effect.
2025-09-26 08:01:08 +02:00
Artem Chikin
c73869e479 Do not fail the build on only finding incompatible-architecture modules on 'canImport'
This change refactors the module loaders to explicitly take a parameter indicating whether or not the loader is handling a 'canImport' query, in order to avoid emitting an error when finding a dependency Swift binary module with only imcompatible architecture variants present.

Resolves rdar://161175498
2025-09-23 15:26:02 -07:00
Owen Voorhees
e6c9dceae9 Update OS versions requiring stdlib OS rpaths 2025-09-21 09:47:18 -07:00
Artem Chikin
926fc78b4c Merge pull request #84191 from artemcm/InMemoryDepScanSerializedDiagnostics
[Dependency Scanning] Configure a serialized diagnostics consumer for in-memory scans
2025-09-15 11:54:44 -04:00
Artem Chikin
50c0dd844f [Dependency Scanning] Refactor 'createScanQueryContext' to directly return an error 2025-09-12 15:50:40 -07:00
Daniel Rodríguez Troitiño
8dbac56f82 [unittests] Fix compilation of Runtime unittests (#84235)
PR#78516 performed a rename from `swiftRuntime` to `swiftRuntimeCore`
but might have skipped these two instances because the code is rarely
compiled in Darwin platforms (and it is not compiled in Linux/Windows
platforms either). The code on the runtime unittests seems to be
associated with the SDK overlays being built (either static or dynamic),
which none are for Darwin platforms by default. Other platforms should
build the dynamic SDK overlay, but the file is surrounded with checks
for `__APPLE__` and `__MACH__`.

The normal CI would never hit this file, but someone might while
building the static or dynamic SDK overlay if they so request it to the
`build-script`.
2025-09-12 15:07:23 -07:00
Artem Chikin
c82048559a [Dependency Scanning] Configure a thread-safe serialized diagnostics consumer for in-memory scans
This change introduces a thread-safe version of the 'SerializedDiagnosticConsumer' and refactors scanning compilation instance creation code to ensure this consumer gets added when the scanner query configuration command-line includes '-serialized-diagnostics-path' option.
2025-09-11 09:50:24 -07:00
Hamish Knight
c02c69a783 [AST] Introduce CaseStmt::createImplicit
This allows us to re-use the same logic to create the case body
variables.
2025-09-09 13:48:40 +01:00
Hamish Knight
23560df5f4 [CS] Remove AllowUnresolvedTypeVariables
This has been unused for a while now.
2025-09-07 12:17:18 +01:00
Artem Chikin
1cd1193e6c [Dependency Scanning] Give each scanner worker a unique Diagnostic Engine
Otherwise, when multiple workers encounter a diagnostic simultaneously we can encounter races which lead to corrupted diagnostic data or crashes

Resolves rdar://159598539
2025-09-03 13:52:44 -07:00
Michael Gottesman
391ad21583 [rbi] Make all PartitionOpErrors noncopyable types.
I am going to be adding support to passes for emitting IsolationHistory behind a
flag. As part of this, we need to store the state of the partition that created
the error when the error is emitted. A partition stores heap memory so it makes
sense to make these types noncopyable types so we just move the heap memory
rather than copying it all over the place.
2025-08-29 15:18:55 -07:00
Michael Gottesman
8745ab00de [rbi] Teach RegionIsolation how to properly error when 'inout sending' params are returned.
We want 'inout sending' parameters to have the semantics that not only are they
disconnected on return from the function but additionally they are guaranteed to
be in their own disconnected region on return. This implies that we must emit
errors when an 'inout sending' parameter or any element that is in the same
region as the current value within an 'inout sending' parameter is
returned. This commit contains a new diagnostic for RegionIsolation that adds
specific logic for detecting and emitting errors in these situations.

To implement this, we introduce 3 new diagnostics with each individual
diagnostic being slightly different to reflect the various ways that this error
can come up in source:

* Returning 'inout sending' directly:

```swift
func returnInOutSendingDirectly(_ x: inout sending NonSendableKlass) -> NonSendableKlass {
  return x // expected-warning {{cannot return 'inout sending' parameter 'x' from global function 'returnInOutSendingDirectly'}}
  // expected-note @-1 {{returning 'x' risks concurrent access since caller assumes that 'x' and the result of global function 'returnInOutSendingDirectly' can be safely sent to different isolation domains}}
}
```

* Returning a value in the same region as an 'inout sending' parameter. E.x.:

```swift
func returnInOutSendingRegionVar(_ x: inout sending NonSendableKlass) -> NonSendableKlass {
  var y = x
  y = x
  return y // expected-warning {{cannot return 'y' from global function 'returnInOutSendingRegionVar'}}
  // expected-note @-1 {{returning 'y' risks concurrent access to 'inout sending' parameter 'x' since the caller assumes that 'x' and the result of global function 'returnInOutSendingRegionVar' can be safely sent to different isolation domains}}
}
```

* Returning the result of a function or computed property that is in the same
region as the 'inout parameter'.

```swift
func returnInOutSendingViaHelper(_ x: inout sending NonSendableKlass) -> NonSendableKlass {
  let y = x
  return useNonSendableKlassAndReturn(y) // expected-warning {{cannot return result of global function 'useNonSendableKlassAndReturn' from global function 'returnInOutSendingViaHelper'}}
  // expected-note @-1 {{returning result of global function 'useNonSendableKlassAndReturn' risks concurrent access to 'inout sending' parameter 'x' since the caller assumes that 'x' and the result of global function 'returnInOutSendingViaHelper' can be safely sent to different isolation domains}}
}
```

Additionally, I had to introduce a specific variant for each of these
diagnostics for cases where due to us being in a method, we are actually in our
caller causing the 'inout sending' parameter to be in the same region as an
actor isolated value:

* Returning 'inout sending' directly:

```swift
extension MyActor {
  func returnInOutSendingDirectly(_ x: inout sending NonSendableKlass) -> NonSendableKlass {
    return x // expected-warning {{cannot return 'inout sending' parameter 'x' from instance method 'returnInOutSendingDirectly'}}
    // expected-note @-1 {{returning 'x' risks concurrent access since caller assumes that 'x' is not actor-isolated and the result of instance method 'returnInOutSendingDirectly' is 'self'-isolated}}
  }
}
```

* Returning a value in the same region as an 'inout sending' parameter. E.x.:

```swift
extension MyActor {
  func returnInOutSendingRegionLet(_ x: inout sending NonSendableKlass) -> NonSendableKlass {
    let y = x
    return y // expected-warning {{cannot return 'y' from instance method 'returnInOutSendingRegionLet'}}
    // expected-note @-1 {{returning 'y' risks concurrent access to 'inout sending' parameter 'x' since the caller assumes that 'x' is not actor-isolated and the result of instance method 'returnInOutSendingRegionLet' is 'self'-isolated}}
  }
}
```

* Returning the result of a function or computed property that is in the same region as the 'inout parameter'.

```swift
extension MyActor {
  func returnInOutSendingViaHelper(_ x: inout sending NonSendableKlass) -> NonSendableKlass {
    let y = x
    return useNonSendableKlassAndReturn(y) // expected-warning {{cannot return result of global function 'useNonSendableKlassAndReturn' from instance method 'returnInOutSendingViaHelper'; this is an error in the Swift 6 language mode}}
    // expected-note @-1 {{returning result of global function 'useNonSendableKlassAndReturn' risks concurrent access to 'inout sending' parameter 'x' since the caller assumes that 'x' is not actor-isolated and the result of instance method 'returnInOutSendingViaHelper' is 'self'-isolated}}
  }
}
```

To implement this, I used two different approaches depending on whether or not
the returned value was generic or not.

* Concrete

In the case where we had a concrete value, I was able to in simple cases emit
diagnostics based off of the values returned by the return inst. In cases where
we phied together results due to multiple results in the same function, we
determine which of the incoming phied values caused the error by grabbing the
exit partition information of each of the incoming value predecessors and seeing
if an InOutSendingAtFunctionExit would emit an error.

* Generic

In the case of generic code, it is a little more interesting since the result is
a value stored in an our parameter instead of being a value directly returned by
a return inst. To work around this, I use PrunedLiveness to determine the last
values stored into the out parameter in the function to avoid having to do a
full dataflow. Then I take the exit blocks where we assign each of those values
and run the same check as we do in the direct phi case to emit the appropriate
error.

rdar://152454571
2025-08-25 14:57:44 -07:00
Anthony Latsis
90f9fce339 Merge pull request #82665 from swiftlang/jepa4
Bridging: Bridge some basic classes like `swift::SourceLoc` directly
2025-07-16 08:27:12 +01:00
Anthony Latsis
2b37e96e22 unittests: Build runtime unit tests with -DGTEST_NO_LLVM_SUPPORT
...to work around error building `unittests/runtime` on Linux.

`stdlib/include/llvm/Support` headers, a subset of
`llvm-project/llvm/include/llvm/Support`, are not compatible with the
latter.

Since we favor stdlib headers here, this makes sure Support headers will
not be transitively included through gtest, and helps to avoid mixed
includes, where a Support header existing only in LLVM is picked from
LLVM, whereas a Support header existing in both of the aforementioned
directories is picked from our stdlib.
2025-07-15 00:40:44 +01:00
Anthony Latsis
06a5670c8f Basic: Untie swift::SourceLoc from llvm::SMLoc
Storing a `llvm::SMLoc` is a superfluous indirection, and getting rid of
it enables us to unconditionally import `SourceLoc` into Swift.
2025-07-11 18:48:42 +01:00
Artem Chikin
a78ee29692 [Dependency Scanning] Remove obsolete placeholder module concept
This was used a long time ago for a design of a scanner which could rely on the client to specify that some modules *will be* present at a given location but are not yet during the scan. We have long ago determined that the scanner must have all modules available to it at the time of scan for soundness. This code has been stale for a couple of years and it is time to simplify things a bit by deleting it.
2025-06-12 08:32:25 -07:00
Ben Barham
381684a389 [SourceKit] Remove diagnostics path calculation
The diagnostic group documentation now point to the swift.org URL rather
than the toolchain path, so it no longer needs to be passed all the way
through sourcekitd.

Resolves rdar://151500502.
2025-05-16 17:58:16 -07:00
Pavel Yaskevich
3854e61c49 Merge pull request #81428 from xedin/rename-some-task-apis
[stdlib] SE-0472: Rename `Task` and`*TaskGroup` APIs to match the pro…
2025-05-12 09:13:11 -07:00
Pavel Yaskevich
001eab867d [stdlib] SE-0472: Rename Task and*TaskGroup APIs to match the proposal
`Task.startSynchronously` -> `Task.immediate`
`*TaskGroup.startTaskSynchronously{UnlessCancelled}` -> `*TaskGroup.addImmediateTask{UnlessCancelled}`
2025-05-09 23:59:30 -07:00
Alejandro Alonso
02d9779ba3 Merge pull request #81184 from Azoy/no-more-is-array-type
[AST] Rename isArrayType and split the InlineArray portion
2025-05-08 20:52:51 -07:00
Slava Pestov
6b4710ed22 Merge pull request #81142 from slavapestov/more-type-subst-cleanup
Clean up duplicated opened existential archetype handling in SIL and more
2025-04-30 02:42:57 -04:00
Pavel Yaskevich
2dca45feec Merge pull request #81149 from xedin/rename-adoptable-to-migratable
[Basic] Features: Align "migration" mode with the latest proposal draft
2025-04-29 16:38:12 -07:00
Alejandro Alonso
e68b398d41 Rename isArrayType and split the InlineArray portion 2025-04-29 15:57:10 -07:00
Konrad 'ktoso' Malawski
6872707574 [embedded][Concurrency] Further refine C-api boundary for isIsolating... 2025-04-29 22:29:26 +09:00
Pavel Yaskevich
1ba077d922 [Feature] Switch migration postfix from :adoption to :migrate 2025-04-28 13:08:24 -07:00