Skip to content

Commit 492a73c

Browse files
committed
Merge branch 'apple-master' into api-digester-match-kind
2 parents 9138b02 + 700da2e commit 492a73c

File tree

117 files changed

+891
-735
lines changed

Some content is hidden

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

117 files changed

+891
-735
lines changed

include/swift/ABI/KeyPath.h

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -82,65 +82,78 @@ class KeyPathComponentHeader {
8282
offset;
8383
}
8484

85+
static constexpr uint32_t isLetBit(bool isLet) {
86+
return isLet ? 0 : _SwiftKeyPathComponentHeader_StoredMutableFlag;
87+
}
88+
8589
public:
8690
static constexpr bool offsetCanBeInline(unsigned offset) {
8791
return offset <= _SwiftKeyPathComponentHeader_MaximumOffsetPayload;
8892
}
8993

9094
constexpr static KeyPathComponentHeader
91-
forStructComponentWithInlineOffset(unsigned offset) {
95+
forStructComponentWithInlineOffset(bool isLet,
96+
unsigned offset) {
9297
return KeyPathComponentHeader(
9398
(_SwiftKeyPathComponentHeader_StructTag
94-
<< _SwiftKeyPathComponentHeader_DiscriminatorShift)
95-
| validateInlineOffset(offset));
99+
<< _SwiftKeyPathComponentHeader_DiscriminatorShift)
100+
| validateInlineOffset(offset)
101+
| isLetBit(isLet));
96102
}
97103

98104
constexpr static KeyPathComponentHeader
99-
forStructComponentWithOutOfLineOffset() {
105+
forStructComponentWithOutOfLineOffset(bool isLet) {
100106
return KeyPathComponentHeader(
101107
(_SwiftKeyPathComponentHeader_StructTag
102-
<< _SwiftKeyPathComponentHeader_DiscriminatorShift)
103-
| _SwiftKeyPathComponentHeader_OutOfLineOffsetPayload);
108+
<< _SwiftKeyPathComponentHeader_DiscriminatorShift)
109+
| _SwiftKeyPathComponentHeader_OutOfLineOffsetPayload
110+
| isLetBit(isLet));
104111
}
105112

106113
constexpr static KeyPathComponentHeader
107-
forStructComponentWithUnresolvedFieldOffset() {
114+
forStructComponentWithUnresolvedFieldOffset(bool isLet) {
108115
return KeyPathComponentHeader(
109116
(_SwiftKeyPathComponentHeader_StructTag
110-
<< _SwiftKeyPathComponentHeader_DiscriminatorShift)
111-
| _SwiftKeyPathComponentHeader_UnresolvedFieldOffsetPayload);
117+
<< _SwiftKeyPathComponentHeader_DiscriminatorShift)
118+
| _SwiftKeyPathComponentHeader_UnresolvedFieldOffsetPayload
119+
| isLetBit(isLet));
112120
}
113121

114122
constexpr static KeyPathComponentHeader
115-
forClassComponentWithInlineOffset(unsigned offset) {
123+
forClassComponentWithInlineOffset(bool isLet,
124+
unsigned offset) {
116125
return KeyPathComponentHeader(
117126
(_SwiftKeyPathComponentHeader_ClassTag
118-
<< _SwiftKeyPathComponentHeader_DiscriminatorShift)
119-
| validateInlineOffset(offset));
127+
<< _SwiftKeyPathComponentHeader_DiscriminatorShift)
128+
| validateInlineOffset(offset)
129+
| isLetBit(isLet));
120130
}
121131

122132
constexpr static KeyPathComponentHeader
123-
forClassComponentWithOutOfLineOffset() {
133+
forClassComponentWithOutOfLineOffset(bool isLet) {
124134
return KeyPathComponentHeader(
125135
(_SwiftKeyPathComponentHeader_ClassTag
126-
<< _SwiftKeyPathComponentHeader_DiscriminatorShift)
127-
| _SwiftKeyPathComponentHeader_OutOfLineOffsetPayload);
136+
<< _SwiftKeyPathComponentHeader_DiscriminatorShift)
137+
| _SwiftKeyPathComponentHeader_OutOfLineOffsetPayload
138+
| isLetBit(isLet));
128139
}
129140

