Skip to content

Commit a2460b8

Browse files
Suyash SrijanSuyash Srijan
authored andcommitted
Merge branch 'master' into fix/SR-6022
2 parents 77300c3 + a3f54ae commit a2460b8

File tree

478 files changed

+13476
-7038
lines changed

Some content is hidden

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

478 files changed

+13476
-7038
lines changed

CHANGELOG.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,33 @@ CHANGELOG
2121

2222
</details>
2323

24+
Swift 5.1
25+
---------
26+
27+
* Key path expressions can now include references to tuple elements.
28+
2429
Swift 5.0
2530
---------
2631

32+
* [SE-0235][]:
33+
34+
The standard library now contains a `Result` type for manually propagating errors.
35+
36+
```swift
37+
enum Result<Success, Failure: Error> {
38+
case success(Success)
39+
case failure(Failure)
40+
}
41+
```
42+
43+
This type serves a complementary role to that of throwing functions and initializers.
44+
Use `Result` in situations where automatic error propagation or `try`-`catch`
45+
blocks are undesirable, such as in asynchronous code or when accumulating the
46+
results of successive error-producing operations.
47+
48+
* `Error` now conforms to itself. This allows for the use of `Error` itself as
49+
the argument for a generic parameter constrained to `Error`.
50+
2751
* Swift 3 mode has been removed. Supported values for the `-swift-version`
2852
flag are `4`, `4.2`, and `5`.
2953

@@ -7406,6 +7430,7 @@ Swift 1.0
74067430
[SE-0227]: <https://github.com/apple/swift-evolution/blob/master/proposals/0227-identity-keypath.md>
74077431
[SE-0228]: <https://github.com/apple/swift-evolution/blob/master/proposals/0228-fix-expressiblebystringinterpolation.md>
74087432
[SE-0230]: <https://github.com/apple/swift-evolution/blob/master/proposals/0230-flatten-optional-try.md>
7433+
[SE-0235]: <https://github.com/apple/swift-evolution/blob/master/proposals/0235-add-result.md>
74097434

74107435
[SR-106]: <https://bugs.swift.org/browse/SR-106>
74117436
[SR-419]: <https://bugs.swift.org/browse/SR-419>

CMakeLists.txt

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -413,13 +413,24 @@ elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
413413
set(SWIFT_BUILD_SYNTAXPARSERLIB_default FALSE)
414414
set(SWIFT_BUILD_SOURCEKIT_default FALSE)
415415
endif()
416+
elseif(CMAKE_SYSTEM_NAME STREQUAL Windows)
417+
if(EXISTS ${SWIFT_PATH_TO_LIBDISPATCH_SOURCE} AND
418+
CMAKE_CXX_COMPILER_ID STREQUAL Clang)
419+
set(SWIFT_BUILD_SYNTAXPARSERLIB_default TRUE)
420+
set(SWIFT_BUILD_SOURCEKIT_default TRUE)
421+
else()
422+
set(SWIFT_BUILD_SYNTAXPARSERLIB_default FALSE)
423+
set(SWIFT_BUILD_SOURCEKIT_default FALSE)
424+
endif()
416425
else()
417426
set(SWIFT_BUILD_SYNTAXPARSERLIB_default FALSE)
418427
set(SWIFT_BUILD_SOURCEKIT_default FALSE)
419428
endif()
420429
option(SWIFT_BUILD_SYNTAXPARSERLIB
421430
"Build the Swift Syntax Parser library"
422431
${SWIFT_BUILD_SYNTAXPARSERLIB_default})
432+
option(SWIFT_BUILD_ONLY_SYNTAXPARSERLIB
433+
"Only build the Swift Syntax Parser library" FALSE)
423434
option(SWIFT_BUILD_SOURCEKIT
424435
"Build SourceKit"
425436
${SWIFT_BUILD_SOURCEKIT_default})
@@ -496,15 +507,11 @@ include(SwiftSharedCMakeConfig)
496507
# Support building Swift as a standalone project, using LLVM as an
497508
# external library.
498509
if(SWIFT_BUILT_STANDALONE)
499-
swift_common_standalone_build_config(SWIFT SWIFT_CROSS_COMPILING)
510+
swift_common_standalone_build_config(SWIFT)
500511
else()
501512
swift_common_unified_build_config(SWIFT)
502513
endif()
503514

