Commit Graph

184973 Commits

Author SHA1 Message Date
Andrew Trick
eab76a4f65 Merge pull request #82049 from atrick/lifedep-fix-yield
LifetimeDependenceScopeFixup: handle yielded value copies.
2025-06-06 06:04:49 -07:00
Slava Pestov
f387e35e1d Merge pull request #82048 from slavapestov/fix-rdar127120469
ASTPrinter: Fix printing of let properties inside @objc @implementation extensions
2025-06-06 08:47:50 -04:00
Karoy Lorentey
e47397730b Merge pull request #81458 from lorentey/range-contains-perf
[stdlib] Mark `contains` methods on `Range/ClosedRange` transparent
2025-06-06 04:12:18 -07:00
Gabor Horvath
6eb7057e75 [cxx-interop] Avoid swiftifying private and protected methods
The generated overloads do not get seralized and later on the compiler
crashes due to the missing body of the SILFunction. This PR works this
problem around by not generating these overloads. We plan to address the
serialization issue later.

rdar://152181531
2025-06-06 11:07:01 +01:00
Hamish Knight
c4e88f5f43 [test] Add a few more known type-checker crashers 2025-06-06 10:57:53 +01:00
Gabor Horvath
868c85d5f0 [cxx-interop] Only swiftify template instantiations behind type aliases
While I could not trigger a scenario where the generated macro triggers
a compilation error, the generated code is definitely not valid Swift.

rdar://151422108
2025-06-06 10:31:52 +01:00
Allan Shortlidge
d787888a61 Merge pull request #82032 from tshortli/language-modes-and-features-in-module-trace
Frontend: Add language mode and enabled features to `.SWIFT_TRACE`
2025-06-06 00:41:43 -07:00
Michael Gottesman
4b06d1ecf4 Merge pull request #82029 from gottesmm/pr-4393908bd2ab4d5c84cd415ea5da407b148fceb1
[silgen] Teach SILGen how to emit a forced dynamic member ref given nonisolated(nonsending) casts.
2025-06-05 23:51:47 -07:00
Slava Pestov
4d977535ff Merge pull request #82011 from slavapestov/clang-importer-assert
AST: Add assertion to BuiltinLiteralExpr::setBuiltinInitializer()
2025-06-06 02:50:57 -04:00
Alex Hoppen
ff483fe092 Merge pull request #81941 from ahoppen/dont-verify-mangle
[Indexing] Don't verify mangling of USRs
2025-06-06 08:36:28 +02:00
Pavel Yaskevich
622475bf15 [ConstraintSystem] Look through ArgumentAttribute element when computing a callee
This element is used purely for diagnostic purposes and locator
should behavior as if it's completely transparent.
2025-06-05 22:30:46 -07:00
Andrew Trick
227f8028e8 LifetimeDependenceScopeFixup: handle yielded value copies.
When extending an access scope over a coroutines, instead of simply
considering the lifetime of the coroutine scope, recurse through all
uses of yielded values. They may be copyable, non-Escapable values
that depend on the coroutine operand.

Fixes rdar://152693622 (Extend coroutines over copied yields)
2025-06-05 20:21:40 -07:00
Andrew Trick
d9eff0c2e1 Merge pull request #81989 from atrick/enable-addressable-tests
Enable lifetime dependence tests for @_addressable.
2025-06-05 20:20:01 -07:00
Andrew Trick
95f7a12c98 [NFC] LifetimeDependence: fix internal debug output 2025-06-05 20:09:06 -07:00
Slava Pestov
0b3fd9eede ASTPrinter: Fix printing of let properties inside @objc @implementation extensions
A `let` here is really just a `var` with a `{ get }`.

Fixes rdar://problem/127120469.
2025-06-05 23:07:04 -04:00
Karoy Lorentey
ff3cf98a2d [stdlib] ClosedRange.contains: Leave this force-inlined, not transparent
Making it transparent evidently induces new retain/release traffic in Array’s subscript, even though I can find no indication that `ClosedRange.contains` is ever called by that code path. Oh well.
2025-06-05 19:42:20 -07:00
Allan Shortlidge
924eb4898b AST: Fix iOS -> visionOS version remap for @backDeployed attrs.
The version remapping for `@backDeployed` regressed due to a bug introduced by
https://github.com/swiftlang/swift/pull/81922.

