Commit Graph

47728 Commits

Author SHA1 Message Date
Anton Korobeynikov
366b552286 Properly substitute coroutines 2025-11-12 21:02:55 -08:00
Anton Korobeynikov
6c504bb9fa Add parsing of @yield_once and @yields attributes and corresponding type checks 2025-11-12 21:02:55 -08:00
Anton Korobeynikov
76c9a23f27 First cut of making coroutine AST type 2025-11-12 21:02:53 -08:00
Anton Korobeynikov
797f500286 Add basic boilerplate for AST coroutines and yields 2025-11-12 21:02:25 -08:00
Sam Pyankov
809f72fde6 Merge pull request #85394 from sepy97/register-module-dependency
Add new flag to enable dependency scanning without importing in the frontend
2025-11-12 14:52:59 -08:00
Alexis Laferrière
937e6c5241 Merge pull request #85446 from xymus/serial-xref-check
Serialization: Error on leaked cross-references to `@_implementationOnly` dependencies
2025-11-12 10:42:58 -08:00
Alexis Laferrière
dc7f30fac9 Merge pull request #85387 from xymus/exportability-nle-proto
Sema: Exportability check protocols in non-library-evolution mode
2025-11-12 10:04:04 -08:00
Pavel Yaskevich
30b207ecf4 Merge pull request #85418 from xedin/rdar-164267736
[AST/Serialization] A few fixes for `nonisolated(nonsending)` handling
2025-11-12 09:34:49 -08:00
Daniel Rodríguez Troitiño
9eca612b86 [ClangImporter] Avoid use-after-free of clang::DiagnosticOptions after rebranch (#85445)
Upstream LLVM in llvm/llvm-project#139584 changed `DiagnosticOptions`
from being a referenced counted object to just be a reference, not owned
by the `clang::DiagnosticEngine`.

In 0981b71090 (part of #82243), the usages
of the Swift repository were adapted to the new memory model, but it
introduced at least one use-after-free and a potential one around the
usage of Clang in the Clang Importer.

This commit tries to fix the use-after-free in both cases, by returning
a `unique_ptr` to the `clang::DiagnosticOptions`, which makes the
lifetime of the `DiagnosticOptions` match the lifetime of the variable
that uses it (normally a `CompilerInvocation`).

Other cases in 0981b71090 should be safe
because the lifetime of the `DiagnosticOptions` do not seem to propagate
beyond the scope of the functions where they live (but I am not fully
sure about the one in `IDETool/CompilerInvocation.cpp` completely).

This was causing compiler crashes during the test
`Interop/Cxx/stdlib/unsupported-stdlib.swift` which eventually uses
`createClangDriver` and tries to emit a diagnostic, which in some cases
was reading the memory from `DiagnosticOptions` when it was already out
of scope.
2025-11-12 08:38:36 -08:00
Andrew Trick
b28cd59dfc [NFC] TypeLowering: add CustomDeinit.
Teach SIL type lowering to recursively track custom vs. default deinit status.

Determine whether each type recursively only has default deinitialization. This
includes any recursive deinitializers that may be invoked by releasing a
reference held by this type.

If a type only has default deinitialization, then the deinitializer cannot
have any semantically-visible side effects. It cannot write to any memory
2025-11-11 17:29:45 -08:00
Pavel Yaskevich
47805810be [AST/Serialization] Remove isCallerIsolated bit from ParamDecl
This was used primarily by the printer and doesn't work when
`nonisolated(nonsending)` is inferred, so let's remove it.
2025-11-11 16:07:19 -08:00
John Hui
d5b3079567 Merge pull request #85379 from j-hui/dont-import-template-type-arguments-round-2
[cxx-interop] Make ClangDeclExplicitSafety request non-recursive
[cxx-interop] Do not import template type arguments
[cxx-interop] Check template argument safety in ClangDeclExplicitSafety
2025-11-11 13:44:07 -08:00
Anthony Latsis
8992ea82a2 Merge pull request #85433 from swiftlang/jepa-main4
AST: Rename `GenericContext::isGeneric` to `hasGenericParamList`
2025-11-11 21:12:34 +00:00
Doug Gregor
2002b90531 Merge pull request #85425 from DougGregor/irgen-multithreaded-lazy-global-var
[IRGen] Correctly assign lazily-emitted global variables in multi-threaded IRGen
2025-11-11 13:10:00 -08:00
Alexis Laferrière
5a49e34426 Serialization: Error on xref to implementation-only dependencies
Introduce a last resort check reporting references to
implementation-only dependencies that would appear in the generated
swiftmodule. This check is applied at serialization, long after
exportability checking applied at typechecking. It should act as a back
stop to references missed by typechecking or @_implementationOnly decls
that should have been skipped.

This check is gated behind CheckImplementationOnlyStrict and should be
used with embedded only.

rdar://160697599
2025-11-11 13:03:16 -08:00
Alexis Laferrière
810c418829 Serialization: Option to skip writing decls marked @_implementationOnly 2025-11-11 13:03:15 -08:00
Alexis Laferrière
06db612d79 Sema: Intro the CheckImplementationOnlyStrict feature 2025-11-11 10:26:00 -08:00
Alexis Laferrière
8eb530cc71 Sema: Accept @_implementationOnly protocols 2025-11-11 09:54:37 -08:00
Anthony Latsis
bda6edb85c AST: Rename GenericContext::isGeneric to hasGenericParamList
`isGeneric` is a misleading name because this method checks for the
existence of a `GenericParamList`, which is not implied by genericity.
2025-11-11 15:55:16 +00:00
Hamish Knight
7821c2c89c Merge pull request #85422 from hamishknight/modulo-module
[AST] NFC: Rename `LookupConformanceInModuleRequest` -> `LookupConformanceRequest`
2025-11-11 14:12:12 +00:00
Doug Gregor
bce3fa000b [IRGen] Correctly assign lazily-emitted global variables in multi-threaded IRGen
With multi-threaded IRGen, the global variables associated with "once"
initialization tokens were not getting colocated with their actual
global variables, which caused the initialization code to get split
across different files. This issue manifest as autolinking errors in
some projects.

Fixes rdar://162400654.
2025-11-10 23:08:57 -08:00
Adrian Prantl
11356acd44 Merge pull request #85397 from adrian-prantl/163167975
[SILOptimzer] Fix a crash caused by SILCombine mishandling inlined variables
2025-11-10 18:41:07 -08:00
Hamish Knight
5e1279516b [AST] NFC: Rename LookupConformanceInModuleRequest -> LookupConformanceRequest
This request no longer takes a module argument.
2025-11-10 21:25:07 +00:00
Pavel Yaskevich
c3ea3031b9 [AST] Fix printing of nonisolated(nonsending) in parameter type positions
Printing shouldn't rely on parameter declaration bit because it only
works in cases when there is an explicit `nonisolated(nonsending)`
modifier on the type.

Always print `nonisolated(nonsending)` before `sending`, `@escaping`
and other declaration attributes/modifiers to avoid parsing issues.

Resolves: rdar://164267736
2025-11-10 11:31:24 -08:00
Steven Wu
22ca80e4fd Merge pull request #85375 from cachemeifyoucan/eng/PR-164208526
[CAS] Support legacy prefix map option
2025-11-10 10:52:28 -08:00
Meghana Gupta
e2123e1b3b Merge pull request #85362 from meg-gupta/moreborrow
Add SIL verification for borrow and mutate accessors and some other minor fixes
2025-11-10 09:04:28 -08:00
Arnold Schwaighofer
e8e3e467b0 Merge pull request #85384 from aschwaighofer/enable_se0496_per_default
SE-0496 @inline(always) attribute was accepted
2025-11-09 16:21:48 -08:00
Doug Gregor
087aee833f Merge pull request #85396 from DougGregor/se-0497-export
[SE-0497] Implement @export attribute syntax
2025-11-08 23:46:06 -08:00
Mike Ash
cc8e6fd877 Merge pull request #85260 from mikeash/client-rr-library-rename
[Runtime] Rename ClientRetainRelease library to SwiftDirectRuntime.
2025-11-08 12:40:27 -05:00
Mike Ash
f149a8bce4 Merge pull request #85259 from mikeash/task-allocator-disable-option
[Concurrency] Add environment variable for disabling async stack slab allocator.
2025-11-08 07:53:56 -05:00
Egor Zhdan
744c57737b Merge pull request #85395 from egorzhdan/egorzhdan/fixup-clang-access-flag
[cxx-interop] Fix-up `-emit-clang-header-min-access` flag
2025-11-08 02:41:02 -08:00
Doug Gregor
020b69d4b6 [SE-0497] Implement @export attribute syntax
Implement the @export(implementation) and @export(interface) attributes
to replace @_alwaysEmitIntoClient and @_neverEmitIntoClient. Provide a
warning + Fix-It to start staging out the very-new
@_neverEmitIntoClient. We'll hold off on pushing folks toward
@_alwaysEmitIntoClient for a little longer.
2025-11-07 22:00:40 -08:00
Mike Ash
a62f08e050 [Concurrency] Add environment variable for disabling async stack slab allocator.
Add SWIFT_DEBUG_ENABLE_TASK_SLAB_ALLOCATOR, which is on by default. When turned off, async stack allocations call through to malloc/free. This allows memory debugging tools to be used on async stack allocations.
2025-11-07 22:48:41 -05:00
Semen Pyankov
b23044c19c Add new flag to enable dependency scanning without importing in the frontend 2025-11-07 18:36:05 -08:00
Adrian Prantl
99cf35cdce [SILOptimzer] Fix a crash caused by SILCombine mishandling inlined variables
This showed up on and off again on the source-compatibility testsuite project hummingbird.

The gist of the problem is that transformations may not rewrite the
type of an inlined instance of a variable without also createing a
deep copy of the inlined function with a different name (and e.g., a
specialization suffix). Otherwise the modified inlined variable will
cause an inconsistency when later compiler passes try to create the
abstract declaration of that inlined function as there would be
conflicting declarations for that variable.

Since SILDebugScope isn't yet available in the SwiftCompilerSources
this fix just drop these variables, but it would be absolutely
possible to preserve them by using the same mechanism that SILCloner
uses to create a deep copy of the inlined function scopes.

rdar://163167975
2025-11-07 17:06:33 -08:00
Egor Zhdan
0afa1aff2f [cxx-interop] Fix-up -emit-clang-header-min-access flag
This fixes a minor issue with the flag: its argument is not a actually a file system path (`ArgumentIsPath`).
2025-11-07 15:47:30 -08:00
John Hui
6b3f8c75cb [cxx-interop] Rename CxxDeclExplicitSafetyDescriptor -> ClangDeclExplicitSafetyDescriptor
Keep the naming convention consistent; this isn't specific to Cxx
2025-11-07 15:24:03 -08:00
John Hui
cbae2fc9b9 [evaluator] hasActiveRequest() considered harmful 2025-11-07 15:12:52 -08:00
Pavel Yaskevich
5f91e49c9c Merge pull request #85105 from xedin/rdar-140928937
[AST/Sema] Allow `Sendable` suppression on Objective-C class declarations
2025-11-07 15:09:35 -08:00
Mike Ash
1898b01ce6 [Runtime] Rename ClientRetainRelease library to SwiftDirectRuntime.
This library will likely become home to other fast-path-in-client functions, so give it a more general name.
2025-11-07 16:36:29 -05:00
Arnold Schwaighofer
fe90be09e3 SE-0496 @inline(always) attribute was accepted
Enable it per default
2025-11-07 09:44:16 -08:00
Alexis Laferrière
1e1361f4ee Merge pull request #85369 from xymus/exportability-nle-classes-and-structs
Sema: Exportability check enums and classes in non-library-evolution mode
2025-11-07 09:19:25 -08:00
Michael Gottesman
1bb65d8def Merge pull request #85165 from gottesmm/rdar153207557
[sil] Change SILIsolationInfo inference for classmethods to use SILDeclRef instead of using the AST directly.
2025-11-07 02:02:50 -08:00
eeckstein
552b665a9e Merge pull request #85334 from eeckstein/mandatory-destroy-hoisting
Optimizer: make destroy hoisting a mandatory pass
2025-11-07 06:45:03 +01:00
Doug Gregor
66e7a783a6 Merge pull request #85370 from DougGregor/extern-global-variables 2025-11-06 21:40:24 -08:00
Steven Wu
23b42cf6c9 [CAS] Support legacy prefix map option
Bring back legacy prefix map option to allow an older swift-driver to
work with newer swift-frontend. For old swift-driver, it will always
send the old style prefix map option, so the new compiler needs to
support that.

rdar://164208526
2025-11-06 20:35:10 -08:00
Michael Gottesman
a302d4e627 Merge pull request #85224 from gottesmm/pr-6cb303a9f5f15489fa44c26d00c70155a6d7cc97
[concurrency] Create builtins for invoking specific concurrency runtime functions.
2025-11-06 20:33:16 -08:00
Michael Gottesman
8016bf2332 [sil] Change SILIsolationInfo inference for classmethods to use SILDeclRef instead of using the AST directly.
We are creating/relying on a contract between the AST and SIL... that SILDeclRef
should accurately describe the method/accessor that a class_method is from. By
doing this we eliminate pattern matching on the AST which ties this code too
tightly to the AST and makes it brittle in the face of AST changes. This also
fixes an issue where we were not handling setters correctly.

I am doing this now since it is natural to fix it along side fixing the
ref_element_addr issue in the previous commit since they are effectively doing
the same thing.

rdar://153207557
2025-11-06 20:25:23 -08:00
Hamish Knight
8b73c9c717 Merge pull request #85363 from hamishknight/hattrick
[Sema] Avoid member attribute cycle in ResolveMacroRequest
2025-11-07 04:02:44 +00:00
Dylan Sturgeon
4b4f9f18fc Add an option for symbol graph to support long module names. (#83782)
Currently symbol graphs are always written in files that contain 1 to 2
module names. It's possible for Swift module names to be very long, so
combining 2 of them in file name like `module1@module2...` in the same
path component means the name can be too long for some file systems. The
new option `-symbol-graph-shorten-output-names` changes the symbol graph
output files to use a MD5 hash of the module name(s) as the filename and
outputs an additional JSON file with the original names mapped to the
real filename. The module names JSON can be used to construct a VFS
overlay with the original naming scheme.

fix #83723

I considered using vfsoverlay, which seems like a viable solution, but
the vfsoverlay options don't seem to apply to any of the outputs from
the compiler. When I set an overlay to remap the symbol graph file
outputs, the remapped external paths aren't used so the root problem of
too long file names remains.
2025-11-06 19:30:44 -08:00