Commit Graph

184973 Commits

Author SHA1 Message Date
Doug Gregor
a32782bcbc Make InferIsolatedConformances a migratable upcoming feature
When migrating, provide warnings that add 'nonisolated' to nonisolated
conformances that don't already have it and would end up being inferred
to be isolated under the upcoming feature.
2025-05-22 11:07:13 +01:00
Anton Korobeynikov
799e0f81b0 [AutoDiff] Correct propagate adjoints for array literal values (#81676)
Fixes #81607
2025-05-22 03:03:28 -07:00
John Hui
828876f4ec Merge pull request #81625 from j-hui/fix-unavailable-enum 2025-05-22 00:01:30 -07:00
Andrew Trick
c65016d307 Unit test the LifetimeDependence feature diagnostic. 2025-05-21 22:56:58 -07:00
Andrew Trick
6cc1a8d880 Diagnostic message: suppress printing "requires LifetimeDependence"
Adopters of the new Span and MutableSpan types should not encounter information
about an experimental feature when they attempt to use these types in
unsupported ways, such as simply returning them from a function.

Fixes rdar://151788740 (Diagnostic message: suppress printing "requires
'-enable-experimental-feature LifetimeDependence'")
2025-05-21 22:56:57 -07:00
eeckstein
021bd4a2c4 Merge pull request #81684 from eeckstein/fix-mark-dependence-addr
SIL: define `mark_dependence_addr` to read and write to its address operand
2025-05-22 07:10:24 +02:00
finagolfin
8e40f0b380 Merge pull request #81695 from finagolfin/lto
[test] Fix IRGen/lto_autolink on Darwin arm64 platforms too
2025-05-22 10:01:24 +05:30
Artem Chikin
16c3ab5094 Merge pull request #81651 from artemcm/CxxUnderlyingStdLibLookupRemap
[Dependency Scanning][C++ Interop] Remap lookup of Clang module `CxxStdlib` to `std`
2025-05-21 19:25:11 -07:00
Karoy Lorentey
a7830d754a Merge pull request #80870 from lorentey/stdlib-version-6.3
[stdlib][runtime] Establish Swift Stdlib/runtime version 6.3
2025-05-21 17:48:22 -07:00
Eric Miotto
80bc75d046 Merge pull request #81687 from edymtt/edymtt/prefer-configs-in-supplemental-build-in-ci
[Runtimes][CMake] use config mode first in Supplemental build in CI
2025-05-21 16:57:53 -07:00
michael-yuji
9a948a9c3b Merge branch 'main' into mchiu/freebsd 2025-05-21 16:29:16 -07:00
Meghana Gupta
dbe548d4e1 Fix use-after-free on substituting function type involving conditional ~Escapable with Escapable type 2025-05-21 15:40:49 -07:00
Pavel Yaskevich
efc6efc4ed [CSApply] Don't inject global actor into closure type if it's marked as @concurrent
When the attribute is specified explicitly passing a `@concurrent`
closure to a global actor-isolated parameter or contextual type
should result in a conversion and closure itself should be nonisolated.

Resolves: rdar://151797372
2025-05-21 15:22:03 -07:00
Slava Pestov
8b8aafb798 Sema: Don't complain about implied Sendable conformance of imported type being retroactive
- Fixes rdar://145184871.
2025-05-21 18:04:43 -04:00
John Hui
89f8855ad6 [cxx-interop] Check for NS_OPTIONS macro in findOptionSetEnum()
importer::findOptionSetEnum() uses some fragile heuristics to determine
whether a typedef is involved in the construction of a CF_OPTIONS or
NS_OPTIONS type. This patch adds an explicit check that the typedef is
expanded from either of those macros, to prevent, e.g., an unavailable
NS_ENUM, from being mistakenly recognized as an NS_OPTIONS.

Note that doing this is still kind of fragile, and prevents users from
building {NS,CF}_OPTIONS with their own macros. The right thing to do is
probably specifically look for the flag_enum attribute, but that is not
currently what we're doing for reasons whose discovery is left as
an exercise to the future git archaeologist.

This patch also removes (part of) a test case that builds
a CF_OPTIONS-like type with the "SOME_OPTIONS" macro, which is no longer
supported as of this patch.

rdar://150399978
2025-05-21 15:01:09 -07:00
Artem Chikin
c4ee4d967f Merge pull request #81681 from artemcm/ReEnableClangArgsSDKSettingsFileTest
[Test] Fix and re-enable test to account for change in clang dependency scanner results
2025-05-21 14:36:34 -07:00
Slava Pestov
a232a2d1e3 Sema: Fix diagnoseRetroactiveConformances() to handle protocol compositions 2025-05-21 17:25:56 -04:00
nate-chandler
393465262b Merge pull request #81581 from nate-chandler/rdar147207926
[TypeLowering] Record packs used in signatures.
2025-05-21 13:37:10 -07:00
Artem Chikin
24f2975db6 Merge pull request #81510 from artemcm/ConstSyntacticVerify
[Compile Time Values] Add syntactic verification of valid expressions in `@const` contexts
2025-05-21 13:22:05 -07:00
Karoy Lorentey
1434440d63 [test] We also export protocol descriptors on x86_64 2025-05-21 13:14:35 -07:00
Eric Miotto
58a782b98b [Runtimes][CMake] use config mode first in Supplemental build in CI
In this configuration we want to pull dependencies from the current
build, not from the underlying SDK.

Addresses rdar://151784135
2025-05-21 12:20:13 -07:00
Andrew Trick
e240dd55d3 Merge pull request #81656 from atrick/lifedep-inout-infer
Allow passing MutableSpan 'inout' without an experimental feature.
2025-05-21 11:47:58 -07:00
Susana Monteiro
e805d93d95 Merge pull request #81035 from swiftlang/susmonteiro/metadata-private-fields
[cxx-interop] Fix metadata mismatch regarding fields of structs
2025-05-21 19:25:08 +01:00
Erik Eckstein
e0f5888a8d SIL: define mark_dependence_addr to read and write to its address operand
This prevents simplification and SILCombine passes to remove (alive) `mark_dependence_addr`.
The instruction is conceptually equivalent to
```
  %v = load %addr
  %d = mark_dependence %v on %base
  store %d to %addr
```

Therefore the address operand has to be defined as writing to the address.
2025-05-21 20:03:53 +02:00
nate-chandler
bbe9f65c76 Merge pull request #81654 from nate-chandler/update-checkout/20250520/1
[update-checkout] Gracefully degrade timestamp matching.
swift-DEVELOPMENT-SNAPSHOT-2025-05-21-a
2025-05-21 10:36:50 -07:00
Doug Gregor
689491c933 Merge pull request #81675 from DougGregor/unsafe-pattern-match
[Strict memory safety] Lift "unsafe" in pattern match expressions
2025-05-21 18:18:26 +01:00
John Hui
fa5c4f298f [cxx-interop] Remove NDEBUG check when importing OptionSetTypes 2025-05-21 10:18:05 -07:00
John Hui
80db05455f [cxx-interop] Fix assertion failure from unavailable NS_ENUM typedef
The NS_OPTIONS macro sometimes uses a pattern where it loosely
associates a typedef with an anonymous enum via a shared underlying
integer type (emphasis on "loosely"). The typedef is marked as
unavailable in Swift so as to not cause name ambiguity when we associate
the anonymous enum with said typedef. We use unavailability as
a heuristic during the import process, but that conflates NS_OPTIONS
with NS_ENUMs that can be marked as unavailable for entirely unrelated
reasons.

That in and of itself is fine, because the import logic is general
enough to handle both cases, but we have an assertion that seems to be
unaware of this scenario, and trips on unavailable NS_ENUMs. (In those
cases, the typedef points to the enum rather than the underlying integer
type.) This patch fixes the assertion to be resilient against such cases
by looking through the enum a typedef refers to.

rdar://150399978
2025-05-21 10:16:11 -07:00
Andrew Sukach
1a144932a7 XFAIL Interop/cxx/stdlib/use-std-function.swift on Amazon Linux 2023 2025-05-21 10:11:09 -07:00
Hamish Knight
352caa4ddc [Completion] NFC: Factor out addMacroCallArguments 2025-05-21 18:06:54 +01:00
Hamish Knight
7522a3ea5b [SourceKit] Handle CustomAttrs arguments for placeholder expansion
Introduce a new ASTWalker option for walking CustomAttrs and use it
for the placeholder scanner to ensure we can expand placeholders in
attribute arguments.
2025-05-21 18:06:54 +01:00
Hamish Knight
60952784fc [SourceKit] Handle macro arguments in placeholder expansion
Allow macro argument placeholders to expand into trailing closures.

rdar://150550747
2025-05-21 18:06:54 +01:00
Jan Svoboda
35e4fa8cf2 [ModuleInterface] Ignore SDKSettings.json in "sourceFiles" 2025-05-21 10:03:09 -07:00
Artem Chikin
c4fcee0875 [Dependency Scanning][C++ Interop] Remap lookup of Clang module 'CxxStdlib' to 'std'
Otherwise querying this clang module, e.g. from the corresponding Swift overlay's underlying module import, will fail, since no such module exists.

Resolves rdar://151718115
2025-05-21 09:54:28 -07:00
Anton Korobeynikov
bc94ac3342 [AutoDiff] Better diagnose non-differentiability for throwing functions (#81669)
Fixes #81608
2025-05-21 09:13:18 -07:00
Anthony Latsis
de15dc6ddd Merge pull request #81671 from AnthonyLatsis/caranx-melampygus
InFlightDiagnostic: Minor improvement to `fixItAddAttribute`
2025-05-21 17:06:17 +01:00
Eric Miotto
64da069187 [Runtimes][CMake] Rename SwiftCore target to swiftCore
This matches the case that we use in the Runtimes build system, so we
rely the exported target instead of adding `-lswiftCore`.

Addresses rdar://151700669
2025-05-21 08:52:15 -07:00
Mishal Shah
0d0ba1d0ff Merge pull request #81652 from hborla/concurrency-error-summary
[Diagnostics] Add a brief summary to the documentation for several concurrency errors.
2025-05-21 08:35:49 -07:00
Mike Ash
8de4c809bd Merge pull request #81642 from mikeash/typeref-decoding-asan-chained-fixups
[Test] Disable chained fixups for typeref_decoding_asan.swift.
2025-05-21 09:46:09 -04:00
Doug Gregor
d5476aeda0 Improve diagnostic for unsafe call arguments
Use the argument type rather than the (potentially generic) parameter type.
2025-05-21 13:46:17 +01:00
Doug Gregor
d4dc36d2f3 [Strict memory safety] Lift "unsafe" in pattern match expressions
When an "unsafe" expression is used as the case expression, lift it up
so it also covers the synthesized matching expression (`=~`). This
eliminates some unsuppressible strict memory safety warnings.

Fixes rdar://151731850.
2025-05-21 13:46:17 +01:00
Egor Zhdan
5583f93de3 Merge pull request #81614 from swiftlang/egorzhdan/silverifier-trivial-frt
[cxx-interop] Relax a SILVerifier assertion for immortal reference types
2025-05-21 12:59:55 +01:00
Anthony Latsis
eedc774fca InFlightDiagnostic: Minor improvement to fixItAddAttribute
Do not follow `in` keyword with a space unless the first token inside
the body begins with the next char after `{`.
2025-05-21 12:11:19 +01:00
Andrew Trick
c04e555858 Update test: protocols.swift for LifetimeDependence evaluation
Evaluating LifetimeDependence changes the order that the declarations are
diagnosed. Fix this test output by flipping the order of two declarations. The
new order actually makes more sense to me.
2025-05-21 00:25:00 -07:00
Andrew Trick
754edc7b8c Type checker: ignore LifetimeDependenceRequest in cycle diagnostic
When reporting the declarations that lead to a cycle, we end up printing an
extra "through reference here" on the function declaration:

class C2: C1, P {
   |       |- note: through reference here
   |       `- note: through reference here
15 |     // expected-note@-1 2{{through reference here}}
16 |     override func run(a: A) {}
   |                   |   |  `- note: while resolving type 'A'
   |                   |   `- note: through reference here
   |                   |- error: circular reference
   |                   |- note: through reference here
   |                   `- note: through reference here
2025-05-21 00:25:00 -07:00
Andrew Trick
f66c04056f Allow passing MutableSpan 'inout' without an experimental feature.
This adds a new lifetime inference rule, loosening the requirement for @lifetime
annotations even when the experimental LifetimeDependence mode is
enabled. Additionally, it enables this new inference rule even when the
experimental mode is disabled. All other inference rules continue to require the
experimental feature. The rule is:

If a function or method has a single inout non-Escapable parameter other than
'self' and has no other non-Escapable parameters including 'self', then infer a
single @lifetime(copy) dependency on the inout parameter from its own incoming
value.

This supports the common case in which the user of a non-Escapable type,
such as MutableSpan, wants to modify the span's contents without modifying
the span value itself. It should be possible to use MutableSpan this way
without requiring any knowledge of lifetime annotations. The tradeoff is
that it makes authoring non-Escapable types less safe. For example, a
MutableSpan method could update the underlying unsafe pointer and forget to
declare a dependence on the incoming pointer.

Disallowing other non-Escapable parameters rules out the easy mistake of
programmers attempting to trivially reassign the inout parameter. There's
is no way to rule out the possibility that they derive another
non-Escapable value from an Escapable parameteter. So users can still write
the following:

    func reassign(s: inout MutableSpan<Int>, a: [Int]) {
      s = a.mutableSpan
    }

The 'reassign' declaration will type check, but it's implementation will
diagnose a lifetime error on 's'.

Fixes rdar://150557314 ([nonescapable] Declaration of inout MutableSpan
parameter requires LifetimeDependence experimental feature)
2025-05-21 00:25:00 -07:00
Mishal Shah
ef74028c85 Merge pull request #81666 from rintaro/disable-rdar151740742
[Test] Disable failing test case
2025-05-20 23:04:09 -07:00
Becca Royal-Gordon
aed46eb81d Merge pull request #81668 from swiftlang/rdar151740686
XFAIL clang-args-transitive-availability.swift
2025-05-20 21:51:35 -07:00
Becca Royal-Gordon
6a9e2d40d3 XFAIL clang-args-transitive-availability.swift
It is failing, probably due to swiftlang/llvm-project#10679. See rdar://151740686.
2025-05-20 21:50:30 -07:00
Rintaro Ishizaki
86e0b45efe [Test] Disable failing test case
rdar://151740742
2025-05-20 21:42:29 -07:00