Also, fix some visionOS tests that have gotten out of date because we don't
seem to be running them in CI.

Resolves rdar://152542983.
2025-06-05 19:19:07 -07:00
Ben Barham
7b4d1bc076 Merge pull request #82018 from al45tair/fix-freestanding-deployment-version
[Build] Fix the minimal-stdlib build by setting a deployment version.
2025-06-05 18:41:19 -07:00
Doug Gregor
55d5de6218 Fix more typos 2025-06-05 18:10:43 -07:00
Doug Gregor
a5554a4840 Fix typos 2025-06-05 18:10:01 -07:00
Nate Chandler
dfcb5ee147 [TypeLowering] Record pack used in aggregate sig.
Every `LowerType::visit*` function eventually calls through to a
`LowerType::handle*` function.  After
https://github.com/swiftlang/swift/pull/81581, every
`LowerType::handle*` needs to set the `hasPack` flag based on the
passed-in type by calling `mergeHasPack`.  Add the missing call in the
`handleAggregateByProperties` function.

rdar://152580661
2025-06-05 17:33:59 -07:00
John Hui
f9e71d6770 [NFC] Silence unused variable warning in assert()
Clang complains that paramIndicesLength is unused. This block is already
guarded by CONDITIONAL_ASSERT_enabled(), so promoting assert() to
ASSERT() should not affect the behavior of assertions-disabled builds.
2025-06-05 17:01:05 -07:00
Doug Gregor
9ab0c57ee9 Improve SendableMetatype documentation 2025-06-05 16:53:55 -07:00
Ben Barham
32ec5a61b7 Add groupings for the various diagnostics
Also make the titles and one line summaries a little more consistent (at
least for diagnsotic groups and upcoming language features, haven't gone
through the educational notes).
2025-06-05 15:49:46 -07:00
Konrad 'ktoso' Malawski
cedcd4afc6 [Distributed] enable additional testing in library evolution mode
We had a number of problems either "only in" or "only without" library
evolution and protocols, so in order to increase the test coverage, run
a few of the crucial tests in both modes.
2025-06-06 07:06:11 +09:00
Steven Wu
8d5d758676 [CAS] Allow uncached job from CAS based dependency scanning
Create a path that swift-frontend can execute an uncached job from
modules built with CAS based explicit module build. The new flag
-import-module-from-cas will allow an uncached build to load module
from CAS, and combined with source file from real file system to build
the current module. This allows quick iterations that bypasses CAS,
without full dependency scanning every time in between.

rdar://152441866
2025-06-05 14:55:42 -07:00
Pavel Yaskevich
8e49860349 [Demangle] Implement missing Node::Kind::OutlinedInitializeWithTakeNoValueWitness
Implements de/remangler support for `WOB` manglings.
2025-06-05 14:07:05 -07:00
Allan Shortlidge
a019419467 Frontend: Add language mode and enabled features to .SWIFT_TRACE.
To allow tooling to analyze use of language mode and experimental/upcoming
features, add that information to the `.SWIFT_TRACE` file.

Resolves rdar://152673681.
2025-06-05 13:47:24 -07:00
Artem Chikin
b4d0fc2e15 Resolve unit test link error due to a build cycle
We currently hit the following errors when attempting to link unit tests:
```
Undefined symbols for architecture arm64:
  "swift::ConstExprEvaluator::ConstExprEvaluator(swift::SymbolicValueAllocator&, unsigned int, bool)", referenced from:
      BridgedConstExprFunctionState::create() in libswiftSIL.a[63](SILBridging.cpp.o)
  "swift::ConstExprEvaluator::~ConstExprEvaluator()", referenced from:
      BridgedConstExprFunctionState::deinitialize() in libswiftSIL.a[63](SILBridging.cpp.o)
  "swift::ConstExprFunctionState::getConstantValue(swift::SILValue)", referenced from:
      BridgedConstExprFunctionState::isConstantValue(BridgedValue) in libswiftSIL.a[63](SILBridging.cpp.o)
  "swift::ConstExprFunctionState::ConstExprFunctionState(swift::ConstExprEvaluator&, swift::SILFunction*, swift::SubstitutionMap, unsigned int&, bool)", referenced from:
      BridgedConstExprFunctionState::create() in libswiftSIL.a[63](SILBridging.cpp.o)
```

