Commit Graph

22435 Commits

Author SHA1 Message Date
Becca Royal-Gordon
d59d219078 Forbid @_borrowed in @abi
It has indirect effects on the accessors, so it shouldn’t matter, but we can defensively redirect the query to the API counterpart anyway.

This was the last `InferredInABIAttr` attribute, so we can now remove all of the infrastructure involved in supporting attribute inference.
2025-05-08 18:27:58 -07:00
Becca Royal-Gordon
51da65bebd Make inlinability non-ABI for @abi
Inlinability doesn’t affect the mangling except in function specializations, which are applied after the fact and should never mangle in information from an ABI-only decl. That means we can simply ban these from `@abi` instead of inferring them.

Also adds some assertions to help double-check that SIL never tries to directly mangle or retrieve inlinability info from an ABI-only decl.
2025-05-08 18:27:57 -07:00
Becca Royal-Gordon
c8db046cfc Forbid lazy with @abi
It’s not clear how `@abi` would apply to the auxiliary decl used for `lazy`.
2025-05-08 18:27:57 -07:00
Becca Royal-Gordon
31429fc522 [Legacy parser] No freestanding macros in @abi
SwiftSyntaxParser is already doing this, and we already diagnosed it in Sema anyway, so we’re just moving that diagnostic earlier so the ASTGen testing mode is happy. Also adding compiler tests for it.

Macro-related tests are not included in this commit; they require matching swift-syntax changes which are being negotiated.
2025-05-08 18:27:57 -07:00
Becca Royal-Gordon
a103e21d11 Diagnose CustomAttrs as needed in @abi
CustomAttr backs four different features, each of which requires a different behavior in `@abi`:

• Global actors: Permitted (and permitted to vary) since they can affect mangling
• Result builders: Forbidden inside an `@abi` since they have no ABI impact
• Property wrappers: Forbidden both inside an `@abi` and on a decl with an `@abi` since it’s not clear how we would apply `@abi` to the auxiliary decls
• Attached macros: Forbidden inside an `@abi` since an ABI-only decl has no body, accessors, members, peers, extensions, or (currently) conformances

Implement these behaviors (outside of `ABIDeclChecker` since they can’t be described there).

