Skip to content

Commit 6726a66

Browse files
committed
Merge remote-tracking branch 'apple/master' into android-build_toolchain
2 parents 98f883d + 1c390bc commit 6726a66

File tree

185 files changed

+4428
-1411
lines changed

Some content is hidden

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

185 files changed

+4428
-1411
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6653,3 +6653,13 @@ Swift 1.0
66536653
[SE-0167]: <https://github.com/apple/swift-evolution/blob/master/proposals/0167-swift-encoders.md>
66546654
[SE-0168]: <https://github.com/apple/swift-evolution/blob/master/proposals/0168-multi-line-string-literals.md>
66556655
[SE-0169]: <https://github.com/apple/swift-evolution/blob/master/proposals/0169-improve-interaction-between-private-declarations-and-extensions.md>
6656+
[SE-0170]: <https://github.com/apple/swift-evolution/blob/master/proposals/0170-nsnumber_bridge.md>
6657+
[SE-0171]: <https://github.com/apple/swift-evolution/blob/master/proposals/0171-reduce-with-inout.md>
6658+
[SE-0172]: <https://github.com/apple/swift-evolution/blob/master/proposals/0172-one-sided-ranges.md>
6659+
[SE-0173]: <https://github.com/apple/swift-evolution/blob/master/proposals/0173-swap-indices.md>
6660+
[SE-0174]: <https://github.com/apple/swift-evolution/blob/master/proposals/0174-filter-range-replaceable.md>
6661+
[SE-0175]: <https://github.com/apple/swift-evolution/blob/master/proposals/0175-package-manager-revised-dependency-resolution.md>
6662+
[SE-0176]: <https://github.com/apple/swift-evolution/blob/master/proposals/0176-enforce-exclusive-access-to-memory.md>
6663+
[SE-0177]: <https://github.com/apple/swift-evolution/blob/master/proposals/0177-add-clamped-to-method.md>
6664+
[SE-0178]: <https://github.com/apple/swift-evolution/blob/master/proposals/0178-character-unicode-view.md>
6665+
[SE-0179]: <https://github.com/apple/swift-evolution/blob/master/proposals/0179-swift-run-command.md>

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ repositories and will update them instead.
8484

8585
**Via SSH** For those who plan on regularly making direct commits,
8686
cloning over SSH may provide a better experience (which requires
87-
uploading SSH keys to GitHub):
87+
[uploading SSH keys to GitHub](https://help.github.com/articles/adding-a-new-ssh-key-to-your-github-account/)):
8888

8989
git clone [email protected]:apple/swift.git
9090
./swift/utils/update-checkout --clone-with-ssh

benchmark/README.md

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ Using the Harness Generator
101101
`CMakeLists.txt` and `utils/main.swift` from single and multiple file tests
102102
contained in the directories `single-source` and `multi-source`. It gathers
103103
information about the tests and then generates the files from templates using
104-
jinja2. The motivation for creating this script was to eliminate the need to
104+
`gyb`. The motivation for creating this script was to eliminate the need to
105105
manually add at least three lines to harness files (one to `CMakeLists.txt` and
106106
two to `utils/main.swift`) for every new benchmark added.
107107

@@ -110,34 +110,23 @@ two to `utils/main.swift`) for every new benchmark added.
110110
Since `CMakeLists.txt` and `utils/main.swift` are now generated from templates,
111111
they should not be directly modified. Work may be lost if the harness is
112112
executed after making changes to derived files. Instead, modifications should
113-
be made to the template files stored in the `scripts/generate_harness`
114-
directory.
113+
be made to the `*.gyb` template files.
115114

116115
### Generating harness files
117116

118-
Start by installing jinja2 if it isn't already installed:
119-
120-
$ sudo easy_install -U jinja2
121-
122117
To generate `CMakeLists.txt` and `utils/main.swift` from test sources, run the
123118
command:
124119

125120
$ scripts/generate_harness/generate_harness.py
126121

