Commit Graph

103491 Commits

Author SHA1 Message Date
Allan Shortlidge
6e3a2d22c8 ModuleInterface: Canonicalize OS version numbers in loaded swiftinterfaces. 2025-06-10 22:11:05 -07:00
Allan Shortlidge
1a8d8413b4 AST: Canonicalize version numbers in @_originallyDefinedIn attributes. 2025-06-10 22:11:05 -07:00
Allan Shortlidge
e16c638fc3 AST: Warn for non-existent platform versions in @available attributes. 2025-06-10 22:11:05 -07:00
Allan Shortlidge
3f305a48c8 AST: Re-map macOS 16 aligned availability versions to 26.
- watchOS 12 -> 26
- visionOS 3 -> 26
- macos 16 -> 26
- iOS 19 -> 26
- tvOS 19 -> 26

The version numbers for `if #available(...)` queries are intentionally not
re-mapped.
2025-06-10 22:11:05 -07:00
Andrew Trick
c2271e2cf1 Merge pull request #82137 from atrick/fix-moveonly-storeborrow
Fix MoveOnlyWrappedTypeEliminator handling of store_borrow.
2025-06-10 14:18:52 -07:00
Slava Pestov
7bbb29938e AST: Remove no longer necessary checks of getSuperclassForDecl() result 2025-06-10 16:49:57 -04:00
Slava Pestov
3b6ee7cf0b RequirementMachine: Add an assert 2025-06-10 16:49:57 -04:00
Slava Pestov
5cdc9a6570 AST: More robust TypeBase::getSuperclassForDecl()
This can return ErrorType if the AST is invalid.

A handful of callers handle the ErrorType result, but most don't,
blindly assuming the result is always a nominal type. This resulted
in a crash in at least one test case.

Lift the burden from callers by always returning a nominal type here.
2025-06-10 16:49:57 -04:00
Slava Pestov
3796b327a5 AST: Relax assertion in getContextSubstitutionMap() 2025-06-10 16:49:57 -04:00
Gábor Horváth
7c5888c566 Merge pull request #82144 from swiftlang/gaborh/using-shadow-decl-mangling 2025-06-10 20:40:22 +01:00
Pavel Yaskevich
dbe19b6d5f [TypeChecker] Remove @_inheritActorContext effect from synchronous types
The compiler would previously accept use of `@_inheritActorContext`
on a parameter with a synchronous function type which wasn't marked
as `@isolated(any)`. That is incorrect because in such cases the
attribute has no effect and furthermore would prevent Sendable
and isolation checking.

Uses like that are currently diagnosed by the type-checker but we
need to go one step further and remove the effect in such case to
prevent invalid uses.

Resolves: rdar://143581268
2025-06-10 10:15:37 -07:00
Henrik G. Olsson
bd714f57fc [ClangImporter] Look through bounds attributes for template matching
When instantiating templated functions with pointers to the templated
type, the ClangImporter does not strip type sugar. This strips type
sugar for bounds attributes, to make sure that they import the same
regardless of whether they are parsed or not.

rdar://151041990
2025-06-10 18:11:47 +02:00
Michael Gottesman
f31236931b Change send-never-sendable of isolated partial applies to use SIL level info instead of AST info.
The reason I am doing this is that we have gotten reports about certain test
cases where we are emitting errors about self being captured in isolated
closures where the sourceloc is invalid. The reason why this happened is that
the decl returned by getIsolationCrossing did not have a SourceLoc since self
was being used implicitly.

In this commit I fix that issue by using SIL level information instead of AST
level information. This guarantees that we get an appropriate SourceLoc. As an
additional benefit, this fixed some extant errors where due to some sort of bug
in the AST, we were saying that a value was nonisolated when it was actor
isolated in some of the error msgs.

rdar://151955519
2025-06-10 08:09:32 -07:00
Hamish Knight
4b2af07ec6 Merge pull request #82118 from hamishknight/excode
[cmake] Remove remaining `XCODE` checks
2025-06-10 16:01:56 +01:00
Gabor Horvath
059051cf69 [cxx-interop] Fix crash in ASTMangler triggered by UsingShadowDecls
We did not handle this declaration kind. This PR introduces makes sure
we mangle it the same way we do for the target declaration.

