Skip to content

Commit 8f79bb8

Browse files
Suyash SrijanSuyash Srijan
authored andcommitted
Merge branch 'master' into fix/throw-in-defer
2 parents a750f22 + de65d30 commit 8f79bb8

File tree

746 files changed

+11947
-5449
lines changed

Some content is hidden

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

746 files changed

+11947
-5449
lines changed

CHANGELOG.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,69 @@ CHANGELOG
2525
Swift 5.1
2626
---------
2727

28+
* [SE-0068][]:
29+
30+
`Self` can now be used inside member functions and for function arguments of structs and enums to refer to the containing type.
31+
32+
* [SR-7799][]:
33+
34+
Enum cases can now be matched against an optional enum without
35+
requiring a '?' at the end of the pattern.
36+
37+
```swift
38+
enum Foo { case zero, one }
39+
40+
let foo: Foo? = .zero
41+
42+
switch foo {
43+
case .zero: break
44+
case .one: break
45+
case .none: break
46+
}
47+
```
48+
49+
* `weak` and `unowned` variables can now be used inside types that
50+
declare `Equatable` or `Hashable` conformance.
51+
52+
* [SR-2688][]:
53+
54+
An `@autoclosure` closure can now be a typealias.
55+
56+
```swift
57+
class Foo {
58+
typealias FooClosure = () -> String
59+
func fooFunction(closure: @autoclosure FooClosure) {}
60+
}
61+
```
62+
63+
* [SR-7601][]:
64+
65+
Functions marked with `@objc` can now return `Self`
66+
67+
```swift
68+
@objc func returnDynamicSelf() -> Self { return self }
69+
```
70+
71+
* [SR-2176][]:
72+
73+
Assigning '.none' to an optional enum which also has a 'none' case
74+
or comparing such an enum with '.none' will now warn. Such expressions
75+
create an ambiguity because the compiler chooses Optional.none
76+
over Foo.none.
77+
78+
```swift
79+
enum Foo { case none }
80+
81+
// Assigned Optional.none instead of Foo.none
82+
let foo: Foo? = .none
83+
// Comparing with Optional.none instead of Foo.none
84+
let isEqual = foo == .none
85+
```
86+
87+
The compiler will provide a warning along with a fix-it to
88+
replace '.none' with 'Optional.none' or 'Foo.none' to resolve
89+
the ambiguity.
90+
2891
* Key path expressions can now include references to tuple elements.
2992

3093
* Single-parameter functions accepting values of type `Any` are no
@@ -7452,12 +7515,16 @@ Swift 1.0
74527515
[SR-1446]: <https://bugs.swift.org/browse/SR-1446>
74537516
[SR-1529]: <https://bugs.swift.org/browse/SR-1529>
74547517
[SR-2131]: <https://bugs.swift.org/browse/SR-2131>
7518+
[SR-2176]: <https://bugs.swift.org/browse/SR-2176>
74557519
[SR-2388]: <https://bugs.swift.org/browse/SR-2388>
74567520
[SR-2394]: <https://bugs.swift.org/browse/SR-2394>
74577521
[SR-2608]: <https://bugs.swift.org/browse/SR-2608>
7522+
[SR-2688]: <https://bugs.swift.org/browse/SR-2688>
74587523
[SR-4248]: <https://bugs.swift.org/browse/SR-4248>
74597524
[SR-5581]: <https://bugs.swift.org/browse/SR-5581>
74607525
[SR-5719]: <https://bugs.swift.org/browse/SR-5719>
74617526
[SR-7139]: <https://bugs.swift.org/browse/SR-7139>
74627527
[SR-7251]: <https://bugs.swift.org/browse/SR-7251>
7528+
[SR-7601]: <https://bugs.swift.org/browse/SR-7601>
7529+
[SR-7799]: <https://bugs.swift.org/browse/SR-7799>
74637530
[SR-8109]: <https://bugs.swift.org/browse/SR-8109>

CMakeLists.txt