There is an implicit cyclic dependency here between `libswiftSIL` and `libswiftSILOptimizer`, which is okay to have at link time as long as these are static archives and as long as respective archives are specified explicitly on the linker invocation. This change achives that.

Resolves rdar://150944677
2025-06-05 13:41:11 -07:00
Michael Gottesman
662dbdb55a [silgen] Teach SILGen how to emit a forced dynamic member ref given nonisolated(nonsending) casts.
Specifically, I taught SILGen how to emit an AST like the following:

```
(force_value_expr implicit type="nonisolated(nonsending) (Date?) async -> Void" implicit_iuo_unwrap
  (open_existential_expr implicit type="(nonisolated(nonsending) (Date?) async  -> Void)?"
    (opaque_value_expr implicit type="AnyObject")
    (declref_expr type="AnyObject" decl="test.(file).repro().anyObject@test.swift:6:7" function_ref=unapplied)
    (optional_evaluation_expr type="(nonisolated(nonsending) (Date?) async -> Void)?"
      (inject_into_optional type="(nonisolated(nonsending) (Date?) async -> Void)?"
        (function_conversion_expr type="nonisolated(nonsending) (Date?) async -> Void"
          (bind_optional_expr type="(Date?) async -> Void" depth=0
            (dynamic_member_ref_expr type="((Date?) async -> Void)?" decl="__ObjC.(file).Foo.start(at:)"
              (opaque_value_expr type="AnyObject"))))))))
```

Since we are emitting an objc async function, there isn't an extra implicit
parameter like if we were using a swift async function. So, I just reused code
that was already used locally to look through these sorts of conversions. I
just had to add to that code support for conversions that add
nonisolated(nonsending). Previously it only supported looking through global
actor conversions.

rdar://152596823
2025-06-05 13:34:42 -07:00
Fabrice de Gans
209984f110 line-directive: Actually stop expanding response files
The changes in #81996 fixed the response file format but failed to
actually make `line-directive` stop expanding the response files in the
compiler invocation. These changes fix that.
2025-06-05 12:02:24 -07:00
Pavel Yaskevich
3495c61840 [Diagnostics] Use contains instead of has when non-Sendable type appears inside of a member type 2025-06-05 11:14:55 -07:00
Pavel Yaskevich
6d45229367 [Concurrency] Downgrade errors to warnings when Sendable requirement is inferred from a preconcurrency protocol
If a type gets `Sendable` conformace requirement through another
`@preconcurrency` protocol the error should be downgraded even
with strict concurrency checking to allow clients time to address
the new requirement.

Resolves: rdar://146027395
2025-06-05 11:13:38 -07:00
Pavel Yaskevich
7cca7225a1 [Concurrency] NFC: Rename ImpliedByStandardProtocol to ImpliedByPreconcurrencyProtocol
The new name better reflects the intention for this Sendable check kind.
2025-06-05 11:13:37 -07:00
Pavel Yaskevich
e24196e365 [Concurrency] Clean-up duplicate code in checkSendableInstanceStorage 2025-06-05 11:13:37 -07:00
Anthony Latsis
f2e1420a90 Sema: Never record argument label mismatches for unlabeled trailing closures
Fixes a crash on invalid. The previous logic was causing a label
mismatch constraint fix to be recorded for an unlabeled trailing closure
argument matching a variadic paramater after a late recovery argument
claim in `matchCallArgumentsImpl`, because the recovery claiming skips
arguments matching defaulted parameters, but not variadic ones. We may
want to reconsider that last part, but currently it regresses the
quality of some diagnostics, and this is a targeted fix.

The previous behavior is fine because the diagnosis routine associate
with the constraint fix (`diagnoseArgumentLabelError`) skips unlabeled
trailing closures when tallying labeling issues — *unless* there are no
other issues and the tally is zero, which we assert it is not.

