Skip to content

Commit a76c925

Browse files
committed
Merge remote-tracking branch 'github-apple/main' into tbkka-RemoteMirror-MPE-zero-sized-plus-generics
2 parents 2f27e06 + c28031c commit a76c925

File tree

527 files changed

+9223
-3672
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

527 files changed

+9223
-3672
lines changed

.github/CODEOWNERS

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050

5151
# include
5252
/include/swift/AST/ @hborla @slavapestov @xedin
53+
/include/swift/AST/*Availability* @tshortli
5354
/include/swift/AST/*Conformance* @slavapestov
5455
/include/swift/AST/*Distributed* @ktoso
5556
/include/swift/AST/*Generic* @hborla @slavapestov
@@ -68,6 +69,7 @@
6869
/include/swift/PrintAsClang @zoecarver @hyp @egorzhdan
6970
# TODO: /include/swift/SIL/
7071
# TODO: /include/swift/SILOptimizer/
72+
/include/swift/SIL/SILDebug* @adrian-prantl
7173
/include/swift/SILOptimizer/Utils/Distributed* @ktoso
7274
/include/swift/Sema/ @hborla @slavapestov @xedin
7375
/include/swift/Sema/CS* @hborla @xedin
@@ -76,6 +78,8 @@
7678

7779
# lib
7880
/lib/AST/ @hborla @slavapestov @xedin
81+
/lib/AST/*Availability* @tshortli
82+
/lib/AST/ASTPrinter.cpp @hborla @slavapestov @xedin @tshortli
7983
/lib/AST/*Conformance* @slavapestov
8084
/lib/AST/*Generic* @hborla @slavapestov
8185
/lib/AST/*Requirement* @hborla @slavapestov
@@ -86,23 +90,28 @@
8690
/lib/ASTGen/ @zoecarver @CodaFi
8791
/lib/Basic/Windows @compnerd
8892
/lib/ClangImporter @zoecarver @hyp @egorzhdan
93+
/lib/ClangImporter/DWARFImporter* @adrian-prantl
8994
/lib/DependencyScan @artemcm
9095
/lib/Driver @artemcm
91-
/lib/Frontend/ModuleInterfaceLoader.cpp @artemcm
96+
/lib/Frontend/*ModuleInterface* @artemcm @tshortli
9297
# TODO: /lib/IRGen/
9398
/lib/IDE/ @ahoppen @bnbarham @rintaro
9499
/lib/IDETool/ @ahoppen @bnbarham @rintaro
95100
/lib/Index/ @bnbarham
96101
/lib/Refactoring/ @ahoppen @bnbarham
102+
/lib/IRGen/*Debug* @adrian-prantl
97103
/lib/IRGen/*Distributed* @ktoso
98104
/lib/Parse/ @ahoppen @bnbarham @CodaFi @DougGregor @rintaro
99105
/lib/PrintAsClang @zoecarver @hyp @egorzhdan
100106
# TODO: /lib/SIL/
107+
/lib/SIL/IR/SILDebug* @adrian-prantl
108+
/lib/SIL/IR/SILLocation* @adrian-prantl
101109
# TODO: /lib/SILGen/
102110
/lib/SILGen/*Distributed* @ktoso
103111
# TODO: /lib/SILOptimizer/
104112
/lib/SILOptimizer/Utils/Distributed* @ktoso
105113
/lib/Sema/ @hborla @slavapestov @xedin
114+
/lib/Sema/*Availability* @tshortli
106115
/lib/Sema/CS* @hborla @xedin
107116
/lib/Sema/CodeSynthesisDistributed* @hborla @ktoso
108117
/lib/Sema/Constraint* @hborla @xedin
@@ -128,6 +137,7 @@
128137
# test
129138
/test/ASTGen/ @zoecarver @CodaFi
130139
/test/Constraints/ @hborla @xedin
140+
/test/DebugInfo/ @adrian-prantl
131141
/test/Distributed/ @ktoso
132142
/test/Driver/ @artemcm
133143
/test/Generics/ @hborla @slavapestov
@@ -155,6 +165,7 @@
155165
# tools
156166
# TODO: /tools
157167
/tools/SourceKit @ahoppen @bnbarham @rintaro
168+
/tools/lldb-moduleimport-test/ @adrian-prantl
158169
/tools/swift-ide-test @ahoppen @bnbarham @rintaro
159170
/tools/swift-refactor @ahoppen @bnbarham
160171

CHANGELOG.md

Lines changed: 74 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,53 @@ _**Note:** This is in reverse chronological order, so newer entries are added to
44

55
## Swift 5.9
66

7+
* [#64927][]:
8+
9+
Swift 5.9 introduces warnings that catch conversions from an inout
10+
argument in the caller to an `UnsafeRawPointer` in the callee
11+
whenever the original type contains an object reference.
12+
13+
```swift
14+
func inspectString(string: inout String) {
15+
readBytes(&string)
16+
// warning: forming an 'UnsafeRawPointer' to an inout variable of type String
17+
// exposes the internal representation rather than the string contents.
18+
}
19+
```
20+
21+
```swift
22+
func inspectData(data: inout Data) {
23+
readBytes(&data)
24+
// warning: forming an 'UnsafeRawPointer' to a variable of type 'T';
25+
// this is likely incorrect because 'T' may contain an object reference.
26+
}
27+
```
28+
29+
Please see the "Workarounds for common cases" section link in github
30+
issue #64927.
31+
32+
* Marking stored properties as unavailable with `@available` has been banned,
33+
closing an unintentional soundness hole that had allowed arbitrary
34+
unavailable code to run and unavailable type metadata to be used at runtime:
35+
36+
```swift
37+
@available(*, unavailable)
38+
struct Unavailable {
39+
init() {
40+
print("Unavailable.init()")
41+
}
42+
}
43+
44+
struct S {
45+
@available(*, unavailable)
46+
var x = Unavailable()
47+
}
48+
49+
_ = S() // prints "Unavailable.init()"
50+
```
51+
52+
Marking `deinit` as unavailable has also been banned for similar reasons.
53+
754
* [SE-0366][]:
855

956
The lifetime of a local variable value can be explicitly ended using the
@@ -31,7 +78,7 @@ _**Note:** This is in reverse chronological order, so newer entries are added to
3178
access to a value provided by the caller, or by `consuming` a value that the
3279
callee is allowed to take ownership of:
3380

34-
```
81+
```swift
3582
struct HealthyFoods {
3683
var values: [String] = []
3784

@@ -269,10 +316,10 @@ _**Note:** This is in reverse chronological order, so newer entries are added to
269316
New types representing time and clocks were introduced. This includes a protocol `Clock` defining clocks which allow for defining a concept of now and a way to wake up after a given instant. Additionally a new protocol `InstantProtocol` for defining instants in time was added. Furthermore a new protocol `DurationProtocol` was added to define an elapsed duration between two given `InstantProtocol` types. Most commonly the `Clock` types for general use are the `SuspendingClock` and `ContinuousClock` which represent the most fundamental clocks for the system. The `SuspendingClock` type does not progress while the machine is suspended whereas the `ContinuousClock` progresses no matter the state of the machine.
270317

271318
```swift
272-
func delayedHello() async throws {
273-
try await Task.sleep(until: .now + .milliseconds(123), clock: .continuous)
274-
print("hello delayed world")
275-
}
319+
func delayedHello() async throws {
320+
try await Task.sleep(until: .now + .milliseconds(123), clock: .continuous)
321+
print("hello delayed world")
322+
}
276323
```
277324

278325
`Clock` also has methods to measure the elapsed duration of the execution of work. In the case of the `SuspendingClock` and `ContinuousClock` this measures with high resolution and is suitable for benchmarks.
@@ -294,17 +341,17 @@ _**Note:** This is in reverse chronological order, so newer entries are added to
294341
`any` type having the same constraints as the associated type. For example:
295342

296343
```swift
297-
protocol Surface {...}
298-
299-
protocol Solid {
300-
associatedtype SurfaceType: Surface
301-
func boundary() -> SurfaceType
302-
}
303-
304-
let solid: any Solid = ...
305-
306-
// Type of 'boundary' is 'any Surface'
307-
let boundary = solid.boundary()
344+
protocol Surface {...}
345+
346+
protocol Solid {
347+
associatedtype SurfaceType: Surface
348+
func boundary() -> SurfaceType
349+
}
350+
351+
let solid: any Solid = ...
352+
353+
// Type of 'boundary' is 'any Surface'
354+
let boundary = solid.boundary()
308355
```
309356

310357
Protocol methods that take an associated type or `Self` cannot be used with `any`,
@@ -317,32 +364,32 @@ _**Note:** This is in reverse chronological order, so newer entries are added to
317364
Protocols can now declare a list of one or more _primary associated types_, which enable writing same-type requirements on those associated types using angle bracket syntax:
318365

319366
```swift
320-
protocol Graph<Vertex, Edge> {
321-
associatedtype Vertex
322-
associatedtype Edge
323-
}
367+
protocol Graph<Vertex, Edge> {
368+
associatedtype Vertex
369+
associatedtype Edge
370+
}
324371
```
325372

326373
You can now write a protocol name followed by type arguments in angle brackets, like
327374
`Graph<Int, String>`, anywhere that a protocol conformance requirement may appear:
328375

329376
```swift
330-
func shortestPath<V, E>(_: some Graph<V, E>, from: V, to: V) -> [E]
377+
func shortestPath<V, E>(_: some Graph<V, E>, from: V, to: V) -> [E]
331378

332-
extension Graph<Int, String> {...}
379+
extension Graph<Int, String> {...}
333380

334-
func build() -> some Graph<Int, String> {}
381+
func build() -> some Graph<Int, String> {}
335382
```
336383

337384
A protocol name followed by angle brackets is shorthand for a conformance requirement,
338385
together with a same-type requirement for the protocol's primary associated types.
339386
The first two examples above are equivalent to the following:
340387

341388
```swift
342-
func shortestPath<V, E, G>(_: G, from: V, to: V) -> [E]
343-
where G: Graph, G.Vertex == V, G.Edge == E
389+
func shortestPath<V, E, G>(_: G, from: V, to: V) -> [E]
390+
where G: Graph, G.Vertex == V, G.Edge == E
344391

345-
extension Graph where Vertex == Int, Edge == String {...}
392+
extension Graph where Vertex == Int, Edge == String {...}
346393
```
347394

348395
The `build()` function returning `some Graph<Int, String>` can't be written using a
@@ -9683,6 +9730,7 @@ using the `.dynamicType` member to retrieve the type of an expression should mig
96839730
[SE-0376]: <https://github.com/apple/swift-evolution/blob/main/proposals/0376-function-back-deployment.md>
96849731
[SE-0377]: <https://github.com/apple/swift-evolution/blob/main/proposals/0377-parameter-ownership-modifiers.md>
96859732

9733+
[#64927]: <https://github.com/apple/swift/issues/64927>
96869734
[#42697]: <https://github.com/apple/swift/issues/42697>
96879735
[#42728]: <https://github.com/apple/swift/issues/42728>
96889736
[#43036]: <https://github.com/apple/swift/issues/43036>

SwiftCompilerSources/Sources/SIL/Argument.swift

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,26 @@ public enum ArgumentConvention {
122122
/// guarantees its validity for the entirety of the call.
123123
case directGuaranteed
124124

125+
/// This argument is a value pack of mutable references to storage,
126+
/// which the function is being given exclusive access to. The elements
127+
/// must be passed indirectly.
128+
case packInout
129+
130+
/// This argument is a value pack, and ownership of the elements is being
131+
/// transferred into this function. Whether the elements are passed
132+
/// indirectly is recorded in the pack type.
133+
case packOwned
134+
135+
/// This argument is a value pack, and ownership of the elements is not
136+
/// being transferred into this function. Whether the elements are passed
137+
/// indirectly is recorded in the pack type.
138+
case packGuaranteed
139+
125140
public var isIndirect: Bool {
126141
switch self {
127142
case .indirectIn, .indirectInGuaranteed,
128-
.indirectInout, .indirectInoutAliasable, .indirectOut:
143+
.indirectInout, .indirectInoutAliasable, .indirectOut,
144+
.packInout, .packOwned, .packGuaranteed:
129145
return true
130146
case .directOwned, .directUnowned, .directGuaranteed:
131147
return false
@@ -134,20 +150,23 @@ public enum ArgumentConvention {
134150

135151
public var isIndirectIn: Bool {
136152
switch self {
137-
case .indirectIn, .indirectInGuaranteed:
153+
case .indirectIn, .indirectInGuaranteed,
154+
.packOwned, .packGuaranteed:
138155
return true
139156
case .directOwned, .directUnowned, .directGuaranteed,
140-
.indirectInout, .indirectInoutAliasable, .indirectOut:
157+
.indirectInout, .indirectInoutAliasable, .indirectOut,
158+
.packInout:
141159
return false
142160
}
143161
}
144162

145163
public var isGuaranteed: Bool {
146164
switch self {
147-
case .indirectInGuaranteed, .directGuaranteed:
165+
case .indirectInGuaranteed, .directGuaranteed, .packGuaranteed:
148166
return true
149167
case .indirectIn, .directOwned, .directUnowned,
150-
.indirectInout, .indirectInoutAliasable, .indirectOut:
168+
.indirectInout, .indirectInoutAliasable, .indirectOut,
169+
.packInout, .packOwned:
151170
return false
152171
}
153172
}
@@ -157,7 +176,10 @@ public enum ArgumentConvention {
157176
case .indirectIn,
158177
.indirectOut,
159178
.indirectInGuaranteed,
160-
.indirectInout:
179+
.indirectInout,
180+
.packInout,
181+
.packOwned,
182+
.packGuaranteed:
161183
return true
162184

163185
case .indirectInoutAliasable,
@@ -171,15 +193,18 @@ public enum ArgumentConvention {
171193
public var isInout: Bool {
172194
switch self {
173195
case .indirectInout,
174-
.indirectInoutAliasable:
196+
.indirectInoutAliasable,
197+
.packInout:
175198
return true
176199

177200
case .indirectIn,
178201
.indirectOut,
179202
.indirectInGuaranteed,
180203
.directUnowned,
181204
.directGuaranteed,
182-
.directOwned:
205+
.directOwned,
206+
.packOwned,
207+
.packGuaranteed:
183208
return false
184209
}
185210
}
@@ -204,6 +229,9 @@ extension BridgedArgumentConvention {
204229
case .Direct_Owned: return .directOwned
205230
case .Direct_Unowned: return .directUnowned
206231
case .Direct_Guaranteed: return .directGuaranteed
232+
case .Pack_Inout: return .packInout
233+
case .Pack_Owned: return .packOwned
234+
case .Pack_Guaranteed: return .packGuaranteed
207235
default:
208236
fatalError("unsupported argument convention")
209237
}

SwiftCompilerSources/Sources/SIL/Effects.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -541,12 +541,12 @@ public struct SideEffects : CustomStringConvertible, NoReflectionChildren {
541541
result.ownership = SideEffects.Ownership()
542542
}
543543
switch convention {
544-
case .indirectIn:
544+
case .indirectIn, .packOwned:
545545
result.memory.write = false
546-
case .indirectInGuaranteed:
546+
case .indirectInGuaranteed, .packGuaranteed:
547547
result.memory.write = false
548548
result.ownership.destroy = false
549-
case .indirectOut:
549+
case .indirectOut, .packInout:
550550
result.memory.read = false
551551
result.ownership.copy = false
552552
result.ownership.destroy = false
File renamed without changes.

cmake/modules/AddSwift.cmake

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ endfunction()
8686
function(_add_host_variant_swift_sanitizer_flags target)
8787
if(LLVM_USE_SANITIZER)
8888
if(LLVM_USE_SANITIZER STREQUAL "Address")
89-
set(_Swift_SANITIZER_FLAGS "-sanitize=address")
89+
set(_Swift_SANITIZER_FLAGS "-sanitize=address" "-Xclang-linker" "-fsanitize=address")
9090
elseif(LLVM_USE_SANITIZER STREQUAL "HWAddress")
9191
# Not supported?
9292
elseif(LLVM_USE_SANITIZER MATCHES "Memory(WithOrigins)?")
@@ -95,14 +95,14 @@ function(_add_host_variant_swift_sanitizer_flags target)
9595
# Not supported
9696
endif()
9797
elseif(LLVM_USE_SANITIZER STREQUAL "Undefined")
98-
set(_Swift_SANITIZER_FLAGS "-sanitize=undefined")
98+
set(_Swift_SANITIZER_FLAGS "-sanitize=undefined" "-Xclang-linker" "-fsanitize=undefined")
9999
elseif(LLVM_USE_SANITIZER STREQUAL "Thread")
100-
set(_Swift_SANITIZER_FLAGS "-sanitize=thread")
100+
set(_Swift_SANITIZER_FLAGS "-sanitize=thread" "-Xclang-linker" "-fsanitize=thread")
101101
elseif(LLVM_USE_SANITIZER STREQUAL "DataFlow")
102102
# Not supported
103103
elseif(LLVM_USE_SANITIZER STREQUAL "Address;Undefined" OR
104104
LLVM_USE_SANITIZER STREQUAL "Undefined;Address")
105-
set(_Swift_SANITIZER_FLAGS "-sanitize=address" "-sanitize=undefined")
105+
set(_Swift_SANITIZER_FLAGS "-sanitize=address" "-sanitize=undefined" "-Xclang-linker" "-fsanitize=address" "-Xclang-linker" "-fsanitize=undefined")
106106
elseif(LLVM_USE_SANITIZER STREQUAL "Leaks")
107107
# Not supported
108108
else()

docs/ABI/CallConvSummary.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ Register usage
5050
+-----------+----------------------------------+----------+----------+----------+
5151
| ``r13`` | Callee-saved register | | | ``self`` |
5252
+-----------+----------------------------------+----------+----------+----------+
53-
| ``r14`` | Callee-saved register | | | |
53+
| ``r14`` | Callee-saved register | | | Async |
54+
| | | | | context |
5455
+-----------+----------------------------------+----------+----------+----------+
5556
| ``r15`` | Callee-saved register | | | |
5657
| | (other platforms use as GOT ptr) | | | |
@@ -152,7 +153,10 @@ Register usage
152153
| ``x21`` | | Callee-saved register | | | Error |
153154
| | | | | | return |
154155
+----------+---------+-------------------------+----------+----------+----------+
155-
| ``x22``- | | Callee-saved registers | | | |
156+
| ``x22`` | | Callee-saved register | | | Async |
157+
| | | | | | context |
158+
+----------+---------+-------------------------+----------+----------+----------+
159+
| ``x23``- | | Callee-saved registers | | | |
156160
| ``x28`` | | | | | |
157161
+----------+---------+-------------------------+----------+----------+----------+
158162
| ``x29`` | ``fp`` | Frame pointer | | | |

0 commit comments

Comments
 (0)