Skip to content

Commit c6c0a6d

Browse files
authored
Merge pull request #17 from apple/master
merge
2 parents 1f0a78e + 0ebe9a1 commit c6c0a6d

File tree

1,977 files changed

+83829
-55403
lines changed

Some content is hidden

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

1,977 files changed

+83829
-55403
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.swift.gyb linguist-language=Swift
2+
*.cpp.gyb linguist-language=C++

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Replace this paragraph with a description of your changes and rationale. Provide links to external references/discussions if appropriate.
33

44
<!-- If this pull request resolves any bugs in the Swift bug tracker, provide a link: -->
5-
Resolves [SR-NNNN](https://bugs.swift.org/browse/SR-NNNN).
5+
Resolves SR-NNNN.
66

77
<!--
88
Before merging this pull request, you must run the Swift continuous integration tests.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
#==============================================================================#
2525
cscope.files
2626
cscope.out
27+
.vimrc
28+
tags
2729

2830
#==============================================================================#
2931
# Directories to ignore (do not add trailing '/'s, they skip symlinks).

CHANGELOG.md

Lines changed: 128 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,130 @@ CHANGELOG
44
<details>
55
<summary>Note: This is in reverse chronological order, so newer entries are added to the top.</summary>
66

7-
| Contents |
8-
| :--------------------- |
9-
| [Swift Next](#swift-next) |
10-
| [Swift 5.1](#swift-51) |
11-
| [Swift 5.0](#swift-50) |
12-
| [Swift 4.2](#swift-42) |
13-
| [Swift 4.1](#swift-41) |
14-
| [Swift 4.0](#swift-40) |
15-
| [Swift 3.1](#swift-31) |
16-
| [Swift 3.0](#swift-30) |
17-
| [Swift 2.2](#swift-22) |
18-
| [Swift 2.1](#swift-21) |
19-
| [Swift 2.0](#swift-20) |
20-
| [Swift 1.2](#swift-12) |
21-
| [Swift 1.1](#swift-11) |
22-
| [Swift 1.0](#swift-10) |
7+
| Version | Released | Toolchain |
8+
| :--------------------- | :--------- | :---------- |
9+
| [Swift 5.2](#swift-52) | | |
10+
| [Swift 5.1](#swift-51) | 2019-09-20 | Xcode 11.0 |
11+
| [Swift 5.0](#swift-50) | 2019-03-25 | Xcode 10.2 |
12+
| [Swift 4.2](#swift-42) | 2018-09-17 | Xcode 10.0 |
13+
| [Swift 4.1](#swift-41) | 2018-03-29 | Xcode 9.3 |
14+
| [Swift 4.0](#swift-40) | 2017-09-19 | Xcode 9.0 |
15+
| [Swift 3.1](#swift-31) | 2017-03-27 | Xcode 8.3 |
16+
| [Swift 3.0](#swift-30) | 2016-09-13 | Xcode 8.0 |
17+
| [Swift 2.2](#swift-22) | 2016-03-21 | Xcode 7.3 |
18+
| [Swift 2.1](#swift-21) | 2015-10-21 | Xcode 7.1 |
19+
| [Swift 2.0](#swift-20) | 2015-09-17 | Xcode 7.0 |
20+
| [Swift 1.2](#swift-12) | 2015-04-08 | Xcode 6.3 |
21+
| [Swift 1.1](#swift-11) | 2014-12-02 | Xcode 6.1.1 |
22+
| [Swift 1.0](#swift-10) | 2014-09-15 | Xcode 6.0 |
2323

2424
</details>
2525

26-
Swift Next
27-
----------
26+
Swift 5.2
27+
---------
28+
29+
* [SR-2790][]:
30+
31+
The compiler will now emit a warning when attempting to pass a temporary
32+
pointer argument produced from an array, string, or inout argument to a
33+
parameter which is known to escape it. This includes the various initializers
34+
for the `UnsafePointer`/`UnsafeBufferPointer` family of types, as well as
35+
memberwise initializers.
36+
37+
```swift
38+
struct S {
39+
var ptr: UnsafePointer<Int8>
40+
}
41+
42+
func foo() {
43+
var i: Int8 = 0
44+
let ptr = UnsafePointer(&i)
45+
// warning: initialization of 'UnsafePointer<Int8>' results in a
46+
// dangling pointer
47+
48+
let s1 = S(ptr: [1, 2, 3])
49+
// warning: passing '[Int8]' to parameter, but argument 'ptr' should be a
50+
// pointer that outlives the call to 'init(ptr:)'
51+
52+
let s2 = S(ptr: "hello")
53+
// warning: passing 'String' to parameter, but argument 'ptr' should be a
54+
// pointer that outlives the call to 'init(ptr:)'
55+
}
56+
```
57+
58+
All 3 of the above examples are unsound because each argument produces a
59+
temporary pointer only valid for the duration of the call they are passed to.
60+
Therefore the returned value in each case references a dangling pointer.
61+
62+
* [SR-2189][]:
63+
64+
The compiler now supports local functions whose default arguments capture
65+
values from outer scopes.
66+
67+
```swift
68+
func outer(x: Int) -> (Int, Int) {
69+
func inner(y: Int = x) -> Int {
70+
return y
71+
}
72+
73+
return (inner(), inner(y: 0))
74+
}
75+
```
76+
77+
* [SR-11429][]:
78+
79+
The compiler will now correctly strip argument labels from function references
80+
used with the `as` operator in a function call. As a result, the `as` operator
81+
can now be used to disambiguate a call to a function with argument labels.
82+
83+
```swift
84+
func foo(x: Int) {}
85+
func foo(x: UInt) {}
86+
87+
(foo as (Int) -> Void)(5) // Calls foo(x: Int)
88+
(foo as (UInt) -> Void)(5) // Calls foo(x: UInt)
89+
```
90+
91+
Previously this was only possible for functions without argument labels.
92+
93+
This change also means that a generic type alias can no longer be used to
94+
preserve the argument labels of a function reference through the `as`
95+
operator. The following is now rejected:
96+
97+
```swift
98+
typealias Magic<T> = T
99+
func foo(x: Int) {}
100+
(foo as Magic)(x: 5) // error: Extraneous argument label 'x:' in call
101+
```
102+
103+
The function value must instead be called without argument labels:
104+
105+
```swift
106+
(foo as Magic)(5)
107+
```
108+
109+
* [SR-11298][]:
110+
111+
A class-constrained protocol extension, where the extended protocol does
112+
not impose a class constraint, will now infer the constraint implicitly.
113+
114+
```swift
115+
protocol Foo {}
116+
class Bar: Foo {
117+
var someProperty: Int = 0
118+
}
119+
120+
// Even though 'Foo' does not impose a class constraint, it is automatically
121+
// inferred due to the Self: Bar constraint.
122+
extension Foo where Self: Bar {
123+
var anotherProperty: Int {
124+
get { return someProperty }
125+
// As a result, the setter is now implicitly nonmutating, just like it would
126+
// be if 'Foo' had a class constraint.
127+
set { someProperty = newValue }
128+
}
129+
}
130+
```
28131

29132
* [SE-0253][]:
30133

@@ -51,7 +154,7 @@ Swift Next
51154

52155
* [SR-4206][]:
53156

54-
A method override is no longer allowed to have a generic signature with
157+
A method override is no longer allowed to have a generic signature with
55158
requirements not imposed by the base method. For example:
56159

57160
```
@@ -88,6 +191,8 @@ Swift Next
88191
Swift 5.1
89192
---------
90193

194+
### 2019-09-20 (Xcode 11.0)
195+
91196
* [SR-8974][]:
92197

93198
Duplicate tuple element labels are no longer allowed, because it leads
@@ -7746,11 +7851,13 @@ Swift 1.0
77467851
[SR-1529]: <https://bugs.swift.org/browse/SR-1529>
77477852
[SR-2131]: <https://bugs.swift.org/browse/SR-2131>
77487853
[SR-2176]: <https://bugs.swift.org/browse/SR-2176>
7854+
[SR-2189]: <https://bugs.swift.org/browse/SR-2189>
77497855
[SR-2388]: <https://bugs.swift.org/browse/SR-2388>
77507856
[SR-2394]: <https://bugs.swift.org/browse/SR-2394>
77517857
[SR-2608]: <https://bugs.swift.org/browse/SR-2608>
77527858
[SR-2672]: <https://bugs.swift.org/browse/SR-2672>
77537859
[SR-2688]: <https://bugs.swift.org/browse/SR-2688>
7860+
[SR-2790]: <https://bugs.swift.org/browse/SR-2790>
77547861
[SR-4206]: <https://bugs.swift.org/browse/SR-4206>
77557862
[SR-4248]: <https://bugs.swift.org/browse/SR-4248>
77567863
[SR-5581]: <https://bugs.swift.org/browse/SR-5581>
@@ -7765,3 +7872,5 @@ Swift 1.0
77657872
[SR-8974]: <https://bugs.swift.org/browse/SR-8974>
77667873
[SR-9043]: <https://bugs.swift.org/browse/SR-9043>
77677874
[SR-9827]: <https://bugs.swift.org/browse/SR-9827>
7875+
[SR-11298]: <https://bugs.swift.org/browse/SR-11298>
7876+
[SR-11429]: <https://bugs.swift.org/browse/SR-11429>

CMakeLists.txt

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

14+
set(CMAKE_DISABLE_IN_SOURCE_BUILD YES)
15+
1416
if(DEFINED CMAKE_JOB_POOLS)
1517
# CMake < 3.11 doesn't support CMAKE_JOB_POOLS. Manually set the property.
1618
set_property(GLOBAL PROPERTY JOB_POOLS "${CMAKE_JOB_POOLS}")
1719
else()
1820
# Make a job pool for things that can't yet be distributed
1921
cmake_host_system_information(
2022
RESULT localhost_logical_cores QUERY NUMBER_OF_LOGICAL_CORES)
21-
set_property(GLOBAL PROPERTY JOB_POOLS local_jobs=${localhost_logical_cores})
23+
set_property(GLOBAL APPEND PROPERTY JOB_POOLS local_jobs=${localhost_logical_cores})
2224
# Put linking in that category
2325
set(CMAKE_JOB_POOL_LINK local_jobs)
2426
endif()
@@ -125,7 +127,7 @@ set(SWIFT_ANALYZE_CODE_COVERAGE FALSE CACHE STRING
125127
# SWIFT_VERSION is deliberately /not/ cached so that an existing build directory
126128
# can be reused when a new version of Swift comes out (assuming the user hasn't
127129
# manually set it as part of their own CMake configuration).
128-
set(SWIFT_VERSION "5.1")
130+
set(SWIFT_VERSION "5.1.1")
129131

130132
set(SWIFT_VENDOR "" CACHE STRING
131133
"The vendor name of the Swift compiler")
@@ -219,7 +221,7 @@ set(SWIFT_NATIVE_CLANG_TOOLS_PATH "" CACHE STRING
219221
set(SWIFT_NATIVE_SWIFT_TOOLS_PATH "" CACHE STRING
220222
"Path to the directory that contains Swift tools that are executable on the build machine")
221223

222-
option(SWIFT_ENABLE_PARSEABLE_MODULE_INTERFACES
224+
option(SWIFT_ENABLE_MODULE_INTERFACES
223225
"Generate .swiftinterface files alongside .swiftmodule files"
224226
TRUE)
225227

@@ -375,6 +377,10 @@ option(SWIFT_ENABLE_STDLIBCORE_EXCLUSIVITY_CHECKING
375377
"Build stdlibCore with exclusivity checking enabled"
376378
FALSE)
377379

380+
option(SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING
381+
"Enable experimental Swift differentiable programming features"
382+
FALSE)
383+
378384
#
379385
# End of user-configurable options.
380386
#
@@ -449,6 +455,10 @@ if(MSVC OR "${CMAKE_SIMULATE_ID}" STREQUAL MSVC)
449455
include(ClangClCompileRules)
450456
endif()
451457

458+
if(CMAKE_C_COMPILER_ID MATCHES Clang)
459+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Werror=gnu>)
460+
endif()
461+
452462
if(CMAKE_SYSTEM_NAME STREQUAL Darwin OR
453463
EXISTS "${SWIFT_PATH_TO_LIBDISPATCH_SOURCE}")
454464
set(SWIFT_BUILD_SYNTAXPARSERLIB_default TRUE)
@@ -962,17 +972,14 @@ if(SWIFT_NEED_EXPLICIT_LIBDISPATCH)
962972
set(SWIFT_LIBDISPATCH_C_COMPILER ${CMAKE_C_COMPILER})
963973
set(SWIFT_LIBDISPATCH_CXX_COMPILER ${CMAKE_CXX_COMPILER})
964974
elseif(${CMAKE_SYSTEM_NAME} STREQUAL ${CMAKE_HOST_SYSTEM_NAME})
965-
get_target_property(CLANG_LOCATION clang LOCATION)
966-
get_filename_component(CLANG_LOCATION ${CLANG_LOCATION} DIRECTORY)
967-
968975
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
969976
set(SWIFT_LIBDISPATCH_C_COMPILER
970-
${CLANG_LOCATION}/clang-cl${CMAKE_EXECUTABLE_SUFFIX})
977+
$<TARGET_FILE_DIR:clang>/clang-cl${CMAKE_EXECUTABLE_SUFFIX})
971978
set(SWIFT_LIBDISPATCH_CXX_COMPILER
972-
${CLANG_LOCATION}/clang-cl${CMAKE_EXECUTABLE_SUFFIX})
979+
$<TARGET_FILE_DIR:clang>/clang-cl${CMAKE_EXECUTABLE_SUFFIX})
973980
else()
974-
set(SWIFT_LIBDISPATCH_C_COMPILER ${CLANG_LOCATION}/clang)
975-
set(SWIFT_LIBDISPATCH_CXX_COMPILER ${CLANG_LOCATION}/clang++)
981+
set(SWIFT_LIBDISPATCH_C_COMPILER $<TARGET_FILE_DIR:clang>/clang)
982+
set(SWIFT_LIBDISPATCH_CXX_COMPILER $<TARGET_FILE_DIR:clang>/clang++)
976983
endif()
977984
else()
978985
message(SEND_ERROR "libdispatch requires a newer clang compiler (${CMAKE_C_COMPILER_VERSION} < 3.9)")
@@ -996,6 +1003,7 @@ if(SWIFT_NEED_EXPLICIT_LIBDISPATCH)
9961003
-DCMAKE_CXX_COMPILER=${SWIFT_LIBDISPATCH_CXX_COMPILER}
9971004
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
9981005
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
1006+
-DCMAKE_INSTALL_LIBDIR=lib
9991007
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
10001008
-DCMAKE_LINKER=${CMAKE_LINKER}
10011009
-DCMAKE_RANLIB=${CMAKE_RANLIB}
@@ -1088,12 +1096,6 @@ endif()
10881096
# declares the swift-stdlib-* set of targets. These targets will then
10891097
# implicitly depend on any targets declared with IS_STDLIB.
10901098
#
1091-
# One such library that declares IS_STDLIB is SwiftSyntax, living in
1092-
# tools/SwiftSyntax. If we include stdlib/ after tools/,
1093-
# the swift-stdlib-* set of targets will not have been generated yet,
1094-
# causing the implicit dependency for SwiftSyntax to silently not be
1095-
# created. This then will cause SwiftSyntax to fail to build.
1096-
#
10971099
# https://bugs.swift.org/browse/SR-5975
10981100
if(SWIFT_BUILD_STDLIB)
10991101
add_subdirectory(stdlib)
@@ -1118,7 +1120,7 @@ add_subdirectory(include)
11181120

11191121
if(SWIFT_INCLUDE_TOOLS)
11201122
add_subdirectory(lib)
1121-
1123+
11221124
# Always include this after including stdlib/!
11231125
# Refer to the large comment above the add_subdirectory(stdlib) call.
11241126
# https://bugs.swift.org/browse/SR-5975
@@ -1127,6 +1129,8 @@ endif()
11271129

11281130
add_subdirectory(utils)
11291131

1132+
add_subdirectory(userdocs)
1133+
11301134
if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
11311135
if(SWIFT_BUILD_PERF_TESTSUITE)
11321136
add_subdirectory(benchmark)

0 commit comments

Comments
 (0)