Fixes rdar://152313388.
2025-06-05 18:01:20 +01:00
Saleem Abdulrasool
68524a8a62 Merge pull request #81951 from Steelskin/fabrice/ucrt-modulemap-26100-3916
Platform: Windows SDK 26100.3916 module map update
2025-06-05 10:00:06 -07:00
Anthony Latsis
7c431c9a9a [NFC] Make a function static 2025-06-05 17:59:34 +01:00
John McCall
b3493bfa23 Prevent PrintOptions from being implicitly copied.
NFC *except* that I noticed a bug by inspection where we suppress
`@escaping` when print enum element types. Since this affects
recursive positions, we end up suppressing `@escaping` in places
we shouldn't. This is unlikely to affect much real code, but should
still obviously be fixed.

The new design is a little sketchy in that we're using `const` to
prevent direct use (and allow initialization of `const &` parameters)
but still relying on modification of the actual object.  Essentially,
we are treating the `const`-ness of the reference as a promise to leave
the original value in the object after computation rather than a
guarantee of not modifying the object. This is okay --- a temporary
bound to a `const` reference is still a non-`const` object formally
and can be modified without invoking UB --- but makes me a little
uncomfortable.
2025-06-05 12:52:01 -04:00
Fabrice de Gans
b6ba8e5e54 line-directive: Update outdated comment 2025-06-05 09:32:46 -07:00
Doug Gregor
67b55566fe Merge pull request #82005 from DougGregor/generalize-checked-cast-options
[SIL] Generalize CastingIsolatedConformances to CheckedCastInstOptions
2025-06-05 08:43:09 -07:00
Henrik G. Olsson
89b09a69e4 Merge pull request #81752 from hnrklssn/swiftify-sized-sizedby
[Swiftify] Support __sized_by on byte-sized pointee types
2025-06-05 08:42:42 -07:00
Saleem Abdulrasool
11dc3d1ca1 Merge pull request #81996 from Steelskin/fabrice/line-directive-stop-expanding-rsp
line-directive: Stop expanding response files
2025-06-05 08:22:24 -07:00
Alex Hoppen
062aaaad53 Merge pull request #81981 from ahoppen/getexpandedattrs
[IDE] Use `getExpandedAttrs` instead of `getSemanticAttrs` to get custom attributes of a declaration
2025-06-05 14:32:56 +02:00
Erik Eckstein
70ba193cd4 SIL: handle drop_deinit in WalkUtils
Also, handle some other missing instructions in the AddressDefUseWalker, which are visited in the AddressUseDefWalker.

This enables various other optimizations, like copy elimination, in the presence of `drop_deinit`.

rdar://152307747
2025-06-05 14:13:51 +02:00
Andrew Trick
765204db66 Merge pull request #81992 from atrick/fix-lifedep-indirect-closure
LifetimeDependenceDiagnostics: diagnose indirect closure results.
2025-06-05 05:11:24 -07:00
Alastair Houghton
df35df17ce [Build] Fix the minimal-stdlib build by setting a deployment version.
We need to set a deployment version, not just blank, because otherwise
we don't know the correct deployment target to use for the standard
library.
2025-06-05 13:09:43 +01:00
Alex Hoppen
021cdd4416 Merge pull request #81975 from ahoppen/sema-annotate-source-range 2025-06-05 13:49:54 +02:00
Mykola (Nickolas) Pokhylets
87e536ebec Merge pull request #80440 from nickolas-pohilets/mpokhylets/weak-let 2025-06-05 09:59:33 +02:00
Konrad 'ktoso' Malawski
30d54531a7 [Distributed] Don't drop dist get accessors from witness tables.
This actually manifested as an pointer auth crash, but the real reason
being is that we messed up the order of elements in the witness table.
If we'd skip the accessor like this, the types we sign/auth with would
no longer align and manifest in a crash.

There is no real reason to skip this entry so we just bring it back, and
avoid making this special in any way.

This unlocks a few tests as well as corrects any distributed+protocol
use where a requirement distributed var was _followed by_ other
requirements.

resolves rdar://125628060
2025-06-05 16:58:00 +09:00