Skip to content

Commit 30d0265

Browse files
Merge pull request #4352 from swiftwasm/main
[pull] swiftwasm from main
2 parents a78f259 + 0ac1040 commit 30d0265

File tree

90 files changed

+1241
-456
lines changed

Some content is hidden

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

90 files changed

+1241
-456
lines changed

include/swift-c/StaticMirror/BinaryScan.h

Lines changed: 76 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
/// SWIFTSTATICMIRROR_VERSION_MINOR should increase when there are API additions.
2626
/// SWIFTSTATICMIRROR_VERSION_MAJOR is intended for "major" source/ABI breaking changes.
2727
#define SWIFTSTATICMIRROR_VERSION_MAJOR 0
28-
#define SWIFTSTATICMIRROR_VERSION_MINOR 2 // Added associated-type gather
28+
#define SWIFTSTATICMIRROR_VERSION_MINOR 3 // Added filed type info gather
2929

3030
SWIFTSTATICMIRROR_BEGIN_DECLS
3131

@@ -42,6 +42,18 @@ typedef void *swift_static_mirror_t;
4242
typedef struct swift_static_mirror_conformance_info_s
4343
*swift_static_mirror_conformance_info_t;
4444

45+
/// Opaque container to a field info (property type or enum case)
46+
typedef struct swift_static_mirror_field_info_s
47+
*swift_static_mirror_field_info_t;
48+
49+
/// Opaque container to a property type info
50+
typedef struct swift_static_mirror_property_info_s
51+
*swift_static_mirror_property_info_t;
52+
53+
/// Opaque container to an enum case info
54+
typedef struct swift_static_mirror_enum_case_info_s
55+
*swift_static_mirror_enum_case_info_t;
56+
4557
/// Opaque container to details of an associated type specification.
4658
typedef struct swift_static_mirror_type_alias_s
4759
*swift_static_mirror_type_alias_t;
@@ -55,7 +67,6 @@ typedef struct {
5567
size_t count;
5668
} swift_static_mirror_type_alias_set_t;
5769

