Skip to content

Commit 614bbc7

Browse files
authored
---
yaml --- r: 343007 b: refs/heads/master-rebranch c: e56743e h: refs/heads/master i: 343005: 7bf1925 343003: d3f6705 342999: 7c0f0d9 342991: 149de45 342975: e8ef15a
1 parent 24eb05d commit 614bbc7

File tree

91 files changed

+1150
-1019
lines changed

Some content is hidden

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

91 files changed

+1150
-1019
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1455,7 +1455,7 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2019-08-02-a: ddd2b2976aa9bfde5f20fe37f6bd2
14551455
refs/tags/swift-DEVELOPMENT-SNAPSHOT-2019-08-03-a: 171cc166f2abeb5ca2a4003700a8a78a108bd300
14561456
refs/heads/benlangmuir-patch-1: baaebaf39d52f3bf36710d4fe40cf212e996b212
14571457
refs/heads/i-do-redeclare: 8c4e6d5de5c1e3f0a2cedccf319df713ea22c48e
1458-
refs/heads/master-rebranch: 8da82d327226f20327fd15b6435913a11713711b
1458+
refs/heads/master-rebranch: e56743e7b449eefb4237c1ad4799b787d5624afd
14591459
refs/heads/rdar-53901732: 9bd06af3284e18a109cdbf9aa59d833b24eeca7b
14601460
refs/heads/revert-26776-subst-always-returns-a-type: 1b8e18fdd391903a348970a4c848995d4cdd789c
14611461
refs/heads/tensorflow-merge: 8b854f62f80d4476cb383d43c4aac2001dde3cec

branches/master-rebranch/docs/Diagnostics.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ Most diagnostics have no reason to change behavior under editor mode. An example
9797

9898
- `%0`, `%1`, etc - Formats the specified diagnostic argument based on its type.
9999

100-
- `%select{a|b|c}0` - Chooses from a list of alternatives, separated by vertical bars, based on the value of the given argument. In this example, a value of 2 in diagnostic argument 0 would result in "c" being output.
100+
- `%select{a|b|c}0` - Chooses from a list of alternatives, separated by vertical bars, based on the value of the given argument. In this example, a value of 2 in diagnostic argument 0 would result in "c" being output. The argument to the %select may be an integer, enum, or StringRef. If it's a StringRef, the specifier acts as an emptiness check.
101101

102102
- `%s0` - Produces an "s" if the given argument is anything other than 1, as meant for an English plural. This isn't particularly localizable without a more general `%plural` form, but most diagnostics try to avoid cases where a plural/singular distinction would be necessary in the first place.
103103

branches/master-rebranch/docs/SIL.rst

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2802,6 +2802,21 @@ It is expected that the strong reference count of the object is one.
28022802
Furthermore, no other thread may increment the strong reference count during
28032803
execution of this instruction.
28042804

