Skip to content

Commit ee906f7

Browse files
authored
Merge branch 'main' into cal--SE-3065-bad-pattern-check
2 parents 870dbcc + 022311e commit ee906f7

File tree

983 files changed

+87284
-69324
lines changed

Some content is hidden

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

983 files changed

+87284
-69324
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: 78 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,57 @@
11
# CHANGELOG
22

3-
_**Note:** This is in reverse chronological order, so newer entries are added to the top._
3+
> **Note**\
4+
> This is in reverse chronological order, so newer entries are added to the top.
45
56
## Swift 5.9
67

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

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

34-
```
82+
```swift
3583
struct HealthyFoods {
3684
var values: [String] = []
3785

@@ -45,6 +93,8 @@ _**Note:** This is in reverse chronological order, so newer entries are added to
4593

4694
## Swift 5.8
4795

96+
### 2023-03-30 (Xcode 14.3)
97+
4898
* [SE-0376][]:
4999

50100
The `@backDeployed(before:)` attribute may now be used to extend the availability of a function to OS releases prior to the introduction of that function as ABI.
@@ -269,10 +319,10 @@ _**Note:** This is in reverse chronological order, so newer entries are added to
269319
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.
270320

271321
```swift
272-
func delayedHello() async throws {
273-
try await Task.sleep(until: .now + .milliseconds(123), clock: .continuous)
274-
print("hello delayed world")
275-
}
322+
func delayedHello() async throws {
323+
try await Task.sleep(until: .now + .milliseconds(123), clock: .continuous)
324+
print("hello delayed world")
325+
}
276326
```
277327

278328
`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 +344,17 @@ _**Note:** This is in reverse chronological order, so newer entries are added to
294344
`any` type having the same constraints as the associated type. For example:
295345

296346
```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()
347+
protocol Surface {...}
348+
349+
protocol Solid {
350+
associatedtype SurfaceType: Surface
351+
func boundary() -> SurfaceType
352+
}
353+
354+
let solid: any Solid = ...
355+
356+
// Type of 'boundary' is 'any Surface'
357+
let boundary = solid.boundary()
308358
```
309359

310360
Protocol methods that take an associated type or `Self` cannot be used with `any`,
@@ -317,32 +367,32 @@ _**Note:** This is in reverse chronological order, so newer entries are added to
317367
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:
318368

319369
```swift
320-
protocol Graph<Vertex, Edge> {
321-
associatedtype Vertex
322-
associatedtype Edge
323-
}
370+
protocol Graph<Vertex, Edge> {
371+
associatedtype Vertex
372+
associatedtype Edge
373+
}
324374
```
325375

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

329379
```swift
330-
func shortestPath<V, E>(_: some Graph<V, E>, from: V, to: V) -> [E]
380+
func shortestPath<V, E>(_: some Graph<V, E>, from: V, to: V) -> [E]
331381

332-
extension Graph<Int, String> {...}
382+
extension Graph<Int, String> {...}
333383

334-
func build() -> some Graph<Int, String> {}
384+
func build() -> some Graph<Int, String> {}
335385
```
336386

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

341391
```swift
342-
func shortestPath<V, E, G>(_: G, from: V, to: V) -> [E]
343-
where G: Graph, G.Vertex == V, G.Edge == E
392+
func shortestPath<V, E, G>(_: G, from: V, to: V) -> [E]
393+
where G: Graph, G.Vertex == V, G.Edge == E
344394

345-
extension Graph where Vertex == Int, Edge == String {...}
395+
extension Graph where Vertex == Int, Edge == String {...}
346396
```
347397

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

9736+
[#64927]: <https://github.com/apple/swift/issues/64927>
96869737
[#42697]: <https://github.com/apple/swift/issues/42697>
96879738
[#42728]: <https://github.com/apple/swift/issues/42728>
96889739
[#43036]: <https://github.com/apple/swift/issues/43036>

CMakeLists.txt

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,10 @@ option(SWIFT_BUILD_STDLIB_EXTRA_TOOLCHAIN_CONTENT
243243
"If not building stdlib, controls whether to build 'stdlib/toolchain' content"
244244
TRUE)
245245

246+
option(SWIFT_BUILD_STDLIB_CXX_MODULE
247+
"If not building stdlib, controls whether to build the Cxx module"
248+
TRUE)
249+
246250
# In many cases, the CMake build system needs to determine whether to include
247251
# a directory, or perform other actions, based on whether the stdlib or SDK is
248252
# being built at all -- statically or dynamically. Please note that these
@@ -304,12 +308,7 @@ endif()
304308
set(SWIFT_ANALYZE_CODE_COVERAGE FALSE CACHE STRING
305309
"Build Swift with code coverage instrumenting enabled [FALSE, NOT-MERGED, MERGED]")
306310

307-
# SWIFT_VERSION is deliberately /not/ cached so that an existing build directory
308-
# can be reused when a new version of Swift comes out (assuming the user hasn't
309-
# manually set it as part of their own CMake configuration).
310-
set(SWIFT_VERSION_MAJOR 5)
311-
set(SWIFT_VERSION_MINOR 9)
312-
set(SWIFT_VERSION "${SWIFT_VERSION_MAJOR}.${SWIFT_VERSION_MINOR}")
311+
include(${CMAKE_CURRENT_LIST_DIR}/cmake/SwiftVersion.cmake)
313312

314313
set(SWIFT_VENDOR "" CACHE STRING
315314
"The vendor name of the Swift compiler")
@@ -1270,6 +1269,10 @@ else()
12701269

12711270
if(SWIFT_BUILD_STDLIB_EXTRA_TOOLCHAIN_CONTENT)
12721271
add_subdirectory(stdlib/toolchain)
1272+
1273+
if(SWIFT_BUILD_STDLIB_CXX_MODULE)
1274+
add_subdirectory(stdlib/public/Cxx)
1275+
endif()
12731276
endif()
12741277

12751278
if (BUILD_SWIFT_CONCURRENCY_BACK_DEPLOYMENT_LIBRARIES)
@@ -1279,7 +1282,7 @@ else()
12791282

12801283
# Some tools (e.g. swift-reflection-dump) rely on a host swiftRemoteInspection,
12811284
# so ensure we build that when building tools.
1282-
if(SWIFT_INCLUDE_TOOLS)
1285+
if(SWIFT_INCLUDE_TOOLS OR SWIFT_BUILD_STDLIB_CXX_MODULE)
12831286
add_subdirectory(stdlib/public/SwiftShims/swift/shims)
12841287
endif()
12851288

SwiftCompilerSources/Sources/AST/DiagnosticEngine.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,17 @@ public struct DiagnosticFixIt {
5353
}
5454

5555
public struct DiagnosticEngine {
56-
private let bridged: swift.DiagnosticEngine
56+
private let bridged: BridgedDiagnosticEngine
5757

58-
public init(bridged: swift.DiagnosticEngine) {
58+
public init(bridged: BridgedDiagnosticEngine) {
5959
self.bridged = bridged
6060
}
61+
public init?(bridged: BridgedOptionalDiagnosticEngine) {
62+
guard let object = bridged.object else {
63+
return nil
64+
}
65+
self.bridged = BridgedDiagnosticEngine(object: object)
66+
}
6167

6268
public func diagnose(_ position: SourceLoc?,
6369
_ id: DiagID,

SwiftCompilerSources/Sources/Optimizer/FunctionPasses/ObjCBridgingOptimization.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,11 +246,14 @@ private func removeBridgingCodeInPredecessors(of block: BasicBlock, _ context: F
246246
}
247247

248248
private func lookThroughOwnershipInsts(_ value: Value) -> Value {
249-
// Looks like it's sufficient to support begin_borrow for now.
250-
// TODO: add copy_value if needed.
249+
// Looks like it's sufficient to support begin_borrow and copy_value for now.
250+
// TODO: add move_value if needed.
251251
if let bbi = value as? BeginBorrowInst {
252252
return bbi.borrowedValue
253253
}
254+
if let cvi = value as? CopyValueInst {
255+
return cvi.fromValue
256+
}
254257
return value
255258
}
256259

SwiftCompilerSources/Sources/Parse/Regex.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ private func _RegexLiteralLexingFn(
4646
_ curPtrPtr: UnsafeMutablePointer<UnsafePointer<CChar>>,
4747
_ bufferEndPtr: UnsafePointer<CChar>,
4848
_ mustBeRegex: CBool,
49-
_ bridgedDiagnosticEngine: swift.DiagnosticEngine?
49+
_ bridgedDiagnosticEngine: BridgedOptionalDiagnosticEngine
5050
) -> /*CompletelyErroneous*/ CBool {
5151
let inputPtr = curPtrPtr.pointee
5252

@@ -62,8 +62,7 @@ private func _RegexLiteralLexingFn(
6262

6363
if let error = error {
6464
// Emit diagnostic if diagnostics are enabled.
65-
if let bridged = bridgedDiagnosticEngine {
66-
let diagEngine = DiagnosticEngine(bridged: bridged)
65+
if let diagEngine = DiagnosticEngine(bridged: bridgedDiagnosticEngine) {
6766
let startLoc = SourceLoc(
6867
locationInFile: error.location.assumingMemoryBound(to: UInt8.self))!
6968
diagEngine.diagnose(startLoc, .foreign_diagnostic, error.message)
@@ -94,7 +93,7 @@ public func _RegexLiteralParsingFn(
9493
_ captureStructureOut: UnsafeMutableRawPointer,
9594
_ captureStructureSize: CUnsignedInt,
9695
_ bridgedDiagnosticBaseLoc: swift.SourceLoc,
97-
_ bridgedDiagnosticEngine: swift.DiagnosticEngine
96+
_ bridgedDiagnosticEngine: BridgedDiagnosticEngine
9897
) -> Bool {
9998
let str = String(cString: inputPtr)
10099
let captureBuffer = UnsafeMutableRawBufferPointer(

0 commit comments

Comments
 (0)