Fixes #82108.
2025-06-10 15:50:54 +01:00
susmonteiro
848fad0021 [cxx-interop] Support for printing C++ foreign references 2025-06-10 12:15:21 +01:00
Andrew Trick
16fffd1704 Fix MoveOnlyWrappedTypeEliminator handling of store_borrow.
Defer visiting an instruction until its operands have been visited. Otherwise,
this pass will crash during ownership verification with invalid operand
ownership.

Fixes rdar://152879038 ([moveonly] MoveOnlyWrappedTypeEliminator ownership
verifier crashes on @_addressableSelf)
2025-06-09 19:45:09 -07:00
Meghana Gupta
7d454533a0 Merge pull request #82067 from meg-gupta/lifetimeunderscored
Update spelling for representing lifetime dependencies to @_lifetime
2025-06-09 19:01:31 -07:00
Allan Shortlidge
26d589e099 Merge pull request #82075 from tshortli/diagnose-unrecognized-availability-domains-as-errors
AST: Diagnose unrecognized platforms as errors with `CustomAvailability` enabled
2025-06-09 18:22:30 -07:00
Hamish Knight
8f4fbe3d9a [cmake] Remove remaining XCODE checks
I missed these when ripping out support for CMake Xcode project
generation.
2025-06-09 22:16:12 +01:00
QuietMisdreavus
0cc46765ec [SymbolGraphGen] distinguish between headers of the same name in different modules (#82112)
Resolves rdar://152676102

In Objective-C, it's reasonable to sort extensions of your dependency's
types into headers that match the name of that type. However, this runs
into a bug in SymbolGraphGen when it comes time to generate Swift symbol
graphs for that Objective-C code: At the moment, it only differentiates
between modules based on their base name, regardless of their parent
modules (if any). This causes these extensions to be incorrectly sorted
into the _extending module's_ symbol graph, rather than in an extension
symbol graph where it can be displayed with the _extended module_. When
processed with Swift-DocC, it would cause these symbols to disappear.

This PR updates the `areModulesEqual` function used by the
`SymbolGraphASTWalker` to consider the fully-qualified module name for
comparisons, rather than just the module's base name, causing situations
like the test's `Dependency.DependencyClass` and
`HeaderCollision.DependencyClass` to be properly distinguished from each
other.
2025-06-09 15:11:31 -06:00
Qiongsi Wu
1b003b2c51 Revert "[Dependency Scanning] Update Uses of ModuleDeps::ClangModuleDeps #81243" (#81658)
This reverts commit 024dbd040f, reversing
changes made to a08b1cbb1d.

The commit did not solve the fundamental issue we need to handle and is
no longer necessary.

rdar://144794793

<!--
If this pull request is targeting a release branch, please fill out the
following form:

https://github.com/swiftlang/.github/blob/main/PULL_REQUEST_TEMPLATE/release.md?plain=1

Otherwise, replace this comment with a description of your changes and
rationale. Provide links to external references/discussions if
appropriate.
If this pull request resolves any GitHub issues, link them like so:

  Resolves <link to issue>, resolves <link to another issue>.

For more information about linking a pull request to an issue, see:

https://docs.github.com/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue
-->

<!--
Before merging this pull request, you must run the Swift continuous
integration tests.
For information about triggering CI builds via @swift-ci, see:

https://github.com/apple/swift/blob/main/docs/ContinuousIntegration.md#swift-ci

Thank you for your contribution to Swift!
-->
2025-06-09 08:36:35 -07:00
Pavel Yaskevich
a5d92bc346 Merge pull request #82053 from xedin/rdar-150689994
[Diagnostics] Correctly diagnose situations when immutable value is passed to `inout` parameter
2025-06-09 00:12:13 -07:00
Konrad `ktoso` Malawski
21291a41bd Merge pull request #82009 from ktoso/wip-fix-computed-variables-arm64-protocol-dist 2025-06-09 12:14:37 +09:00
Saleem Abdulrasool
c66d43e1c5 ClangImporter: enhance the importer to alias declarations
Import simple CPP macro aliases as aliases in Swift. Extend the macro
importer to import the following construct:

  ```
  #define alias aliasee
  ```

as the following Swift construct:

  ```
  @_transparent @inline(__always)
  var alias: type(of: aliasee) {
    aliasee
  }
  ```

This improves the QoI for Windows where there is a universal define
(`UNICODE`) which normally is used for translating APIs between ANSI and
Unicode variants, e.g.:

  ```
  #if defined(UNICODE)
  #define MessageBox MessageBoxW
  #else
  #define MessageBox MessageBoxA
  #endif
  ```

Global variables which are non-const also have a setter synthesized:

  ```
  @_transparent @inline(__always)
  var alias: type(of: aliasee) {
    get { return aliasee }
    set { aliasee = newValue }
  }
  ```
2025-06-08 12:45:40 -07:00
Meghana Gupta
dcf072f9d0 Introduce a new suppressible experimental feature to guard @_lifetime 2025-06-07 12:49:07 -07:00
Meghana Gupta
0dfa1fc312 Update spelling for representing lifetime dependencies to @_lifetime 2025-06-07 12:49:07 -07:00
Slava Pestov
28af54a778 Merge pull request #80913 from stzn/fix-crash-self-keypath-root
[SILGen]Check if baseType is DynamicSelfType
2025-06-06 22:35:47 -04:00
Allan Shortlidge
85444fd1e5 AST: Diagnose unrecognized platforms as errors with CustomAvailability enabled.
When the CustomAvailability experimental feature is enabled, make it an error
to specify an unrecognized availability domain name. Also, add these
diagnostics to a diagnostic group so that developers can control their behavior
when they are warnings.

Resolves rdar://152741624.
2025-06-06 17:30:01 -07:00
Anthony Latsis
d10dfb3ae9 Merge pull request #82020 from AnthonyLatsis/camellia-sinensis
Sema: Never record argument label mismatches for unlabeled trailing closures
2025-06-07 01:29:54 +01:00
Pavel Yaskevich
74471e858b [ClangImporter] Use DefaultsToSendable with completion handler parameter
This lifts the check for the feature flag up into the `importParameterType`
from `importType` and means that completion handler type for `async` variant
is no longer gains `@Sendable` attribute.
2025-06-06 17:08:22 -07:00
Gábor Horváth
a2a760ab27 Merge pull request #82019 from swiftlang/gaborh/ambiguous-overloads
[cxx-interop] Support _LIBCPP_PREFERRED_OVERLOAD
2025-06-06 23:44:23 +01:00
Saleem Abdulrasool
083cb114b3 Merge pull request #82065 from compnerd/import-shims
ClangImporter: import SwiftShims properly for static linking
2025-06-06 15:05:04 -07:00
Pavel Yaskevich
6bbc101a98 [Diagnostics] Correctly diagnose situations when immutable value is passed to inout parameter
Currently the note is going to point to the "callee" but that is
incorrect when the failure is related to an argument of a call.

Detect this situation in `RValueTreatedAsLValueFailure::diagnoseAsNote`
and produce a correct note.

Resolves: rdar://150689994
2025-06-06 14:36:19 -07:00
Pavel Yaskevich
aa92bcf9b0 Merge pull request #82004 from xedin/rdar-151911135
[Concurrency] Fix `SendableMetatype` conformance failures to behave l…
2025-06-06 14:07:55 -07:00
John McCall
237e617fab Merge pull request #82008 from rjmccall/dont-copy-print-options
Prevent PrintOptions from being implicitly copied
2025-06-06 17:06:02 -04:00
Arnold Schwaighofer
11942d70bd Merge pull request #81995 from aschwaighofer/fix_looprotate_densemap_subscript_bug
LoopRotate: Fix a by reference map bug under reallocation
2025-06-06 12:56:10 -07:00
Artem Chikin
8c8a754145 Merge pull request #82030 from artemcm/FixSILOptCycleCmake
Resolve unit test link error due to a build cycle
2025-06-06 12:46:40 -07:00
Steven Wu
debdd224d5 Merge pull request #81990 from cachemeifyoucan/eng/PR-152441866
[CAS] Allow uncached job from CAS based dependency scanning
2025-06-06 12:08:21 -07:00
nate-chandler
17798c781f Merge pull request #82043 from nate-chandler/rdar152580661
[TypeLowering] Record pack used in aggregate signature.
2025-06-06 11:37:24 -07:00
Allan Shortlidge
21fa0b4024 Merge pull request #82046 from tshortli/back-deployed-attr-remap
AST: Fix iOS -> visionOS version remap for `@backDeployed` attrs
2025-06-06 11:30:25 -07:00
Gabor Horvath
27879c7bfa [cxx-interop] Support _LIBCPP_PREFERRED_OVERLOAD
Some functions like memchr are defined both in libc++ and libc.
Including both would result in ambiguous references at the call sites.
This is worked around by an attribute that tells the compiler to prefer
one overload over the others. This attribute was not interpreted by
Swift. As a result, importing both libc and libc++ and calling such
functions resulted in compilation errors due to ambiguous overloads.
This PR modifies the lookup logic to exclude the non-preferred Clang
functions from the overload set whenever a preferred overload is
available.

rdar://152192945
2025-06-06 18:05:35 +01:00
Artem Chikin
10cd7baef0 [Legacy Driver] Obsolete and remove batch compilation mode from the legacy driver
It is a maintenance burden and having the legacy driver exist in a simplified state reduces the possibility of things going wrong and hitting old bugs.
2025-06-06 09:51:00 -07:00
Saleem Abdulrasool
43b2b596fe ClangImporter: import SwiftShims properly for static linking
When building against the static standard library, we should define
`SWIFT_STATIC_STDLIB` to indicate to the shims that the declarations
should be giving hidden visibility and default DLL storage. This is
required to ensure that these symbols are known to be `dso_local` when
compiling to avoid an unnecessary look up through the PLT/GOT or the
indirection through the synthesized `__imp_` symbol and the IAT. This
corrects a number of incorrect code generation cases on Windows with the
static standard library.
2025-06-06 09:35:51 -07:00
Gábor Horváth
296726aa12 Merge pull request #82016 from swiftlang/gaborh/swiftify-private
[cxx-interop] Avoid swiftifying private and protected methods
2025-06-06 17:19:46 +01:00
Gábor Horváth
e2ab10b1ab Merge pull request #81973 from swiftlang/gaborh/disable-non-aliased-instantiations
[cxx-interop] Only swiftify template instantiations behind type aliases
2025-06-06 17:18:10 +01:00
Pavel Yaskevich
aaf153d7a1 [Concurrency] Fix SendableMetatype conformance failures to behave like Sendable ones
No warnings with minimal checking, warnings with `strict-concurrency=complete` and
if declaration is `@preconcurrency` until next major swift version.

Resolves: rdar://151911135
Resolves: https://github.com/swiftlang/swift/issues/81739
2025-06-06 08:48:29 -07:00
Pavel Yaskevich
f5b30b06b8 Merge pull request #82034 from xedin/rdar-152665294
[Demangle] Implement missing `Node::Kind::OutlinedInitializeWithTakeN…
2025-06-06 08:21:25 -07:00
Pavel Yaskevich
86d036ddca Merge pull request #81960 from xedin/rdar-146027395
[Concurrency] Downgrade errors to warnings when `Sendable` requirement is inferred from a preconcurrency protocol
2025-06-06 08:20:45 -07:00
eeckstein
a33ff9879a Merge pull request #81969 from eeckstein/temp-lvalue-elimination
Optimizer: improve TempLValueOpt
2025-06-06 15:30:29 +02:00