Skip to content

Commit 01d3115

Browse files
Merge pull request #2108 from swiftwasm/katei/merge-main-2020-10-27
Merge main 2020-10-27
2 parents ae9ccac + 1becb8e commit 01d3115

File tree

159 files changed

+3965
-544
lines changed

Some content is hidden

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

159 files changed

+3965
-544
lines changed

.github/workflows/main.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
sudo apt clean
2828
docker rmi $(docker image ls -aq)
2929
df -h
30-
- uses: actions/checkout@v2
30+
- uses: actions/checkout@v1
3131
with:
3232
path: swift
3333
- name: Prepare sccache timestamp
@@ -73,7 +73,7 @@ jobs:
7373
sudo apt clean
7474
docker rmi $(docker image ls -aq)
7575
df -h
76-
- uses: actions/checkout@v2
76+
- uses: actions/checkout@v1
7777
with:
7878
path: swift
7979
- name: Prepare sccache timestamp
@@ -109,7 +109,7 @@ jobs:
109109
runs-on: macos-10.15
110110

111111
steps:
112-
- uses: actions/checkout@v2
112+
- uses: actions/checkout@v1
113113
with:
114114
path: swift
115115
- name: Prepare sccache timestamp

.github/workflows/manual-distribution.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
manual-distribution:
1717
runs-on: macos-latest
1818
steps:
19-
- uses: actions/checkout@v2
19+
- uses: actions/checkout@v1
2020
- name: Setup keychain
2121
run: |
2222
security create-keychain -p "$KEYCHAIN_PASSWORD" swiftwasm-ci

.github/workflows/nightly-distribution.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
nightly-distribution:
77
runs-on: macos-latest
88
steps:
9-
- uses: actions/checkout@v2
9+
- uses: actions/checkout@v1
1010
- name: Setup keychain
1111
run: |
1212
security create-keychain -p "$KEYCHAIN_PASSWORD" swiftwasm-ci

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ if(POLICY CMP0076)
1717
cmake_policy(SET CMP0076 NEW)
1818
endif()
1919

