Skip to content

Commit e6ef70a

Browse files
committed
Merge tag 'swift-DEVELOPMENT-SNAPSHOT-2019-10-24-a' into tensorflow-merge
Tag build swift-DEVELOPMENT-SNAPSHOT-2019-10-24-a
2 parents 1862c95 + 35518d7 commit e6ef70a

File tree

470 files changed

+10420
-11030
lines changed

Some content is hidden

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

470 files changed

+10420
-11030
lines changed

.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.

CHANGELOG.md

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,21 @@ CHANGELOG
2626
Swift 5.2
2727
---------
2828

29+
* [SR-2189][]:
30+
31+
The compiler now supports local functions whose default arguments capture
32+
values from outer scopes.
33+
34+
```swift
35+
func outer(x: Int) -> (Int, Int) {
36+
func inner(y: Int = x) -> Int {
37+
return y
38+
}
39+
40+
return (inner(), inner(y: 0))
41+
}
42+
```
43+
2944
* [SR-11429][]:
3045

3146
The compiler will now correctly strip argument labels from function references
@@ -58,6 +73,29 @@ Swift 5.2
5873
(foo as Magic)(5)
5974
```
6075

76+
* [SR-11298][]:
77+
78+
A class-constrained protocol extension, where the extended protocol does
79+
not impose a class constraint, will now infer the constraint implicitly.
80+
81+
```swift
82+
protocol Foo {}
83+
class Bar: Foo {
84+
var someProperty: Int = 0
85+
}
86+
87+
// Even though 'Foo' does not impose a class constraint, it is automatically
88+
// inferred due to the Self: Bar constraint.
89+
extension Foo where Self: Bar {
90+
var anotherProperty: Int {
91+
get { return someProperty }
92+
// As a result, the setter is now implicitly nonmutating, just like it would
93+
// be if 'Foo' had a class constraint.
94+
set { someProperty = newValue }
95+
}
96+
}
97+
```
98+
6199
* [SE-0253][]:
62100

63101
Values of types that declare `func callAsFunction` methods can be called
@@ -83,7 +121,7 @@ Swift 5.2
83121

84122
* [SR-4206][]:
85123

86-
A method override is no longer allowed to have a generic signature with
124+
A method override is no longer allowed to have a generic signature with
87125
requirements not imposed by the base method. For example:
88126

89127
```
@@ -7780,6 +7818,7 @@ Swift 1.0
77807818
[SR-1529]: <https://bugs.swift.org/browse/SR-1529>
77817819
[SR-2131]: <https://bugs.swift.org/browse/SR-2131>
77827820
[SR-2176]: <https://bugs.swift.org/browse/SR-2176>
7821+
[SR-2189]: <https://bugs.swift.org/browse/SR-2189>
77837822
[SR-2388]: <https://bugs.swift.org/browse/SR-2388>
77847823
[SR-2394]: <https://bugs.swift.org/browse/SR-2394>
77857824
[SR-2608]: <https://bugs.swift.org/browse/SR-2608>
@@ -7799,4 +7838,5 @@ Swift 1.0
77997838
[SR-8974]: <https://bugs.swift.org/browse/SR-8974>
78007839
[SR-9043]: <https://bugs.swift.org/browse/SR-9043>
78017840
[SR-9827]: <https://bugs.swift.org/browse/SR-9827>
7841+
[SR-11298]: <https://bugs.swift.org/browse/SR-11298>
78027842
[SR-11429]: <https://bugs.swift.org/browse/SR-11429>

CMakeLists.txt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,10 @@ if(MSVC OR "${CMAKE_SIMULATE_ID}" STREQUAL MSVC)
472472
include(ClangClCompileRules)
473473
endif()
474474