Macro-related tests are not included in this commit; they require matching swift-syntax changes which are being negotiated.
2025-05-08 18:27:57 -07:00
Steven Wu
8e30d7f7c7 Merge pull request #81245 from cachemeifyoucan/eng/PR-145676736-release 2025-05-08 18:21:43 -07:00
Ben Barham
464223e479 Merge pull request #81259 from bnbarham/cherry-merge-modules
[6.2][InterfaceGen] Merge exported modules with the same public name in generated interface
2025-05-08 10:17:17 -07:00
Anthony Latsis
c3b1e97f82 Merge pull request #81358 from AnthonyLatsis/arachnocampa-luminosa-6.2
[6.2] Cherry-pick "Frontend: Obsolete `-fixit-all` and `-emit-fixits-path`"
2025-05-08 13:33:00 +01:00
Artem Chikin
8e1bc70454 Merge pull request #81337 from artemcm/DepScanVariantError-62
[6.2 🍒][Dependency Scanning] Emit a detailed error diagnostic on Clang module variant discovery
2025-05-07 21:12:31 -07:00
Artem Chikin
3c19103270 Downgrade the scanning module variant diagnostic to a warning, for now.
There is concern that this diagnostic may be breaking in some cases on its own.
2025-05-07 10:35:36 -07:00
Anthony Latsis
8a14528728 [6.2] Cherry-pick "Frontend: Obsolete -fixit-all and -emit-fixits-path"
With `ARCMigrate` and `arcmt-test` removed from clang in
https://github.com/llvm/llvm-project/pull/119269 and the new code
migration experience under way (see
https://github.com/swiftlang/swift-evolution/pull/2673), these options
are no longer relevant nor known to be in use. They were introduced
long ago to support fix-it application in Xcode.

For now, turn them into a no-op and emit a obsoletion warning.

(cherry picked from commit 46c394788a84d5932289c71274dd32ea2d61d9dc)
2025-05-07 15:28:17 +01:00
Michael Gottesman
322a376432 Merge pull request #81334 from gottesmm/release/6.2-rdar150695113
[6.2][swift-settings] Now that we aren't using it immediately, remove it from tree.
2025-05-06 22:41:46 -07:00
Alejandro Alonso
2cc9fc61f4 Merge pull request #80855 from Azoy/62-value-generic-namelookup
[6.2] [NameLookup] Allow value generics to show up as static members
2025-05-06 20:55:07 -07:00
Doug Gregor
91eda514bf [Request evaluator] Eliminate assert that fires on cycles
This assertion will trigger whenever there is a cycle with a
split-cached request. Remove the assertion.
2025-05-06 16:07:27 -07:00
Doug Gregor
89358d6a0e Make ConformanceIsolationRequest cache per-ProtocolConformance
This request was looking through to the root conformance, which could
mess with the caching bits. Sink the "is nonisolated conformance" bit
down into ProtocolConformance, and have the request for a non-root
conformance be defined in terms of the request for the root
conformance.
2025-05-06 16:07:25 -07:00
Michael Gottesman
e04e15f125 [swift-settings] Now that we aren't using it immediately, remove it from tree.
We can always get it back from the git history.

rdar://150695113
(cherry picked from commit 9d59dbed17)

Conflicts:
	include/swift/AST/DiagnosticsSema.def
	include/swift/Basic/Features.def
	test/abi/macOS/arm64/concurrency.swift
	test/abi/macOS/x86_64/concurrency.swift
2025-05-06 14:12:23 -07:00
Artem Chikin
7f950ff180 [Dependency Scanning] Emit a detailed error diagnostic on Clang module variant discovery
In expectation, this should never happen. Such a situation means that within the same scanning action, Clang Dependency Scanner has produced two different variants of the same module. This is not supposed to happen, but we are currently hunting down the rare cases where it does, seemingly due to differences in Clang Scanner direct by-name queries and transitive header lookup queries.
2025-05-06 10:14:14 -07:00
Allan Shortlidge
44ecddd26d Merge pull request #81307 from tshortli/clang-importer-warning-group-6.2
[6.2] ClangImporter: Introduce the `#ClangDeclarationImport` diagnostic group
2025-05-05 22:01:10 -07:00
Max Desiatov
ea237d5548 Merge pull request #81104 from Azoy/value-generic-namelookup-warning
[AST] Temporarily downgrade value generic redeclaration to warning
2025-05-05 18:42:38 -07:00
Alejandro Alonso
12919a2300 Merge pull request #78248 from Azoy/value-generic-static-member
[NameLookup] Allow value generics to show up as static members
2025-05-05 18:42:15 -07:00
Holly Borla
b684e716fe Merge pull request #81275 from jamieQ/invalid-isolated-any-conversion-6.2
[6.2][Sema]: ban @isolated(any) conversions to synchronous function types
2025-05-05 18:00:20 -07:00
Allan Shortlidge
e867788d65 ClangImporter: Introduce the #ClangDeclarationImport diagnostic group.
The warnings that ClangImporter emits about issues it encounters while
importing declarations from Clang modules should all belong to a diagnostic
group so that users of `-warnings-as-errors` can control their behavior using
the compiler flags introduce with SE-0443. It's especially important that these
diagnostics be controllable since they are often caused by external
dependencies and therefore the developer may not have any control over whether
they are emitted.

The `#ClangDeclarationImport` diagnostic group is intentionally broad so that
developers have a way to control all of these diagnostics with a single
`-Wwarning` flag. I fully expect that we'll introduce finer-grained diagnostic
groups for some of these diagnostics in the future, but those groups should be
hierarchically nested under `#ClangDeclarationImport`, which is supported by
SE-0443.

Resolves rdar://150524204.
2025-05-05 14:19:04 -07:00
Artem Chikin
bb581a885b Merge pull request #81255 from artemcm/IncrementalScanFixes_62
[6.2 🍒][Dependency Scanning] Fix search path context hashing hole and avoid serializing unnecessary field
2025-05-05 09:29:27 -07:00
Alastair Houghton
55cda7dd85 Merge pull request #80795 from al45tair/eng/PR-149058236-6.2
[Concurrency] Remove -executor-factory option and replace with magic type.
2025-05-04 18:29:30 +01:00
Jamie
89b98a2cb5 [Sema]: ban @isolated(any) conversions to synchronous function types
per SE-0431, function conversions from an @isolated(any) function to a synchronous,
non-@isolated(any) function type should not be allowed. this adds a warning during
type checking to enforce this, which will be an error in a future major
language mode.

(cherry picked from commit 629e208970)
2025-05-03 12:51:39 -05:00
Ben Barham
d829fcf2eb Merge exported modules with the same public name in generated interface
If a module has the same `public-module-name` as the module being
generated and its import is exported, merge it into the same generated
interface.

Fix various always-imported modules from being printed while here and
update all the tests that checked for them.

Resolves rdar://137887712.

(cherry picked from commit ddddc667c8)
2025-05-02 12:52:44 -07:00
Artem Chikin
b684af4c88 Include system-ness of framework and import search paths in the PCH hash
This hash is also used for the dependency scanning hash. In both cases, PCH contents may differ based on whether a certain module they depend on is found in a system or non-system search path. In dependency scanning, systemness should cause a full change of scanning context requiring a from-scratch scan.

Resolves rdar://150334077
2025-05-02 10:02:56 -07:00
Artem Chikin
28289e9d94 [Dependency Scanning][Serialization] Do not serialize auxiliary files
The field is only used to store information to be used in finalize stage, in caching builds. When loading scan results from the cache, the entries are finalized already and have the file info encoded in CASIDs already.

Resolves rdar://150307865
2025-05-02 10:02:50 -07:00
Steven Wu
edb94fb2fb [Caching] Improve diagnostics around swift caching
Improve diagnostics message for swift caching build by trying to emit
the diagnostics early when there is more context to differentiate the
different kind of problems.

After the improvement, CAS Error should be more closer to when there is
functional problem with the CAS, rather than mixing in other kinds of
problem (like scanning dependency failures) when operating with a CAS.

rdar://145676736
(cherry picked from commit 226552bf23)
2025-05-01 16:59:43 -07:00
Meghana Gupta
7b0ac8b5b6 Merge pull request #81216 from meg-gupta/fixcowcp
[6.2] Insert end_cow_mutation_addr for lifetime dependent values dependent on mutable addresses
2025-05-01 00:44:41 -07:00
Doug Gregor
fcedb0b2a4 Merge pull request #81125 from DougGregor/unsafe-call-effects-6.2
[6.2] [Strict memory safety] Provide argument-specific diagnostics for calls
2025-04-30 15:09:50 -07:00
Meghana Gupta
5885421c06 Bridge getSwiftMutableSpanDecl() and isBuiltinType() 2025-04-30 14:39:44 -07:00
Andrew Trick
3efcc14d60 Merge pull request #81192 from atrick/62-var-walker-recursion
[6.2] LifetimeDependenceDiagnostics: bug fixes and output clarity
2025-04-30 07:34:14 -07:00
Andrew Trick
7756a322fa LifetimeDependenceDiagnostics: note for unsupported closure capture
Add a note explaining that dependence on closure captures is not
supported. Otherwise, the diagnostics are very confusing:
"it depends on a closure capture; this is not yet supported"

(cherry picked from commit 83b0ce1098)
2025-04-30 00:09:40 -07:00
Andrew Trick
4c78ece643 LifetimeDependence: clarify diagnostics for many unusual cases.
Ensure that we always issue a diagnostic on error, but avoid emitting any notes that don't have source locations.

With implicit accessors and thunks, report the correct line number and indicate which accessor generates the error.

Always check for debug_value users.

Consistently handle access scopes across diagnostic analysis and diagnostic messages.

(cherry picked from commit ec512864eb)
2025-04-30 00:09:40 -07:00
Andrew Trick
9b9a4056bd [NFC] SwiftCompilerSource: bridge Function.accessorKindName
(cherry picked from commit 25e9cbf3f1)
2025-04-30 00:09:39 -07:00
Slava Pestov
9bb6673bbd AST: Fix existential erasure of long member types
Suppose protocol P has a primary associated type A, and we have
a `any P<S>` value. We form the generalization signature <T>
with substitution map {T := S}, and the existential signature
<T, Self where T == Self.A>.

Now, if we call a protocol requirement that takes Self.A.A.A,
we see this is fixed concrete type, because the reduced type of
Self.A.A.A is T.A.A in the existential signature.

However, this type parameter is not formed from the
conformance requirements of the generalization signature
(there aren't any), so we cannot directly apply the outer
substitution map.

Instead, change the outer substitution conformance lookup
callback to check if the reduced type parameter is valid
in the generalization signature, and not just rooted in a
generic parameter of the generalization signature.

If it isn't, fall back to global conformance lookup.

A better fix would introduce new requirements into the
generalization signature to handle this, or store them
separately in the generic environment itself. But this is fine
for now.

- Fixes https://github.com/swiftlang/swift/issues/79763.
- Fixes rdar://problem/146111083.
2025-04-29 19:00:50 -04:00
Doug Gregor
428da5e1dd Ungroup "no unsafe operations occur within 'unsafe'" warnings
These should not be escalated to errors when other strict memory safety
warnings are, because they aren't safety issues. They could go into a
separate group along with the corresponding try and await diagnostics.

(cherry picked from commit 02e1d11896)
2025-04-26 07:45:38 -07:00
Doug Gregor
56c0ac51de [Strict memory safety] Provide argument-specific diagnostics for calls
Similar to what we do for 'throws' checking, perform argument-specific
checking for unsafe call arguments. This provides more detailed failures:

```
example.swift:18:3: warning: expression uses unsafe constructs but is not
marked with 'unsafe' [#StrictMemorySafety]
16 |   x.f(a: 0, b: 17, c: nil)
17 |
18 |   x.f(a: 0, b: 17, c: &i)
   |   |                   `- note: argument 'c' in call to instance
method 'f' has unsafe type 'UnsafePointer<Int>?'
   |   `- warning: expression uses unsafe constructs but is not marked
with 'unsafe' [#StrictMemorySafety]
19 |   unsafeF()
20 | }
```

It also means that we won't complain for `nil` or `Optional.none`
arguments passed to unsafe types, which eliminates some false
positives, and won't complain about unsafe result types when there is
a call---because we'd still get complaints later about the
actually-unsafe bit, which is using those results.

Fixes rdar://149629670.

(cherry picked from commit ee9487b86f)
2025-04-26 07:45:30 -07:00
Anthony Latsis
d3cead65fe Merge pull request #81038 from AnthonyLatsis/collybia-nuda-6.2
[6.2] AST: Quote attributes more consistently in diagnostics
2025-04-25 21:53:21 +01:00
Michael Gottesman
da57f9665c Merge pull request #80953 from gottesmm/release/6.2-135459885
[6.2][sil-isolation-info] When determining isolation of a function arg, use its VarDecl.
2025-04-24 10:14:41 -07:00
Anthony Latsis
f4d323bdbf AST: Quote attributes more consistently in DiagnosticsSIL.def 2025-04-23 19:18:11 +01:00
Anthony Latsis
cdae255f9f AST: Quote attributes more consistently in DiagnosticsModuleDiffer.def 2025-04-23 19:18:11 +01:00
Anthony Latsis
735b24af28 AST: Quote attributes more consistently in DiagnosticsIRGen.def 2025-04-23 19:18:11 +01:00
Anthony Latsis
6e94080c93 AST: Quote attributes more consistently in DiagnosticsCommon.def 2025-04-23 19:18:11 +01:00
Anthony Latsis
7b92a8f041 AST: Quote attributes more consistently in DiagnosticsParse.def 2025-04-23 19:18:11 +01:00
Anthony Latsis
5e41794680 AST: Quote attributes more consistently in DiagnosticsSema.def 2025-04-23 19:18:08 +01:00
Slava Pestov
a10356aa27 Merge pull request #80680 from slavapestov/compatibility-span-6.2
[6.2] Cherry-pick recent CompatibilitySpan work
2025-04-23 01:00:29 -04:00
Doug Gregor
172229eea9 Merge pull request #80988 from DougGregor/new-diagnostics-formatter-without-sourceloc-6.2 2025-04-22 20:39:31 -07:00
Allan Shortlidge
5a557d5261 Merge pull request #80996 from tshortli/member-import-visibility-cross-import-overlay-6.2
[6.2] Sema: Improve MemberImportVisibility diagnostics for cross import overlays
2025-04-22 18:18:04 -07:00