Commit Graph

46165 Commits

Author SHA1 Message Date
Slava Pestov
b79f2817f9 Sema: Fix MissingCallFailure::diagnoseAsError() crash with special base names 2025-06-17 09:52:04 -04:00
Slava Pestov
908c9368ed Parse: Only accept certain literals as enum case raw values
Just checking for LiteralExpr is too broad, because Sema doesn't
know what to do with RegexLiteralExpr for example.
2025-06-17 09:19:00 -04:00
Anthony Latsis
faa7f67960 Merge pull request #82165 from AnthonyLatsis/jepa
{AST,Basic}Bridging: Use  `<swift/bridging>` and try directly bridging one of our enums
2025-06-17 04:52:41 +01:00
Mike Ash
020dde58fc Merge pull request #82245 from mikeash/auth-code-function-begone
[Runtime] Remove redundant swift_auth_code_function, use existing swift_auth_code.
2025-06-16 18:50:20 -04:00
Pavel Yaskevich
64404f5b7d Merge pull request #82229 from xedin/rdar-152689053
[Concurrency] NonisolatedNonsendingByDefault: Except `@Test` test-cases and `$` prefixed declarations from migration
2025-06-16 13:42:17 -07:00
Cyndy Ishida
64168edbf5 [Modules] Allow implicit conversions when loading interfaces with invalid os versions (#82228)
Initially, the compiler rejected building dependencies that contained OS
versions in an invalid range. However, this happens to be quite
disruptive, so instead allow it and request that these versions be
implicitly bumped based on what `llvm::Triple::getCanonicalVersionForOS`
computes.

resolves: rdar://153205856
2025-06-16 12:46:32 -07:00
Anthony Latsis
b40b192227 ASTBriding: Bridge swift::DiagnosticKind directly 2025-06-16 19:11:35 +01:00
Anthony Latsis
106d5f4461 {AST,Basic}Bridging: Use SWIFT_COMPUTED_PROPERTY 2025-06-16 19:11:32 +01:00
Mike Ash
ec6a042831 [Runtime] Remove redundant swift_auth_code_function, use existing swift_auth_code.
rdar://153169049
2025-06-13 18:46:23 -04:00
Anthony Latsis
08d71a46eb Basic, SIL: Include <swift/bridging> when avaiable instead of defining our own macros 2025-06-13 23:13:26 +01:00
Pavel Yaskevich
17976c7775 [Concurrency] NonisolatedNonsendingByDefault: Don't attempt to migrate $ prefixed declarations
These are special declarations that are synthesized by the compiler
or a macro and warnings about them are non-actionable.
2025-06-13 14:36:41 -07:00
Hamish Knight
9a0a831b01 Merge pull request #82147 from hamishknight/fix-nested-arenas
[CS] Avoid solver-allocated inputs with `typesSatisfyConstraint`
2025-06-13 16:53:51 +01:00
Gabor Horvath
ddacdf416d [cxx-interop] Shared references are considered safe
This patch makes sure we don't get warnings in strict memory safe mode
when using shared references. Those types are reference counted so we
are unlikely to run into lifetime errors.

rdar://151039766
2025-06-13 15:41:51 +01:00
Hamish Knight
fad9e24362 Merge pull request #82201 from hamishknight/no-copy 2025-06-13 08:01:40 +01:00
John Hui
44aba1382d [SourceKit] Support location info for macro-expanded Clang imports
Currently, when we jump-to-definition for decls that are macro-expanded
from Clang imported decls (e.g., safe overloads generated by
@_SwiftifyImport), setLocationInfo() emits a bongus location pointing to
a generated buffer, leading the IDE to try to jump to a file that does
not exist.

The root cause here is that setLocationInfo() calls getOriginalRange()
(earlier, getOriginalLocation()), which was not written to account for
such cases where a macro is generated from another generated buffer
whose kind is 'AttributeFromClang'.

This patch fixes setLocationInfo() with some refactoring:

-   getOriginalRange() is inlined into setLocationInfo(), so that the
    generated buffer-handling logic is localized to that function. This
    includes how it handles buffers generated for ReplacedFunctionBody.

-   getOriginalLocation() is used in a couple of other places that only
    care about macros expanded from the same buffer (so other generated
    buffers not not relevant). This "macro-chasing" logic is simplified
    and moved from ModuleDecl::getOriginalRange() to a free-standing
    function, getMacroUnexpandedRange() (there is no reason for it to be
    a method of ModuleDecl).

-   GeneratedSourceInfo now carries an extra ClangNode field, which is
    populated by getClangSwiftAttrSourceFile() when constructing
    a generated buffer for an 'AttributeFromClang'. This could probably
    be union'ed with one or more of the other fields in the future.

rdar://151020332
2025-06-12 18:22:06 -07:00
John Hui
270f56aed3 Merge pull request #82042 from j-hui/silence-warnings
[NFC] Silence some unused variable warnings
2025-06-12 15:41:23 -07:00
Artem Chikin
1c08abab43 Merge pull request #82169 from artemcm/DepScanImportAccessControl
[Dependency Scanning] Keep track of each imported module's access control
2025-06-12 12:41:51 -07:00
Meghana Gupta
e42b564800 Merge pull request #82033 from meg-gupta/fixinlinercrash
Fix an inliner crash when inlining begin_apply with scoped lifetime dependence
2025-06-12 10:53:19 -07:00
Andrew Trick
d90903a823 Merge pull request #82189 from atrick/lifedep-trivial-inout
Disallow @_lifetime(borrow) for trivial 'inout' arguments
2025-06-12 10:30:54 -07:00
John Hui
8aca536b97 [NFC] Use ASSERT() and silence unused variable warning
Comments in PR #80438, where this code comes from, already suggest using
ASSERT() instead of assert().
2025-06-12 09:57:25 -07:00
Stephen Canon
9259c3eec4 Add new interleave and deinterleave builtins (#81689)
Ideally we'd be able to use the llvm interleave2 and deinterleave2
intrinsics instead of adding these, but deinterleave currently isn't
available from Swift, and even if you hack that in, the codegen from
LLVM is worse than what shufflevector produces for both x86 and arm. So
in the medium-term we'll use these builtins, and hope to remove them in
favor of [de]interleave2 at some future point.
2025-06-12 12:01:53 -04: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
Slava Pestov
72401cabdb Merge pull request #82129 from slavapestov/bind-extensions-macro
Sema: Don't expand macros when binding extensions
2025-06-12 10:33:56 -04:00
Artem Chikin
c3ce91e071 [Dependency Scanning] Add libSwiftScan API and JSON output for source import information 2025-06-12 06:56:33 -07:00
Artem Chikin
6816922dd4 [Dependency Scanning] Keep track of each imported module's access control
Adds an access control field for each imported module identified. When multiple imports of the same module are found, this keeps track of the most "open" access specifier.
2025-06-12 06:56:30 -07:00
Hamish Knight
6d0da8d5cc [CS] Avoid solver-allocated inputs with typesSatisfyConstraint
Escaping solver-allocated types into a nested allocation arena is
problematic since we can e.g lazily compute the `ContextSubMap` for a
`NominalOrBoundGenericNominalType`, which is then destroyed when we
exit the nested arena. Ensure we don't pass any types with type
variables or placeholders to `typesSatisfyConstraint`.

rdar://152763265
2025-06-12 12:11:19 +01:00
Hamish Knight
71d20b7635 [CS] NFC: Remove FreeTypeVariableBinding::UnresolvedType
This is now unused.
2025-06-12 12:11:19 +01:00
Hamish Knight
a0b05904b3 [AST] Delete copy constructor for LoadedExecutablePlugin::PluginProcess
Avoid a potential footgun here since copying would lead to waiting
for the child process multiple times.
2025-06-12 11:33:52 +01:00
Meghana Gupta
8396a6d8c0 Fix an inliner crash when inlining begin_apply with scoped lifetime dependence
LifetimeDependenceInsertion inserts mark_dependence on token result of a begin_apply
when it yields a lifetime dependent value. When such a begin_apply gets inlined,
the inliner can crash because of the remaining uses of the token result.

Fix this by inserting mark_dependence on parameter operands that are lifetime dependence sources
and deleting the mark_dependence on token results in the inliner.

Fixes rdar://151568816
2025-06-12 01:35:36 -07:00
Konrad `ktoso` Malawski
01f911a36b Merge pull request #82179 from ktoso/wip-fix-incorrect-memory-effects-on-task-create 2025-06-12 13:42:32 +09:00
Artem Chikin
a35c112a70 Merge pull request #81919 from artemcm/DiagnoseMissingModulesSeenInSerializedSearchPaths
[Dependency Scanning] On failure to locate a module, attempt to diagnose if binary dependencies contain search paths with this module.
2025-06-11 18:00:01 -07:00
Slava Pestov
d4280d4f98 AST: Add excludeMacroExpansions parameter to computeExtendedNominal() 2025-06-11 20:07:42 -04:00
Andrew Trick
a38925493b Disallow @_lifetime(borrow) for trivial 'inout' arguments
@_lifetime(borrow holder) // ERROR
    func test(holder: inout Holder) -> NE

Fixes rdar://153040843 ([nonescapable] disallow @_lifetime(borrow)
for trivial 'inout' arguments)
2025-06-11 11:33:35 -07:00
Konrad 'ktoso' Malawski
3aa28b4de9 [Concurrency] Correct memory effect attributes of task_create
Without this, llvm would sometimes wrongly assume there's no indirect
accesses and the optimizations can lead to a runtime crash, by
optimizing away initializing options properly.

Resolves rdar://152548190
2025-06-11 22:03:52 +09:00
Allan Shortlidge
6e3a2d22c8 ModuleInterface: Canonicalize OS version numbers in loaded swiftinterfaces. 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
Erik Eckstein
73da214986 GenericSpecializer: remove some kind of instructions if their operands become trivial after specialization
Fixes a SIL verifier crash.

https://github.com/swiftlang/swift/issues/82093
rdar://152807200
2025-06-10 16:49:54 +02: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
Allan Shortlidge
c0589753d4 Merge pull request #82079 from tshortli/implementation-only-deprecation-diagnostic-group
AST: Add a warning group for `@_implementationOnly` deprecation diagnostics
2025-06-09 17:43:30 -07:00
Philippe Hausler
694aebb1fb Add an additional case for clocks to sleep with a wallclock deadline (#79139)
This only modifies the runtime function `swift_task_enqueueGlobalWithDeadline` to take new clock primitive to
interoperate with existing dispatch wall clock values.
2025-06-09 09:01:27 -07:00
Adrian Prantl
e84d5609ba Merge pull request #82073 from adrian-prantl/152743797
[RemoteInspection] Add a hook to process addresses before converting
2025-06-09 08:11:02 -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
Meghana Gupta
74e4c2e597 Downgrade use of @lifetime outside stdlib as a warning 2025-06-07 12:49:08 -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
Allan Shortlidge
8ceba34f62 AST: Add a warning group for @_implementationOnly deprecation diagnostics.
This allows developers to control the level of these diagnostics.

Resolves rdar://152735425.
2025-06-06 19:12:32 -07: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