Skip to content

Commit 8e2a5bf

Browse files
author
Dave Abrahams
committed
Merge apple/swift:master into tensorflow-stage (using imerge)
2 parents 3d4c3cc + 76a7160 commit 8e2a5bf

File tree

194 files changed

+3325
-1481
lines changed

Some content is hidden

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

194 files changed

+3325
-1481
lines changed

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,20 @@ CHANGELOG
2828
Swift Next
2929
----------
3030

31+
* [SE-0284][]:
32+
33+
Functions, subscripts, and initializers may now have more than one variadic parameter, as long as all parameters which follow variadic parameters are labeled. This makes declarations like the following valid:
34+
35+
```swift
36+
func foo(_ a: Int..., b: Double...) { }
37+
38+
struct Bar {
39+
subscript(a: Int..., b b: Int...) -> [Int] { a + b }
40+
41+
init(a: String..., b: Float...) { }
42+
}
43+
```
44+
3145
* [SE-0287][]:
3246

3347
Implicit member expressions now support chains of member accesses, making the following valid:
@@ -8143,6 +8157,7 @@ Swift 1.0
81438157
[SE-0276]: <https://github.com/apple/swift-evolution/blob/master/proposals/0276-multi-pattern-catch-clauses.md>
81448158
[SE-0279]: <https://github.com/apple/swift-evolution/blob/master/proposals/0279-multiple-trailing-closures.md>
81458159
[SE-0280]: <https://github.com/apple/swift-evolution/blob/master/proposals/0280-enum-cases-as-protocol-witnesses.md>
8160+
[SE-0284]: <https://github.com/apple/swift-evolution/blob/master/proposals/0284-multiple-variadic-parameters.md>
81468161
[SE-0286]: <https://github.com/apple/swift-evolution/blob/master/proposals/0286-forward-scan-trailing-closures.md>
81478162
[SE-0287]: <https://github.com/apple/swift-evolution/blob/master/proposals/0287-implicit-member-chains.md>
81488163

CMakeLists.txt

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -648,22 +648,6 @@ if("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC" OR "${CMAKE_CXX_SIMULATE_ID}" STREQU
648648
set(SWIFT_COMPILER_IS_MSVC_LIKE TRUE)
649649
endif()
650650

651-
if(NOT SWIFT_COMPILER_IS_MSVC_LIKE)
652-
# CMake's default for CMAKE_CXX_FLAGS_RELEASE is "-O3 -DNDEBUG". Let's avoid "-O3" for consistency
653-
# between Release and RelWithDebInfo. Dropping -DNDEBUG from this setting is blocked by triggering
654-
# a test failure of Swift-Unit :: Syntax/./SwiftSyntaxTests/TypeSyntaxTests.MetatypeTypeWithAPIs
655-
# because unit tests don't currently explicitly set -DNDEBUG/-UNDEBUG.
656-
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
657-
658-
_compute_lto_flag("${SWIFT_TOOLS_ENABLE_LTO}" _lto_flag_out)
659-
if(_lto_flag_out)
660-
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_RELEASE} -gline-tables-only")
661-
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -gline-tables-only")
662-
endif()
663-
else()
664-
665-
endif()
666-
667651
#
668652
# Configure SDKs.
669653
#

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@
3232