130141
constexpr static KeyPathComponentHeader
131-
forClassComponentWithUnresolvedFieldOffset() {
142+
forClassComponentWithUnresolvedFieldOffset(bool isLet) {
132143
return KeyPathComponentHeader(
133144
(_SwiftKeyPathComponentHeader_ClassTag
134-
<< _SwiftKeyPathComponentHeader_DiscriminatorShift)
135-
| _SwiftKeyPathComponentHeader_UnresolvedFieldOffsetPayload);
145+
<< _SwiftKeyPathComponentHeader_DiscriminatorShift)
146+
| _SwiftKeyPathComponentHeader_UnresolvedFieldOffsetPayload
147+
| isLetBit(isLet));
136148
}
137149

138150
constexpr static KeyPathComponentHeader
139-
forClassComponentWithUnresolvedIndirectOffset() {
151+
forClassComponentWithUnresolvedIndirectOffset(bool isLet) {
140152
return KeyPathComponentHeader(
141153
(_SwiftKeyPathComponentHeader_ClassTag
142-
<< _SwiftKeyPathComponentHeader_DiscriminatorShift)
143-
| _SwiftKeyPathComponentHeader_UnresolvedIndirectOffsetPayload);
154+
<< _SwiftKeyPathComponentHeader_DiscriminatorShift)
155+
| _SwiftKeyPathComponentHeader_UnresolvedIndirectOffsetPayload
156+
| isLetBit(isLet));
144157
}
145158

146159
constexpr static KeyPathComponentHeader

include/swift/AST/Decl.h

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1786,7 +1786,7 @@ class ExtensionDecl final : public GenericContext, public Decl,
17861786
return D->getKind() == DeclKind::Extension;
17871787
}
17881788
static bool classof(const DeclContext *C) {
1789-
if (auto D = C->getAsDeclOrDeclExtensionContext())
1789+
if (auto D = C->getAsDecl())
17901790
return classof(D);
17911791
return false;
17921792
}
@@ -2117,7 +2117,7 @@ class TopLevelCodeDecl : public DeclContext, public Decl {
21172117
return D->getKind() == DeclKind::TopLevelCode;
21182118
}
21192119
static bool classof(const DeclContext *C) {
2120-
if (auto D = C->getAsDeclOrDeclExtensionContext())
2120+
if (auto D = C->getAsDecl())
21212121
return classof(D);
21222122
return false;
21232123
}
@@ -2645,7 +2645,7 @@ class GenericTypeDecl : public GenericContext, public TypeDecl {
26452645
using TypeDecl::getDeclaredInterfaceType;
26462646

26472647
static bool classof(const DeclContext *C) {
2648-
if (auto D = C->getAsDeclOrDeclExtensionContext())
2648+
if (auto D = C->getAsDecl())
26492649
return classof(D);
26502650
return false;
26512651
}
@@ -2719,7 +2719,7 @@ class TypeAliasDecl : public GenericTypeDecl {
27192719
return D->getKind() == DeclKind::TypeAlias;
27202720
}
27212721
static bool classof(const DeclContext *C) {
2722-
if (auto D = C->getAsDeclOrDeclExtensionContext())
2722+
if (auto D = C->getAsDecl())
27232723
return classof(D);
27242724
return false;
27252725
}
@@ -3205,7 +3205,7 @@ class NominalTypeDecl : public GenericTypeDecl, public IterableDeclContext {
32053205
}
32063206

32073207
static bool classof(const DeclContext *C) {
3208-
if (auto D = C->getAsDeclOrDeclExtensionContext())
3208+
if (auto D = C->getAsDecl())
32093209
return classof(D);
32103210
return false;
32113211
}
@@ -3313,7 +3313,7 @@ class EnumDecl final : public NominalTypeDecl {
33133313
return D->getKind() == DeclKind::Enum;
33143314
}
33153315
static bool classof(const DeclContext *C) {
3316-
if (auto D = C->getAsDeclOrDeclExtensionContext())
3316+
if (auto D = C->getAsDecl())
33173317
return classof(D);
33183318
return false;
33193319
}
@@ -3408,7 +3408,7 @@ class StructDecl final : public NominalTypeDecl {
34083408
return D->getKind() == DeclKind::Struct;
34093409
}
34103410
static bool classof(const DeclContext *C) {
3411-
if (auto D = C->getAsDeclOrDeclExtensionContext())
3411+
if (auto D = C->getAsDecl())
34123412
return classof(D);
34133413
return false;
34143414
}
@@ -3693,7 +3693,7 @@ class ClassDecl final : public NominalTypeDecl {
36933693
return D->getKind() == DeclKind::Class;
36943694
}
36953695
static bool classof(const DeclContext *C) {
3696-
if (auto D = C->getAsDeclOrDeclExtensionContext())
3696+
if (auto D = C->getAsDecl())
36973697
return classof(D);
36983698
return false;
36993699
}
@@ -4025,7 +4025,7 @@ class ProtocolDecl final : public NominalTypeDecl {
40254025
return D->getKind() == DeclKind::Protocol;
40264026
}
40274027
static bool classof(const DeclContext *C) {
4028-
if (auto D = C->getAsDeclOrDeclExtensionContext())
4028+
if (auto D = C->getAsDecl())
40294029
return classof(D);
40304030
return false;
40314031
}
@@ -4900,7 +4900,7 @@ class SubscriptDecl : public GenericContext, public AbstractStorageDecl {
49004900
}
49014901

49024902
static bool classof(const DeclContext *DC) {
4903-
if (auto D = DC->getAsDeclOrDeclExtensionContext())
4903+
if (auto D = DC->getAsDecl())
49044904
return classof(D);
49054905
return false;
49064906
}
@@ -5281,7 +5281,7 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
52815281
}
52825282