58-
5970
typedef struct {
6071
swift_static_mirror_associated_type_info_t *associated_type_infos;
6172
size_t count;
@@ -66,26 +77,35 @@ typedef struct {
6677
size_t count;
6778
} swift_static_mirror_conformances_set_t;
6879

80+
typedef struct {
81+
swift_static_mirror_property_info_t *properties;
82+
size_t count;
83+
} swift_static_mirror_property_info_set_t;
6984

70-
// swift_static_mirror_conformance_info query methods
85+
typedef struct {
86+
swift_static_mirror_enum_case_info_t *enum_cases;
87+
size_t count;
88+
} swift_static_mirror_enum_case_info_set_t;
89+
90+
typedef struct {
91+
swift_static_mirror_field_info_t *field_infos;
92+
size_t count;
93+
} swift_static_mirror_field_info_set_t;
7194

95+
// swift_static_mirror_conformance_info query methods
7296
SWIFTSTATICMIRROR_PUBLIC swift_static_mirror_string_ref_t
7397
swift_static_mirror_conformance_info_get_type_name(
7498
swift_static_mirror_conformance_info_t);
75-
7699
SWIFTSTATICMIRROR_PUBLIC swift_static_mirror_string_ref_t
77100
swift_static_mirror_conformance_info_get_protocol_name(
78101
swift_static_mirror_conformance_info_t);
79-
80102
SWIFTSTATICMIRROR_PUBLIC swift_static_mirror_string_ref_t
81103
swift_static_mirror_conformance_info_get_mangled_type_name(
82104
swift_static_mirror_conformance_info_t);
105+
SWIFTSTATICMIRROR_PUBLIC void swift_static_mirror_conformance_info_dispose(
106+
swift_static_mirror_conformance_info_t);
83107

84-
SWIFTSTATICMIRROR_PUBLIC void
85-
swift_static_mirror_conformance_info_dispose(
86-
swift_static_mirror_conformance_info_t);
87-
88-
// swift_static_mirror_associated_type query methods
108+
// swift_static_mirror_associated_type_info query methods
89109
SWIFTSTATICMIRROR_PUBLIC swift_static_mirror_string_ref_t
90110
swift_static_mirror_type_alias_get_type_alias_name(
91111
swift_static_mirror_type_alias_t);
@@ -100,41 +120,77 @@ SWIFTSTATICMIRROR_PUBLIC swift_static_mirror_string_ref_t
100120
SWIFTSTATICMIRROR_PUBLIC swift_static_mirror_string_ref_t
101121
swift_static_mirror_associated_type_info_get_mangled_type_name(
102122
swift_static_mirror_associated_type_info_t);
103-
SWIFTSTATICMIRROR_PUBLIC swift_static_mirror_type_alias_set_t*
123+
SWIFTSTATICMIRROR_PUBLIC swift_static_mirror_type_alias_set_t *
104124
swift_static_mirror_associated_type_info_get_type_alias_set(
105125
swift_static_mirror_associated_type_info_t);
106126

127+
// swift_static_mirror_field_info query methods
128+
SWIFTSTATICMIRROR_PUBLIC swift_static_mirror_string_ref_t
129+
swift_static_mirror_field_info_get_mangled_type_name(
130+
swift_static_mirror_field_info_t);
131+
SWIFTSTATICMIRROR_PUBLIC swift_static_mirror_property_info_set_t *
132+
swift_static_mirror_field_info_get_property_info_set(
133+
swift_static_mirror_field_info_t);
134+
SWIFTSTATICMIRROR_PUBLIC swift_static_mirror_enum_case_info_set_t *
135+
swift_static_mirror_field_info_get_enum_case_info_set(
136+
swift_static_mirror_field_info_t);
137+
SWIFTSTATICMIRROR_PUBLIC swift_static_mirror_string_ref_t
138+
swift_static_mirror_property_info_get_label(
139+
swift_static_mirror_property_info_t);
140+
SWIFTSTATICMIRROR_PUBLIC swift_static_mirror_string_ref_t
141+
swift_static_mirror_property_info_get_type_name(
142+
swift_static_mirror_property_info_t);
143+
SWIFTSTATICMIRROR_PUBLIC swift_static_mirror_string_ref_t
144+
swift_static_mirror_property_info_get_mangled_type_name(
145+
swift_static_mirror_property_info_t);
146+
SWIFTSTATICMIRROR_PUBLIC swift_static_mirror_string_ref_t
147+
swift_static_mirror_enum_case_info_get_label(
148+
swift_static_mirror_enum_case_info_t);
149+
107150
/// Create an \c swift_static_mirror_t instance.
108151
/// The returned \c swift_static_mirror_t is owned by the caller and must be
109152
/// disposed of using \c swift_static_mirror_dispose .
110153
SWIFTSTATICMIRROR_PUBLIC swift_static_mirror_t
111154
swift_static_mirror_create(int, const char **, const char *);
112155

113156
SWIFTSTATICMIRROR_PUBLIC void
114-
swift_static_mirror_dispose(swift_static_mirror_t);
157+
swift_static_mirror_dispose(swift_static_mirror_t);
115158

116159
/// Identify and collect all types conforming to any of the protocol names
117160
/// specified as arguments
118161
SWIFTSTATICMIRROR_PUBLIC swift_static_mirror_conformances_set_t *
119-
swift_static_mirror_conformances_set_create(
120-
swift_static_mirror_t, int, const char **);
162+
swift_static_mirror_conformances_set_create(swift_static_mirror_t, int,
163+
const char **);
121164

122165
SWIFTSTATICMIRROR_PUBLIC void swift_static_mirror_conformances_set_dispose(
123166
swift_static_mirror_conformances_set_t *);
124167

125-
/// Identify and collect all associated types of a given input type (by mangled name)
168+
/// Identify and collect all associated types of a given input type (by mangled
169+
/// name)
126170
SWIFTSTATICMIRROR_PUBLIC swift_static_mirror_associated_type_info_set_t *
127-
swift_static_mirror_associated_type_info_set_create(
128-
swift_static_mirror_t, const char *);
171+
swift_static_mirror_associated_type_info_set_create(swift_static_mirror_t,
172+
const char *);
129173

130174
/// Identify and collect associated types of all discovered types.
131175
SWIFTSTATICMIRROR_PUBLIC swift_static_mirror_associated_type_info_set_t *
132-
swift_static_mirror_all_associated_type_info_set_create(
133-
swift_static_mirror_t);
176+
swift_static_mirror_all_associated_type_info_set_create(
177+
swift_static_mirror_t);
134178

135-
SWIFTSTATICMIRROR_PUBLIC void swift_static_mirror_associated_type_info_set_dispose(
179+
SWIFTSTATICMIRROR_PUBLIC void
180+
swift_static_mirror_associated_type_info_set_dispose(
136181
swift_static_mirror_associated_type_info_set_t *);
137182

183+
/// Identify and collect all field types of a given input type (by mangled name)
184+
SWIFTSTATICMIRROR_PUBLIC swift_static_mirror_field_info_set_t *
185+
swift_static_mirror_field_info_set_create(swift_static_mirror_t, const char *);
186+
187+
/// Identify and collect field types of all discovered types.
188+
SWIFTSTATICMIRROR_PUBLIC swift_static_mirror_field_info_set_t *
189+
swift_static_mirror_all_field_info_set_create(swift_static_mirror_t);
190+
191+
SWIFTSTATICMIRROR_PUBLIC void swift_static_mirror_field_info_set_dispose(
192+
swift_static_mirror_field_info_set_t *);
193+
138194
SWIFTSTATICMIRROR_END_DECLS
139195

140196
#endif // SWIFT_C_BINARY_SCAN_H

include/swift/AST/ASTContext.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,8 +1298,17 @@ class ASTContext final {
12981298
CanGenericSignature getSingleGenericParameterSignature() const;
12991299

13001300
/// Retrieve a generic signature with a single type parameter conforming
1301-
/// to the given protocol or composition type, like <T: type>.
1302-
CanGenericSignature getOpenedArchetypeSignature(Type type);
1301+
/// to the given protocol or composition type, like <T: P>.
1302+
///
1303+
/// The opened archetype may have a different set of conformances from the
1304+
/// corresponding existential. The opened archetype conformances are dictated
1305+
/// by the ABI for generic arguments, while the existential value conformances
1306+
/// are dictated by their layout (see \c Type::getExistentialLayout()). In
1307+
/// particular, the opened archetype signature does not have requirements for
1308+
/// conformances inherited from superclass constraints while existential
1309+
/// values do.
1310+
CanGenericSignature getOpenedArchetypeSignature(Type type,
1311+
GenericSignature parentSig);
13031312

13041313
GenericSignature getOverrideGenericSignature(const ValueDecl *base,
13051314
const ValueDecl *derived);

include/swift/AST/Decl.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2693,7 +2693,8 @@ class ValueDecl : public Decl {
26932693
/// property, or the uncurried result type of a method/subscript, e.g.
26942694
/// '() -> () -> Self'.
26952695
GenericParameterReferenceInfo findExistentialSelfReferences(
2696-
Type baseTy, bool treatNonResultCovariantSelfAsInvariant) const;
2696+
Type baseTy, const DeclContext *useDC,
2697+
bool treatNonResultCovariantSelfAsInvariant) const;
26972698
};
26982699

26992700
/// This is a common base class for declarations which declare a type.

include/swift/AST/DiagnosticsParse.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,8 @@ ERROR(expected_dynamic_func_attr,none,
804804
ERROR(async_after_throws,none,
805805
"%select{'async'|'reasync'}0 must precede %select{'throws'|'rethrows'}1",
806806
(bool, bool))
807+
ERROR(await_in_function_type,none,
808+
"expected async specifier; did you mean 'async'?", ())
807809
ERROR(duplicate_effects_specifier,none,
808810
"'%0' has already been specified", (StringRef))
809811

include/swift/AST/GenericEnvironment.h

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,29 @@ class alignas(1 << DeclAlignInBits) GenericEnvironment final
157157
GenericEnvironment *getIncomplete(GenericSignature signature);
158158

159159
/// Create a new generic environment for an opened existential.
160-
static GenericEnvironment *forOpenedExistential(Type existential, UUID uuid);
160+
///
161+
/// This function uses the provided parent signature to construct a new
162+
/// signature suitable for use with an opened archetype. If you have an
163+
/// existing generic signature from e.g. deserialization use
164+
/// \c GenericEnvironment::forOpenedArchetypeSignature instead.
165+
///
166+
/// \param existential The subject existential type
167+
/// \param parentSig The signature of the context where this existential type is being opened
168+
/// \param uuid The unique identifier for this opened existential
169+
static GenericEnvironment *
170+
forOpenedExistential(Type existential, GenericSignature parentSig, UUID uuid);
171+
172+
/// Create a new generic environment for an opened existential.
173+
///
174+
/// It is unlikely you want to use this function.
175+
/// Call \c GenericEnvironment::forOpenedExistential instead.
176+
///
177+
/// \param existential The subject existential type
178+
/// \param signature The signature of the opened archetype
179+
/// \param uuid The unique identifier for this opened existential
180+
static GenericEnvironment *
181+
forOpenedArchetypeSignature(Type existential,
182+
GenericSignature signature, UUID uuid);
161183

162184
/// Create a new generic environment for an opaque type with the given set of
163185
/// outer substitutions.

include/swift/AST/Types.h

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ class alignas(1 << TypeAlignInBits) TypeBase
507507
/// Canonical protocol composition types are minimized only to a certain
508508
/// degree to preserve ABI compatibility. This routine enables performing
509509
/// slower, but stricter minimization at need (e.g. redeclaration checking).
510-
CanType getMinimalCanonicalType() const;
510+
CanType getMinimalCanonicalType(const DeclContext *useDC) const;
511511

512512
/// Reconstitute type sugar, e.g., for array types, dictionary
513513
/// types, optionals, etc.
@@ -648,7 +648,8 @@ class alignas(1 << TypeAlignInBits) TypeBase
648648

649649
/// Replace opened archetypes with the given root with their most
650650
/// specific non-dependent upper bounds throughout this type.
651-
Type typeEraseOpenedArchetypesWithRoot(const OpenedArchetypeType *root) const;
651+
Type typeEraseOpenedArchetypesWithRoot(const OpenedArchetypeType *root,
652+
const DeclContext *useDC) const;
652653

653654
/// Given a declaration context, returns a function type with the 'self'
654655
/// type curried as the input if the declaration context describes a type.
@@ -763,7 +764,8 @@ class alignas(1 << TypeAlignInBits) TypeBase
763764
bool isClassExistentialType();
764765

765766
/// Opens an existential instance or meta-type and returns the opened type.
766-
Type openAnyExistentialType(OpenedArchetypeType *&opened);
767+
Type openAnyExistentialType(OpenedArchetypeType *&opened,
768+
GenericSignature parentSig);
767769

768770
/// Break an existential down into a set of constraints.
769771
ExistentialLayout getExistentialLayout();
@@ -5189,7 +5191,7 @@ class ProtocolCompositionType final : public TypeBase,
51895191
/// Canonical protocol composition types are minimized only to a certain
51905192
/// degree to preserve ABI compatibility. This routine enables performing
51915193
/// slower, but stricter minimization at need (e.g. redeclaration checking).
5192-
CanType getMinimalCanonicalType() const;
5194+
CanType getMinimalCanonicalType(const DeclContext *useDC) const;
51935195

51945196
/// Retrieve the set of members composed to create this type.
51955197
///
@@ -5272,7 +5274,6 @@ class ParameterizedProtocolType final : public TypeBase,
52725274
friend TrailingObjects;
52735275

52745276
ProtocolType *Base;
5275-
Type Arg;
52765277

52775278
public:
52785279
/// Retrieve an instance of a protocol composition type with the
@@ -5745,40 +5746,69 @@ class OpenedArchetypeType final : public ArchetypeType,
57455746
ArrayRef<ProtocolDecl *> conformsTo, Type superclass,
57465747
LayoutConstraint layout);
57475748

5749+
public:
5750+
/// Compute the parameter that serves as the \c Self type for an opened
5751+
/// archetype from the given outer generic signature.
5752+
///
5753+
/// This type is a generic parameter one level deeper
5754+
/// than the deepest generic context depth.
5755+
static Type getSelfInterfaceTypeFromContext(GenericSignature parentSig,
5756+
ASTContext &ctx);
5757+
57485758
public:
57495759
/// Get or create an archetype that represents the opened type
57505760
/// of an existential value.
57515761
///
57525762
/// \param existential The existential type to open.
5763+
/// \param parentSig The generic signature of the context opening
5764+
/// this existential.
57535765
///
57545766
/// \param knownID When non-empty, the known ID of the archetype. When empty,
57555767
/// a fresh archetype with a unique ID will be opened.
5756-
static CanTypeWrapper<OpenedArchetypeType> get(
5757-
CanType existential, Optional<UUID> knownID = None);
5768+
static CanTypeWrapper<OpenedArchetypeType> get(CanType existential,
5769+
GenericSignature parentSig,
5770+
Optional<UUID> knownID = None);
57585771

57595772
/// Get or create an archetype that represents the opened type
57605773
/// of an existential value.
57615774
///
57625775
/// \param existential The existential type to open.
57635776
/// \param interfaceType The interface type represented by this archetype.
5777+
/// \param parentSig The generic signature of the context opening
5778+
/// this existential.
57645779
///
57655780
/// \param knownID When non-empty, the known ID of the archetype. When empty,
57665781
/// a fresh archetype with a unique ID will be opened.
5767-
static CanTypeWrapper<OpenedArchetypeType> get(
5768-
CanType existential, Type interfaceType, Optional<UUID> knownID = None);
5782+
static CanTypeWrapper<OpenedArchetypeType> get(CanType existential,
5783+
Type interfaceType,
5784+
GenericSignature parentSig,
5785+
Optional<UUID> knownID = None);
57695786

57705787
/// Create a new archetype that represents the opened type
57715788
/// of an existential value.
57725789
///
5790+
/// Use this function when you are unsure of whether the
5791+
/// \c existential type is a metatype or an instance type. This function
5792+
/// will unwrap any existential metatype containers.
5793+
///
57735794
/// \param existential The existential type or existential metatype to open.
57745795
/// \param interfaceType The interface type represented by this archetype.
5775-
static CanType getAny(CanType existential, Type interfaceType);
5796+
/// \param parentSig The generic signature of the context opening
5797+
/// this existential.
5798+
static CanType getAny(CanType existential, Type interfaceType,
5799+
GenericSignature parentSig);
57765800

57775801
/// Create a new archetype that represents the opened type
57785802
/// of an existential value.
57795803
///
5804+
/// Use this function when you are unsure of whether the
5805+
/// \c existential type is a metatype or an instance type. This function
5806+
/// will unwrap any existential metatype containers.
5807+
///
57805808
/// \param existential The existential type or existential metatype to open.
5781-
static CanType getAny(CanType existential);
5809+
/// \param parentSig The generic signature of the context opening
5810+
/// this existential.
5811+
static CanType getAny(CanType existential, GenericSignature parentSig);
57825812

57835813
/// Retrieve the ID number of this opened existential.
57845814
UUID getOpenedExistentialID() const;

include/swift/LLVMPasses/Passes.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ namespace swift {
102102
static char ID;
103103
InlineTreePrinter() : llvm::ModulePass(ID) {}
104104
};
105-
106105
} // end namespace swift
107106

108107
#endif

include/swift/LLVMPasses/PassesFwd.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ namespace llvm {
2525
void initializeSwiftARCContractPass(PassRegistry &);
2626
void initializeInlineTreePrinterPass(PassRegistry &);
2727
void initializeSwiftMergeFunctionsPass(PassRegistry &);
28+
void initializeSwiftDbgAddrBlockSplitterPass(PassRegistry &);
2829
}
2930

3031
namespace swift {
@@ -33,6 +34,7 @@ namespace swift {
3334
llvm::ModulePass *createInlineTreePrinterPass();
3435
llvm::ModulePass *createSwiftMergeFunctionsPass(bool ptrAuthEnabled,
3536
unsigned ptrAuthKey);
37+
llvm::FunctionPass *createSwiftDbgAddrBlockSplitter();
3638
llvm::ImmutablePass *createSwiftAAWrapperPass();
3739
llvm::ImmutablePass *createSwiftRCIdentityPass();
3840
} // end namespace swift

0 commit comments

Comments
 (0)