Commit Graph

46689 Commits

Author SHA1 Message Date
Allan Shortlidge
5d98ca63c7 Merge pull request #83168 from tshortli/custom-availability-domain-fix-its
AST/Sema: Generalize availability fix-its to support custom availability domains
2025-07-18 21:45:57 -07:00
Slava Pestov
4eaa7e3b47 AST: Add -max-substitution-count= and -max-substitution-depth= frontend flags 2025-07-18 20:03:03 -04:00
Slava Pestov
8d05d79fad AST: Cache substituted substitution maps inside the InFlightSubstitution
A substitution map contains conformances, and a conformance can contain
a substitution map. This will always be a DAG, but not a tree, and to
avoid exponential blowup in certain edge cases, let's cache the work to
avoid visiting the same substitution map repeatedly, if multiple
conformances refer to the same substitution map.
2025-07-18 20:03:03 -04:00
Slava Pestov
103428fe80 AST: More robust recursion check for opaque types with infinite underlying types
Tracking seen declarations and substitution maps only detects the
situation where the opaque type's underlying type contains itself
with the same substitution map. However, it is also possible to
recurse with a different substitution map.

In general termination is undecidable with a problem like this,
so instead of trying to catch cycles, just impose a termination
limit.

This converts a stack overflow into an assertion, which is still
not ideal; we should really diagnose something instead. But this
is a first step.
2025-07-18 20:03:03 -04:00
Slava Pestov
7a0ff5ccb6 AST: Add SubstitutionMap::DumpStyle::NoConformances and use it by default for opaque types 2025-07-18 19:12:34 -04:00
Slava Pestov
ef0164dcbd AST: Small cleanup for InFlightSubstitution 2025-07-18 19:12:33 -04:00
Artem Chikin
cf50dd0c1e Merge pull request #82552 from artemcm/ScannerDiagnoseWrontTargetCandidate
[Dependency Scanning] Discard and diagnose discovered binary modules built for an incompatible target
2025-07-18 15:52:15 -07:00
Augusto Noronha
95abf09e1d [NFC] Stack allocate buffer in readRemoteAddressImpl instead of malloc
Since this is only 4 or 8 bytes, it makes more sense (and is more
readable) to stack allocate the buffer instead of mallocking it.
2025-07-18 15:39:57 -07:00
Artem Chikin
8682ed3a74 Merge pull request #82934 from artemcm/DepScanExplicitInput
[Dependency Scanning] Consider `-swift-module-file` inputs when looking for dependencies
2025-07-18 15:30:12 -07:00
Allan Shortlidge
034c62cf01 AST: Generalize availability fix-its to support custom availability domains.
Resolves rdar://156118254.
2025-07-18 13:27:08 -07:00
Allan Shortlidge
aeb5a46d9e AST: Emit warnings for redundant availability checks in custom domains. 2025-07-18 13:27:08 -07:00
Allan Shortlidge
a3fbe3d530 AST: Introduce queries on Decl for active @available attrs.
Use these queries to replace some duplicated code. Also, move the
`attr_inlinable_available.swift` test to the `Availability` sub-directory since
the test has more to do with availability checking than it has to do
specifically with the `@inlinable` attr.
2025-07-18 13:27:08 -07:00
Allan Shortlidge
6b29700554 Merge pull request #83162 from tshortli/misc-availability-cleanups
Miscellaneous availability cleanups
2025-07-18 12:03:46 -07:00
Augusto Noronha
6d3d51f0db Merge pull request #83122 from augusto2112/virtual-read-remote-addr
[RemoteInspection] Make MemoryReader::readRemoteAddress virtual
2025-07-18 11:02:22 -07:00
Artem Chikin
bd14089551 Warn on multiple '-swift-module-file' options 2025-07-18 10:05:55 -07:00
Artem Chikin
e08b78226c [Dependency Scanning] Consider '-swift-module-file' inputs when looking for dependencies
Previously this flag was only used to pass explicit dependencies to compilation tasks. This change adds support for the dependency scanner to also consider these inputs when resolving dependencies.

Resolves https://github.com/swiftlang/swift-driver/issues/1951
2025-07-18 09:48:02 -07:00
Susana Monteiro
0337f7e64a Merge pull request #83067 from susmonteiro/rename-virtual-methods
[cxx-interop] Adding swift_name attributes to virtual methods overrides
2025-07-18 11:57:46 +01:00
Hamish Knight
33b58d25d8 [CS] NFC: Factor out Solution::hasAppliedSelf 2025-07-18 10:54:17 +01:00
eeckstein
8a689bb4d3 Merge pull request #82982 from augusto2112/templ-read-remote-addr
[NFC][RemoteMirrors] Add "template" in front of calls to readRemoteAddress
2025-07-18 08:19:14 +02:00
Allan Shortlidge
634f28176e AST: Move parentDeclForInferredAvailability() to Decl.
NFC.
2025-07-17 18:59:14 -07:00
Allan Shortlidge
4a7e76775a AST: Add llvm::raw_ostream conveniences for availability constructs.
Make it easier to debug availability by printing to output streams like
`llvm::errs()`.