52835283
static bool classof(const DeclContext *DC) {
5284-
if (auto D = DC->getAsDeclOrDeclExtensionContext())
5284+
if (auto D = DC->getAsDecl())
52855285
return classof(D);
52865286
return false;
52875287
}
@@ -5508,7 +5508,7 @@ class FuncDecl : public AbstractFunctionDecl {
55085508
return classof(static_cast<const Decl*>(D));
55095509
}
55105510
static bool classof(const DeclContext *DC) {
5511-
if (auto D = DC->getAsDeclOrDeclExtensionContext())
5511+
if (auto D = DC->getAsDecl())
55125512
return classof(D);
55135513
return false;
55145514
}
@@ -5648,7 +5648,7 @@ class AccessorDecl final : public FuncDecl {
56485648
return classof(static_cast<const Decl*>(D));
56495649
}
56505650
static bool classof(const DeclContext *DC) {
5651-
if (auto D = DC->getAsDeclOrDeclExtensionContext())
5651+
if (auto D = DC->getAsDecl())
56525652
return classof(D);
56535653
return false;
56545654
}
@@ -6042,7 +6042,7 @@ class ConstructorDecl : public AbstractFunctionDecl {
60426042
return classof(static_cast<const Decl*>(D));
60436043
}
60446044
static bool classof(const DeclContext *DC) {
6045-
if (auto D = DC->getAsDeclOrDeclExtensionContext())
6045+
if (auto D = DC->getAsDecl())
60466046
return classof(D);
60476047
return false;
60486048
}
@@ -6078,7 +6078,7 @@ class DestructorDecl : public AbstractFunctionDecl {
60786078
return classof(static_cast<const Decl*>(D));
60796079
}
60806080
static bool classof(const DeclContext *DC) {
6081-
if (auto D = DC->getAsDeclOrDeclExtensionContext())
6081+
if (auto D = DC->getAsDecl())
60826082
return classof(D);
60836083
return false;
60846084
}
@@ -6581,7 +6581,7 @@ inline bool Decl::isPotentiallyOverridable() const {
65816581
isa<SubscriptDecl>(this) ||
65826582
isa<FuncDecl>(this) ||
65836583
isa<DestructorDecl>(this)) {
6584-
return getDeclContext()->getAsClassOrClassExtensionContext();
6584+
return getDeclContext()->getSelfClassDecl();
65856585
} else {
65866586
return false;
65876587
}
@@ -6602,7 +6602,7 @@ inline const GenericContext *Decl::getAsGenericContext() const {
66026602
}
66036603

