Commit Graph

27802 Commits

Author SHA1 Message Date
Slava Pestov
4c60e036ac Merge pull request #79882 from slavapestov/sizeof-constraint
Sema: Optimize Constraint layout to save 24 bytes
2025-03-11 14:30:44 -04:00
Doug Gregor
fed1a74848 Merge pull request #79904 from DougGregor/unsafe-concurrency-cycle
[Strict memory safety] Eliminate false cycle when checking nonisolated(unsafe)
2025-03-11 11:01:09 -07:00
Allan Shortlidge
e68d8edb03 Merge pull request #79902 from tshortli/result-builder-member-import-visibility
Sema: Adjust result builder operation lookup for MemberImportVisibility
2025-03-11 10:45:46 -07:00
Slava Pestov
e48d00d26c Merge pull request #79876 from jameesbrown/pack-generic-param
[CS] Deep-equality match OpenedArchetypeTypes
2025-03-11 10:02:15 -04:00
Anthony Latsis
5a92bc5e12 Merge pull request #79897 from AnthonyLatsis/danaus-plexippus-3
Small adjustments to adoption mode modeling
2025-03-11 11:47:18 +00:00
Doug Gregor
733dd86c92 Merge pull request #79896 from DougGregor/strict-memory-safety-cleanups
Strict memory safety cleanups
2025-03-11 01:26:30 -07:00
Doug Gregor
81e8f75f93 [Strict memory safety] Eliminate false cycle when checking nonisolated(unsafe)
Whenc hecking for nonisolated(unsafe), don't evaluate the full isolation
of the entity, because doing so causes a reference cycle.
2025-03-10 22:59:50 -07:00
Michael Gottesman
04bb69f426 Merge pull request #79727 from gottesmm/pr-025c1133954b74e7b4eda77e1a6f3bcafd4eb6cf
[concurrency] Add initial support for SwiftSettings to control defaultIsolation at the file level.
2025-03-10 22:35:00 -07:00
Allan Shortlidge
7a514c99e2 Sema: Adjust result builder operation lookup for MemberImportVisibility.
To avoid spurious diagnostics about unavailable operations when checking uses
of functions that take result builder closures, lookup of result builder
operations needs to ignore the restrictions of the `MemberImportVisibility`
feature. The result builder transform should simply use the operations that are
found and allow later checks to diagnose the use of inaccessible builder
operations.

