Skip to content

Commit 9b4e20f

Browse files
Merge pull request #5299 from swiftwasm/main
[pull] swiftwasm from main
2 parents ff334d2 + 69a1311 commit 9b4e20f

File tree

143 files changed

+4276
-1656
lines changed

Some content is hidden

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

143 files changed

+4276
-1656
lines changed

docs/SIL.rst

Lines changed: 527 additions & 17 deletions
Large diffs are not rendered by default.

include/swift/ABI/MetadataValues.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,6 +1442,9 @@ namespace SpecialPointerAuthDiscriminators {
14421442

14431443
/// C type StoreExtraInhabitantTag function descriminator
14441444
const uint16_t StoreExtraInhabitantTagFunction = 0x9bf6; // = 39926
1445+
1446+
// Relative protocol witness table descriminator
1447+
const uint16_t RelativeProtocolWitnessTable = 0xb830; // = 47152
14451448
}
14461449

14471450
/// The number of arguments that will be passed directly to a generic

include/swift/AST/ASTDemangler.h

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,16 @@ namespace Demangle {
3737
SWIFT_BEGIN_INLINE_NAMESPACE
3838

3939
Type getTypeForMangling(ASTContext &ctx,
40-
llvm::StringRef mangling);
40+
llvm::StringRef mangling,
41+
GenericSignature genericSig=GenericSignature());
4142

4243
TypeDecl *getTypeDeclForMangling(ASTContext &ctx,
43-
llvm::StringRef mangling);
44+
llvm::StringRef mangling,
45+
GenericSignature genericSig=GenericSignature());
4446

4547
TypeDecl *getTypeDeclForUSR(ASTContext &ctx,
46-
llvm::StringRef usr);
48+
llvm::StringRef usr,
49+
GenericSignature genericSig=GenericSignature());
4750