3333
| **OS** | **Architecture** | **Build** |
3434
|---|:---:|:---:|
35-
|**[Ubuntu 16.04](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)|
35+
|**[Ubuntu 18.04](https://github.com/apple/swift-community-hosted-continuous-integration/blob/master/nodes/x86_64_ubuntu_18_04_tensorflow.json)** | x86_64 |[![Build Status](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-18.04-tensorflow/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-18.04-tensorflow)|
3636
|**[macOS 10.13](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)|
37-
|**[Ubuntu 16.04 (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)|
37+
|**[Ubuntu 18.04 (GPU)](https://github.com/apple/swift-community-hosted-continuous-integration/blob/master/nodes/x86_64_ubuntu_18_04_tensorflow_gpu.json)** | x86_64 |[![Build Status](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-18.04-tensorflow-gpu/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-18.04-tensorflow-gpu)|
3838

3939
<!-- SWIFT_ENABLE_TENSORFLOW -->
4040

@@ -89,6 +89,8 @@ If you are interested in:
8989
up until the "Building the project" section. After that, follow the
9090
instructions in the [Swift Toolchains](#swift-toolchains) section below.
9191

92+
We also have an [FAQ](/docs/HowToGuides/FAQ.md) that answers common questions.
93+
9294
[Getting Started guide]: /docs/HowToGuides/GettingStarted.md
9395

9496
### Swift For TensorFlow Toolchains
@@ -151,14 +153,14 @@ Try the suggestions in
151153
[Troubleshooting build issues](/docs/HowToGuides/GettingStarted.md#troubleshooting-build-issues).
152154

153155
Make sure you are using the
154-
[correct release](/docs/HowToGuides/GettingStared.md#installing-dependencies)
156+
[correct release](/docs/HowToGuides/GettingStarted.md#installing-dependencies)
155157
of Xcode.
156158

157159
If you have changed Xcode versions but still encounter errors that appear to
158160
be related to the Xcode version, try passing `--clean` to `build-script`.
159161

160162
When a new version of Xcode is released, you can update your build without
161-
recompiling the entire project by passing the `--reconfigure` option.
163+
recompiling the entire project by passing `--reconfigure` to `build-script`.
162164

163165
## Learning More
164166

cmake/modules/AddSwift.cmake

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,18 +130,17 @@ function(_add_host_variant_c_compile_flags target)
130130
_add_host_variant_c_compile_link_flags(${target})
131131

132132
is_build_type_optimized("${CMAKE_BUILD_TYPE}" optimized)
133-
is_build_type_with_debuginfo("${CMAKE_BUILD_TYPE}" debuginfo)
134-
135-
# Add -O0/-O2/-O3/-Os/-g/-momit-leaf-frame-pointer/... based on CMAKE_BUILD_TYPE.
136-
target_compile_options(${target} PRIVATE "${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}}")
137-
138133
if(optimized)
134+
if("${CMAKE_BUILD_TYPE}" STREQUAL "MinSizeRel")
135+
target_compile_options(${target} PRIVATE -Os)
136+
else()
137+
target_compile_options(${target} PRIVATE -O2)
138+
endif()
139+
139140
# Omit leaf frame pointers on x86 production builds (optimized, no debug
140141
# info, and no asserts).
141-
if(NOT debuginfo AND NOT LLVM_ENABLE_ASSERTIONS)
142-
# Unfortunately, this cannot be folded into the standard
143-
# CMAKE_CXX_FLAGS_... because Apple multi-SDK builds use different
144-
# architectures for different SDKs.
142+
is_build_type_with_debuginfo("${CMAKE_BUILD_TYPE}" debug)
143+
if(NOT debug AND NOT LLVM_ENABLE_ASSERTIONS)
145144
if(SWIFT_HOST_VARIANT_ARCH MATCHES "i?86")
146145
if(NOT SWIFT_COMPILER_IS_MSVC_LIKE)
147146
target_compile_options(${target} PRIVATE -momit-leaf-frame-pointer)
@@ -150,6 +149,27 @@ function(_add_host_variant_c_compile_flags target)
150149
endif()
151150
endif()
152151
endif()
152+
else()
153+
if(NOT SWIFT_COMPILER_IS_MSVC_LIKE)
154+
target_compile_options(${target} PRIVATE -O0)
155+
else()
156+
target_compile_options(${target} PRIVATE /Od)
157+
endif()
158+
endif()
159+
160+
# CMake automatically adds the flags for debug info if we use MSVC/clang-cl.
161+
if(NOT SWIFT_COMPILER_IS_MSVC_LIKE)
162+
is_build_type_with_debuginfo("${CMAKE_BUILD_TYPE}" debuginfo)
163+
if(debuginfo)
164+
_compute_lto_flag("${SWIFT_TOOLS_ENABLE_LTO}" _lto_flag_out)
165+
if(_lto_flag_out)
166+
target_compile_options(${target} PRIVATE -gline-tables-only)
167+
else()
168+
target_compile_options(${target} PRIVATE -g)
169+
endif()
170+
else()
171+
target_compile_options(${target} PRIVATE -g0)
172+
endif()
153173
endif()
154174

155175
if(SWIFT_HOST_VARIANT_SDK STREQUAL WINDOWS)

docs/CppInteroperabilityManifesto.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ Assumptions:
6363
+ [Function templates](#function-templates)
6464
+ [Function templates: import as Swift generic functions](#function-templates-import-as-swift-generic-functions)
6565
+ [Function templates: allow to specify template arguments](#function-templates-allow-to-specify-template-arguments)
66-
+ [Function templates: calls to specific specilalizations](#function-templates-calls-to-specific-specilalizations)
66+
+ [Function templates: calls to specific specializations](#function-templates-calls-to-specific-specializations)
6767
+ [Function templates: calls with generic type parameters](#function-templates-calls-with-generic-type-parameters)
6868
+ [Function templates: importing as real generic functions](#function-templates-importing-as-real-generic-functions)
6969
+ [Class templates](#class-templates)
7070
+ [Class templates: importing instantiation behind typedef](#class-templates-importing-instantiation-behind-typedef)
71-
+ [Class templates: importing specific specilalizations](#class-templates-importing-specific-specilalizations)
71+
+ [Class templates: importing specific specializations](#class-templates-importing-specific-specializations)
7272
+ [Class templates: using with generic type parameters](#class-templates-using-with-generic-type-parameters)
7373
+ [Class templates: using in generic code through a synthesized protocol](#class-templates-using-in-generic-code-through-a-synthesized-protocol)
7474
+ [Class templates: importing as real generic structs](#class-templates-importing-as-real-generic-structs)
@@ -1902,7 +1902,7 @@ struct Employee {
19021902
private func _getName() -> UnsafePointer<std.string>
19031903
19041904
// void setName(std::string newName);
1905-
private func _setName(_ newName: std.string)
1905+
private mutating func _setName(_ newName: std.string)
19061906
19071907
// Swifty API.
19081908
public var name: std.string {
@@ -2436,7 +2436,7 @@ possible to do so when importing a C++ function template as a C++ generic
24362436
function; "inout"-ness of an argument can't change across instantiations of a
24372437
generic function in Swift.
24382438

2439-
### Function templates: calls to specific specilalizations
2439+
### Function templates: calls to specific specializations
24402440

24412441
From an implementation point of view, it is easy to compile Swift code that
24422442
calls C++ function templates if template arguments are concrete types that are
@@ -2615,7 +2615,7 @@ struct MagicNumber {}
26152615
typealias WrappedMagicNumber = __CxxTemplateInst12MagicWrapperI11MagicNumberE
26162616
```
26172617

2618-
### Class templates: importing specific specilalizations
2618+
### Class templates: importing specific specializations
26192619

26202620
Just like with calls to C++ function templates, it is easy to compile a use of a
26212621
C++ class templates if the usage in Swift code unambiguously specifies which

docs/HowToGuides/FAQ.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,14 @@ This very depends on what X is, but some broad guidelines are:
6464
1. Do a case-insensitive recursive string search.
6565
- Use a specialized tool like [ripgrep](https://github.com/BurntSushi/ripgrep)
6666
or [ag](https://github.com/ggreer/the_silver_searcher).
67+
- Use `git grep --ignore-case "mypattern"`. `git grep` also supports helpful
68+
flags which provide more context:
69+
- `--show-function`: Tries to print the function name that a match was
70+
found in.
71+
- `--function-context`: Tries to print the entire surrounding function
72+
containing the match.
6773
- Use 'Find in Workspace' in Xcode (<kbd>⌘</kbd>+<kbd>⇧</kbd>+<kbd>F</kbd>).
68-
- Use `grep -i -r "mypattern" .`.
74+
- Use `grep --ignore-case --recursive "mypattern" .`.
6975
2. Go through the [Documentation Index](/docs/README.md).
7076

7177
### How do I build the documentation as HTML?

docs/HowToGuides/FirstPullRequest.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ you are an experienced open source contributor who is excited about Swift, or
66
maybe you are somewhere in-between. Regardless of your background, we are
77
excited to have you contribute and improve the developer experience for Swift
88
programmers all over the globe.
9-
:sparkles::child::student::woman_technologist::technologist::man_technologist::sparkles:
9+
:sparkles:🧒🏾🧑🏼‍🎓👩🏽‍💻🧑🏻‍💻👨🏿‍💻:sparkles:
1010

1111
This document provides a high-level overview of different parts of the
1212
contribution process.

docs/HowToGuides/GettingStarted.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ toolchain as a one-off, there are a couple of differences:
1919
- [Ubuntu Linux](#ubuntu-linux)
2020
- [Building the project for the first time](#building-the-project-for-the-first-time)
2121
- [Spot check dependencies](#spot-check-dependencies)
22-
- [Understanding the pieces](#understanding-the-pieces)
22+
- [The roles of different tools](#the-roles-of-different-tools)
2323
- [The actual build](#the-actual-build)
2424
- [Troubleshooting build issues](#troubleshooting-build-issues)
2525
- [Editing code](#editing-code)
@@ -373,7 +373,7 @@ The codebase is your oyster!
373373
374374
Now that you have made some changes, you will need to rebuild...
375375
376-
### Incremental rebuilds with Ninja
376+
### Incremental builds with Ninja
377377
378378
To rebuild the compiler:
379379
```sh
@@ -503,7 +503,7 @@ utils/build-script --release-debuginfo --debug-swift # other flags...
503503
# debug Stdlib + optimized Swiftc + optimized Clang/LLVM
504504
utils/build-script --release-debuginfo --debug-swift-stdlib # other flags...
505505
506-
# optimized Stdlib + debug Swiftc (expect typechecker) + optimized Clang/LLVM
506+
# optimized Stdlib + debug Swiftc (except typechecker) + optimized Clang/LLVM
507507
utils/build-script --release-debuginfo --debug-swift --force-optimized-typechecker
508508
509509
# Last resort option, it is highly unlikely that you will need this

docs/Lexicon.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,28 @@ introduces [reabstraction](#reabstraction) conversions when a value is used with
4545
different abstraction pattern. (This is where the infamous "reabstraction
4646
thunk helpers" sometimes seen in Swift backtraces come from.)
4747

48+
## access path
49+
50+
Broadly, an "access path" is a list of "accesses" which must be chained together
51+
to compute some output from an input. For instance, the generics system has a
52+
type called a `ConformanceAccessPath` which explains how to, for example,
53+
walk from `T: Collection` to `T: Sequence` to `T.Iterator: IteratorProtocol`.
54+
There are several different kinds of "access path" in different parts of the compiler,
55+
but they all follow this basic theme.
56+
57+
In the specific context of imports, an "access path" is the `Bar` portion of a scoped
58+
import like `import class Foo.Bar`. Theoretically, it could have several identifiers
59+
to designate a nested type, although the compiler doesn't currently support this. It can
60+
also be empty, matching all top-level declarations in the module.
61+
62+
Note, however, that there has historically been some confusion about the meaning of
63+
"access path" with regards to imports. You might see some code use "access path"
64+
to include the `Foo` part or even to describe a chain of submodule names where a
65+
declaration is not valid at all. (Strictly, the chain of module names is a "module path"
66+
and the combination of module path + access path is an "import path".)
67+
68+
See `ImportPath` and the types nested inside it for more on this.
69+
4870
## archetype
4971

5072
A placeholder for a generic parameter or an associated type within a

include/swift/AST/ASTContext.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "swift/AST/Evaluator.h"
2121
#include "swift/AST/GenericSignature.h"
2222
#include "swift/AST/Identifier.h"
23+
#include "swift/AST/Import.h"
2324
#include "swift/AST/SearchPathOptions.h"
2425
#include "swift/AST/Type.h"
2526
#include "swift/AST/Types.h"
@@ -891,12 +892,12 @@ class ASTContext final {
891892
///
892893
/// Note that even if this check succeeds, errors may still occur if the
893894
/// module is loaded in full.
894-
bool canImportModule(Located<Identifier> ModulePath);
895+
bool canImportModule(ImportPath::Element ModulePath);
895896

896897
/// \returns a module with a given name that was already loaded. If the
897898
/// module was not loaded, returns nullptr.
898899
ModuleDecl *getLoadedModule(
899-
ArrayRef<Located<Identifier>> ModulePath) const;
900+
ImportPath::Module ModulePath) const;
900901

901902
ModuleDecl *getLoadedModule(Identifier ModuleName) const;
902903

@@ -906,10 +907,12 @@ class ASTContext final {
906907
/// be returned.
907908
///
908909
/// \returns The requested module, or NULL if the module cannot be found.
909-
ModuleDecl *getModule(ArrayRef<Located<Identifier>> ModulePath);
910+
ModuleDecl *getModule(ImportPath::Module ModulePath);
910911

911912
ModuleDecl *getModuleByName(StringRef ModuleName);
912913

914+
ModuleDecl *getModuleByIdentifier(Identifier ModuleID);
915+
913916
/// Returns the standard library module, or null if the library isn't present.
914917
///
915918
/// If \p loadIfAbsent is true, the ASTContext will attempt to load the module

include/swift/AST/AnyFunctionRef.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,9 @@ class AnyFunctionRef {
137137
return cast<AutoClosureExpr>(ACE)->getBody();
138138
}
139139

140-
void setBody(BraceStmt *stmt, bool isSingleExpression) {
140+
void setTypecheckedBody(BraceStmt *stmt, bool isSingleExpression) {
141141
if (auto *AFD = TheFunction.dyn_cast<AbstractFunctionDecl *>()) {
142-
AFD->setBody(stmt);
142+
AFD->setBody(stmt, AbstractFunctionDecl::BodyKind::TypeChecked);
143143
AFD->setHasSingleExpressionBody(isSingleExpression);
144144
return;
145145
}

include/swift/AST/Attr.def

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,11 +566,17 @@ SIMPLE_DECL_ATTR(asyncHandler, AsyncHandler,
566566
ABIStableToAdd | ABIStableToRemove | APIStableToAdd | APIStableToRemove,
567567
101)
568568

569+
CONTEXTUAL_SIMPLE_DECL_ATTR(actor, Actor,
570+
OnClass | ConcurrencyOnly |
571+
ABIBreakingToAdd | ABIBreakingToRemove |
572+
APIBreakingToAdd | APIBreakingToRemove,
573+
102)
574+
569575
// SWIFT_ENABLE_TENSORFLOW
570576
SIMPLE_DECL_ATTR(compilerEvaluable, CompilerEvaluable,
571577
OnAccessor | OnFunc | OnConstructor | OnSubscript |
572578
ABIStableToAdd | ABIStableToRemove | APIStableToAdd | APIStableToRemove |
573-
NotSerialized, 102)
579+
NotSerialized, 103)
574580
// SWIFT_ENABLE_TENSORFLOW END
575581

576582
#undef TYPE_ATTR

include/swift/AST/Attr.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,9 @@ class DeclAttribute : public AttributeBase {
419419

420420
/// The opposite of ABIBreakingToRemove
421421
ABIStableToRemove = 1ull << (unsigned(DeclKindIndex::Last_Decl) + 15),
422+
423+
/// Whether this attribute is only valid when concurrency is enabled.
424+
ConcurrencyOnly = 1ull << (unsigned(DeclKindIndex::Last_Decl) + 16),
422425
};
423426

424427
LLVM_READNONE
@@ -497,6 +500,10 @@ class DeclAttribute : public AttributeBase {
497500
return getOptions(DK) & SILOnly;
498501
}
499502

503+
static bool isConcurrencyOnly(DeclAttrKind DK) {
504+
return getOptions(DK) & ConcurrencyOnly;
505+
}
506+
500507
static bool isUserInaccessible(DeclAttrKind DK) {
501508
return getOptions(DK) & UserInaccessible;
502509
}

0 commit comments

Comments
 (0)