20+
# Don't clobber existing variable values when evaluating `option()` declarations.
21+
if(POLICY CMP0077)
22+
cmake_policy(SET CMP0077 NEW)
23+
endif()
24+
2025
# Add path for custom CMake modules.
2126
list(APPEND CMAKE_MODULE_PATH
2227
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")

include/swift/ABI/Metadata.h

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information
@@ -2295,37 +2295,28 @@ struct TargetTypeMetadataRecord {
22952295
union {
22962296
/// A direct reference to a nominal type descriptor.
22972297
RelativeDirectPointerIntPair<TargetContextDescriptor<Runtime>,
2298-
TypeReferenceKind>
2298+
TypeMetadataRecordKind>
22992299
DirectNominalTypeDescriptor;
23002300

23012301
/// An indirect reference to a nominal type descriptor.
23022302
RelativeDirectPointerIntPair<TargetSignedPointer<Runtime, TargetContextDescriptor<Runtime> * __ptrauth_swift_type_descriptor>,
2303-
TypeReferenceKind>
2303+
TypeMetadataRecordKind>
23042304
IndirectNominalTypeDescriptor;
2305-
2306-
// We only allow a subset of the TypeReferenceKinds here.
2307-
// Should we just acknowledge that this is a different enum?
23082305
};
23092306

23102307
public:
2311-
TypeReferenceKind getTypeKind() const {
2308+
TypeMetadataRecordKind getTypeKind() const {
23122309
return DirectNominalTypeDescriptor.getInt();
23132310
}
23142311

23152312
const TargetContextDescriptor<Runtime> *
23162313
getContextDescriptor() const {
23172314
switch (getTypeKind()) {
2318-
case TypeReferenceKind::DirectTypeDescriptor:
2315+
case TypeMetadataRecordKind::DirectTypeDescriptor:
23192316
return DirectNominalTypeDescriptor.getPointer();
23202317

2321-
case TypeReferenceKind::IndirectTypeDescriptor:
2318+
case TypeMetadataRecordKind::IndirectTypeDescriptor:
23222319
return *IndirectNominalTypeDescriptor.getPointer();
2323-
2324-
// These types (and any others we might add to TypeReferenceKind
2325-
// in the future) are just never used in these lists.
2326-
case TypeReferenceKind::DirectObjCClassName:
2327-
case TypeReferenceKind::IndirectObjCClass:
2328-
return nullptr;
23292320
}
23302321

23312322
return nullptr;
@@ -2415,6 +2406,9 @@ struct TargetTypeReference {
24152406
/// A direct reference to an Objective-C class name.
24162407
RelativeDirectPointer<const char>
24172408
DirectObjCClassName;
2409+
2410+
/// A "reference" to some metadata kind, e.g. tuple.
2411+
MetadataKind MetadataKind;
24182412
};
24192413

24202414
const TargetContextDescriptor<Runtime> *
@@ -2428,12 +2422,18 @@ struct TargetTypeReference {
24282422

24292423
case TypeReferenceKind::DirectObjCClassName:
24302424
case TypeReferenceKind::IndirectObjCClass:
2425+
case TypeReferenceKind::MetadataKind:
24312426
return nullptr;
24322427
}
24332428

24342429
return nullptr;
24352430
}
24362431

2432+
enum MetadataKind getMetadataKind(TypeReferenceKind kind) const {
2433+
assert(kind == TypeReferenceKind::MetadataKind);
2434+
return MetadataKind;
2435+
}
2436+
24372437
#if SWIFT_OBJC_INTEROP
24382438
/// If this type reference is one of the kinds that supports ObjC
24392439
/// references,
@@ -2519,6 +2519,10 @@ struct TargetProtocolConformanceDescriptor final
25192519
return Flags.getTypeReferenceKind();
25202520
}
25212521

2522+
enum MetadataKind getMetadataKind() const {
2523+
return TypeRef.getMetadataKind(getTypeKind());
2524+
}
2525+
25222526
const char *getDirectObjCClassName() const {
25232527
return TypeRef.getDirectObjCClassName(getTypeKind());
25242528
}
@@ -2546,6 +2550,11 @@ struct TargetProtocolConformanceDescriptor final
25462550
TargetRelativeContextPointer<Runtime>>();
25472551
}
25482552

2553+
/// Whether this conformance is builtin by the compiler + runtime.
2554+
bool isBuiltin() const {
2555+
return getTypeKind() == TypeReferenceKind::MetadataKind;
2556+
}
2557+
25492558
/// Whether this conformance is non-unique because it has been synthesized
25502559
/// for a foreign type.
25512560
bool isSynthesizedNonUnique() const {

include/swift/ABI/MetadataValues.h

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information
@@ -361,7 +361,19 @@ enum : unsigned {
361361
NumGenericMetadataPrivateDataWords = 16,
362362
};
363363

364-
/// Kinds of type metadata/protocol conformance records.
364+
/// Kinds of type metadata reocrds.
365+
enum class TypeMetadataRecordKind : unsigned {
366+
/// A direct reference to a nominal type descriptor.
367+
DirectTypeDescriptor = 0x00,
368+
369+
/// An indirect reference to a nominal type descriptor.
370+
IndirectTypeDescriptor = 0x01,
371+
372+
First_Kind = DirectTypeDescriptor,
373+
Last_Kind = IndirectTypeDescriptor,
374+
};
375+
376+
/// Kinds of references to type metadata.
365377
enum class TypeReferenceKind : unsigned {
366378
/// The conformance is for a nominal type referenced directly;
367379
/// getTypeDescriptor() points to the type context descriptor.
@@ -384,10 +396,14 @@ enum class TypeReferenceKind : unsigned {
384396
/// unused.
385397
IndirectObjCClass = 0x03,
386398

399+
/// The conformance is for a non-nominal type whose metadata kind we recorded;
400+
/// getMetadataKind() returns the kind.
401+
MetadataKind = 0x04,
402+
387403
// We only reserve three bits for this in the various places we store it.
388404

389405
First_Kind = DirectTypeDescriptor,
390-
Last_Kind = IndirectObjCClass,
406+
Last_Kind = MetadataKind,
391407
};
392408

393409
/// Flag that indicates whether an existential type is class-constrained or not.

include/swift/AST/ASTContext.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ namespace swift {
103103
class InheritedProtocolConformance;
104104
class SelfProtocolConformance;
105105
class SpecializedProtocolConformance;
106+
class BuiltinProtocolConformance;
106107
enum class ProtocolConformanceState;
107108
class Pattern;
108109
enum PointerTypeKind : unsigned;
@@ -948,6 +949,11 @@ class ASTContext final {
948949
SelfProtocolConformance *
949950
getSelfConformance(ProtocolDecl *protocol);
950951

952+
/// Produce the builtin conformance for some structural type to some protocol.
953+
BuiltinProtocolConformance *
954+
getBuiltinConformance(Type type, ProtocolDecl *protocol,
955+
ArrayRef<ProtocolConformanceRef> conformances);
956+
951957
/// A callback used to produce a diagnostic for an ill-formed protocol
952958
/// conformance that was type-checked before we're actually walking the
953959
/// conformance itself, along with a bit indicating whether this diagnostic

include/swift/AST/Module.h

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -593,8 +593,7 @@ class ModuleDecl : public DeclContext, public TypeDecl {
593593
Default = 1 << 1,
594594
/// Include imports declared with `@_implementationOnly`.
595595
ImplementationOnly = 1 << 2,
596-
/// Include imports of SPIs declared with `@_spi`. Non-SPI imports are
597-
/// included whether or not this flag is specified.
596+
/// Include imports of SPIs declared with `@_spi`
598597
SPIAccessControl = 1 << 3,
599598
/// Include imports shadowed by a cross-import overlay. Unshadowed imports
600599
/// are included whether or not this flag is specified.
@@ -605,33 +604,8 @@ class ModuleDecl : public DeclContext, public TypeDecl {
605604

606605
/// Looks up which modules are imported by this module.
607606
///
608-
/// \p filter controls which imports are included in the list.
609-
///
610-
/// There are three axes for categorizing imports:
611-
/// 1. Privacy: Exported/Private/ImplementationOnly (mutually exclusive).
612-
/// 2. SPI/non-SPI: An import of any privacy level may be @_spi("SPIName").
613-
/// 3. Shadowed/Non-shadowed: An import of any privacy level may be shadowed
614-
/// by a cross-import overlay.
615-
///
616-
/// It is also possible for SPI imports to be shadowed by a cross-import
617-
/// overlay.
618-
///
619-
/// If \p filter contains multiple privacy levels, modules at all the privacy
620-
/// levels are included.
621-
///
622-
/// If \p filter contains \c ImportFilterKind::SPIAccessControl, then both
623-
/// SPI and non-SPI imports are included. Otherwise, only non-SPI imports are
624-
/// included.
625-
///
626-
/// If \p filter contains \c ImportFilterKind::ShadowedByCrossImportOverlay,
627-
/// both shadowed and non-shadowed imports are included. Otherwise, only
628-
/// non-shadowed imports are included.
629-
///
630-
/// Clang modules have some additional complexities; see the implementation of
631-
/// \c ClangModuleUnit::getImportedModules for details.
632-
///
633-
/// \pre \p filter must contain at least one privacy level, i.e. one of
634-
/// \c Exported or \c Private or \c ImplementationOnly.
607+
/// \p filter controls whether public, private, or any imports are included
608+
/// in this list.
635609
void getImportedModules(SmallVectorImpl<ImportedModule> &imports,
636610
ImportFilter filter = ImportFilterKind::Exported) const;
637611

0 commit comments

Comments
 (0)