NFC.
2025-07-17 18:59:01 -07:00
Gábor Horváth
4b9ef8c53c Merge pull request #83130 from Xazax-hun/objc-configurable-from-frontend
[cxx-interop] Configure requires ObjC from frontend option
2025-07-18 02:29:48 +01:00
Allan Shortlidge
d0929b67ce AST: Remove AvailabilityInference::isAvailableAsSPI().
It has been replaced by `Decl::isAvailableAsSPI()`.

NFC.
2025-07-17 14:14:21 -07:00
Gabor Horvath
4b64abdc45 [cxx-interop] Configure requires ObjC from frontend option
We sometimes don't have the information in the modulemaps whether a
module requires ObjC or not. This info is useful for reverse interop.
This PR introduces a frontend flag to have a comma separated list of
modules that we should import as if they had "requires ObjC" in their
modulemaps.
2025-07-17 21:29:50 +01:00
Steven Wu
fbfc7a6f71 Merge pull request #82745 from sina-mahdavi/sina-mahdavi/new-scanner-prefix-map-option
Add `-scanner-prefix-map-paths` to the frontend
2025-07-17 11:35:06 -07:00
Eric Miotto
4923ce817e Merge pull request #81529 from edymtt/edymtt/add-distributed-to-new-build-system-inert
[Runtimes][CMake] Add Distributed to Supplemental build
2025-07-17 08:51:20 -07:00
susmonteiro
585ca5e2da [cxx-interop] Adding swift_name attributes to virtual methods overrides 2025-07-17 16:23:32 +01:00
Allan Shortlidge
59b136ccc4 Merge pull request #83054 from tshortli/unavailable-setters-require-read-only-key-paths
ConstraintSystem: Make key paths for properties with unavailable setters read-only
2025-07-16 21:31:41 -07:00
Augusto Noronha
45d6d45623 [RemoteInspection] Make MemoryReader::readRemoteAddress virtual
Allow subclasses to override the behavior of readRemoteAddress. LLDB in
particular needs this to correctly set the address space of the result
remote address.

rdar://148361743
2025-07-16 21:29:46 -07:00
Artem Chikin
c8714b5627 [Dependency Scanning] Discard and diagnose discovered binary modules built for an incompatible target
Previously the scanner accepted binary modules regardless of what triple they were built for
2025-07-16 12:43:35 -07:00
Erik Eckstein
f962d76362 GenericSpecializer: don't pre-specialize C++ reference type for AnyObject
Reference counting is not compatible.
Fixes a runtime crash if a C++ reference type is put into an Array.

https://github.com/swiftlang/swift/issues/83082
rdar://155919841
2025-07-16 21:30:36 +02:00
Michael Gottesman
e18c68a552 Merge pull request #83083 from gottesmm/pr-e0e1571656b80b6c2d45f1a0cad842fbf6ae4800
[concurrency] Make optimize hop to executor more conservative for 6.2 around caller isolation inheriting functions.
2025-07-16 11:55:35 -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
Slava Pestov
de068cb130 Merge pull request #83070 from slavapestov/remove-redundant-functor
AST: Remove MakeAbstractConformanceForGenericType
2025-07-15 23:44:59 -04:00
Allan Shortlidge
fa267fefff Merge pull request #83051 from tshortli/diagnose-more-invalid-os-versions
Sema: Diagnose invalid platform versions in more places
2025-07-15 17:06:39 -07:00
Michael Gottesman
b3942424c8 [concurrency] Make optimize hop to executor more conservative for 6.2 around caller isolation inheriting functions.
Specifically for 6.2, we are making optimize hop to executor more conservative
around caller isolation inheriting functions. This means that we are:

1. No longer treating calls to caller isolation inheriting functions as having a
hop in their prologue. In terms of this pass, it means that when determining
dead hop to executors, we no longer think that a caller isolation inheriting
function means that an earlier hop to executor is not required.

2. Treating returns from caller isolation inheriting callees as requiring a
hop. The reason why we are doing this is that we can no longer assume that our
caller will hop after we return.

Post 6.2, there are three main changes we are going to make:

* Forward Dataflow

Caller isolation inheriting functions will no longer be treated as suspension
points meaning that we will be able to propagate hops over them and can assume
that we know the actor that we are on when we enter the function. Practically
this means that trees of calls that involve just nonisolated(nonsending) async
functions will avoid /all/ hop to executor calls since we will be able to
eliminate all of them since the dataflow will just propagate forward from the
entrance that we are already on the actor.

* Backwards Dataflow

