Skip to content

Commit 48308b8

Browse files
authored
Merge branch 'main' into ns-option-linkage-spec-decl-fixes
2 parents 79d7484 + 3cd4b63 commit 48308b8

File tree

632 files changed

+12418
-5804
lines changed

Some content is hidden

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

632 files changed

+12418
-5804
lines changed

.github/CODEOWNERS

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,19 @@
55
# Owners of ASTGen
66
lib/ASTGen @zoecarver @CodaFi
77

8+
# Dependency scanning
9+
include/swift/DependencyScan @artemcm
10+
lib/AST/ModuleLoader.cpp @artemcm
11+
lib/DependencyScan @artemcm
12+
lib/Frontend/ModuleInterfaceLoader.cpp @artemcm
13+
lib/Serialization/SerializedModuleLoader.cpp @artemcm
14+
test/ScanDependencies @artemcm
15+
16+
# Driver
17+
include/swift/Driver @artemcm
18+
lib/Driver @artemcm
19+
test/Driver @artemcm
20+
821
# Owners of the parser
922
include/swift/Parse @ahoppen @bnbarham @CodaFi @DougGregor @rintaro
1023
lib/Parse @ahoppen @bnbarham @CodaFi @DougGregor @rintaro
@@ -19,3 +32,13 @@ lib/ClangImporter @zoecarver @hyp @egorzhdan
1932
lib/PrintAsClang @zoecarver @hyp @egorzhdan
2033
stdlib/public/Cxx @zoecarver @hyp @egorzhdan
2134
test/Interop @zoecarver @hyp @egorzhdan
35+
36+
# Threading implementation
37+
include/swift/Threading @al45tair
38+
lib/Threading @al45tair
39+
40+
# Windows support
41+
cmake/**/*Windows* @compnerd
42+
lib/Basic/Windows @compnerd
43+
stdlib/public/Windows @compnerd
44+
utils/*windows* @compnerd

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name: Bug report
33
about: Create a report to help us improve
44
title: ''
5-
labels: bug
5+
labels: bug, triage needed
66
assignees: ''
77

88
---

.github/ISSUE_TEMPLATE/feature_request.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name: Feature request
33
about: Share an idea
44
title: ''
5-
labels: feature request
5+
labels: feature request, triage needed
66
assignees: ''
77

88
---

CHANGELOG.md

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

55
## Swift 5.8
66

7+
* [#56139][]:
8+
9+
Сollection downcasts in cast patterns are now supported. For example:
10+
11+
```swift
12+
func collectionDowncast(_ arr: [Any]) {
13+
switch arr {
14+
case let ints as [Int]:
15+
// ...
16+
case is [Bool]:
17+
// ...
18+
}
19+
}
20+
```
21+
* [SE-0370][]:
22+
23+
The API of `UnsafeMutableRawPointer`, `UnsafeMutableBufferPointer`, `UnsafeMutableRawBufferPointer` were improved, adding previously missing initialization (and deinitialization) methods, including more performant initialization from `Collection` types.
24+
25+
For `UnsafeMutablePointer<T>` and `UnsafeMutableBufferPointer<T>`, method names containing the word "assign" were renamed to use the word "update", and many more were added. Every multi-element initialization method of `UnsafeMutablePointer` and `UnsafeMutableBufferPointer` now has a corresponding "update" method.
26+
27+
Slices of `UnsafeBufferPointer`, `UnsafeRawBufferPointer`, `UnsafeMutableBufferPointer` and `UnsafeMutableRawBufferPointer` now share the collection-like API of their base type. For example, given an initialized `b: UnsafeMutableBufferPointer<Int>`, the following lines are synonymous:
28+
```swift
29+
b.update(repeating: 0)
30+
b[b.startIndex..<b.endIndex].update(repeating: 0)
31+
```
32+
733
* [SE-0365][]:
834

935
Implicit `self` is now permitted for `weak self` captures, after `self` is unwrapped.
@@ -9584,6 +9610,7 @@ using the `.dynamicType` member to retrieve the type of an expression should mig
95849610
[SE-0358]: <https://github.com/apple/swift-evolution/blob/main/proposals/0358-primary-associated-types-in-stdlib.md>
95859611
[SE-0362]: <https://github.com/apple/swift-evolution/blob/main/proposals/0362-piecemeal-future-features.md>
95869612
[SE-0365]: <https://github.com/apple/swift-evolution/blob/main/proposals/0365-implicit-self-weak-capture.md>
9613+
[SE-0370]: <https://github.com/apple/swift-evolution/blob/main/proposals/0370-pointer-family-initialization-improvements.md>
95879614

95889615
[#42697]: <https://github.com/apple/swift/issues/42697>
95899616
[#42728]: <https://github.com/apple/swift/issues/42728>
@@ -9624,3 +9651,4 @@ using the `.dynamicType` member to retrieve the type of an expression should mig
96249651
[#54246]: <https://github.com/apple/swift/issues/54246>
96259652
[#57081]: <https://github.com/apple/swift/issues/57081>
96269653
[#57225]: <https://github.com/apple/swift/issues/57225>
9654+
[#56139]: <https://github.com/apple/swift/issues/56139>

SwiftCompilerSources/Sources/Basic/Utils.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
@_exported import BasicBridging
14-
import std
14+
import CxxStdlib
1515

1616
/// The assert function to be used in the compiler.
1717
///

SwiftCompilerSources/Sources/Optimizer/FunctionPasses/ComputeSideEffects.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ private extension PartialApplyInst {
463463
struct EscapesToApply : EscapeVisitor {
464464
func visitUse(operand: Operand, path: EscapePath) -> UseResult {
465465
switch operand.instruction {
466-
case is ApplySite:
466+
case is FullApplySite:
467467
// Any escape to apply - regardless if it's an argument or the callee operand - might cause
468468
// the closure to be called.
469469
return .abort

cmake/modules/AddSwift.cmake

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ function(_add_swift_runtime_link_flags target relpath_to_lib_dir bootstrapping)
569569
570570
if(SWIFT_SWIFT_PARSER)
571571
# Make sure we can find the early SwiftSyntax libraries.
572-
target_link_directories(${target} PRIVATE "${SWIFT_PATH_TO_EARLYSWIFTSYNTAX_BUILD_DIR}/lib")
572+
target_link_directories(${target} PRIVATE "${SWIFT_PATH_TO_EARLYSWIFTSYNTAX_BUILD_DIR}/lib/swift/host")
573573
574574
# For the "end step" of bootstrapping configurations on Darwin, need to be
575575
# able to fall back to the SDK directory for libswiftCore et al.
@@ -912,9 +912,17 @@ function(add_swift_host_tool executable)
912912
endif()
913913
914914
if(SWIFT_SWIFT_PARSER)
915+
set(extra_relative_rpath "")
916+
if(NOT ${ASHT_BOOTSTRAPPING} STREQUAL "")
917+
if (${executable} MATCHES "-bootstrapping")
918+
set(extra_relative_rpath "../")
919+
endif()
920+
endif()
921+
915922
set_property(
916923
TARGET ${executable}
917-
APPEND PROPERTY INSTALL_RPATH "@executable_path/../lib")
924+
APPEND PROPERTY INSTALL_RPATH
925+
"@executable_path/../${extra_relative_rpath}lib/swift/host")
918926
endif()
919927
920928
if(ASHT_THINLTO_LD64_ADD_FLTO_CODEGEN_ONLY)

cmake/modules/SwiftConfigureSDK.cmake

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ macro(configure_sdk_unix name architectures)
378378
message(WARNING "CMAKE_SYSTEM_VERSION will not match target")
379379
endif()
380380

381-
string(REPLACE "[-].*" "" freebsd_system_version ${CMAKE_SYSTEM_VERSION})
381+
string(REGEX REPLACE "[-].*" "" freebsd_system_version ${CMAKE_SYSTEM_VERSION})
382382
message(STATUS "FreeBSD Version: ${freebsd_system_version}")
383383

384384
set(SWIFT_SDK_FREEBSD_ARCH_x86_64_TRIPLE "x86_64-unknown-freebsd${freebsd_system_version}")
@@ -387,14 +387,14 @@ macro(configure_sdk_unix name architectures)
387387
message(FATAL_ERROR "unsupported arch for OpenBSD: ${arch}")
388388
endif()
389389

390-
string(REPLACE "[-].*" "" openbsd_system_version ${CMAKE_SYSTEM_VERSION})
390+
set(openbsd_system_version ${CMAKE_SYSTEM_VERSION})
391391
message(STATUS "OpenBSD Version: ${openbsd_system_version}")
392392

393393
set(SWIFT_SDK_OPENBSD_ARCH_amd64_TRIPLE "amd64-unknown-openbsd${openbsd_system_version}")
394394

395-
if(CMAKE_SYSROOT)
396-
set(SWIFT_SDK_OPENBSD_ARCH_${arch}_PATH "${CMAKE_SYSROOT}${SWIFT_SDK_OPENBSD_ARCH_${arch}_PATH}" CACHE INTERNAL "sysroot path" FORCE)
397-
endif()
395+
if(CMAKE_SYSROOT)
396+
set(SWIFT_SDK_OPENBSD_ARCH_${arch}_PATH "${CMAKE_SYSROOT}${SWIFT_SDK_OPENBSD_ARCH_${arch}_PATH}" CACHE INTERNAL "sysroot path" FORCE)
397+
endif()
398398
elseif("${prefix}" STREQUAL "CYGWIN")
399399
if(NOT arch STREQUAL x86_64)
400400
message(FATAL_ERROR "unsupported arch for cygwin: ${arch}")

cmake/modules/SwiftHandleGybSources.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ function(handle_gyb_sources dependency_out_var_name sources_var_name)
135135
"${SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE}/gyb_syntax_support/DeclNodes.py"
136136
"${SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE}/gyb_syntax_support/ExprNodes.py"
137137
"${SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE}/gyb_syntax_support/GenericNodes.py"
138-
"${SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE}/gyb_syntax_support/NodeSerializationCodes.py"
139138
"${SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE}/gyb_syntax_support/PatternNodes.py"
140139
"${SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE}/gyb_syntax_support/StmtNodes.py"
141140
"${SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE}/gyb_syntax_support/TypeNodes.py"

docs/ABI/Mangling.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ Entities
362362
entity-spec ::= decl-name label-list? type 'v' ACCESSOR // variable
363363
entity-spec ::= decl-name type 'fp' // generic type parameter
364364
entity-spec ::= decl-name type 'fo' // enum element (currently not used)
365+
entity-spec ::= decl-name label-list? type generic-signature? 'fm' // macro
365366
entity-spec ::= identifier 'Qa' // associated type declaration
366367

367368
ACCESSOR ::= 'm' // materializeForSet

docs/AccessControlInStdlib.md

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
# Scope and introduction
2+
3+
This document defines the policy for applying access control modifiers
4+
and related naming conventions for the Swift standard library and
5+
overlays.
6+
7+
In this document, \"stdlib\" refers to the core standard library and
8+
overlays for system frameworks written in Swift.
9+
10+
Swift has four levels of access control — `private`, `fileprivate`, `internal`
11+
and `public`. As currently implemented, access control is only concerned with
12+
API-level issues, not ABI. The stdlib does not have a stable ABI, and is
13+
compiled in \"non-resilient\" mode with inlining into user code; thus,
14+
all stdlib symbols are considered ABI and stdlib clients should be
15+
recompiled after *any* change to the stdlib.
16+
17+
# `public`
18+
19+
User-visible APIs should be marked public.
20+
21+
Unfortunately, the compiler has bugs and limitations that the stdlib
22+
must work around by defining additional public symbols not intended for
23+
direct consumption by users. For example:
24+
25+
```swift
26+
// Workaround.
27+
public protocol _Pointer {
28+
// ...
29+
}
30+
31+
// Symbol intended for use outside stdlib.
32+
public struct UnsafeRawPointer: _Pointer {
33+
// ...
34+
}
35+
```
36+
37+
These symbols are hidden using the [leading underscore
38+
rule](#leading-underscore-rule).
39+
40+
Because Swift does not yet support a notion of SPI, any implementation
41+
details that are shared across the stdlib\'s various sub-modules must
42+
also be public. These names, too, use the [leading underscore
43+
rule](#leading-underscore-rule).
44+
45+
To document the reason for marking symbols public, we use comments:
46+
47+
- symbols used in tests:
48+
49+
public // @testable
50+
func _foo() { ... }
51+
52+
- symbols that are SPIs for the module X:
53+
54+
public // SPI(X)
55+
func _foo() { ... }
56+
57+
# `internal`
58+
59+
In Swift, `internal` is an implied default everywhere — except within `public`
60+
extensions and protocols. Therefore, `internal` should be used explicitly
61+
everywhere in the stdlib to avoid confusion.
62+
63+
### Note
64+
65+
> No declaration should omit an access.
66+
67+
To create a \"single point of truth\" about whether a name is intended
68+
for user consumption, the following names should all use the [leading
69+
underscore rule](#leading-underscore-rule):
70+
71+
- module-scope `private` and `internal`
72+
symbols:
73+
74+
```swift
75+
var _internalStdlibConstant: Int { ... }
76+
```
77+
78+
- `private` and `internal` symbols nested within `public` types:
79+
80+
```swift
81+
public struct Dictionary {
82+
var _representation: _DictionaryRepresentation
83+
}
84+
```
85+
86+
# `private`
87+
88+
# Leading Underscore Rule
89+
90+
Variables, functions and typealiases should have names that start with
91+
an underscore:
92+
93+
```swift
94+
var _value: Int
95+
func _bridgeSomethingToAnything(_ something: AnyObject) -> AnyObject
96+
typealias _InternalTypealias = HeapBuffer<Int, Int>
97+
```
98+
99+
To apply the rule to an initializer, one of its label arguments *or*
100+
internal parameter names must start with an underscore:
101+
102+
```
103+
public struct Foo {
104+
init(_count: Int) {}
105+
init(_ _otherInitializer: Int) {}
106+
}
107+
```
108+
109+
### Note
110+
111+
> The identifier that consists of a single underscore `_` is not
112+
considered to be a name that starts with an underscore. For example,
113+
this initializer is public:
114+
115+
```swift
116+
public struct Foo {
117+
init(\_ count: Int) {}
118+
119+
}
120+
```
121+
122+
The compiler and IDE tools may use the leading underscore rule, combined
123+
with additional heuristics, to hide stdlib symbols that users don\'t
124+
need to see.
125+
126+
Users are prohibited to use leading underscores symbols in their own
127+
source code, even if these symbols are visible through compiler
128+
diagnostics or IDE tools.

0 commit comments

Comments
 (0)