475+
if(CMAKE_C_COMPILER_ID STREQUAL Clang)
476+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Werror=gnu>)
477+
endif()
478+
475479
if(CMAKE_SYSTEM_NAME STREQUAL Darwin OR
476480
EXISTS "${SWIFT_PATH_TO_LIBDISPATCH_SOURCE}")
477481
set(SWIFT_BUILD_SYNTAXPARSERLIB_default TRUE)
@@ -985,17 +989,14 @@ if(SWIFT_NEED_EXPLICIT_LIBDISPATCH)
985989
set(SWIFT_LIBDISPATCH_C_COMPILER ${CMAKE_C_COMPILER})
986990
set(SWIFT_LIBDISPATCH_CXX_COMPILER ${CMAKE_CXX_COMPILER})
987991
elseif(${CMAKE_SYSTEM_NAME} STREQUAL ${CMAKE_HOST_SYSTEM_NAME})
988-
get_target_property(CLANG_LOCATION clang LOCATION)
989-
get_filename_component(CLANG_LOCATION ${CLANG_LOCATION} DIRECTORY)
990-
991992
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
992993
set(SWIFT_LIBDISPATCH_C_COMPILER
993-
${CLANG_LOCATION}/clang-cl${CMAKE_EXECUTABLE_SUFFIX})
994+
$<TARGET_FILE_DIR:clang>/clang-cl${CMAKE_EXECUTABLE_SUFFIX})
994995
set(SWIFT_LIBDISPATCH_CXX_COMPILER
995-
${CLANG_LOCATION}/clang-cl${CMAKE_EXECUTABLE_SUFFIX})
996+
$<TARGET_FILE_DIR:clang>/clang-cl${CMAKE_EXECUTABLE_SUFFIX})
996997
else()
997-
set(SWIFT_LIBDISPATCH_C_COMPILER ${CLANG_LOCATION}/clang)
998-
set(SWIFT_LIBDISPATCH_CXX_COMPILER ${CLANG_LOCATION}/clang++)
998+
set(SWIFT_LIBDISPATCH_C_COMPILER $<TARGET_FILE_DIR:clang>/clang)
999+
set(SWIFT_LIBDISPATCH_CXX_COMPILER $<TARGET_FILE_DIR:clang>/clang++)
9991000
endif()
10001001
else()
10011002
message(SEND_ERROR "libdispatch requires a newer clang compiler (${CMAKE_C_COMPILER_VERSION} < 3.9)")

benchmark/scripts/run_smoke_bench

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ def main():
9393
argparser.add_argument(
9494
'-num-samples', type=int,
9595
help='The (minimum) number of samples to run', default=3)
96+
argparser.add_argument(
97+
'-num-reruns', type=int,
98+
help="The number of re-runs until it's assumed to be a real change",
99+
default=8)
96100
argparser.add_argument(
97101
'-platform', type=str,
98102
help='The benchmark build platform', default='macosx')
@@ -120,7 +124,7 @@ def test_opt_levels(args):
120124
if test_performance(opt_level, args.oldbuilddir[0],
121125
args.newbuilddir[0],
122126
float(args.threshold) / 100, args.num_samples,
123-
output_file):
127+
args.num_reruns, output_file):
124128
changes = True
125129

126130
# There is no point in reporting code size for Onone.
@@ -171,7 +175,7 @@ def merge(results, other_results):
171175

172176