A caller isolation inheriting call site will still cause preceding
hop_to_executor functions to be live. This is because we need to ensure that we
are on the caller isolation inheriting actor before we hit the call site. If we
are already on that actor, the hop will be eliminated by the forward pass. But
if the hop has not been eliminated, then the hop must be needed to return us to
the appropriate actor.

We will also keep the behavior that returns from a caller isolation inheriting
function are considered to keep hop to executors alive. If we were able to
propagate to a hop to executor before the return inst with the forward dataflow,
then we know that we are guaranteed to still be on the relevant actor. If the
hop to executor is still there, then we need it to ensure that our caller can
treat the caller isolation inheriting function as a non-suspension point.

rdar://155905383
2025-07-15 17:03:49 -07:00
Eric Miotto
7348469093 Cleanup CMakeConfig.h.in generation across the codebase
Addresses rdar://154230645
2025-07-15 14:44:40 -07:00
Allan Shortlidge
99380bf00f Sema: Sometimes allow universally unavailable declarations to be referenced.
In implicit contexts that are universally unavailable, allow writable key paths
to be formed to properties with setters that are also marked as universally
unavailable. This fixes a regression from the previous commit where the code
synthesized for `@Observable` properties in universally unavailable classes was
rejected by the availability checker.
2025-07-15 14:08:57 -07:00
Anthony Latsis
5620abbad8 Bridging: Bridge swift::CharSourceRange directly 2025-07-15 21:34:48 +01:00
Slava Pestov
ee440f3c91 AST: Remove MakeAbstractConformanceForGenericType
While the intent behind this functor was noble, it has grown in complexity
considerably over the years, and it seems to be nothing but a source of
crashes in practice. I don't want to deal with it anymore, so I've decided
to just subsume all usages with LookUpConformanceInModule instead.
2025-07-15 16:34:11 -04:00
Anthony Latsis
9001ce4687 Bridging: Bridge swift::SourceRange directly 2025-07-15 21:33:28 +01:00
Anthony Latsis
6eb5d7d857 Bridging: Bridge swift::SourceLoc directly 2025-07-15 21:33:06 +01:00
Sina Mahdavi
03843475c1 Add -scanner-prefix-map-paths to the frontend 2025-07-15 10:46:50 -07:00
Gábor Horváth
761c50364c Merge pull request #83002 from Xazax-hun/guard-more-objc
[cxx-interop] Types exposed from ObjC modules should be behind a macro
2025-07-15 17:07:53 +01:00
Mike Ash
67506f5045 Merge pull request #82818 from DmT021/wp/conformance-cache-by-descriptor
Protocol conformance cache for generic types
2025-07-15 11:52:49 -04:00
fahadnayyar
a4eeae2a01 [cxx-interop] Re-enable warnings for unannotated C++ APIs returning SWIFT_SHARED_REFERENCE types under an experimental feature flag (#82488)
This patch re-enables diagnostics for unannotated C++ functions or
methods returning `SWIFT_SHARED_REFERENCE` types. These warnings now
fire only **once per source location**, even in the presence of multiple
template instantiations. This avoids diagnostic duplication that was a
key source of noise in the compilation of larger codebases.

These warnings were previously disabled starting in **Swift 6.2** via
[PR-#81411](https://github.com/swiftlang/swift/pull/81411) due to
concerns around false positives and excessive duplication in projects
adopting C++ interop. This patch addresses the duplication issue by
adding source-location-based caching, which ensures that a warning is
emitted only once per source location, even across template
instantiations with different types.

However, the false positive issue remains to be investigated and will be
addressed in a follow-up patch. Until that happens, the warnings are
gated behind a new experimental feature flag:
`WarnUnannotatedReturnOfCxxFrt`. This feature will be enabled by default
only after thorough qualification and testing on large C++ codebases.

rdar://154261051
2025-07-15 02:56:34 -07:00
Konrad `ktoso` Malawski
9cc555c567 Merge pull request #83053 from ktoso/pick-better-class-sendable-diagnostic
[Concurrency] add fixit to add final to non-sendable class -> Sendable
2025-07-15 17:23:30 +09:00
Konrad 'ktoso' Malawski
03774d245a fix some tests due to diagnostic rewording 2025-07-15 11:16:13 +09:00
Konrad 'ktoso' Malawski
f52f445358 [Concurrency] add fixit to add final to non-sendable class -> Sendable
The previous message was just suggesting unchecked Sendable, but instead
we should be suggesting to add final to the class. We also don't
outright suggest using unchecked Sendable -- following
https://github.com/swiftlang/swift/pull/81738 precedent.

Resolves rdar://155790695
2025-07-15 10:42:25 +09:00
Allan Shortlidge
d09e117dc0 AST: Canonicalize platform versions for @backDeployed attrs.
Also, diagnose invalid platform versions.

Part of rdar://155558161.
2025-07-14 16:40:16 -07:00