Lines changed: 62 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,17 @@ endif()
1111
list(APPEND CMAKE_MODULE_PATH
1212
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
1313

14-
# Make a job pool for things that can't yet be distributed
15-
cmake_host_system_information(
16-
RESULT localhost_logical_cores QUERY NUMBER_OF_LOGICAL_CORES)
17-
set_property(GLOBAL PROPERTY JOB_POOLS local_jobs=${localhost_logical_cores})
18-
# Put linking in that category
19-
set_property(GLOBAL PROPERTY JOB_POOL_LINK local_jobs)
14+
if(DEFINED CMAKE_JOB_POOLS)
15+
# CMake < 3.11 doesn't support CMAKE_JOB_POOLS. Manually set the property.
16+
set_property(GLOBAL PROPERTY JOB_POOLS "${CMAKE_JOB_POOLS}")
17+
else()
18+
# Make a job pool for things that can't yet be distributed
19+
cmake_host_system_information(
20+
RESULT localhost_logical_cores QUERY NUMBER_OF_LOGICAL_CORES)
21+
set_property(GLOBAL PROPERTY JOB_POOLS local_jobs=${localhost_logical_cores})
22+
# Put linking in that category
23+
set(CMAKE_JOB_POOL_LINK local_jobs)
24+
endif()
2025

2126
ENABLE_LANGUAGE(C)
2227

@@ -101,25 +106,6 @@ if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
101106
message(STATUS "No build type was specified, will default to ${CMAKE_BUILD_TYPE}")
102107
endif()
103108

104-
set(SWIFT_STDLIB_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING
105-
"Build type for the Swift standard library and SDK overlays [Debug, RelWithDebInfo, Release, MinSizeRel]")
106-
set_property(CACHE SWIFT_STDLIB_BUILD_TYPE PROPERTY
107-
STRINGS "Debug" "RelWithDebInfo" "Release" "MinSizeRel")
108-
109-
is_build_type_optimized("${SWIFT_STDLIB_BUILD_TYPE}" swift_optimized)
110-
if(swift_optimized)
111-
set(SWIFT_STDLIB_ASSERTIONS_default FALSE)
112-
else()
113-
set(SWIFT_STDLIB_ASSERTIONS_default TRUE)
114-
endif()
115-
option(SWIFT_STDLIB_ASSERTIONS
116-
"Enable internal checks for the Swift standard library (useful for debugging the library itself, does not affect checks required for safety)"
117-
"${SWIFT_STDLIB_ASSERTIONS_default}")
118-
119-
option(SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER
120-
"Use the host compiler and not the internal clang to build the swift runtime"
121-
FALSE)
122-
123109
set(SWIFT_ANALYZE_CODE_COVERAGE FALSE CACHE STRING
124110
"Build Swift with code coverage instrumenting enabled [FALSE, NOT-MERGED, MERGED]")
125111
set_property(CACHE SWIFT_ANALYZE_CODE_COVERAGE PROPERTY
@@ -146,23 +132,6 @@ set(SWIFT_ENABLE_LLD_LINKER TRUE CACHE BOOL
146132
set(SWIFT_ENABLE_GOLD_LINKER TRUE CACHE BOOL
147133
"Enable using the gold linker when available")
148134

149-
set(SWIFT_SDKS "" CACHE STRING
150-
"If non-empty, limits building target binaries only to specified SDKs (despite other SDKs being available)")
151-
152-
set(SWIFT_PRIMARY_VARIANT_SDK "" CACHE STRING
153-
"Primary SDK for target binaries")
154-
set(SWIFT_PRIMARY_VARIANT_ARCH "" CACHE STRING
155-
"Primary arch for target binaries")
156-
157-
set(SWIFT_NATIVE_LLVM_TOOLS_PATH "" CACHE STRING
158-
"Path to the directory that contains LLVM tools that are executable on the build machine")
159-
160-
set(SWIFT_NATIVE_CLANG_TOOLS_PATH "" CACHE STRING
161-
"Path to the directory that contains Clang tools that are executable on the build machine")
162-
163-
set(SWIFT_NATIVE_SWIFT_TOOLS_PATH "" CACHE STRING
164-
"Path to the directory that contains Swift tools that are executable on the build machine")
165-
166135
set(SWIFT_TOOLS_ENABLE_LTO OFF CACHE STRING "Build Swift tools with LTO. One
167136
must specify the form of LTO by setting this to one of: 'full', 'thin'. This
168137
option only affects the tools that run on the host (the compiler), and has
@@ -176,10 +145,6 @@ option(SWIFT_FORCE_OPTIMIZED_TYPECHECKER "Override the optimization setting of
176145
the type checker so that it always compiles with optimization. This eases
177146
debugging after type checking occurs by speeding up type checking" FALSE)
178147

179-
option(SWIFT_ENABLE_PARSEABLE_MODULE_INTERFACES
180-
"Generate .swiftinterface files alongside .swiftmodule files"
181-
TRUE)
182-
183148
# Allow building Swift with Clang's Profile Guided Optimization
184149
if(SWIFT_PROFDATA_FILE AND EXISTS ${SWIFT_PROFDATA_FILE})
185150
if(NOT CMAKE_C_COMPILER_ID MATCHES Clang)
@@ -188,6 +153,57 @@ if(SWIFT_PROFDATA_FILE AND EXISTS ${SWIFT_PROFDATA_FILE})
188153
add_definitions("-fprofile-instr-use=${SWIFT_PROFDATA_FILE}")
189154
endif()
190155

156+
#
157+
# User-configurable Swift Standard Library specific options.
158+
#
159+
# TODO: Once the stdlib/compiler builds are split, this should be sunk into the
160+
# stdlib cmake.
161+
#
162+
163+
set(SWIFT_STDLIB_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING
164+
"Build type for the Swift standard library and SDK overlays [Debug, RelWithDebInfo, Release, MinSizeRel]")
165+
set_property(CACHE SWIFT_STDLIB_BUILD_TYPE PROPERTY
166+
STRINGS "Debug" "RelWithDebInfo" "Release" "MinSizeRel")
167+
168+
is_build_type_optimized("${SWIFT_STDLIB_BUILD_TYPE}" swift_optimized)
169+
if(swift_optimized)
170+
set(SWIFT_STDLIB_ASSERTIONS_default FALSE)
171+
else()
172+
set(SWIFT_STDLIB_ASSERTIONS_default TRUE)
173+
endif()
174+
option(SWIFT_STDLIB_ASSERTIONS
175+
"Enable internal checks for the Swift standard library (useful for debugging the library itself, does not affect checks required for safety)"
176+
"${SWIFT_STDLIB_ASSERTIONS_default}")
177+
178+
option(SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER
179+
"Use the host compiler and not the internal clang to build the swift runtime"
180+
FALSE)
181+
182+
set(SWIFT_SDKS "" CACHE STRING
183+
"If non-empty, limits building target binaries only to specified SDKs (despite other SDKs being available)")
184+
185+
set(SWIFT_PRIMARY_VARIANT_SDK "" CACHE STRING
186+
"Primary SDK for target binaries")
187+
set(SWIFT_PRIMARY_VARIANT_ARCH "" CACHE STRING
188+
"Primary arch for target binaries")
189+
190+
set(SWIFT_NATIVE_LLVM_TOOLS_PATH "" CACHE STRING
191+
"Path to the directory that contains LLVM tools that are executable on the build machine")
192+
193+
set(SWIFT_NATIVE_CLANG_TOOLS_PATH "" CACHE STRING
194+
"Path to the directory that contains Clang tools that are executable on the build machine")
195+
196+
set(SWIFT_NATIVE_SWIFT_TOOLS_PATH "" CACHE STRING
197+
"Path to the directory that contains Swift tools that are executable on the build machine")
198+
199+
option(SWIFT_ENABLE_PARSEABLE_MODULE_INTERFACES
200+
"Generate .swiftinterface files alongside .swiftmodule files"
201+
TRUE)
202+
203+
option(SWIFT_STDLIB_ENABLE_SIB_TARGETS
204+
"Should we generate sib targets for the stdlib or not?"
205+
FALSE)
206+
191207
#
192208
# User-configurable Android specific options.
193209
#
@@ -234,10 +250,6 @@ option(SWIFT_RUNTIME_CRASH_REPORTER_CLIENT
234250
"Whether to enable CrashReporter integration"
235251
FALSE)
236252

237-
option(SWIFT_DARWIN_ENABLE_STABLE_ABI_BIT
238-
"Enable the Swift stable ABI's class marker bit"
239-
FALSE)
240-
241253
set(SWIFT_DARWIN_XCRUN_TOOLCHAIN "XcodeDefault" CACHE STRING
242254
"The name of the toolchain to pass to 'xcrun'")
243255

@@ -315,10 +327,6 @@ option(SWIFT_STDLIB_USE_NONATOMIC_RC
315327
"Build the standard libraries and overlays with nonatomic reference count operations enabled"
316328
FALSE)
317329

318-
option(SWIFT_STDLIB_ENABLE_SIL_OWNERSHIP
319-
"Build the standard libraries and overlays with sil ownership enabled."
320-
FALSE)
321-
322330
option(SWIFT_ENABLE_RUNTIME_FUNCTION_COUNTERS
323331
"Enable runtime function counters and expose the API."
324332
FALSE)

apinotes/os.apinotes

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ Enumerators:
3030
SwiftPrivate: true
3131
Functions:
3232
- Name: _os_log_impl
33-
Availability: nonswift
34-
AvailabilityMsg: 'Use os_log'
33+
SwiftPrivate: true
34+
NullabilityOfRet: O
3535
- Name: _os_log_error_impl
3636
Availability: nonswift
3737
AvailabilityMsg: 'Use os_log'

benchmark/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ set(SWIFT_BENCH_MODULES
134134
single-source/RandomValues
135135
single-source/RangeAssignment
136136
single-source/RangeIteration
137+
single-source/RangeOverlaps
137138
single-source/RangeReplaceableCollectionPlusDefault
138139
single-source/RecursiveOwnedParameter
139140
single-source/ReduceInto

benchmark/cmake/modules/AddSwiftBenchmarkSuite.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ macro(configure_sdks_darwin)
7777
set(appletvos_ver "9.1")
7878
set(watchos_ver "2.0")
7979

80+
set(macosx_vendor "apple")
81+
set(iphoneos_vendor "apple")
82+
set(appletvos_vendor "apple")
83+
set(watchos_vendor "apple")
84+
8085
set(macosx_triple_platform "macosx")
8186
set(iphoneos_triple_platform "ios")
8287
set(appletvos_triple_platform "tvos")
@@ -309,6 +314,7 @@ function (swift_benchmark_compile_archopts)
309314

310315
set(common_options
311316
"-c"
317+
"-Xfrontend" "-verify-sil-ownership"
312318
"-target" "${target}"
313319
"-${BENCH_COMPILE_ARCHOPTS_OPT}" ${PAGE_ALIGNMENT_OPTION})
314320

@@ -338,6 +344,7 @@ function (swift_benchmark_compile_archopts)
338344

339345
set(common_options_driver
340346
"-c"
347+
"-Xfrontend" "-verify-sil-ownership"
341348
"-target" "${target}"
342349
"-${driver_opt}")
343350

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
//===--- RangeOverlaps.swift ----------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2019 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
import TestsUtils
14+
15+
public let RangeOverlaps = [
16+
BenchmarkInfo(
17+
name: "RangeOverlapsRange",
18+
runFunction: run_RangeOverlapsRange,
19+
tags: [.validation, .api],
20+
setUpFunction: buildRanges),
21+
BenchmarkInfo(
22+
name: "RangeOverlapsClosedRange",
23+
runFunction: run_RangeOverlapsClosedRange,
24+
tags: [.validation, .api],
25+
setUpFunction: buildRanges),
26+
BenchmarkInfo(
27+
name: "ClosedRangeOverlapsClosedRange",
28+
runFunction: run_ClosedRangeOverlapsClosedRange,
29+
tags: [.validation, .api],
30+
setUpFunction: buildRanges)
31+
]
32+
33+
private func buildRanges() {
34+
blackHole(ranges)
35+
blackHole(closedRanges)
36+
}
37+
38+
private let ranges: [Range<Int>] = (-8...8).flatMap { a in (0...16).map { l in a..<(a+l) } }
39+
private let closedRanges: [ClosedRange<Int>] = (-8...8).flatMap { a in (0...16).map { l in a...(a+l) } }
40+
41+
@inline(never)
42+
public func run_RangeOverlapsRange(_ N: Int) {
43+
var check: UInt64 = 0
44+
for _ in 0..<N {
45+
for lhs in ranges {
46+
for rhs in ranges {
47+
if lhs.overlaps(rhs) { check += 1 }
48+
}
49+
}
50+
}
51+
CheckResults(check == 47872 * UInt64(N))
52+
}
53+
54+
@inline(never)
55+
public func run_RangeOverlapsClosedRange(_ N: Int) {
56+
var check: UInt64 = 0
57+
for _ in 0..<N {
58+
for lhs in ranges {
59+
for rhs in closedRanges {
60+
if lhs.overlaps(rhs) { check += 1 }
61+
}
62+
}
63+
}
64+
CheckResults(check == 51680 * UInt64(N))
65+
}
66+
67+
@inline(never)
68+
public func run_ClosedRangeOverlapsClosedRange(_ N: Int) {
69+
var check: UInt64 = 0
70+
for _ in 0..<N {
71+
for lhs in closedRanges {
72+
for rhs in closedRanges {
73+
if lhs.overlaps(rhs) { check += 1 }
74+
}
75+
}
76+
}
77+
CheckResults(check == 55777 * UInt64(N))
78+
}

benchmark/utils/main.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ import RandomShuffle
127127
import RandomValues
128128
import RangeAssignment
129129
import RangeIteration
130+
import RangeOverlaps
130131
import RangeReplaceableCollectionPlusDefault
131132
import RecursiveOwnedParameter
132133
import ReduceInto
@@ -298,6 +299,7 @@ registerBenchmark(RandomShuffle)
298299
registerBenchmark(RandomValues)
299300
registerBenchmark(RangeAssignment)
300301
registerBenchmark(RangeIteration)
302+
registerBenchmark(RangeOverlaps)
301303
registerBenchmark(RangeReplaceableCollectionPlusDefault)
302304
registerBenchmark(RecursiveOwnedParameter)
303305
registerBenchmark(ReduceInto)

0 commit comments

Comments
 (0)