127-
**Note:**
128-
129-
Ensure `generate_harness.py` remains in `scripts/generate_harness` as it
130-
modifies files relative to its location instead of the current working
131-
directory.
132-
133122
### Modifying CMakeLists.txt or utils/main.swift
134123

135124
To make changes to `CMakeLists.txt` or `utils/main.swift`, modify the template
136-
files `CMakeLists.txt_template` and `main.swift_template` stored in the
137-
`scripts/generate_harness` directory. These are jinja2 templates, rendered by
138-
jinja2 calls in `generate_harness.py`, so ensure static changes don't interfere
139-
with the template portions. Test changes by regenerating the harness
140-
(*Generating harness files*) and rebuilding the repository with `build-script`.
125+
files `CMakeLists.txt.gyb` and `main.swift.gyb` These are templates, rendered by
126+
`gyb` in `generate_harness.py`, so ensure static changes don't interfere
127+
with the template portions. Test changes by
128+
[regenerating the harness](#generating-harness-files) and rebuilding the
129+
repository with `build-script`.
141130

142131
Adding New Benchmarks
143132
---------------------
@@ -149,7 +138,8 @@ To add a new single file test:
149138
1. Add a new Swift file (`YourTestNameHere.swift`), built according to
150139
the template below, to the `single-source` directory.
151140
2. Regenerate harness files by following the directions in
152-
*Generating harness files* before committing changes.
141+
[Generating harness files](#generating-harness-files) before committing
142+
changes.
153143

154144
To add a new multiple file test:
155145

@@ -166,7 +156,8 @@ To add a new multiple file test:
166156
exist in the files.
167157

168158
2. Regenerate harness files by following the directions in
169-
*Generating harness files* before committing changes.
159+
[Generating harness files](#generating-harness-files) before committing
160+
changes.
170161

171162
**Note:**
172163

@@ -204,4 +195,3 @@ public func run_YourTestNameHere(N: Int) {
204195
# Assert with CheckResults that work was done
205196
}
206197
```
207-

include/swift/AST/Decl.h

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3418,46 +3418,54 @@ class ClassDecl : public NominalTypeDecl {
34183418
struct SelfReferenceKind {
34193419
bool result;
34203420
bool parameter;
3421+
bool requirement;
34213422
bool other;
34223423

34233424
/// The type does not refer to 'Self' at all.
34243425
static SelfReferenceKind None() {
3425-
return SelfReferenceKind(false, false, false);
3426+
return SelfReferenceKind(false, false, false, false);
34263427
}
34273428

34283429
/// The type refers to 'Self', but only as the result type of a method.
34293430
static SelfReferenceKind Result() {
3430-
return SelfReferenceKind(true, false, false);
3431+
return SelfReferenceKind(true, false, false, false);
34313432
}
34323433

34333434
/// The type refers to 'Self', but only as the parameter type of a method.
34343435
static SelfReferenceKind Parameter() {
3435-
return SelfReferenceKind(false, true, false);
3436+
return SelfReferenceKind(false, true, false, false);
3437+
}
3438+
3439+
/// The type refers to 'Self' within a same-type requiement.
3440+
static SelfReferenceKind Requirement() {
3441+
return SelfReferenceKind(false, false, true, false);
34363442
}
34373443

34383444
/// The type refers to 'Self' in a position that is invariant.
34393445
static SelfReferenceKind Other() {
3440-
return SelfReferenceKind(false, false, true);
3446+
return SelfReferenceKind(false, false, false, true);
34413447
}
34423448

34433449
SelfReferenceKind flip() const {
3444-
return SelfReferenceKind(parameter, result, other);
3450+
return SelfReferenceKind(parameter, result, requirement, other);
34453451
}
34463452

34473453
SelfReferenceKind operator|=(SelfReferenceKind kind) {
34483454
result |= kind.result;
3455+
requirement |= kind.requirement;
34493456
parameter |= kind.parameter;
34503457
other |= kind.other;
34513458
return *this;
34523459
}
34533460

34543461
operator bool() const {
3455-
return result || parameter || other;
3462+
return result || parameter || requirement || other;
34563463
}
34573464

34583465
private:
3459-
SelfReferenceKind(bool result, bool parameter, bool other)
3460-
: result(result), parameter(parameter), other(other) { }
3466+
SelfReferenceKind(bool result, bool parameter, bool requirement, bool other)
3467+
: result(result), parameter(parameter), requirement(requirement),
3468+
other(other) { }
34613469
};
34623470

34633471
/// ProtocolDecl - A declaration of a protocol, for example:

include/swift/AST/DiagnosticsSema.def

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,10 @@ ERROR(expr_swift_keypath_unimplemented_component,none,
450450
ERROR(expr_smart_keypath_value_covert_to_contextual_type,none,
451451
"KeyPath value type %0 cannot be converted to contextual type %1",
452452
(Type, Type))
453+
ERROR(expr_string_interpolation_outside_string,none,
454+
"string interpolation can only appear inside a string literal", ())
455+
ERROR(unsupported_keypath_tuple_element_reference,none,
456+
"key path cannot reference tuple elements", ())
453457

454458
// Selector expressions.
455459
ERROR(expr_selector_no_objc_runtime,none,
@@ -1413,6 +1417,19 @@ ERROR(witness_self_non_subtype,none,
14131417
"(%2) because it uses 'Self' in a non-parameter, non-result type "
14141418
"position",
14151419
(Type, DeclName, Type))
1420+
ERROR(witness_self_same_type,none,
1421+
"%0 %1 in non-final class %2 cannot be used to satisfy requirement %3 %4"
1422+
" (in protocol %5) due to same-type requirement involving 'Self'",
1423+
(DescriptiveDeclKind, DeclName, Type, DescriptiveDeclKind,
1424+
DeclName, Type))
1425+
WARNING(witness_self_same_type_warn,none,
1426+
"%0 %1 in non-final class %2 cannot be used to satisfy requirement %3 %4"
1427+
" (in protocol %5) due to same-type requirement involving 'Self'",
1428+
(DescriptiveDeclKind, DeclName, Type, DescriptiveDeclKind,
1429+
DeclName, Type))
1430+
NOTE(witness_self_weaken_same_type,none,
1431+
"consider weakening the same-type requirement %0 == %1 to a superclass "
1432+
"requirement", (Type, Type))
14161433
ERROR(witness_requires_dynamic_self,none,
14171434
"method %0 in non-final class %1 must return `Self` to conform to "
14181435
"protocol %2",
@@ -2035,7 +2052,7 @@ ERROR(broken_decodable_requirement,none,
20352052
NOTE(codable_extraneous_codingkey_case_here,none,
20362053
"CodingKey case %0 does match any stored properties", (Identifier))
20372054
NOTE(codable_non_conforming_property_here,none,
2038-
"cannot automatically synthesize %0 because %1 does not conform to %0", (Type, Identifier))
2055+
"cannot automatically synthesize %0 because %1 does not conform to %0", (Type, Type))
20392056
NOTE(codable_non_decoded_property_here,none,
20402057
"cannot automatically synthesize %0 because %1 does not have a matching CodingKey and does not have a default value", (Type, Identifier))
20412058
NOTE(codable_codingkeys_type_is_not_an_enum_here,none,

include/swift/AST/Expr.h

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1382,12 +1382,37 @@ class TypeExpr : public Expr {
13821382
static TypeExpr *createImplicitHack(SourceLoc Loc, Type Ty, ASTContext &C);
13831383

13841384

1385-
/// Return a TypeExpr for a TypeDecl and the specified location.
1385+
/// Create a TypeExpr for a TypeDecl at the specified location.
13861386
static TypeExpr *createForDecl(SourceLoc Loc, TypeDecl *D,
13871387
bool isImplicit);
1388+
1389+
/// Create a TypeExpr for a member TypeDecl of the given parent TypeDecl.
1390+
static TypeExpr *createForMemberDecl(SourceLoc ParentNameLoc,
1391+
TypeDecl *Parent,
1392+
SourceLoc NameLoc,
1393+
TypeDecl *Decl);
1394+
1395+
/// Create a TypeExpr for a member TypeDecl of the given parent IdentTypeRepr.
1396+
static TypeExpr *createForMemberDecl(IdentTypeRepr *ParentTR,
1397+
SourceLoc NameLoc,
1398+
TypeDecl *Decl);
1399+
1400+
/// Create a TypeExpr for a generic TypeDecl with the given arguments applied
1401+
/// at the specified location.
13881402
static TypeExpr *createForSpecializedDecl(SourceLoc Loc, TypeDecl *D,
13891403
ArrayRef<TypeRepr*> args,
13901404
SourceRange angleLocs);
1405+
1406+
/// Create a TypeExpr from an IdentTypeRepr with the given arguments applied
1407+
/// at the specified location.
1408+
///
1409+
/// Returns nullptr if the reference cannot be formed, which is a hack due
1410+
/// to limitations in how we model generic typealiases.
1411+
static TypeExpr *createForSpecializedDecl(IdentTypeRepr *ParentTR,
1412+
ArrayRef<TypeRepr*> Args,
1413+
SourceRange AngleLocs,
1414+
ASTContext &C);
1415+
13911416
TypeLoc &getTypeLoc() { return Info; }
13921417
TypeLoc getTypeLoc() const { return Info; }
13931418
TypeRepr *getTypeRepr() const { return Info.getTypeRepr(); }
@@ -4582,6 +4607,7 @@ class KeyPathExpr : public Expr {
45824607
class Component {
45834608
public:
45844609
enum class Kind: unsigned {
4610+
Invalid,
45854611
UnresolvedProperty,
45864612
UnresolvedSubscript,
45874613
Property,
@@ -4616,7 +4642,7 @@ class KeyPathExpr : public Expr {
46164642
{}
46174643

46184644
public:
4619-
Component() : Component({}, nullptr, (Kind)0, Type(), SourceLoc()) {}
4645+
Component() : Component({}, nullptr, Kind::Invalid, Type(), SourceLoc()) {}
46204646

46214647
/// Create an unresolved component for a property.
46224648
static Component forUnresolvedProperty(DeclName UnresolvedName,
@@ -4720,12 +4746,17 @@ class KeyPathExpr : public Expr {
47204746
return SubscriptIndexExprAndKind.getInt();
47214747
}
47224748

4749+
bool isValid() const {
4750+
return getKind() != Kind::Invalid;
4751+
}
4752+
47234753
Expr *getIndexExpr() const {
47244754
switch (getKind()) {
47254755
case Kind::Subscript:
47264756
case Kind::UnresolvedSubscript:
47274757
return SubscriptIndexExprAndKind.getPointer();
47284758

4759+
case Kind::Invalid:
47294760
case Kind::OptionalChain:
47304761
case Kind::OptionalWrap:
47314762
case Kind::OptionalForce:
@@ -4740,6 +4771,7 @@ class KeyPathExpr : public Expr {
47404771
case Kind::UnresolvedProperty:
47414772
return Decl.UnresolvedName;
47424773

4774+
case Kind::Invalid:
47434775
case Kind::Subscript:
47444776
case Kind::UnresolvedSubscript:
47454777
case Kind::OptionalChain:
@@ -4756,6 +4788,7 @@ class KeyPathExpr : public Expr {
47564788
case Kind::Subscript:
47574789
return Decl.ResolvedDecl;
47584790

4791+
case Kind::Invalid:
47594792
case Kind::UnresolvedProperty:
47604793
case Kind::UnresolvedSubscript:
47614794
case Kind::OptionalChain:

include/swift/AST/KnownIdentifiers.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,14 @@ IDENTIFIER(Darwin)
4040
IDENTIFIER(dealloc)
4141
IDENTIFIER(Decodable)
4242
IDENTIFIER(decode)
43+
IDENTIFIER(decodeIfPresent)
4344
IDENTIFIER(Decoder)
4445
IDENTIFIER(decoder)
4546
IDENTIFIER(deinit)
4647
IDENTIFIER(Element)
4748
IDENTIFIER(Encodable)
4849
IDENTIFIER(encode)
50+
IDENTIFIER(encodeIfPresent)
4951
IDENTIFIER(Encoder)
5052
IDENTIFIER(encoder)
5153
IDENTIFIER(error)

include/swift/AST/SILOptions.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@ class SILOptions {
149149
/// Enable the mandatory semantic arc optimizer.
150150
bool EnableMandatorySemanticARCOpts = false;
151151

152+
/// \brief Enable large loadable types IRGen pass.
153+
bool EnableLargeLoadableTypes = false;
154+
152155
SILOptions() : Sanitize(SanitizerKind::None) {}
153156

154157
/// Return a hash code of any components from these options that should

include/swift/AST/TypeAlignments.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ namespace swift {
4747
class Substitution;
4848
class TypeVariableType;
4949
class TypeBase;
50+
class TypeDecl;
5051
class ValueDecl;
5152

5253
/// We frequently use three tag bits on all of these types.
@@ -87,6 +88,7 @@ LLVM_DECLARE_TYPE_ALIGNMENT(swift::AssociatedTypeDecl, swift::DeclAlignInBits)
8788
LLVM_DECLARE_TYPE_ALIGNMENT(swift::GenericTypeParamDecl, swift::DeclAlignInBits)
8889
LLVM_DECLARE_TYPE_ALIGNMENT(swift::OperatorDecl, swift::DeclAlignInBits)
8990
LLVM_DECLARE_TYPE_ALIGNMENT(swift::ProtocolDecl, swift::DeclAlignInBits)
91+
LLVM_DECLARE_TYPE_ALIGNMENT(swift::TypeDecl, swift::DeclAlignInBits)
9092
LLVM_DECLARE_TYPE_ALIGNMENT(swift::ValueDecl, swift::DeclAlignInBits)
9193
LLVM_DECLARE_TYPE_ALIGNMENT(swift::ExtensionDecl, swift::DeclAlignInBits)
9294

include/swift/AST/TypeRepr.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ namespace swift {
3333
class DeclContext;
3434
class GenericEnvironment;
3535
class IdentTypeRepr;
36-
class ValueDecl;
36+
class TypeDecl;
3737

3838
enum class TypeReprKind : uint8_t {
3939
#define TYPEREPR(ID, PARENT) ID,
@@ -243,7 +243,7 @@ class ComponentIdentTypeRepr : public IdentTypeRepr {
243243
///
244244
/// The initial parsed representation is always an identifier, and
245245
/// name binding will resolve this to a specific declaration.
246-
llvm::PointerUnion<Identifier, ValueDecl *> IdOrDecl;
246+
llvm::PointerUnion<Identifier, TypeDecl *> IdOrDecl;
247247

248248
protected:
249249
ComponentIdentTypeRepr(TypeReprKind K, SourceLoc Loc, Identifier Id)
@@ -258,11 +258,11 @@ class ComponentIdentTypeRepr : public IdentTypeRepr {
258258
void overwriteIdentifier(Identifier newId) { IdOrDecl = newId; }
259259

260260
/// Return true if this has been name-bound already.
261-
bool isBound() const { return IdOrDecl.is<ValueDecl *>(); }
261+
bool isBound() const { return IdOrDecl.is<TypeDecl *>(); }
262262

263-
ValueDecl *getBoundDecl() const { return IdOrDecl.dyn_cast<ValueDecl*>(); }
263+
TypeDecl *getBoundDecl() const { return IdOrDecl.dyn_cast<TypeDecl*>(); }
264264

265-
void setValue(ValueDecl *VD) { IdOrDecl = VD; }
265+
void setValue(TypeDecl *TD) { IdOrDecl = TD; }
266266

267267
static bool classof(const TypeRepr *T) {
268268
return T->getKind() == TypeReprKind::SimpleIdent ||

0 commit comments

Comments
 (0)