4851
/// An implementation of MetadataReader's BuilderType concept that
4952
/// just finds and builds things in the AST.
@@ -55,6 +58,11 @@ class ASTBuilder {
5558
/// Created lazily.
5659
DeclContext *NotionalDC = nullptr;
5760

61+
/// The generic signature for interpreting type parameters. This is used
62+
/// because the mangling for a type parameter doesn't record whether it
63+
/// is a pack or not, so we have to find it here.
64+
GenericSignature GenericSig;
65+
5866
public:
5967
using BuiltType = swift::Type;
6068
using BuiltTypeDecl = swift::GenericTypeDecl *; // nominal or type alias
@@ -66,7 +74,8 @@ class ASTBuilder {
6674

6775
static constexpr bool needsToPrecomputeParentGenericContextShapes = false;
6876

69-
explicit ASTBuilder(ASTContext &ctx) : Ctx(ctx) {}
77+
explicit ASTBuilder(ASTContext &ctx, GenericSignature genericSig)
78+
: Ctx(ctx), GenericSig(genericSig) {}
7079

7180
ASTContext &getASTContext() { return Ctx; }
7281
DeclContext *getNotionalDC();
@@ -102,6 +111,12 @@ class ASTBuilder {
102111

103112
Type createTupleType(ArrayRef<Type> eltTypes, StringRef labels);
104113

114+
Type createPackType(ArrayRef<Type> eltTypes);
115+
116+
Type createSILPackType(ArrayRef<Type> eltTypes, bool isElementAddress);
117+
118+
Type createPackExpansionType(Type patternType, Type countType);
119+
105120
Type createFunctionType(
106121
ArrayRef<Demangle::FunctionParam<Type>> params,
107122
Type output, FunctionTypeFlags flags,

include/swift/AST/DiagnosticsSIL.def

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -760,12 +760,11 @@ ERROR(sil_moveonlychecker_notconsumable_but_assignable_was_consumed_global_var,
760760
ERROR(sil_moveonlychecker_notconsumable_but_assignable_was_consumed_global_let, none,
761761
"'%0' was consumed but it is illegal to consume a noncopyable global let. One can only read from it",
762762
(StringRef))
763-
ERROR(sil_moveonlychecker_notconsumable_but_assignable_was_consumed_escaping_let, none,
764-
"'%0' was consumed but it is illegal to consume a noncopyable escaping immutable capture. One can only read from it",
765-
(StringRef))
766763
ERROR(sil_moveonlychecker_notconsumable_but_assignable_was_consumed_escaping_var, none,
767-
"'%0' was consumed but it is illegal to consume a noncopyable escaping mutable capture. One can only read from it or assign over it",
764+
"'%0' was consumed but it is illegal to consume a noncopyable mutable capture of an escaping closure. One can only read from it or assign over it",
768765
(StringRef))
766+
ERROR(sil_moveonlychecker_let_capture_consumed, none,
767+
"'%0' was consumed but it is illegal to consume a noncopyable immutable capture of an escaping closure. One can only read from it", (StringRef))
769768

770769
NOTE(sil_moveonlychecker_moveonly_field_consumed_here, none,
771770
"move only field consumed here", ())

include/swift/AST/DiagnosticsSema.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3893,6 +3893,9 @@ ERROR(optional_used_as_boolean,none,
38933893
ERROR(integer_used_as_boolean,none,
38943894
"type %0 cannot be used as a boolean; "
38953895
"test for '%select{!|=}1= 0' instead", (Type, bool))
3896+
ERROR(integer_used_as_boolean_literal,none,
3897+
"integer literal value '%0' cannot be used as a boolean; "
3898+
"did you mean '%select{false|true}1'?", (StringRef, bool))
38963899

38973900
ERROR(interpolation_missing_proto,none,
38983901
"string interpolation requires the protocol 'ExpressibleByStringInterpolation' to be defined",

include/swift/AST/IRGenOptions.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,9 @@ struct PointerAuthOptions : clang::PointerAuthOptions {
204204

205205
/// C type StoreExtraInhabitantTag function descriminator.
206206
PointerAuthSchema StoreExtraInhabitantTagFunction;
207+
208+
/// Relative protocol witness table descriminator.
209+
PointerAuthSchema RelativeProtocolWitnessTable;
207210
};
208211

209212
enum class JITDebugArtifact : unsigned {

include/swift/AST/SemanticAttrs.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,5 +120,9 @@ SEMANTICS_ATTR(LIFETIMEMANAGEMENT_COPY, "lifetimemanagement.copy")
120120

121121
SEMANTICS_ATTR(NO_PERFORMANCE_ANALYSIS, "no_performance_analysis")
122122

123+
// A flag used to turn off moveonly diagnostics on functions that allocbox to
124+
// stack specialized.
125+
SEMANTICS_ATTR(NO_MOVEONLY_DIAGNOSTICS, "sil.optimizer.moveonly.diagnostic.ignore")
126+
123127
#undef SEMANTICS_ATTR
124128

include/swift/AST/TypeCheckRequests.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3181,16 +3181,16 @@ void simple_display(llvm::raw_ostream &out,
31813181
/// Resolve a given custom attribute to an attached macro declaration.
31823182
class ResolveMacroRequest
31833183
: public SimpleRequest<ResolveMacroRequest,
3184-
MacroDecl *(UnresolvedMacroReference,
3185-
DeclContext *),
3184+
ConcreteDeclRef(UnresolvedMacroReference,
3185+
DeclContext *),
31863186
RequestFlags::Cached> {
31873187
public:
31883188
using SimpleRequest::SimpleRequest;
31893189

31903190
private:
31913191
friend SimpleRequest;
31923192

3193-
MacroDecl *
3193+
ConcreteDeclRef
31943194
evaluate(Evaluator &evaluator, UnresolvedMacroReference macroRef,
31953195
DeclContext *dc) const;
31963196

include/swift/AST/TypeCheckerTypeIDZone.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ SWIFT_REQUEST(TypeChecker, ResolveImplicitMemberRequest,
341341
evaluator::SideEffect(NominalTypeDecl *, ImplicitMemberAction),
342342
Uncached, NoLocationInfo)
343343
SWIFT_REQUEST(TypeChecker, ResolveMacroRequest,
344-
MacroDecl *(CustomAttr *, DeclContext *),
344+
ConcreteDeclRef(UnresolvedMacroReference, DeclContext *),
345345
Cached, NoLocationInfo)
346346
SWIFT_REQUEST(TypeChecker, ResolveTypeEraserTypeRequest,
347347
Type(ProtocolDecl *, TypeEraserAttr *),

include/swift/Basic/LangOptions.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ namespace swift {
331331
bool UseMalloc = false;
332332

333333
/// Specifies how strict concurrency checking will be.
334-
StrictConcurrency StrictConcurrencyLevel = StrictConcurrency::Targeted;
334+
StrictConcurrency StrictConcurrencyLevel = StrictConcurrency::Minimal;
335335

336336
/// Enable experimental concurrency model.
337337
bool EnableExperimentalConcurrency = false;
@@ -532,6 +532,9 @@ namespace swift {
532532
/// The model of concurrency to be used.
533533
ConcurrencyModel ActiveConcurrencyModel = ConcurrencyModel::Standard;
534534

535+
/// Allows the explicit 'import Builtin' within Swift modules.
536+
bool EnableBuiltinModule = false;
537+
535538
bool isConcurrencyModelTaskToThread() const {
536539
return ActiveConcurrencyModel == ConcurrencyModel::TaskToThread;
537540
}

include/swift/Basic/SourceManager.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,17 +214,25 @@ class SourceManager {
214214
(isBeforeInBuffer(R.Start, Loc) && isBeforeInBuffer(Loc, R.End));
215215
}
216216

217+
/// Returns true if range \c R contains the location \c Loc. The location
218+
/// \c Loc should point at the beginning of the token.
219+
bool rangeContainsTokenLoc(CharSourceRange R, SourceLoc Loc) const {
220+
return Loc == R.getStart() || (isBeforeInBuffer(R.getStart(), Loc) &&
221+
isBeforeInBuffer(Loc, R.getEnd()));
222+
}
223+
217224
/// Returns true if range \c Enclosing contains the range \c Inner.
218225
bool rangeContains(SourceRange Enclosing, SourceRange Inner) const {
219226
return rangeContainsTokenLoc(Enclosing, Inner.Start) &&
220227
rangeContainsTokenLoc(Enclosing, Inner.End);
221228
}
222229

223230
/// Returns true if range \p R contains the code-completion location, if any.
224-
bool rangeContainsIDEInspectionTarget(SourceRange R) const {
225-
return IDEInspectionTargetBufferID
226-
? rangeContainsTokenLoc(R, getIDEInspectionTargetLoc())
227-
: false;
231+
bool rangeContainsIDEInspectionTarget(CharSourceRange R) const {
232+
if (!IDEInspectionTargetBufferID) {
233+
return false;
234+
}
235+
return rangeContainsTokenLoc(R, getIDEInspectionTargetLoc());
228236
}
229237

230238
/// Returns the buffer ID for the specified *valid* location.

include/swift/Demangling/DemangleNodes.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,8 @@ NODE(Tuple)
236236
NODE(TupleElement)
237237
NODE(TupleElementName)
238238
NODE(Pack)
239+
NODE(SILPackDirect)
240+
NODE(SILPackIndirect)
239241
NODE(PackExpansion)
240242
NODE(Type)
241243
CONTEXT_NODE(TypeSymbolicReference)

include/swift/Demangling/Demangler.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,7 @@ class Demangler : public NodeFactory {
530530
NodePointer popTuple();
531531
NodePointer popTypeList();
532532
NodePointer popPack();
533+
NodePointer popSILPack();
533534
NodePointer popProtocol();
534535
NodePointer demangleBoundGenericType();
535536
NodePointer demangleBoundGenericArgs(NodePointer nominalType,

include/swift/Demangling/TypeDecoder.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,6 +1072,46 @@ class TypeDecoder {
10721072
return decodeMangledType(Node->getChild(0), depth + 1,
10731073
/*forRequirement=*/false);
10741074

1075+
case NodeKind::Pack:
1076+
case NodeKind::SILPackDirect:
1077+
case NodeKind::SILPackIndirect: {
1078+
llvm::SmallVector<BuiltType, 8> elements;
1079+
1080+
for (auto &element : *Node) {
1081+
// Decode the element type.
1082+
auto elementType =
1083+
decodeMangledType(element, depth + 1, /*forRequirement=*/false);
1084+
if (elementType.isError())
1085+
return elementType;
1086+
1087+
elements.push_back(elementType.getType());
1088+
}
1089+
1090+
switch (Node->getKind()) {
1091+
case NodeKind::Pack:
1092+
return Builder.createPackType(elements);
1093+
case NodeKind::SILPackDirect:
1094+
return Builder.createSILPackType(elements, /*isElementAddress=*/false);
1095+
case NodeKind::SILPackIndirect:
1096+
return Builder.createSILPackType(elements, /*isElementAddress=*/true);
1097+
default:
1098+
llvm_unreachable("Bad kind");
1099+
}
1100+
}
1101+
1102+
case NodeKind::PackExpansion: {
1103+
if (Node->getNumChildren() < 2)
1104+
return MAKE_NODE_TYPE_ERROR(Node,
1105+
"fewer children (%zu) than required (2)",
1106+
Node->getNumChildren());
1107+
1108+
auto patternType = decodeMangledType(Node->getChild(0), depth + 1);
1109+
auto countType = decodeMangledType(Node->getChild(1), depth + 1);
1110+
1111+
return Builder.createPackExpansionType(patternType.getType(),
1112+
countType.getType());
1113+
}
1114+
10751115
case NodeKind::DependentGenericType: {
10761116
if (Node->getNumChildren() < 2)
10771117
return MAKE_NODE_TYPE_ERROR(Node,

0 commit comments

Comments
 (0)