66046604
inline bool DeclContext::isExtensionContext() const {
6605-
if (auto D = getAsDeclOrDeclExtensionContext())
6605+
if (auto D = getAsDecl())
66066606
return ExtensionDecl::classof(D);
66076607
return false;
66086608
}

include/swift/AST/DeclContext.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ class alignas(1 << DeclContextAlignInBits) DeclContext {
213213

214214
/// If this DeclContext is a GenericType declaration or an
215215
/// extension thereof, return the GenericTypeDecl.
216-
GenericTypeDecl *getAsTypeOrTypeExtensionContext() const;
216+
GenericTypeDecl *getSelfTypeDecl() const;
217217

218218
static ASTHierarchy getASTHierarchyFromKind(DeclContextKind Kind) {
219219
switch (Kind) {
@@ -238,12 +238,12 @@ class alignas(1 << DeclContextAlignInBits) DeclContext {
238238

239239
public:
240240
LLVM_READONLY
241-
Decl *getAsDeclOrDeclExtensionContext() {
241+
Decl *getAsDecl() {
242242
return ParentAndKind.getInt() == ASTHierarchy::Decl ?
243243
reinterpret_cast<Decl*>(this + 1) : nullptr;
244244
}
245-
const Decl *getAsDeclOrDeclExtensionContext() const {
246-
return const_cast<DeclContext*>(this)->getAsDeclOrDeclExtensionContext();
245+
const Decl *getAsDecl() const {
246+
return const_cast<DeclContext*>(this)->getAsDecl();
247247
}
248248

249249
DeclContext(DeclContextKind Kind, DeclContext *Parent)
@@ -283,36 +283,36 @@ class alignas(1 << DeclContextAlignInBits) DeclContext {
283283
/// If this DeclContext is a NominalType declaration or an
284284
/// extension thereof, return the NominalTypeDecl.
285285
LLVM_READONLY
286-
NominalTypeDecl *getAsNominalTypeOrNominalTypeExtensionContext() const;
286+
NominalTypeDecl *getSelfNominalTypeDecl() const;
287287

288288
/// If this DeclContext is a class, or an extension on a class, return the
289289
/// ClassDecl, otherwise return null.
290290
LLVM_READONLY
291-
ClassDecl *getAsClassOrClassExtensionContext() const;
291+
ClassDecl *getSelfClassDecl() const;
292292

293293
/// If this DeclContext is an enum, or an extension on an enum, return the
294294
/// EnumDecl, otherwise return null.
295295
LLVM_READONLY
296-
EnumDecl *getAsEnumOrEnumExtensionContext() const;
296+
EnumDecl *getSelfEnumDecl() const;
297297

298298
/// If this DeclContext is a struct, or an extension on a struct, return the
299299
/// StructDecl, otherwise return null.
300300
LLVM_READONLY
301-
StructDecl *getAsStructOrStructExtensionContext() const;
301+
StructDecl *getSelfStructDecl() const;
302302

303303
/// If this DeclContext is a protocol, or an extension on a
304304
/// protocol, return the ProtocolDecl, otherwise return null.
305305
LLVM_READONLY
306-
ProtocolDecl *getAsProtocolOrProtocolExtensionContext() const;
306+
ProtocolDecl *getSelfProtocolDecl() const;
307307

308308
/// If this DeclContext is a protocol extension, return the extended protocol.
309309
LLVM_READONLY
310-
ProtocolDecl *getAsProtocolExtensionContext() const;
310+
ProtocolDecl *getExtendedProtocolDecl() const;
311311

312312
/// \brief Retrieve the generic parameter 'Self' from a protocol or
313313
/// protocol extension.
314314
///
315-
/// Only valid if \c getAsProtocolOrProtocolExtensionContext().
315+
/// Only valid if \c getSelfProtocolDecl().
316316
GenericTypeParamType *getProtocolSelfType() const;
317317

318318
/// Gets the type being declared by this context.

include/swift/AST/DiagnosticsCommon.def

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,19 @@ ERROR(attr_only_on_parameters, none,
9393
ERROR(function_type_no_parens,none,
9494
"single argument function types require parentheses", ())
9595

96+
// FIXME: Used by swift-api-digester. Don't want to set up a separate diagnostics
97+
// file just for a few errors.
98+
ERROR(sdk_node_unrecognized_key,none,
99+
"unrecognized key '%0' in SDK node", (StringRef))
100+
ERROR(sdk_node_unrecognized_node_kind,none,
101+
"unrecognized SDK node kind '%0'", (StringRef))
102+
ERROR(sdk_node_unrecognized_type_attr_kind,none,
103+
"unrecognized type attribute '%0' in SDK node", (StringRef))
104+
ERROR(sdk_node_unrecognized_decl_attr_kind,none,
105+
"unrecognized declaration attribute '%0' in SDK node", (StringRef))
106+
ERROR(sdk_node_unrecognized_decl_kind,none,
107+
"unrecognized declaration kind '%0' in SDK node", (StringRef))
108+
96109
//------------------------------------------------------------------------------
97110
// MARK: Circular reference diagnostics
98111
//------------------------------------------------------------------------------

include/swift/AST/Module.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ class ModuleDecl : public DeclContext, public TypeDecl {
484484
SourceRange getSourceRange() const { return SourceRange(); }
485485

486486
static bool classof(const DeclContext *DC) {
487-
if (auto D = DC->getAsDeclOrDeclExtensionContext())
487+
if (auto D = DC->getAsDecl())
488488
return classof(D);
489489
return false;
490490
}
@@ -1231,7 +1231,7 @@ class ModuleEntity {
12311231
};
12321232

12331233
inline bool DeclContext::isModuleContext() const {
1234-
if (auto D = getAsDeclOrDeclExtensionContext())
1234+
if (auto D = getAsDecl())
12351235
return ModuleDecl::classof(D);
12361236
return false;
12371237
}

include/swift/IDE/APIDigesterData.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ enum class SDKNodeKind: uint8_t {
3333
#include "DigesterEnums.def"
3434
};
3535

36-
SDKNodeKind parseSDKNodeKind(StringRef Content);
36+
Optional<SDKNodeKind> parseSDKNodeKind(StringRef Content);
3737

3838
enum class NodeAnnotation: uint8_t{
3939
#define NODE_ANNOTATION(NAME) NAME,

include/swift/Runtime/Metadata.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,10 @@ void verifyMangledNameRoundtrip(const Metadata *metadata);
766766
SWIFT_CC(swift) SWIFT_RUNTIME_STDLIB_API
767767
const TypeContextDescriptor *swift_getTypeContextDescriptor(const Metadata *type);
768768

769+
// Defined in KeyPath.swift in the standard library.
770+
SWIFT_RUNTIME_EXPORT
771+
const HeapObject *swift_getKeyPath(const void *pattern, const void *arguments);
772+
769773
} // end namespace swift
770774

771775
#endif // SWIFT_RUNTIME_METADATA_H

include/swift/SIL/SILInstruction.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5682,8 +5682,7 @@ class WitnessMethodInst final
56825682
public:
56835683
CanType getLookupType() const { return LookupType; }
56845684
ProtocolDecl *getLookupProtocol() const {
5685-
return getMember().getDecl()->getDeclContext()
5686-
->getAsProtocolOrProtocolExtensionContext();
5685+
return getMember().getDecl()->getDeclContext()->getSelfProtocolDecl();
56875686
}
56885687

56895688
ProtocolConformanceRef getConformance() const { return Conformance; }

0 commit comments

Comments
 (0)