Resolves rdar://144100445.
2025-03-10 20:54:41 -07:00
Anthony Latsis
b3df0dcd08 [NFC] Basic: Do not return true in LangOptions::hasFeature if adoption mode
This check is used to enact features, whereas adoption mode should not
change behavior.
2025-03-11 01:14:39 +00:00
Anthony Latsis
6b12faf5c1 [NFC] TypeCheckType: Compute language mode to limit diagnostic behavior for ExistentialAny 2025-03-11 01:14:39 +00:00
Michael Gottesman
f64dd5a8d5 [concurrency] Add initial support for SwiftSettings to control defaultIsolation at the file level.
We introduce a new macro called #SwiftSettings that can be used in conjunction
with a new stdlib type called SwiftSetting to control the default isolation at
the file level. It overrides the current default isolation whether it is the
current nonisolated state or main actor (when -enable-experimental-feature
UnspecifiedMeansMainActorIsolated is set).
2025-03-10 17:33:45 -07:00
Pavel Yaskevich
1e88bc6849 Merge pull request #79828 from xedin/rdar-145103149
[CSBindings] Don't delay inferred loeading-dot base inference if sour…
2025-03-10 17:29:23 -07:00
James Brown
edb0fa7b3d [CS] Deep-equality match OpenedArchetypeTypes
When we have two distinct OpenedArchetypeTypes that have the same
interface type and UUID, we need to match their generic arguments.
2025-03-10 19:19:53 -04:00
Doug Gregor
f404c8a58c [Distributed] Inject "unsafe" expression for synthesized unsafe code 2025-03-10 15:42:25 -07:00
Slava Pestov
83118a73ed Sema: Shave another 8 bytes off of Constraint 2025-03-10 14:53:48 -04:00
Slava Pestov
ada6f77655 Sema: Track solver arena size in statistics 2025-03-10 14:03:05 -04:00
Slava Pestov
a7a19a0915 Sema: Optimize Constraint layout to save 16 bytes
The largest union member was for SyntacticElement constraints;
let's tail-allocate the ContextualTypeInfo instead of storing
one in every constraint.
2025-03-10 13:28:17 -04:00
Rintaro Ishizaki
accd108e4a Merge pull request #79857 from rintaro/retire-pound-diagnostics-decl
[Parse/AST] Remove PoundDiagnosticDecl
2025-03-09 21:23:16 -07:00
Hamish Knight
deac7012cb [AST] Avoid setting questionLoc for implicit OptionalSomePatterns
Instead fix `getSourceRange` to handle cases where the question
location is missing.
2025-03-08 18:45:39 +00:00
Rintaro Ishizaki
5eac58e1e0 [AST] SwitchStmt only hold CaseStmt
Now that there is no way SwitchStmt to hold AST nodes other than
CaseStmt.
2025-03-08 09:14:40 -08:00
Allan Shortlidge
56f7ffd26c Merge pull request #79858 from tshortli/spi-available-attr-diagnostics
Sema: Diagnose `@_spi_available` on declarations that cannot be unavailable
2025-03-08 03:48:56 -08:00
Hamish Knight
a596f23fbf Merge pull request #79850 from hamishknight/key-hack
[Sema] Apply CodingKeys hack to `TypeChecker::lookupUnqualifiedType`
2025-03-08 10:35:16 +00:00
Rintaro Ishizaki
002d7d7cdf [Parse/AST] Remove PoundDiagnosticDecl
There is no reson to make a AST node for '#error' and '#warning'
directives. Parser knows the diagnostics should be emitted or not.
2025-03-07 21:48:01 -08:00
Allan Shortlidge
0fd2f3fc1c Sema: Diagnose @_spi_available on declarations that cannot be unavailable.
The attribute makes the declaration unavailable from the perspective of clients
of the module's public interface and was creating a loophole that admitted
inappropriate unavailability.
2025-03-07 19:44:48 -08:00
Allan Shortlidge
396e8f033b Merge pull request #79849 from tshortli/allow-unavailable-proto-requirements-in-swiftinterface
Sema: Downgrade diagnostics about unavailable requirements in swiftinterfaces
2025-03-07 18:02:26 -08:00
Allan Shortlidge
4276771252 Sema: Consolidate diagnostics for decls that cannot be unavailable. 2025-03-07 17:43:51 -08:00
Evan Wilde
28f96411c9 Merge pull request #79778 from etcwilde/ewilde/yo-dawg-heard-you-liked-swift
CMake: option to disable swift in swift
2025-03-07 13:12:00 -08:00
Hamish Knight
7ae3ccf0bf [Sema] Apply CodingKeys hack to TypeChecker::lookupUnqualifiedType
Currently we handle CodingKeys synthesis in
`TypeChecker::lookupUnqualified`, make sure we do the same in
`TypeChecker::lookupUnqualifiedType`.

rdar://146055457
2025-03-07 21:03:33 +00:00
Allan Shortlidge
6284dd4895 Sema: Downgrade diagnostics about unavailable requirements in swiftinterfaces.
Historically, we've allowed protocol requirements to be written with
`@_spi_available` which makes them unavailable to clients of the public
`.swiftinterface`. Don't diagnose this when checking a `.swiftinterface` since
there's nothing the client can do about it.

Resolves rdar://146334181.
2025-03-07 12:02:42 -08:00
Anthony Latsis
5d92f7953c Merge pull request #79792 from AnthonyLatsis/danaus-plexippus-2
Introduce adoption mode for Swift features (take 2)
2025-03-07 19:47:44 +00:00
nate-chandler
38c8cc8ff4 Merge pull request #77661 from nate-chandler/general-coro/20241115/1
[CoroutineAccessors] Default implementations are transparent.
2025-03-07 11:39:21 -08:00
Pavel Yaskevich
87e3e3d8a1 [CSBindings] Don't delay inferred loeading-dot base inference if source is a contextual type
Transitively inferring a protocol type binding from a contextual
type means that the binding set for a leading-dot member reference
is complete because there could be no other sources of bindings
when expression is connected directly to a contextual type.