504-
if(NOT EXISTS "${CLANG_MAIN_INCLUDE_DIR}/clang/AST/Decl.h")
505-
message(FATAL_ERROR "Clang is missing from llvm/tools subdirectory.")
506-
endif()
507-
508515
set(SWIFT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
509516
set(SWIFT_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
510517
set(SWIFT_CMAKE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
@@ -902,8 +909,18 @@ if(SWIFT_NEED_EXPLICIT_LIBDISPATCH)
902909
set(SWIFT_LIBDISPATCH_C_COMPILER ${CMAKE_C_COMPILER})
903910
set(SWIFT_LIBDISPATCH_CXX_COMPILER ${CMAKE_CXX_COMPILER})
904911
elseif(${CMAKE_SYSTEM_NAME} STREQUAL ${CMAKE_HOST_SYSTEM_NAME})
905-
set(SWIFT_LIBDISPATCH_C_COMPILER ${PATH_TO_CLANG_BUILD}/bin/clang)
906-
set(SWIFT_LIBDISPATCH_CXX_COMPILER ${PATH_TO_CLANG_BUILD}/bin/clang++)
912+
get_target_property(CLANG_LOCATION clang LOCATION)
913+
get_filename_component(CLANG_LOCATION ${CLANG_LOCATION} DIRECTORY)
914+
915+
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
916+
set(SWIFT_LIBDISPATCH_C_COMPILER
917+
${CLANG_LOCATION}/clang-cl${CMAKE_EXECUTABLE_SUFFIX})
918+
set(SWIFT_LIBDISPATCH_CXX_COMPILER
919+
${CLANG_LOCATION}/clang-cl${CMAKE_EXECUTABLE_SUFFIX})
920+
else()
921+
set(SWIFT_LIBDISPATCH_C_COMPILER ${CLANG_LOCATION}/clang)
922+
set(SWIFT_LIBDISPATCH_CXX_COMPILER ${CLANG_LOCATION}/clang++)
923+
endif()
907924
else()
908925
message(SEND_ERROR "libdispatch requires a newer clang compiler (${CMAKE_C_COMPILER_VERSION} < 3.9)")
909926
endif()

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
|**[Ubuntu 16.04](https://github.com/apple/swift-community-hosted-continuous-integration/blob/master/nodes/x86_64_ubuntu_16_04.json)** | x86_64 |[![Build Status](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04)|
2020
|**[Ubuntu 16.04 ](https://github.com/apple/swift-community-hosted-continuous-integration/blob/master/nodes/ppc64le_ubuntu_16_04.json)** | PPC64LE |[![Build Status](https://ci-external.swift.org/job/oss-swift-4.1-RA-linux-ubuntu-16.04-ppc64le/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-4.1-RA-linux-ubuntu-16.04-ppc64le)|
2121
|**[Ubuntu 16.04 ](https://github.com/apple/swift-community-hosted-continuous-integration/blob/master/nodes/aarch64_ubuntu_16.04.json)** | AArch64 |[![Build Status](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04-aarch64/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04-aarch64)|
22-
|**[Ubuntu 16.04 (Android)](https://github.com/apple/swift-community-hosted-continuous-integration/blob/master/nodes/x86_64_ubuntu_16_04_LTS_android.json)** | x86_64 |[![Build Status](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04-android/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04-android)|
22+
|**[Android](https://github.com/apple/swift-community-hosted-continuous-integration/blob/master/nodes/x86_64_ubuntu_16_04_LTS_android.json)** | ARMv7 |[![Build Status](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04-android/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04-android)|
23+
|**[Android](https://github.com/apple/swift-community-hosted-continuous-integration/blob/master/nodes/x86_64_ubuntu_16_04_LTS_android.json)** | AArch64 |[![Build Status](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04-android-arm64/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04-android-arm64)|
2324
|**[Ubuntu 16.04 (TensorFlow)](https://github.com/apple/swift-community-hosted-continuous-integration/blob/master/nodes/x86_64_ubuntu_16_04_tensorflow.json)** | x86_64 |[![Build Status](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04-tensorflow/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04-tensorflow)|
2425
|**[macOS 10.13 (TensorFlow)](https://github.com/apple/swift-community-hosted-continuous-integration/blob/master/nodes/x86_64_macos_high_sierra_tensorflow.json)** | x86_64 |[![Build Status](https://ci-external.swift.org/job/oss-swift-RA-macOS-tensorflow/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-RA-macOS-tensorflow)|
2526
|**[Ubuntu 16.04 (TensorFlow with GPU)](https://github.com/apple/swift-community-hosted-continuous-integration/blob/master/nodes/x86_64_ubuntu_16_04_tensorflow_gpu.json)** | x86_64 |[![Build Status](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04-tensorflow-gpu/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04-tensorflow-gpu)|

benchmark/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ set(SWIFT_BENCH_MODULES
7777
single-source/DictionaryRemove
7878
single-source/DictionarySubscriptDefault
7979
single-source/DictionarySwap
80-
single-source/DoubleWidthDivision
8180
single-source/DropFirst
8281
single-source/DropLast
8382
single-source/DropWhile

benchmark/single-source/ArrayInClass.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@ public let ArrayInClass = [
1717
runFunction: run_ArrayInClass,
1818
tags: [.validation, .api, .Array],
1919
setUpFunction: { ac = ArrayContainer() },
20-
tearDownFunction: { ac = nil }),
20+
tearDownFunction: { ac = nil },
21+
legacyFactor: 5),
2122
BenchmarkInfo(name: "DistinctClassFieldAccesses",
2223
runFunction: run_DistinctClassFieldAccesses,
23-
tags: [.unstable, .api, .Array],
24-
setUpFunction: { workload = ClassWithArrs(N: 100_000) },
24+
tags: [.validation, .api, .Array],
25+
setUpFunction: { workload = ClassWithArrs(N: 10_000) },
2526
tearDownFunction: { workload = nil }),
2627
]
2728

@@ -31,7 +32,7 @@ class ArrayContainer {
3132
final var arr : [Int]
3233

3334
init() {
34-
arr = [Int] (repeating: 0, count: 100_000)
35+
arr = [Int] (repeating: 0, count: 20_000)
3536
}
3637

3738
func runLoop(_ N: Int) {

benchmark/single-source/DictionaryOfAnyHashableStrings.swift

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,15 @@ public var DictionaryOfAnyHashableStrings = [
2121
name: "DictionaryOfAnyHashableStrings_insert",
2222
runFunction: run_DictionaryOfAnyHashableStrings_insert,
2323
tags: [.abstraction, .runtime, .cpubench],
24-
setUpFunction: {
25-
keys = buildKeys(500)
26-
}
24+
setUpFunction: { keys = buildKeys(50) },
25+
legacyFactor: 14
2726
),
2827
BenchmarkInfo(
2928
name: "DictionaryOfAnyHashableStrings_lookup",
3029
runFunction: run_DictionaryOfAnyHashableStrings_lookup,
3130
tags: [.abstraction, .runtime, .cpubench],
32-
setUpFunction: {
33-
keys = buildKeys(500)
34-
workload = buildWorkload()
35-
}
31+
setUpFunction: { keys = buildKeys(50); workload = buildWorkload() },
32+
legacyFactor: 24
3633
),
3734
]
3835

@@ -65,7 +62,7 @@ func buildWorkload() -> [AnyHashable: Any] {
6562
@inline(never)
6663
public func run_DictionaryOfAnyHashableStrings_insert(_ n: Int) {
6764
precondition(keys.count > 0)
68-
for _ in 0 ... n {
65+
for _ in 1...n {
6966
blackHole(buildWorkload())
7067
}
7168
}
@@ -74,7 +71,7 @@ public func run_DictionaryOfAnyHashableStrings_insert(_ n: Int) {
7471
public func run_DictionaryOfAnyHashableStrings_lookup(_ n: Int) {
7572
precondition(workload.count > 0)
7673
precondition(keys.count > 0)
77-
for _ in 0 ... n {
74+
for _ in 1...n {
7875
for i in 0 ..< keys.count {
7976
let key = keys[i]
8077
CheckResults((workload[key] as! Int) == i)

benchmark/single-source/DoubleWidthDivision.swift

Lines changed: 0 additions & 63 deletions
This file was deleted.

benchmark/single-source/Substring.swift

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ public let SubstringTest = [
3131

3232
// A string that doesn't fit in small string storage and doesn't fit in Latin-1
3333
let longWide = "fὢasὢodὢijὢadὢolὢsjὢalὢsdὢjlὢasὢdfὢijὢliὢsdὢjøὢslὢdiὢalὢiὢ"
34+
let (s1, ss1) = equivalentWithDistinctBuffers()
35+
let (s2, ss2) = equivalentWithDistinctBuffers()
3436

3537
@inline(never)
3638
public func run_SubstringFromLongString(_ N: Int) {
@@ -89,33 +91,33 @@ private func equivalentWithDistinctBuffers() -> (String, Substring) {
8991

9092
@inline(never)
9193
public func run_EqualStringSubstring(_ N: Int) {
92-
let (a, b) = equivalentWithDistinctBuffers()
94+
let (a, b) = (s1, ss1)
9395
for _ in 1...N*500 {
9496
blackHole(a == b)
9597
}
9698
}
9799

98100
@inline(never)
99101
public func run_EqualSubstringString(_ N: Int) {
100-
let (a, b) = equivalentWithDistinctBuffers()
102+
let (a, b) = (s1, ss1)
101103
for _ in 1...N*500 {
102104
blackHole(b == a)
103105
}
104106
}
105107

106108
@inline(never)
107109
public func run_EqualSubstringSubstring(_ N: Int) {
108-
let (_, a) = equivalentWithDistinctBuffers()
109-
let (_, b) = equivalentWithDistinctBuffers()
110+
let (_, a) = (s1, ss1)
111+
let (_, b) = (s2, ss2)
110112
for _ in 1...N*500 {
111113
blackHole(a == b)
112114
}
113115
}
114116

115117
@inline(never)
116118
public func run_EqualSubstringSubstringGenericEquatable(_ N: Int) {
117-
let (_, a) = equivalentWithDistinctBuffers()
118-
let (_, b) = equivalentWithDistinctBuffers()
119+
let (_, a) = (s1, ss1)
120+
let (_, b) = (s2, ss2)
119121
func check<T>(_ x: T, _ y: T) where T : Equatable {
120122
blackHole(x == y)
121123
}
@@ -132,24 +134,24 @@ where T : StringProtocol, U : StringProtocol {
132134

133135
@inline(never)
134136
public func run _EqualStringSubstringGenericStringProtocol(_ N: Int) {
135-
let (a, b) = equivalentWithDistinctBuffers()
137+
let (a, b) = (s1, ss1)
136138
for _ in 1...N*500 {
137139
checkEqual(a, b)
138140
}
139141
}
140142

141143
@inline(never)
142144
public func run _EqualSubstringStringGenericStringProtocol(_ N: Int) {
143-
let (a, b) = equivalentWithDistinctBuffers()
145+
let (a, b) = (s1, ss1)
144146
for _ in 1...N*500 {
145147
checkEqual(b, a)
146148
}
147149
}
148150

149151
@inline(never)
150152
public func run _EqualSubstringSubstringGenericStringProtocol(_ N: Int) {
151-
let (_, a) = equivalentWithDistinctBuffers()
152-
let (_, b) = equivalentWithDistinctBuffers()
153+
let (_, a) = (s1, ss1)
154+
let (_, b) = (s2, ss2)
153155
for _ in 1...N*500 {
154156
checkEqual(a, b)
155157
}
@@ -161,15 +163,15 @@ public func run _EqualSubstringSubstringGenericStringProtocol(_ N: Int) {
161163
/*
162164
@inline(never)
163165
public func run _LessStringSubstring(_ N: Int) {
164-
let (a, b) = equivalentWithDistinctBuffers()
166+
let (a, b) = (s1, ss1)
165167
for _ in 1...N*500 {
166168
blackHole(a < b)
167169
}
168170
}
169171

170172
@inline(never)
171173
public func run _LessSubstringString(_ N: Int) {
172-
let (a, b) = equivalentWithDistinctBuffers()
174+
let (a, b) = (s1, ss1)
173175
for _ in 1...N*500 {
174176
blackHole(b < a)
175177
}
@@ -178,17 +180,17 @@ public func run _LessSubstringString(_ N: Int) {
178180

179181
@inline(never)
180182
public func run_LessSubstringSubstring(_ N: Int) {
181-
let (_, a) = equivalentWithDistinctBuffers()
182-
let (_, b) = equivalentWithDistinctBuffers()
183+
let (_, a) = (s1, ss1)
184+
let (_, b) = (s2, ss2)
183185
for _ in 1...N*500 {
184186
blackHole(a < b)
185187
}
186188
}
187189

188190
@inline(never)
189191
public func run_LessSubstringSubstringGenericComparable(_ N: Int) {
190-
let (_, a) = equivalentWithDistinctBuffers()
191-
let (_, b) = equivalentWithDistinctBuffers()
192+
let (_, a) = (s1, ss1)
193+
let (_, b) = (s2, ss2)
192194
func check<T>(_ x: T, _ y: T) where T : Comparable {
193195
blackHole(x < y)
194196
}
@@ -251,24 +253,24 @@ where T : StringProtocol, U : StringProtocol {
251253

252254
@inline(never)
253255
public func run _LessStringSubstringGenericStringProtocol(_ N: Int) {
254-
let (a, b) = equivalentWithDistinctBuffers()
256+
let (a, b) = (s1, ss1)
255257
for _ in 1...N*500 {
256258
checkLess(a, b)
257259
}
258260
}
259261

260262
@inline(never)
261263
public func run _LessSubstringStringGenericStringProtocol(_ N: Int) {
262-
let (a, b) = equivalentWithDistinctBuffers()
264+
let (a, b) = (s1, ss1)
263265
for _ in 1...N*500 {
264266
checkLess(b, a)
265267
}
266268
}
267269

268270
@inline(never)
269271
public func run _LessSubstringSubstringGenericStringProtocol(_ N: Int) {
270-
let (_, a) = equivalentWithDistinctBuffers()
271-
let (_, b) = equivalentWithDistinctBuffers()
272+
let (_, a) = (s1, ss1)
273+
let (_, b) = (s2, ss2)
272274
for _ in 1...N*500 {
273275
checkLess(a, b)
274276
}

0 commit comments

Comments
 (0)