Commit Graph

45907 Commits

Author SHA1 Message Date
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
Artem Chikin
e42f05fb5e Merge pull request #81294 from artemcm/DepScanParallelDiagnosticConsumer_62
[6.2 🍒][Dependency Scanning] Always use a locking diagnostic consumer
2025-05-06 16:55:28 -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
Erik Eckstein
2f34dae56f Swift SIL: add Builder.createUncheckedOwnershipConversion 2025-05-06 17:57:37 +02: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
d355233cbd [Dependency Scanning][libSwiftScan] Deprecate scanner-global diagnostic collection
All clients are expected to have switched to the per-scan-query diagnostics using 'swiftscan_dependency_graph_get_diagnostics'
2025-05-05 10:43:45 -07:00
Artem Chikin
f830a207b2 [Dependency Scanning] Always use a locking diagnostic consumer
Since we enabled parallel dependency scanning by-default, each individual scan needs a diagnostic consumer that is safe to use across many threads. Deprecate the 'Locking' sub-class, making its behavior the default in the base class.
2025-05-05 10:43:40 -07:00
Karoy Lorentey
4cde33c4b0 Merge pull request #80867 from lorentey/is_same_metatype_condfail_6.2
[6.2][stdlib] Allow metatype comparisons to work with outdated compilers
2025-05-05 10:03:35 -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
John Hui
b7812babdf Merge pull request #81212 from j-hui/base-6.2/fix-recursive-inheritance
🍒 [6.2] [cxx-interop] Avoid unchecked recursion when importing C++ classes with circular inheritance
2025-05-02 10:24:37 -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
Konrad `ktoso` Malawski
f6a864a188 Merge pull request #81135 from ktoso/pick-22b20e731eaa70746d3c21bf8c44836aa49dfabb
[6.2][Concurrency] Change isIsolatingCurrent... to return Bool?
2025-05-02 07:53:12 +09:00
Konrad `ktoso` Malawski
413349a0e8 Merge pull request #81230 from ktoso/pick-wip-escalation-handler-priority-auth
[6.2][Concurrency] Fix ptr auth for task priority escalation handler
2025-05-02 05:51:49 +09: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
Konrad 'ktoso' Malawski
3615dbf398 [Concurrency] Fix ptr auth for task priority escalation handler
We missed to sign the handler. Along the way the signature of it
changed, so adjust for that.

How to get the number:

```
func PROPER(bar: (TaskPriority, TaskPriority) -> Void) {
    let p = TaskPriority.default
    bar(p, p)
}
```

```
-> % swiftc -target arm64e-apple-macos13 example.swift -S -o - | swift demangle | grep -a3 autda
	stur	x8, [x29, #-64]
	mov	x17, x8
	movk	x17, #11839, lsl #48 <<<<<<<<<
	autda	x16, x17
	ldr	x8, [x16, #64]
	lsr	x8, x8, #0
	add	x8, x8, #15
```

Resolves rdar://150378890
2025-05-01 12:13:29 +09:00
Artem Chikin
f2a8ed196c Merge pull request #81183 from artemcm/AddSourceOnlyImportDeps_62
[6.2 🍒][Dependency Scanning] Add a field of source-imported dependencies
2025-04-30 17:42:14 -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
Meghana Gupta
cc72edb119 Introduce end_cow_mutation_addr instruction 2025-04-30 14:38:48 -07:00
John Hui
c4fed45f54 [cxx-interop] Avoid unchecked recursion when importing C++ classes with circular inheritance
It is possible for a C++ class template to inherit from a specialization
of itself. Normally, these are imported to Swift as separate (unrelated)
types, but when symbolic import is enabled, unspecialized templates are
imported in place of their specializations, leading to circularly
inheriting classes to seemingly inherit from themselves.

This patch adds a check to guard against the most common case of
circular inheritance, when a class template directly inherits from
itself. This pattern appears in a recent version of libc++,
necessitating this patch. However, the solution here is imperfect as it
does not handle more complex/contrived circular inheritance patterns.

This patch also adds a test case exercising this pattern. The
-index-store-path flag causes swift-frontend to index the C++ module
with symbolic import enabled, without the fix in this patch, that test
triggers an assertion failure due to the circular reference (and can
infinitely recurse in the StorageVisitor when assertions are disabled).

rdar://148026461
(cherry picked from commit 1f2107f357)
2025-04-30 13:40:19 -07:00
Artem Chikin
f0518f64ec [Dependency Scanning] Add a field of source-imported dependencies
For the main source module, provide info on which dependencies are directly imported into the user program, explicitly ('import' statement) or implicitly (e.g. stdlib). Thist list does not include Swift overlay dependencies, cross-import dependencies, bridging header dependencies.
2025-04-30 10:17:45 -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
Slava Pestov
75181f9fa7 Merge pull request #81182 from slavapestov/fix-issue-79763-6.2
[6.2] AST: Fix existential erasure of long member types
2025-04-30 07:13:46 -04: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
Guillaume Lessard
e9b21cff7d Merge pull request #80847 from glessard/rdar149227278-nonescapable-mutating-accessor-62
[6.2, LifetimeDependenceMutableAccessors] defensive feature flag
2025-04-29 12:30:10 -07:00
Konrad 'ktoso' Malawski
25413d2ef4 [embedded][Concurrency] Further refine C-api boundary for isIsolating... 2025-04-29 22:29:54 +09:00
Slava Pestov
140abae262 Merge pull request #81046 from slavapestov/fix-rdar149801864-6.2
[6.2] Demangle: Implement missing Node::Kind::DependentProtocolConformanceOpaque
2025-04-28 11:55:04 -04:00
Konrad 'ktoso' Malawski
a63356ed0d [Concurrency] adjust how we fail creating an IsIsolatingCurrentContextDecision 2025-04-28 20:26:17 +09:00
Konrad 'ktoso' Malawski
eaf0b15ea3 [Concurrency] Change isIsolatingCurrent... to return Bool?
This changes the isIsolatingCurrentContext function to return `Bool?`
and removes all the witness table trickery we did previously to detect
if it was implemented or not. This comes at a cost of trying to invoke
it always, before `checkIsolated`, but it makes for an simpler
implementation and more checkable even by third party Swift code which
may want to ask this question.

Along with the `withSerialExecutor` function, this now enables us to
check the isolation at runtime when we have an `any Actor` e.g. from
`#isolation`.

Updates SE-0471 according to
https://forums.swift.org/t/se-0471-improved-custom-serialexecutor-isolation-checking-for-concurrency-runtime/78834/
review discussions
2025-04-28 19:17:58 +09: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