Skip to content

Commit a506f60

Browse files
authored
Merge branch 'master' into redeclaration-fixes
2 parents 9dddf34 + b49c43d commit a506f60

File tree

705 files changed

+18735
-11571
lines changed

Some content is hidden

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

705 files changed

+18735
-11571
lines changed

CHANGELOG.md

Lines changed: 53 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ CHANGELOG
66

77
| Contents |
88
| :--------------------- |
9+
| [Swift 5.0](#swift-50) |
910
| [Swift 4.2](#swift-42) |
1011
| [Swift 4.1](#swift-41) |
1112
| [Swift 4.0](#swift-40) |
@@ -20,6 +21,43 @@ CHANGELOG
2021

2122
</details>
2223

24+
Swift 5.0
25+
---------
26+
27+
- [SR-419][]
28+
29+
In Swift 5 mode, when setting a property from within its own `didSet` or `willSet` observer, the observer will now only avoid being recursively called if the property is set on `self` (either implicitly or explicitly).
30+
31+
For example:
32+
```swift
33+
class Node {
34+
var children = [Node]()
35+
36+
var depth: Int {
37+
didSet {
38+
if depth < 0 {
39+
// Will not recursively call didSet, as setting depth on self (same
40+
// with `self.depth = 0`).
41+
depth = 0
42+
}
43+
44+
// Will call didSet for each of the children, as we're not setting the
45+
// property on self (prior to Swift 5, this did not trigger property
46+
// observers to be called again).
47+
for child in children {
48+
child.depth = depth + 1
49+
}
50+
}
51+
}
52+
53+
init(depth: Int) {
54+
self.depth = depth
55+
}
56+
}
57+
```
58+
59+
**Add new entries to the top of this section, not here!**
60+
2361
Swift 4.2
2462
---------
2563

@@ -55,7 +93,7 @@ Swift 4.2
5593
conditionally conforms to `P`, will succeed when the conditional
5694
requirements are met.
5795

58-
**Add new entries to the top of this file, not here!**
96+
**Add new entries to the top of this section, not here!**
5997

6098
Swift 4.1
6199
---------
@@ -276,7 +314,7 @@ Swift 4.0
276314
CFHash and CFEqual as the implementation. This change applies even to "Swift
277315
3 mode", so if you were previously adding this conformance yourself, use
278316
`#if swift(>=3.2)` to restrict the extension to Swift 3.1 and below.
279-
([SR-2388](https://bugs.swift.org/browse/SR-2388))
317+
([SR-2388][])
280318

281319
* [SE-0156][]
282320

@@ -425,7 +463,7 @@ Swift 4.0
425463
slice[i..<j] = buffer[k..<l]
426464
```
427465

428-
* [SR-1529](https://bugs.swift.org/browse/SR-1529):
466+
* [SR-1529][]:
429467

430468
Covariant method overrides are now fully supported, fixing many crashes
431469
and compile-time assertions when defining or calling such methods.
@@ -508,7 +546,7 @@ Swift 3.1
508546
side effects, leading to bugs when Swift code attempted to override
509547
`initialize`.
510548

511-
* [SR-2394](https://bugs.swift.org/browse/SR-2394)
549+
* [SR-2394][]
512550

513551
C functions that "return twice" are no longer imported into Swift. Instead,
514552
they are explicitly made unavailable, so attempting to reference them will
@@ -585,7 +623,7 @@ Swift 3.1
585623
is not guaranteed to work in future versions of Swift, and will
586624
now raise a warning.
587625

588-
* [SR-1446](https://bugs.swift.org/browse/SR-1446)
626+
* [SR-1446][]
589627

590628
Nested types may now appear inside generic types, and nested types may have their own generic parameters:
591629

@@ -605,7 +643,7 @@ Swift 3.1
605643
extension OuterGeneric.InnerGeneric {}
606644
```
607645

608-
* [SR-1009](https://bugs.swift.org/browse/SR-1009):
646+
* [SR-1009][]:
609647

610648
Constrained extensions allow same-type constraints between generic parameters and concrete types. This enables you to create extensions, for example, on `Array` with `Int` elements:
611649

@@ -827,7 +865,7 @@ using the `.dynamicType` member to retrieve the type of an expression should mig
827865
var x2 = p as! [Int]
828866
```
829867

830-
* [SR-2131](https://bugs.swift.org/browse/SR-2131):
868+
* [SR-2131][]:
831869

832870
The `hasPrefix` and `hasSuffix` functions now consider the empty string to be a prefix and suffix of all strings.
833871

@@ -6915,3 +6953,11 @@ Swift 1.0
69156953
[SE-0197]: <https://github.com/apple/swift-evolution/blob/master/proposals/0197-remove-where.md>
69166954
[SE-0198]: <https://github.com/apple/swift-evolution/blob/master/proposals/0198-playground-quicklook-api-revamp.md>
69176955
[SE-0199]: <https://github.com/apple/swift-evolution/blob/master/proposals/0199-bool-toggle.md>
6956+
6957+
[SR-419]: <https://bugs.swift.org/browse/SR-419>
6958+
[SR-1009]: <https://bugs.swift.org/browse/SR-1009>
6959+
[SR-1446]: <https://bugs.swift.org/browse/SR-1446>
6960+
[SR-1529]: <https://bugs.swift.org/browse/SR-1529>
6961+
[SR-2131]: <https://bugs.swift.org/browse/SR-2131>
6962+
[SR-2388]: <https://bugs.swift.org/browse/SR-2388>
6963+
[SR-2394]: <https://bugs.swift.org/browse/SR-2394>

benchmark/scripts/Benchmark_QuickCheck.in

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,16 @@ class QuickCheckResult(perf_test_driver.Result):
4141

4242
class QuickCheckBenchmarkDriver(perf_test_driver.BenchmarkDriver):
4343

44-
def __init__(self, binary, xfail_list, num_iters):
44+
def __init__(self, binary, xfail_list, num_iters, opt_levels):
4545
perf_test_driver.BenchmarkDriver.__init__(
4646
self, binary, xfail_list,
47-
enable_parallel=True)
47+
enable_parallel=True,
48+
opt_levels=opt_levels)
4849
self.num_iters = num_iters
4950

5051
def print_data_header(self, max_test_len):
51-
fmt = '{:<%d}{:<10}{:}' % (max_test_len + 5)
52-
print(fmt.format('Name', 'Result', 'RC Delta'))
52+
fmt = '{:<%d}{:<10}' % (max_test_len + 5)
53+
print(fmt.format('Name', 'Result'))
5354

5455
# Propagate any data from this class that is needed for individual
5556
# tests. The reason this is needed is to avoid issues with attempting to
@@ -99,15 +100,21 @@ def parse_args():
99100
import argparse
100101
parser = argparse.ArgumentParser()
101102
parser.add_argument(
102-
'-filter', type=str, default=None,
103+
'--filter', type=str, default=None,
103104
help='Filter out any test that does not match the given regex')
104-
parser.add_argument('-num-iters', type=int, default=2)
105+
parser.add_argument('--num-iters', type=int, default=2)
106+
default_opt_levels = perf_test_driver.BenchmarkDriver_OptLevels
107+
parser.add_argument('--opt-level', choices=default_opt_levels)
105108
return parser.parse_args()
106109

107110

108111
if __name__ == "__main__":
109112
args = parse_args()
110-
l = QuickCheckBenchmarkDriver(SWIFT_BIN_DIR, XFAIL_LIST, args.num_iters)
113+
opt_levels = perf_test_driver.BenchmarkDriver_OptLevels
114+
if args.opt_level is not None:
115+
opt_levels = [args.opt_level]
116+
l = QuickCheckBenchmarkDriver(SWIFT_BIN_DIR, XFAIL_LIST, args.num_iters,
117+
opt_levels)
111118
if l.run(args.filter):
112119
sys.exit(0)
113120
else:

cmake/modules/AddSwift.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,8 @@ function(_add_variant_swift_compile_flags
333333
list(APPEND result "-D" "INTERNAL_CHECKS_ENABLED")
334334
endif()
335335

336-
if (SWIFT_ENABLE_GUARANTEED_NORMAL_ARGUMENTS)
337-
list(APPEND result "-Xfrontend" "-enable-guaranteed-normal-arguments")
336+
if (NOT SWIFT_ENABLE_GUARANTEED_NORMAL_ARGUMENTS)
337+
list(APPEND result "-Xfrontend" "-disable-guaranteed-normal-arguments")
338338
endif()
339339

340340
if(SWIFT_ENABLE_RUNTIME_FUNCTION_COUNTERS)

docs/ABI/Mangling.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ Entities
209209
entity-spec ::= decl-name label-list? type 'v' ACCESSOR // variable
210210
entity-spec ::= decl-name type 'fp' // generic type parameter
211211
entity-spec ::= decl-name type 'fo' // enum element (currently not used)
212+
entity-spec ::= identifier 'Qa'                                                   // associated type declaration
212213

213214
ACCESSOR ::= 'm' // materializeForSet
214215
ACCESSOR ::= 's' // setter

docs/RefcountingStates.graffle

12.1 KB
Binary file not shown.

docs/StandardLibraryProgrammersManual.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,3 +170,23 @@ The standard library utilizes thread local storage (TLS) to cache expensive comp
170170
3. If the field is not trivially destructable, update `_destroyTLS` to properly destroy the value.
171171
172172
See [ThreadLocalStorage.swift](https://github.com/apple/swift/blob/master/stdlib/public/core/ThreadLocalStorage.swift) for more details.
173+
174+
## Productivity Hacks
175+
176+
### Be a Ninja
177+
178+
To *be* a productivity ninja, one must *use* `ninja`. `ninja` can be invoked inside the swift build directory, e.g. `<path>/build/Ninja-ReleaseAssert/swift-macosx-x86_64/`. Running `ninja` (which is equivalent to `ninja all`) will build the local swift, stdlib and overlays. It doesn’t necessarily build all the testing infrastructure, benchmarks, etc.
179+
180+
`ninja -t targets` gives a list of all possible targets to pass to ninja. This is useful for grepping.
181+
182+
For this example, we will figure out how to quickly iterate on a change to the standard library to fix 32-bit build errors while building on a 64-bit host, suppressing warnings along the way.
183+
184+
`ninja -t targets | grep stdlib | grep i386` will output many targets, but at the bottom we see `swift-stdlib-iphonesimulator-i386`, which looks like a good first step. This target will just build i386 parts and not waste our time also building the 64-bit stdlib, overlays, etc.
185+
186+
Going further, ninja can spawn a web browser for you to navigate dependencies and rules. `ninja -t browse swift-stdlib-iphonesimulator-i386` will open a webpage with hyperlinks for all related targets. “target is built using” lists all this target’s dependencies, while “dependent edges build” list all the targets that depend directly on this.
187+
188+
Clicking around a little bit, we can find `lib/swift/iphonesimulator/i386/libswiftCore.dylib` as a commonly-depended-upon target. This will perform just what is needed to compile the standard library for i386 and nothing else.
189+
190+
Going further, for various reasons the standard library has lots of warnings. This is actively being addressed, but fixing all of them may require language features, etc. In the mean time, let’s suppress warnings in our build so that we just see the errors. `ninja -nv lib/swift/iphonesimulator/i386/libswiftCore.dylib` will show us the actual commands ninja will issue to build the i386 stdlib. (You’ll notice that an incremental build here is merely 3 commands as opposed to ~150 for `swift-stdlib-iphonesimulator-i386`).
191+
192+
Copy the invocation that has ` -o <build-path>/swift-macosx-x86_64/stdlib/public/core/iphonesimulator/i386/Swift.o`, so that we can perform the actual call to swiftc ourselves. Tack on `-suppress-warnings` at the end, and now we have the command to just build `Swift.o` for i386 while only displaying the actual errors.

docs/WindowsBuild.md

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ argument to `x86` and run
7474
VsDevCmd -arch=x86
7575
```
7676

77-
- Then adapt the following command and run it.
77+
- Then adapt the following command and run it. Make sure to use forward slashes
78+
(`/`) instead of backslashes (`\`) as the path separators. `clang` breaks
79+
with backslashed paths.
7880
```cmd
7981
set swift_source_dir=path-to-directory-containing-all-cloned-repositories
8082
```
@@ -113,7 +115,14 @@ cmake -G "Ninja"^
113115
-DLLVM_TARGETS_TO_BUILD=X86^
114116
"%swift_source_dir%/llvm"
115117
popd
116-
cmake --build "%swift_source_dir%/build/Ninja-DebugAssert/llvm-windows-amd64"
118+
cmake --build "%swift_source_dir%/build/Ninja-RelWithDebInfoAssert/llvm-windows-amd64"
119+
```
120+
- Store the LLVM `bin` directory in an environment variable so it can be used
121+
to build Swift. Assuming you followed the instructions exactly, the path
122+
below is correct, but it may be different based on your build variant and
123+
platform, so double check.
124+
```cmd
125+
set llvm_bin_dir="%swift_source_dir%/build/Ninja-RelWithDebInfoAssert/llvm-windows-amd64/bin"
117126
```
118127

119128
### 7. Build Swift
@@ -122,8 +131,8 @@ cmake --build "%swift_source_dir%/build/Ninja-DebugAssert/llvm-windows-amd64"
122131
- You may need to adjust the `SWIFT_WINDOWS_LIB_DIRECTORY` parameter depending on
123132
your target platform or Windows SDK version.
124133
```cmd
125-
mkdir "%swift_source_dir%/build/Ninja-DebugAssert/swift-windows-amd64/ninja"
126-
pushd "%swift_source_dir%/build/Ninja-DebugAssert/swift-windows-amd64/ninja"
134+
mkdir "%swift_source_dir%/build/Ninja-DebugAssert/swift-windows-amd64"
135+
pushd "%swift_source_dir%/build/Ninja-DebugAssert/swift-windows-amd64"
127136
cmake -G "Ninja" "%swift_source_dir%/swift"^
128137
-DCMAKE_BUILD_TYPE=Debug^
129138
-DSWIFT_PATH_TO_CMARK_SOURCE="%swift_source_dir%/cmark"^
@@ -141,13 +150,13 @@ cmake -G "Ninja" "%swift_source_dir%/swift"^
141150
-DICU_I18N_LIB_NAME="icuin"^
142151
-DSWIFT_INCLUDE_DOCS=FALSE^
143152
-DSWIFT_INCLUDE_TESTS=FALSE^
144-
-DCMAKE_C_COMPILER="<path-to-llvm-bin>/clang-cl.exe"^
145-
-DCMAKE_CXX_COMPILER="<path-to-llvm-bin>/bin/clang-cl.exe"^
153+
-DCMAKE_C_COMPILER="%llvm_bin_dir%/clang-cl.exe"^
154+
-DCMAKE_CXX_COMPILER="%llvm_bin_dir%/clang-cl.exe"^
146155
-DCMAKE_C_FLAGS="-fms-compatibility-version=19.00 /Z7"^
147156
-DCMAKE_CXX_FLAGS="-fms-compatibility-version=19.00 -Z7" ^
148157
-DSWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER=FALSE
149158
popd
150-
cmake --build "%swift_source_dir%/build/Ninja-DebugAssert/swift-windows-amd64/ninja"
159+
cmake --build "%swift_source_dir%/build/Ninja-DebugAssert/swift-windows-amd64"
151160
```
152161

153162
- To create a Visual Studio project, you'll need to change the generator and,
@@ -168,13 +177,13 @@ cmake -G "Visual Studio 15" "%swift_source_dir%/swift"^
168177
Follow instructions 1-6 for `clang-cl`, but run the following instead to build Swift
169178

170179
```cmd
171-
mkdir "%swift_source_dir%/build/Ninja-DebugAssert/swift-windows-amd64/ninja"
172-
pushd "%swift_source_dir%/build/Ninja-DebugAssert/swift-windows-amd64/ninja"
180+
mkdir "%swift_source_dir%/build/Ninja-DebugAssert/swift-windows-amd64"
181+
pushd "%swift_source_dir%/build/Ninja-DebugAssert/swift-windows-amd64"
173182
cmake -G "Ninja" "%swift_source_dir%/swift"^
174183
-DCMAKE_BUILD_TYPE=Debug^
175184
-DSWIFT_PATH_TO_CMARK_SOURCE="%swift_source_dir%/cmark"^
176-
-DSWIFT_PATH_TO_CMARK_BUILD="%swift_source_dir%/build/Ninja-DebugAssert/cmark-windows-amd64"^
177-
-DSWIFT_CMARK_LIBRARY_DIR="%swift_source_dir%/build/Ninja-DebugAssert/cmark-windows-amd64/src"^
185+
-DSWIFT_PATH_TO_CMARK_BUILD="%swift_source_dir%/build/Ninja-RelWithDebInfoAssert/cmark-windows-amd64"^
186+
-DSWIFT_CMARK_LIBRARY_DIR="%swift_source_dir%/build/Ninja-RelWithDebInfoAssert/cmark-windows-amd64/src"^
178187
-DSWIFT_PATH_TO_LLVM_SOURCE="%swift_source_dir%/llvm"^
179188
-DSWIFT_PATH_TO_LLVM_BUILD="%swift_source_dir%/build/Ninja-RelWithDebInfoAssert/llvm-windows-amd64"^
180189
-DSWIFT_PATH_TO_CLANG_SOURCE="%swift_source_dir%/llvm/tools/clang"^
@@ -190,5 +199,5 @@ cmake -G "Ninja" "%swift_source_dir%/swift"^
190199
-DSWIFT_BUILD_DYNAMIC_SDK_OVERLAY=FALSE^
191200
-DSWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER=FALSE
192201
popd
193-
cmake --build "%swift_source_dir%/build/Ninja-DebugAssert/swift-windows-amd64/ninja"
202+
cmake --build "%swift_source_dir%/build/Ninja-DebugAssert/swift-windows-amd64"
194203
```

0 commit comments

Comments
 (0)