Skip to content

Commit 065e752

Browse files
authored
Merge pull request #4276 from swiftwasm/main
2 parents ed561cc + 5974cd0 commit 065e752

File tree

59 files changed

+2211
-624
lines changed

Some content is hidden

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

59 files changed

+2211
-624
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ to track the status of our builds, please refer to our [GitHub Actions page](htt
2626
| | **Architecture** | **main** | **Package** |
2727
|---|:---:|:---:|:---:|
2828
| **macOS** | x86_64 |[![Build Status](https://ci.swift.org/job/oss-swift-incremental-RA-macos/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-incremental-RA-macos)|[![Build Status](https://ci.swift.org/job/oss-swift-package-macos/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-macos)|
29-
| **Ubuntu 16.04** | x86_64 | [![Build Status](https://ci.swift.org/job/oss-swift-incremental-RA-linux-ubuntu-16_04/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-incremental-RA-linux-ubuntu-16_04)|[![Build Status](https://ci.swift.org/job/oss-swift-package-linux-ubuntu-16_04/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-linux-ubuntu-16_04)|
30-
| **Ubuntu 18.04** | x86_64 | [![Build Status](https://ci.swift.org/job/oss-swift-incremental-RA-linux-ubuntu-18_04/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-incremental-RA-linux-ubuntu-18_04)|[![Build Status](https://ci.swift.org/job/oss-swift-package-linux-ubuntu-18_04/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-linux-ubuntu-18_04)|
29+
| **Ubuntu 18.04** | x86_64 | [![Build Status](https://ci.swift.org/job/oss-swift-package-ubuntu-18_04/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-ubuntu-18_04)|[![Build Status](https://ci.swift.org/job/oss-swift-package-ubuntu-18_04/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-ubuntu-18_04)|
3130
| **Ubuntu 20.04** | x86_64 | [![Build Status](https://ci.swift.org/job/oss-swift-package-ubuntu-20_04/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-ubuntu-20_04)|[![Build Status](https://ci.swift.org/job/oss-swift-package-ubuntu-20_04/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-ubuntu-20_04)|
3231
| **CentOS 8** | x86_64 | [![Build Status](https://ci.swift.org/job/oss-swift-package-centos-8/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-centos-8)|[![Build Status](https://ci.swift.org/job/oss-swift-package-centos-8/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-centos-8)|
3332
| **CentOS 7** | x86_64 | [![Build Status](https://ci.swift.org/job/oss-swift-package-centos-7/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-centos-7)|[![Build Status](https://ci.swift.org/job/oss-swift-package-centos-7/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-centos-7)|

include/swift/ABI/ObjectFile.h

Lines changed: 18 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,9 @@ namespace swift {
1414

1515
/// Represents the nine reflection sections used by Swift
1616
enum ReflectionSectionKind : uint8_t {
17-
fieldmd,
18-
assocty,
19-
builtin,
20-
capture,
21-
typeref,
22-
reflstr,
23-
conform,
24-
protocs,
25-
acfuncs,
17+
#define HANDLE_SWIFT_SECTION(KIND, MACHO, ELF, COFF) KIND,
18+
#include "llvm/BinaryFormat/Swift.def"
19+
#undef HANDLE_SWIFT_SECTION
2620
};
2721

2822
/// Abstract base class responsible for providing the correct reflection section
@@ -43,24 +37,11 @@ class SwiftObjectFileFormatMachO : public SwiftObjectFileFormat {
4337
public:
4438
llvm::StringRef getSectionName(ReflectionSectionKind section) override {
4539
switch (section) {
46-
case fieldmd:
47-
return "__swift5_fieldmd";
48-
case assocty:
49-
return "__swift5_assocty";
50-
case builtin:
51-
return "__swift5_builtin";
52-
case capture:
53-
return "__swift5_capture";
54-
case typeref:
55-
return "__swift5_typeref";
56-
case reflstr:
57-
return "__swift5_reflstr";
58-
case conform:
59-
return "__swift5_proto";
60-
case protocs:
61-
return "__swift5_protos";
62-
case acfuncs:
63-
return "__swift5_acfuncs";
40+
#define HANDLE_SWIFT_SECTION(KIND, MACHO, ELF, COFF) \
41+
case KIND: \
42+
return MACHO;
43+
#include "llvm/BinaryFormat/Swift.def"
44+
#undef HANDLE_SWIFT_SECTION
6445
}
6546
llvm_unreachable("Section type not found.");
6647
}
@@ -78,24 +59,11 @@ class SwiftObjectFileFormatELF : public SwiftObjectFileFormat {
7859
public:
7960
llvm::StringRef getSectionName(ReflectionSectionKind section) override {
8061
switch (section) {
81-
case fieldmd:
82-
return "swift5_fieldmd";
83-
case assocty:
84-
return "swift5_assocty";
85-
case builtin:
86-
return "swift5_builtin";
87-
case capture:
88-
return "swift5_capture";
89-
case typeref:
90-
return "swift5_typeref";
91-
case reflstr:
92-
return "swift5_reflstr";
93-
case conform:
94-
return "swift5_protocol_conformances";
95-
case protocs:
96-
return "swift5_protocols";
97-
case acfuncs:
98-
return "swift5_accessible_functions";
62+
#define HANDLE_SWIFT_SECTION(KIND, MACHO, ELF, COFF) \
63+
case KIND: \
64+
return ELF;
65+
#include "llvm/BinaryFormat/Swift.def"
66+
#undef HANDLE_SWIFT_SECTION
9967
}
10068
llvm_unreachable("Section type not found.");
10169
}
@@ -110,24 +78,11 @@ class SwiftObjectFileFormatCOFF : public SwiftObjectFileFormat {
11078
public:
11179
llvm::StringRef getSectionName(ReflectionSectionKind section) override {
11280
switch (section) {
113-
case fieldmd:
114-
return ".sw5flmd";
115-
case assocty:
116-
return ".sw5asty";
117-
case builtin:
118-
return ".sw5bltn";
119-
case capture:
120-
return ".sw5cptr";
121-
case typeref:
122-
return ".sw5tyrf";
123-
case reflstr:
124-
return ".sw5rfst";
125-
case conform:
126-
return ".sw5prtc$B";
127-
case protocs:
128-
return ".sw5prt$B";
129-
case acfuncs:
130-
return ".sw5acfn$B";
81+
#define HANDLE_SWIFT_SECTION(KIND, MACHO, ELF, COFF) \
82+
case KIND: \
83+
return COFF;
84+
#include "llvm/BinaryFormat/Swift.def"
85+
#undef HANDLE_SWIFT_SECTION
13186
}
13287
llvm_unreachable("Section not found.");
13388
}

include/swift/AST/Decl.h

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2159,9 +2159,9 @@ class PoundDiagnosticDecl : public Decl {
21592159
class OpaqueTypeDecl;
21602160

21612161
/// Describes the least favorable positions at which a requirement refers
2162-
/// to 'Self' in terms of variance, for use in the is-inheritable and
2163-
/// is-available-existential checks.
2164-
class SelfReferenceInfo final {
2162+
/// to a given generic parameter in terms of variance, for use in the
2163+
/// is-inheritable and is-available-existential checks.
2164+
class GenericParameterReferenceInfo final {
21652165
using OptionalTypePosition = OptionalEnum<decltype(TypePosition::Covariant)>;
21662166

21672167
public:
@@ -2171,27 +2171,27 @@ class SelfReferenceInfo final {
21712171
OptionalTypePosition assocTypeRef;
21722172

21732173
/// A reference to 'Self'.
2174-
static SelfReferenceInfo forSelfRef(TypePosition position) {
2175-
return SelfReferenceInfo(false, position, llvm::None);
2174+
static GenericParameterReferenceInfo forSelfRef(TypePosition position) {
2175+
return GenericParameterReferenceInfo(false, position, llvm::None);
21762176
}
21772177

21782178
/// A reference to 'Self' through an associated type.
2179-
static SelfReferenceInfo forAssocTypeRef(TypePosition position) {
2180-
return SelfReferenceInfo(false, llvm::None, position);
2179+
static GenericParameterReferenceInfo forAssocTypeRef(TypePosition position) {
2180+
return GenericParameterReferenceInfo(false, llvm::None, position);
21812181
}
21822182

2183-
SelfReferenceInfo &operator|=(const SelfReferenceInfo &other);
2183+
GenericParameterReferenceInfo &operator|=(const GenericParameterReferenceInfo &other);
21842184

21852185
explicit operator bool() const {
21862186
return hasCovariantSelfResult || selfRef || assocTypeRef;
21872187
}
21882188

2189-
SelfReferenceInfo()
2189+
GenericParameterReferenceInfo()
21902190
: hasCovariantSelfResult(false), selfRef(llvm::None),
21912191
assocTypeRef(llvm::None) {}
21922192

21932193
private:
2194-
SelfReferenceInfo(bool hasCovariantSelfResult, OptionalTypePosition selfRef,
2194+
GenericParameterReferenceInfo(bool hasCovariantSelfResult, OptionalTypePosition selfRef,
21952195
OptionalTypePosition assocTypeRef)
21962196
: hasCovariantSelfResult(hasCovariantSelfResult), selfRef(selfRef),
21972197
assocTypeRef(assocTypeRef) {}
@@ -2682,7 +2682,7 @@ class ValueDecl : public Decl {
26822682
/// is considered covariant only when it appears as the immediate type of a
26832683
/// property, or the uncurried result type of a method/subscript, e.g.
26842684
/// '() -> () -> Self'.
2685-
SelfReferenceInfo findExistentialSelfReferences(
2685+
GenericParameterReferenceInfo findExistentialSelfReferences(
26862686
Type baseTy, bool treatNonResultCovariantSelfAsInvariant) const;
26872687
};
26882688

@@ -7800,6 +7800,14 @@ class MissingMemberDecl : public Decl {
78007800
}
78017801
};
78027802

7803+
/// Find references to the given generic paramaeter in the generic signature
7804+
/// and the type of the given value.
7805+
GenericParameterReferenceInfo findGenericParameterReferences(
7806+
const ValueDecl *value,
7807+
CanGenericSignature sig, GenericTypeParamType *genericParam,
7808+
bool treatNonResultCovarianceAsInvariant,
7809+
Optional<unsigned> skipParamIndex);
7810+
78037811
inline bool AbstractStorageDecl::isSettable(const DeclContext *UseDC,
78047812
const DeclRefExpr *base) const {
78057813
if (auto vd = dyn_cast<VarDecl>(this))

include/swift/AST/DiagnosticsSema.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4794,8 +4794,8 @@ ERROR(global_actor_on_actor_class,none,
47944794
ERROR(global_actor_on_local_variable,none,
47954795
"local variable %0 cannot have a global actor", (DeclName))
47964796
ERROR(global_actor_on_storage_of_value_type,none,
4797-
"stored property %0 within %1 cannot have a global actor",
4798-
(DeclName, DescriptiveDeclKind))
4797+
"stored property %0 within struct cannot have a global actor",
4798+
(DeclName))
47994799
ERROR(global_actor_non_unsafe_init,none,
48004800
"global actor attribute %0 argument can only be '(unsafe)'", (Type))
48014801
ERROR(global_actor_non_final_class,none,

include/swift/Basic/LangOptions.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,10 @@ namespace swift {
313313
/// `func f() -> <T> T`.
314314
bool EnableExperimentalNamedOpaqueTypes = false;
315315

316+
/// Enable support for implicitly opening existential argument types
317+
/// in calls to generic functions.
318+
bool EnableOpenedExistentialTypes = false;
319+
316320
/// Enable support for protocol types parameterized by primary
317321
/// associated type.
318322
bool EnableParameterizedProtocolTypes = false;

include/swift/Basic/StringExtras.h

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,16 @@ namespace swift {
5252
/// Determine the part of speech for the given word.
5353
PartOfSpeech getPartOfSpeech(StringRef word);
5454

55+
/// Copy \p string to \p Allocator and return it as a null terminated C
56+
/// string.
57+
const char *copyCString(StringRef string, llvm::BumpPtrAllocator &Allocator);
58+
5559
/// Scratch space used for returning a set of StringRefs.
5660
class StringScratchSpace {
5761
llvm::BumpPtrAllocator Allocator;
5862

5963
public:
60-
StringRef copyString(StringRef string);
64+
StringRef copyString(StringRef string) { return string.copy(Allocator); }
6165

6266
llvm::BumpPtrAllocator &getAllocator() { return Allocator; }
6367
};
@@ -465,6 +469,52 @@ bool omitNeedlessWords(StringRef &baseName,
465469
/// If the name has a completion-handler suffix, strip off that suffix.
466470
Optional<StringRef> stripWithCompletionHandlerSuffix(StringRef name);
467471

472+
/// Represents a string that can be efficiently retrieved either as a StringRef
473+
/// or as a null-terminated C string.
474+
class NullTerminatedStringRef {
475+
StringRef Ref;
476+
477+
public:
478+
/// Create a \c NullTerminatedStringRef from a null-terminated C string with
479+
/// size \p Size (excluding the null character).
480+
NullTerminatedStringRef(const char *Data, size_t Size) : Ref(Data, Size) {
481+
assert(Data != nullptr && Data[Size] == '\0' &&
482+
"Data should be null-terminated");
483+
}
484+
485+
/// Create an empty null-terminated string. \c data() is not a \c nullptr.
486+
constexpr NullTerminatedStringRef() : Ref("") {}
487+
488+
/// Create an null terminated string with a C string.
489+
constexpr NullTerminatedStringRef(const char *Data) : Ref(Data) {}
490+
491+
/// Create a null-terminated string, copying \p Str into \p A .
492+
template <typename Allocator>
493+
NullTerminatedStringRef(StringRef Str, Allocator &A) : Ref("") {
494+
if (Str.empty())
495+
return;
496+
497+
size_t size = Str.size();
498+
char *memory = A.template Allocate<char>(size + 1);
499+
memcpy(memory, Str.data(), size);
500+
memory[size] = '\0';
501+
Ref = {memory, size};
502+
}
503+
504+
/// Returns the string as a `StringRef`. The `StringRef` does not include the
505+
/// null character.
506+
operator StringRef() const { return Ref; }
507+
508+
/// Returns the string as a null-terminated C string.
509+
const char *data() const { return Ref.data(); }
510+
511+
/// The size of the string, excluding the null character.
512+
size_t size() const { return Ref.size(); }
513+
514+
bool empty() const { return Ref.empty(); }
515+
int compare(NullTerminatedStringRef RHS) const { return Ref.compare(RHS); }
516+
};
517+
468518
} // end namespace swift
469519

470520
#endif // SWIFT_BASIC_STRINGEXTRAS_H

include/swift/ClangImporter/ClangImporter.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,12 @@ class DWARFImporterDelegate {
110110
virtual void anchor();
111111
};
112112

113+
// ⚠️ DANGER ⚠️
114+
// Putting more than four types in this `PointerUnion` will break the build for
115+
// 32-bit hosts. If we need five or more types in the future, we'll need to
116+
// design a proper larger-than-word-sized type.
113117
typedef llvm::PointerUnion<const clang::Decl *, const clang::MacroInfo *,
114-
const clang::ModuleMacro *, const clang::Type *,
115-
const clang::Token *>
118+
const clang::Type *, const clang::Token *>
116119
ImportDiagnosticTarget;
117120

118121
/// Class that imports Clang modules into Swift, mapping directly

0 commit comments

Comments
 (0)