173177
def test_performance(opt_level, old_dir, new_dir, threshold, num_samples,
174-
output_file):
178+
num_reruns, output_file):
175179
"""Detect performance changes in benchmarks.
176180
177181
Start fast with few samples per benchmark and gradually spend more time
@@ -185,7 +189,7 @@ def test_performance(opt_level, old_dir, new_dir, threshold, num_samples,
185189
tests = TestComparator(results[0], results[1], threshold)
186190
changed = tests.decreased + tests.increased
187191

188-
while len(changed) > 0 and unchanged_length_count < 10:
192+
while len(changed) > 0 and unchanged_length_count < num_reruns:
189193
i += 1
190194
if VERBOSE:
191195
log(' test again: ' + str([test.name for test in changed]))

benchmark/single-source/ObjectiveCBridging.swift

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,18 @@ public let ObjectiveCBridging = [
7979
BenchmarkInfo(name: "UnicodeStringFromCodable",
8080
runFunction: run_UnicodeStringFromCodable, tags: ts,
8181
setUpFunction: setup_UnicodeStringFromCodable),
82+
BenchmarkInfo(name: "NSArray.bridged.objectAtIndex",
83+
runFunction: run_BridgedNSArrayObjectAtIndex, tags: t,
84+
setUpFunction: setup_bridgedArrays),
85+
BenchmarkInfo(name: "NSArray.bridged.mutableCopy.objectAtIndex",
86+
runFunction: run_BridgedNSArrayMutableCopyObjectAtIndex, tags: t,
87+
setUpFunction: setup_bridgedArrays),
88+
BenchmarkInfo(name: "NSArray.nonbridged.objectAtIndex",
89+
runFunction: run_RealNSArrayObjectAtIndex, tags: t,
90+
setUpFunction: setup_bridgedArrays),
91+
BenchmarkInfo(name: "NSArray.nonbridged.mutableCopy.objectAtIndex",
92+
runFunction: run_RealNSArrayMutableCopyObjectAtIndex, tags: t,
93+
setUpFunction: setup_bridgedArrays),
8294
]
8395

8496
#if _runtime(_ObjC)
@@ -773,3 +785,65 @@ public func run_UnicodeStringFromCodable(_ N: Int) {
773785
}
774786
#endif
775787
}
788+
789+
#if _runtime(_ObjC)
790+
var bridgedArray:NSArray! = nil
791+
var bridgedArrayMutableCopy:NSMutableArray! = nil
792+
var nsArray:NSArray! = nil
793+
var nsArrayMutableCopy:NSMutableArray! = nil
794+
#endif
795+
796+
public func setup_bridgedArrays() {
797+
#if _runtime(_ObjC)
798+
var arr = Array(repeating: NSObject(), count: 100) as [AnyObject]
799+
bridgedArray = arr as NSArray
800+
bridgedArrayMutableCopy = (bridgedArray.mutableCopy() as! NSMutableArray)
801+
nsArray = NSArray(objects: &arr, count: 100)
802+
nsArrayMutableCopy = (nsArray.mutableCopy() as! NSMutableArray)
803+
#endif
804+
}
805+
806+
@inline(never)
807+
public func run_BridgedNSArrayObjectAtIndex(_ N: Int) {
808+
#if _runtime(_ObjC)
809+
for _ in 0 ..< N * 50 {
810+
for i in 0..<100 {
811+
blackHole(bridgedArray[i])
812+
}
813+
}
814+
#endif
815+
}
816+
817+
@inline(never)
818+
public func run_BridgedNSArrayMutableCopyObjectAtIndex(_ N: Int) {
819+
#if _runtime(_ObjC)
820+
for _ in 0 ..< N * 100 {
821+
for i in 0..<100 {
822+
blackHole(bridgedArrayMutableCopy[i])
823+
}
824+
}
825+
#endif
826+
}
827+
828+
@inline(never)
829+
public func run_RealNSArrayObjectAtIndex(_ N: Int) {
830+
#if _runtime(_ObjC)
831+
for _ in 0 ..< N * 100 {
832+
for i in 0..<100 {
833+
blackHole(nsArray[i])
834+
}
835+
}
836+
#endif
837+
}
838+
839+
@inline(never)
840+
public func run_RealNSArrayMutableCopyObjectAtIndex(_ N: Int) {
841+
#if _runtime(_ObjC)
842+
for _ in 0 ..< N * 100 {
843+
for i in 0..<100 {
844+
blackHole(nsArrayMutableCopy[i])
845+
}
846+
}
847+
#endif
848+
}
849+

benchmark/single-source/UTF8Decode.swift

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,18 @@ public let UTF8Decode = [
4242
name: "UTF8Decode_InitFromBytes_ascii",
4343
runFunction: run_UTF8Decode_InitFromBytes_ascii,
4444
tags: [.validation, .api, .String]),
45+
BenchmarkInfo(
46+
name: "UTF8Decode_InitFromData_ascii_as_ascii",
47+
runFunction: run_UTF8Decode_InitFromData_ascii_as_ascii,
48+
tags: [.validation, .api, .String]),
49+
BenchmarkInfo(
50+
name: "UTF8Decode_InitDecoding_ascii_as_ascii",
51+
runFunction: run_UTF8Decode_InitDecoding_ascii_as_ascii,
52+
tags: [.validation, .api, .String]),
53+
BenchmarkInfo(
54+
name: "UTF8Decode_InitFromBytes_ascii_as_ascii",
55+
runFunction: run_UTF8Decode_InitFromBytes_ascii_as_ascii,
56+
tags: [.validation, .api, .String]),
4557
]
4658

4759
// 1-byte sequences
@@ -129,4 +141,26 @@ public func run_UTF8Decode_InitFromBytes_ascii(_ N: Int) {
129141
}
130142
}
131143

144+
@inline(never)
145+
public func run_UTF8Decode_InitFromData_ascii_as_ascii(_ N: Int) {
146+
let input = asciiData
147+
for _ in 0..<1_000*N {
148+
blackHole(String(data: input, encoding: .ascii))
149+
}
150+
}
151+
@inline(never)
152+
public func run_UTF8Decode_InitDecoding_ascii_as_ascii(_ N: Int) {
153+
let input = asciiBytes
154+
for _ in 0..<1_000*N {
155+
blackHole(String(decoding: input, as: Unicode.ASCII.self))
156+
}
157+
}
158+
@inline(never)
159+
public func run_UTF8Decode_InitFromBytes_ascii_as_ascii(_ N: Int) {
160+
let input = asciiBytes
161+
for _ in 0..<1_000*N {
162+
blackHole(String(bytes: input, encoding: .ascii))
163+
}
164+
}
165+
132166

cmake/modules/SwiftHandleGybSources.cmake

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,11 @@ function(handle_gyb_sources dependency_out_var_name sources_var_name arch)
118118
"${SWIFT_SOURCE_DIR}/utils/gyb_syntax_support/AttributeNodes.py"
119119
"${SWIFT_SOURCE_DIR}/utils/gyb_syntax_support/AvailabilityNodes.py"
120120
"${SWIFT_SOURCE_DIR}/utils/gyb_syntax_support/CommonNodes.py"
121-
"${SWIFT_SOURCE_DIR}/utils/gyb_syntax_support/CompletionOnlyNodes.py"
122121
"${SWIFT_SOURCE_DIR}/utils/gyb_syntax_support/DeclNodes.py"
123122
"${SWIFT_SOURCE_DIR}/utils/gyb_syntax_support/ExprNodes.py"
124123
"${SWIFT_SOURCE_DIR}/utils/gyb_syntax_support/GenericNodes.py"
125124
"${SWIFT_SOURCE_DIR}/utils/gyb_syntax_support/NodeSerializationCodes.py"
126125
"${SWIFT_SOURCE_DIR}/utils/gyb_syntax_support/PatternNodes.py"
127-
"${SWIFT_SOURCE_DIR}/utils/gyb_syntax_support/SILOnlyNodes.py"
128126
"${SWIFT_SOURCE_DIR}/utils/gyb_syntax_support/StmtNodes.py"
129127
"${SWIFT_SOURCE_DIR}/utils/gyb_syntax_support/TypeNodes.py"
130128
"${SWIFT_SOURCE_DIR}/utils/gyb_syntax_support/Token.py"

cmake/modules/SwiftSource.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,11 @@ function(_compile_swift_files
346346
"-emit-module-interface-path" "${interface_file}")
347347
endif()
348348

349+
if (NOT SWIFTFILE_IS_STDLIB_CORE)
350+
list(APPEND swift_module_flags
351+
"-Xfrontend" "-experimental-skip-non-inlinable-function-bodies")
352+
endif()
353+
349354
# If we have extra regexp flags, check if we match any of the regexps. If so
350355
# add the relevant flags to our swift_flags.
351356
if (SWIFT_EXPERIMENTAL_EXTRA_REGEXP_FLAGS OR SWIFT_EXPERIMENTAL_EXTRA_NEGATIVE_REGEXP_FLAGS)

cmake/modules/SwiftWindowsSupport.cmake

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -84,20 +84,19 @@ endfunction()
8484
macro(swift_swap_compiler_if_needed target)
8585
if(NOT CMAKE_C_COMPILER_ID MATCHES Clang)
8686
if(CMAKE_SYSTEM_NAME STREQUAL CMAKE_HOST_SYSTEM_NAME)
87-
get_target_property(CLANG_LOCATION clang LOCATION)
88-
get_filename_component(CLANG_LOCATION ${CLANG_LOCATION} DIRECTORY)
89-
90-
if("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC" OR
91-
"${CMAKE_C_SIMULATE_ID}" STREQUAL "MSVC")
92-
set(CMAKE_C_COMPILER
93-
${CLANG_LOCATION}/clang-cl${CMAKE_EXECUTABLE_SUFFIX})
94-
set(CMAKE_CXX_COMPILER
95-
${CLANG_LOCATION}/clang-cl${CMAKE_EXECUTABLE_SUFFIX})
87+
if(SWIFT_BUILT_STANDALONE)
88+
get_target_property(CLANG_LOCATION clang LOCATION)
89+
get_filename_component(CLANG_LOCATION ${CLANG_LOCATION} DIRECTORY)
9690
else()
97-
set(CMAKE_C_COMPILER
98-
${CLANG_LOCATION}/clang${CMAKE_EXECUTABLE_SUFFIX})
99-
set(CMAKE_CXX_COMPILER
100-
${CLANG_LOCATION}/clang++${CMAKE_EXECUTABLE_SUFFIX})
91+
set(CLANG_LOCATION ${LLVM_RUNTIME_OUTPUT_INTDIR})
92+
endif()
93+
94+
if("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC" OR "${CMAKE_C_SIMULATE_ID}" STREQUAL "MSVC")
95+
set(CMAKE_C_COMPILER ${CLANG_LOCATION}/clang-cl${CMAKE_EXECUTABLE_SUFFIX})
96+
set(CMAKE_CXX_COMPILER ${CLANG_LOCATION}/clang-cl${CMAKE_EXECUTABLE_SUFFIX})
97+
else()
98+
set(CMAKE_C_COMPILER ${CLANG_LOCATION}/clang${CMAKE_EXECUTABLE_SUFFIX})
99+
set(CMAKE_CXX_COMPILER ${CLANG_LOCATION}/clang++${CMAKE_EXECUTABLE_SUFFIX})
101100
endif()
102101
else()
103102
message(SEND_ERROR "${target} requires a clang based compiler")

0 commit comments

Comments
 (0)