Resolves: rdar://145103149
2025-03-06 14:58:21 -08:00
Doug Gregor
0ec13f9a90 Build compiler and runtimes without Swift
Remove dependency on macros from compiler and stdlib build when
bootstrapping the compiler without Swift available.
2025-03-06 13:32:52 -08:00
Allan Shortlidge
6ab32cff94 Sema: Parameterize potential unavailability diagnostics to allow no version.
This allows `X is only available in` diagnostics to be emitted for potential
unavailability in domains that do not support versioning.
2025-03-06 13:04:18 -08:00
Allan Shortlidge
0bf464b272 AST: Return optional AvailabilityRange from SemanticAvailableAttr queries.
Introduction, deprecation, and obsoleteion ranges should only be returned by
the accessors on `SemanticAvailableAttr` when the attribute actually has an
affect on the corresponding kind of availability.
2025-03-06 13:02:19 -08:00
Hamish Knight
cc145482de Merge pull request #79759 from jameesbrown/bool-literal-case
[TypeChecker] Simplify ExprPattern from Bool literals in Bool? switch
2025-03-06 18:09:08 +00:00
Allan Shortlidge
77d18a87ea Merge pull request #79784 from tshortli/optimize-version-range-layout
AST: Optimize the layout of `AvailabilityRange`
2025-03-05 12:10:29 -08:00
Pavel Yaskevich
4a646b43f1 Merge pull request #79776 from xedin/fix-recording-of-opened-pack-expansions-in-trail
[CSSolver] Properly record opened pack expansion types
2025-03-05 09:03:23 -08:00
Anthony Latsis
6a3903bb53 Revert "Revert "Introduce adoption mode for Swift features""
This reverts commit 393c59c078.
2025-03-05 15:21:01 +00:00
Allan Shortlidge
cad1ee75d5 AST: Optimize the layout of AvailabilityRange.
`AvailabilityRange` is now being used as a currency type in more of the
compiler, and some of those uses are in permanent `ASTContext` allocations. The
class wraps the `VersionRange` utility, which is itself a wrapper around
`llvm::VersionTuple` with some additional storage for representing sentinel
values. Even though the two sentinel values can be be represented with just a
single bit of additional storage on top of the 16 bytes required to represent
`VersionTuple`, because of alignment requirements the sentinel values end up
bloating the layout of `VersionRange` by many bytes.

To make `AvailabilityRange` and `VersionRange` more efficient to store, we can
instead reserve two unlikely `llvm::VersionTuple` bit patterns as the sentinel
values instead. The values chosen are the same ones LLVM uses to represent
version tuple tombstones and empty keys in a `DenseMap`.
2025-03-05 07:15:15 -08:00
James Brown
3649dcbf04 [TypeChecker] Bool literals in switch
Bool literals are regarded as expr patterns when
switching over Optional<Bool>. Simplify the expr
by converting to their optional counterparts.
2025-03-05 09:33:24 -05:00
Allan Shortlidge
6eab842e7a Merge pull request #79777 from tshortli/potential-unavailability-diagnostics
AST/Sema: Decouple potential unavailability diagnostics from platform version
2025-03-05 00:35:23 -08:00
Allan Shortlidge
fe0688c40e Sema: Update diagnostics to take AvailabilityRange instead of VersionTuple. 2025-03-04 19:41:04 -08:00
Allan Shortlidge
b64df7384e AST: Simplify AvailabilityRange construction.
Introduce a constructor that takes an `llvm::VersionTuple` directly, instead of
needing to spell out `VersionRange::allGTE(<tuple>)` which is unnecessarily
verbose.
2025-03-04 19:41:04 -08:00
Allan Shortlidge
cb778b7ce4 AST/Sema: Expand potential unavailability diagnostics to arbitrary domains.
When emitting potential unavailability diagnostics, don't assume that they can
only apply to the target platform `AvailabilityDomain`.
2025-03-04 19:41:04 -08:00
Rintaro Ishizaki
393c59c078 Revert "Introduce adoption mode for Swift features" 2025-03-04 19:13:05 -08:00
Anthony Latsis
43b00af490 Merge pull request #79649 from AnthonyLatsis/danaus-plexippus
Introduce adoption mode for Swift features
2025-03-04 23:16:28 +00:00
Pavel Yaskevich
effc468f99 [CSSolver] Properly record opened pack expansion types
This bug leads to accumulation of data in the constraint
system even though most of it is out of scope.
2025-03-04 14:48:02 -08:00
Artem Chikin
6da529f098 Merge pull request #79753 from artemcm/NewConstFeatureDefinition
[Compile Time Values] Add a new experimental feature and the parsing of the `@const` attribute
2025-03-04 12:26:04 -08:00