2805+
copy_unowned_value
2806+
``````````````````
2807+
::
2808+
2809+
sil-instruction ::= 'copy_unowned_value' sil-operand
2810+
2811+
%1 = copy_unowned_value %0 : $@unowned T
2812+
// %1 will be a strong @owned value of type $T.
2813+
// $T must be a reference type
2814+
2815+
Asserts that the strong reference count of the heap object referenced by ``%0``
2816+
is still positive, then increments the reference count and returns a new strong
2817+
reference to ``%0``. The intention is that this instruction is used as a "safe
2818+
ownership conversion" from ``unowned`` to ``strong``.
2819+
28052820
strong_retain_unowned
28062821
`````````````````````
28072822
::
@@ -3712,6 +3727,21 @@ This instruction has the same local semantics as ``retain_value`` but:
37123727
The intention is that this instruction is used to implement unmanaged
37133728
constructs.
37143729

3730+
copy_unmanaged_value
3731+
``````````````````````
3732+
3733+
::
3734+
3735+
sil-instruction ::= 'copy_unmanaged_value' sil-value
3736+
3737+
%1 = copy_unmanaged_value %0 : $@sil_unmanaged A
3738+
// %1 will be a strong @owned $A.
3739+
3740+
This instruction has the same semantics as ``copy_value`` except that its input
3741+
is a trivial ``@sil_unmanaged`` type that doesn't require ref counting. This is
3742+
intended to be used semantically as a "conversion" like instruction from
3743+
``unmanaged`` to ``strong`` and thus should never be removed by the optimizer.
3744+
37153745
copy_value
37163746
``````````
37173747

branches/master-rebranch/include/swift/AST/ASTTypeIDZone.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,6 @@ SWIFT_TYPEID_NAMED(Optional<PropertyWrapperMutability>, PropertyWrapperMutabilit
2929
SWIFT_TYPEID_NAMED(CustomAttr *, CustomAttr)
3030
SWIFT_TYPEID_NAMED(TypeAliasDecl *, TypeAliasDecl)
3131
SWIFT_TYPEID(AncestryFlags)
32+
SWIFT_TYPEID_NAMED(GenericSignature *, GenericSignature)
33+
SWIFT_TYPEID_NAMED(GenericTypeParamType *, GenericTypeParamType)
34+
SWIFT_TYPEID(Requirement)

branches/master-rebranch/include/swift/AST/ASTTypeIDs.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,14 @@
2121
namespace swift {
2222

2323
class CustomAttr;
24+
class GenericSignature;
25+
class GenericTypeParamType;
2426
class NominalTypeDecl;
2527
struct PropertyWrapperBackingPropertyInfo;
2628
struct PropertyWrapperTypeInfo;
2729
enum class CtorInitializerKind;
2830
struct PropertyWrapperMutability;
31+
class Requirement;
2932
class Type;
3033
class VarDecl;
3134
class TypeAliasDecl;

branches/master-rebranch/include/swift/AST/Attr.h

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -258,11 +258,9 @@ class DeclAttribute : public AttributeBase {
258258
ownership : NumReferenceOwnershipBits
259259
);
260260

261-
SWIFT_INLINE_BITFIELD_FULL(SpecializeAttr, DeclAttribute, 1+1+32,
261+
SWIFT_INLINE_BITFIELD(SpecializeAttr, DeclAttribute, 1+1,
262262
exported : 1,
263-
kind : 1,
264-
: NumPadBits,
265-
numRequirements : 32
263+
kind : 1
266264
);
267265

268266
SWIFT_INLINE_BITFIELD(SynthesizedProtocolAttr, DeclAttribute,
@@ -1236,39 +1234,29 @@ class SpecializeAttr : public DeclAttribute {
12361234

12371235
private:
12381236
TrailingWhereClause *trailingWhereClause;
1239-
1240-
Requirement *getRequirementsData() {
1241-
return reinterpret_cast<Requirement *>(this+1);
1242-
}
1237+
GenericSignature *specializedSignature;
12431238

12441239
SpecializeAttr(SourceLoc atLoc, SourceRange Range,
12451240
TrailingWhereClause *clause, bool exported,
1246-
SpecializationKind kind);
1247-
1248-
SpecializeAttr(SourceLoc atLoc, SourceRange Range,
1249-
ArrayRef<Requirement> requirements,
1250-
bool exported,
1251-
SpecializationKind kind);
1241+
SpecializationKind kind,
1242+
GenericSignature *specializedSignature);
12521243

12531244
public:
12541245
static SpecializeAttr *create(ASTContext &Ctx, SourceLoc atLoc,
12551246
SourceRange Range, TrailingWhereClause *clause,
1256-
bool exported, SpecializationKind kind);
1257-
1258-
static SpecializeAttr *create(ASTContext &Ctx, SourceLoc atLoc,
1259-
SourceRange Range,
1260-
ArrayRef<Requirement> requirement,
1261-
bool exported, SpecializationKind kind);
1247+
bool exported, SpecializationKind kind,
1248+
GenericSignature *specializedSignature
1249+
= nullptr);
12621250

12631251
TrailingWhereClause *getTrailingWhereClause() const;
12641252

1265-
ArrayRef<Requirement> getRequirements() const;
1266-
1267-
MutableArrayRef<Requirement> getRequirements() {
1268-
return { getRequirementsData(), Bits.SpecializeAttr.numRequirements };
1253+
GenericSignature *getSpecializedSgnature() const {
1254+
return specializedSignature;
12691255
}
12701256

1271-
void setRequirements(ASTContext &Ctx, ArrayRef<Requirement> requirements);
1257+
void setSpecializedSignature(GenericSignature *newSig) {
1258+
specializedSignature = newSig;
1259+
}
12721260

12731261
bool isExported() const {
12741262
return Bits.SpecializeAttr.exported;

branches/master-rebranch/include/swift/AST/DiagnosticsSema.def

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2226,10 +2226,8 @@ ERROR(multiple_override,none,
22262226
NOTE(multiple_override_prev,none,
22272227
"%0 previously overridden here", (DeclName))
22282228

2229-
ERROR(override_unavailable,none,
2230-
"cannot override %0 which has been marked unavailable", (DeclBaseName))
2231-
ERROR(override_unavailable_msg, none,
2232-
"cannot override %0 which has been marked unavailable: %1",
2229+
ERROR(override_unavailable, none,
2230+
"cannot override %0 which has been marked unavailable%select{|: %1}1",
22332231
(DeclBaseName, StringRef))
22342232

22352233
ERROR(override_less_available,none,
@@ -4121,27 +4119,16 @@ ERROR(dynamic_replacement_replaced_constructor_is_not_convenience, none,
41214119

41224120
ERROR(availability_decl_unavailable, none,
41234121
"%select{getter for |setter for |}0%1 is unavailable"
4124-
"%select{ in %3|}2",
4125-
(unsigned, DeclName, bool, StringRef))
4122+
"%select{ in %3|}2%select{|: %4}4",
4123+
(unsigned, DeclName, bool, StringRef, StringRef))
41264124

41274125
#define REPLACEMENT_DECL_KIND_SELECT "select{| instance method| property}"
41284126
ERROR(availability_decl_unavailable_rename, none,
41294127
"%select{getter for |setter for |}0%1 has been "
41304128
"%select{renamed to|replaced by}2%" REPLACEMENT_DECL_KIND_SELECT "3 "
4131-
"'%4'",
4132-
(unsigned, DeclName, bool, unsigned, StringRef))
4133-
4134-
ERROR(availability_decl_unavailable_rename_msg, none,
4135-
"%select{getter for |setter for |}0%1 has been "
4136-
"%select{renamed to|replaced by}2%" REPLACEMENT_DECL_KIND_SELECT "3 "
4137-
"'%4': %5",
4129+
"'%4'%select{|: %5}5",
41384130
(unsigned, DeclName, bool, unsigned, StringRef, StringRef))
41394131

4140-
ERROR(availability_decl_unavailable_msg, none,
4141-
"%select{getter for |setter for |}0%1 is unavailable"
4142-
"%select{ in %3|}2: %4",
4143-
(unsigned, DeclName, bool, StringRef, StringRef))
4144-
41454132
NOTE(availability_marked_unavailable, none,
41464133
"%select{getter for |setter for |}0%1 has been explicitly marked "
41474134
"unavailable here", (unsigned, DeclName))
@@ -4156,12 +4143,7 @@ NOTE(availability_obsoleted, none,
41564143

41574144
WARNING(availability_deprecated, none,
41584145
"%select{getter for |setter for |}0%1 %select{is|%select{is|was}4}2 "
4159-
"deprecated%select{| in %3%select{| %5}4}2",
4160-
(unsigned, DeclName, bool, StringRef, bool, llvm::VersionTuple))
4161-
4162-
WARNING(availability_deprecated_msg, none,
4163-
"%select{getter for |setter for |}0%1 %select{is|%select{is|was}4}2 "
4164-
"deprecated%select{| in %3%select{| %5}4}2: %6",
4146+
"deprecated%select{| in %3%select{| %5}4}2%select{|: %6}6",
41654147
(unsigned, DeclName, bool, StringRef, bool, llvm::VersionTuple,
41664148
StringRef))
41674149

branches/master-rebranch/include/swift/AST/GenericSignature.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,8 @@ CanGenericSignature::CanGenericSignature(GenericSignature *Signature)
335335
assert(!Signature || Signature->isCanonical());
336336
}
337337

338+
void simple_display(raw_ostream &out, const GenericSignature *sig);
339+
338340
} // end namespace swift
339341

340342
#endif // SWIFT_AST_GENERIC_SIGNATURE_H

branches/master-rebranch/include/swift/AST/LayoutConstraint.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "swift/Basic/SourceLoc.h"
2222
#include "llvm/ADT/DenseMap.h"
2323
#include "llvm/ADT/FoldingSet.h"
24+
#include "llvm/ADT/Hashing.h"
2425
#include "llvm/ADT/StringRef.h"
2526
#include "swift/AST/PrintOptions.h"
2627

@@ -290,6 +291,10 @@ class LayoutConstraint {
290291
/// Return the layout constraint as a string, for use in diagnostics only.
291292
std::string getString(const PrintOptions &PO = PrintOptions()) const;
292293

294+
friend llvm::hash_code hash_value(const LayoutConstraint &layout) {
295+
return hash_value(layout.getPointer());
296+
}
297+
293298
bool operator==(LayoutConstraint rhs) const {
294299
if (isNull() && rhs.isNull())
295300
return true;

branches/master-rebranch/include/swift/AST/Module.h

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,10 @@ static inline unsigned alignOfFileUnit();
644644
/// FileUnit is an abstract base class; its subclasses represent different
645645
/// sorts of containers that can each provide a set of decls, e.g. a source
646646
/// file. A module can contain several file-units.
647+
#pragma clang diagnostic push
648+
#pragma clang diagnostic ignored "-Wnon-virtual-dtor"
647649
class FileUnit : public DeclContext {
650+
#pragma clang diagnostic pop
648651
virtual void anchor();
649652

650653
// FIXME: Stick this in a PointerIntPair.
@@ -655,8 +658,6 @@ class FileUnit : public DeclContext {
655658
: DeclContext(DeclContextKind::FileUnit, &M), Kind(kind) {
656659
}
657660

658-
virtual ~FileUnit() = default;
659-
660661
public:
661662
FileUnitKind getKind() const {
662663
return Kind;
@@ -874,10 +875,6 @@ class FileUnit : public DeclContext {
874875
return getParentModule()->getName().str();
875876
}
876877

877-
/// If this is a module imported from a parseable interface, return the path
878-
/// to the interface file, otherwise an empty StringRef.
879-
virtual StringRef getParseableInterface() const { return {}; }
880-
881878
/// Traverse the decls within this file.
882879
///
883880
/// \returns true if traversal was aborted, false if it completed
@@ -897,13 +894,7 @@ class FileUnit : public DeclContext {
897894
// Make placement new and vanilla new/delete illegal for FileUnits.
898895
void *operator new(size_t Bytes) throw() = delete;
899896
void *operator new(size_t Bytes, void *Mem) throw() = delete;
900-
901-
protected:
902-
// Unfortunately we can't remove this altogether because the virtual
903-
// destructor requires it to be accessible.
904-
void operator delete(void *Data) throw() {
905-
llvm_unreachable("Don't use operator delete on a SourceFile");
906-
}
897+
void operator delete(void *Data) throw() = delete;
907898

908899
public:
909900
// Only allow allocation of FileUnits using the allocator in ASTContext
@@ -1386,35 +1377,23 @@ class BuiltinUnit final : public FileUnit {
13861377
};
13871378

13881379
/// Represents an externally-loaded file of some kind.
1380+
#pragma clang diagnostic push
1381+
#pragma clang diagnostic ignored "-Wnon-virtual-dtor"
13891382
class LoadedFile : public FileUnit {
1383+
#pragma clang diagnostic pop
13901384
protected:
1391-
~LoadedFile() = default;
13921385
LoadedFile(FileUnitKind Kind, ModuleDecl &M) noexcept
13931386
: FileUnit(Kind, M) {
13941387
assert(classof(this) && "invalid kind");
13951388
}
1396-
1397-
/// A map from private/fileprivate decls to the file they were defined in.
1398-
llvm::DenseMap<const ValueDecl *, Identifier> FilenameForPrivateDecls;
1399-
14001389
public:
1401-
14021390
/// Returns an arbitrary string representing the storage backing this file.
14031391
///
14041392
/// This is usually a filesystem path.
14051393
virtual StringRef getFilename() const;
14061394

1407-
void addFilenameForPrivateDecl(const ValueDecl *decl, Identifier id) {
1408-
assert(!FilenameForPrivateDecls.count(decl) ||
1409-
FilenameForPrivateDecls[decl] == id);
1410-
FilenameForPrivateDecls[decl] = id;
1411-
}
1412-
1413-
StringRef getFilenameForPrivateDecl(const ValueDecl *decl) {
1414-
auto it = FilenameForPrivateDecls.find(decl);
1415-
if (it == FilenameForPrivateDecls.end())
1416-
return StringRef();
1417-
return it->second.str();
1395+
virtual StringRef getFilenameForPrivateDecl(const ValueDecl *decl) const {
1396+
return StringRef();
14181397
}
14191398

14201399
/// Look up an operator declaration.

branches/master-rebranch/include/swift/AST/Requirement.h

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#define SWIFT_AST_REQUIREMENT_H
1919

2020
#include "swift/AST/Type.h"
21+
#include "llvm/ADT/Hashing.h"
2122
#include "llvm/ADT/PointerIntPair.h"
2223
#include "llvm/Support/ErrorHandling.h"
2324

@@ -119,12 +120,60 @@ class Requirement {
119120
return SecondLayout;
120121
}
121122

123+
/// Whether this requirement is in its canonical form.
124+
bool isCanonical() const;
125+
126+
/// Get the canonical form of this requirement.
127+
Requirement getCanonical() const;
128+
122129
void dump() const;
123130
void dump(raw_ostream &out) const;
124131
void print(raw_ostream &os, const PrintOptions &opts) const;
125132
void print(ASTPrinter &printer, const PrintOptions &opts) const;
133+
134+
friend llvm::hash_code hash_value(const Requirement &requirement) {
135+
using llvm::hash_value;
136+
137+
llvm::hash_code first =
138+
hash_value(requirement.FirstTypeAndKind.getOpaqueValue());
139+
llvm::hash_code second;
140+
switch (requirement.getKind()) {
141+
case RequirementKind::Conformance:
142+
case RequirementKind::Superclass:
143+
case RequirementKind::SameType:
144+
second = hash_value(requirement.getSecondType());
145+
break;
146+
147+
case RequirementKind::Layout:
148+
second = hash_value(requirement.getLayoutConstraint());
149+
break;
150+
}
151+
152+
return llvm::hash_combine(first, second);
153+
}
154+
155+
friend bool operator==(const Requirement &lhs, const Requirement &rhs) {
156+
if (lhs.FirstTypeAndKind.getOpaqueValue()
157+
!= rhs.FirstTypeAndKind.getOpaqueValue())
158+
return false;
159+
160+
switch (lhs.getKind()) {
161+
case RequirementKind::Conformance:
162+
case RequirementKind::Superclass:
163+
case RequirementKind::SameType:
164+
return lhs.getSecondType().getPointer() ==
165+
rhs.getSecondType().getPointer();
166+
167+
case RequirementKind::Layout:
168+
return lhs.getLayoutConstraint() == rhs.getLayoutConstraint();
169+
}
170+
}
126171
};
127172

173+
inline void simple_display(llvm::raw_ostream &out, const Requirement &req) {
174+
req.print(out, PrintOptions());
175+
}
176+
128177
} // end namespace swift
129178

130179
#endif

0 commit comments

Comments
 (0)