Skip to content

Commit 3d8b2f7

Browse files
authored
Merge pull request #2004 from swiftwasm/main
[pull] swiftwasm from main
2 parents fd0d667 + aa3e590 commit 3d8b2f7

Some content is hidden

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

41 files changed

+262
-379
lines changed

include/swift/AST/Decl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3762,6 +3762,7 @@ struct SelfReferencePosition final {
37623762
case Contravariant:
37633763
return Covariant;
37643764
}
3765+
llvm_unreachable("unhandled self reference position!");
37653766
}
37663767

37673768
explicit operator bool() const { return kind > None; }

include/swift/AST/DiagnosticsSema.def

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2455,16 +2455,10 @@ NOTE(suggest_removing_override, none,
24552455
ERROR(override_less_available,none,
24562456
"overriding %0 must be as available as declaration it overrides",
24572457
(DeclBaseName))
2458-
WARNING(override_less_available_warn,none,
2459-
"overriding %0 must be as available as declaration it overrides",
2460-
(DeclBaseName))
24612458

24622459
ERROR(override_accessor_less_available,none,
24632460
"overriding %0 for %1 must be as available as declaration it overrides",
24642461
(DescriptiveDeclKind, DeclBaseName))
2465-
WARNING(override_accessor_less_available_warn,none,
2466-
"overriding %0 for %1 must be as available as declaration it overrides",
2467-
(DescriptiveDeclKind, DeclBaseName))
24682462

24692463
ERROR(override_let_property,none,
24702464
"cannot override immutable 'let' property %0 with the getter of a 'var'",

include/swift/AST/ForeignErrorConvention.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ class ForeignErrorConvention {
198198
case NonNilError:
199199
return false;
200200
}
201+
llvm_unreachable("unhandled foreign error kind!");
201202
}
202203

203204
bool operator==(ForeignErrorConvention other) const {

include/swift/AST/TypeCheckRequests.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2687,9 +2687,13 @@ enum class CustomAttrTypeKind {
26872687
/// any contextual type parameters.
26882688
NonGeneric,
26892689

2690-
/// Property delegates have some funky rules, like allowing
2690+
/// Property wrappers have some funky rules, like allowing
26912691
/// unbound generic types.
2692-
PropertyDelegate,
2692+
PropertyWrapper,
2693+
2694+
/// Global actors are represented as custom type attributes. They don't
2695+
/// have any particularly interesting semantics.
2696+
GlobalActor,
26932697
};
26942698

26952699
void simple_display(llvm::raw_ostream &out, CustomAttrTypeKind value);

include/swift/AST/TypeRefinementContext.h

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -154,23 +154,16 @@ class TypeRefinementContext {
154154

155155
SourceRange SrcRange;
156156

157-
/// Runtime availability information for the code in this context.
158157
AvailabilityContext AvailabilityInfo;
159158

160-
/// Runtime availability information as explicitly declared by attributes
161-
/// for the inlinable code in this context. Compared to AvailabilityInfo,
162-
/// this is not bounded to the minimum deployment OS version.
163-
AvailabilityContext AvailabilityInfoExplicit;
164-
165159
std::vector<TypeRefinementContext *> Children;
166160

167161
TypeRefinementContext(ASTContext &Ctx, IntroNode Node,
168162
TypeRefinementContext *Parent, SourceRange SrcRange,
169-
const AvailabilityContext &Info,
170-
const AvailabilityContext &InfoExplicit);
163+
const AvailabilityContext &Info);
171164

172165
public:
173-
166+
174167
/// Create the root refinement context for the given SourceFile.
175168
static TypeRefinementContext *createRoot(SourceFile *SF,
176169
const AvailabilityContext &Info);
@@ -179,9 +172,8 @@ class TypeRefinementContext {
179172
static TypeRefinementContext *createForDecl(ASTContext &Ctx, Decl *D,
180173
TypeRefinementContext *Parent,
181174
const AvailabilityContext &Info,
182-
const AvailabilityContext &InfoExplicit,
183175
SourceRange SrcRange);
184-
176+
185177
/// Create a refinement context for the Then branch of the given IfStmt.
186178
static TypeRefinementContext *
187179
createForIfStmtThen(ASTContext &Ctx, IfStmt *S, TypeRefinementContext *Parent,
@@ -248,19 +240,11 @@ class TypeRefinementContext {
248240
SourceRange getSourceRange() const { return SrcRange; }
249241

250242
/// Returns the information on what can be assumed present at run time when
251-
/// running code contained in this context, taking into account the minimum
252-
/// deployment target.
243+
/// running code contained in this context.
253244
const AvailabilityContext &getAvailabilityInfo() const {
254245
return AvailabilityInfo;
255246
}
256247

257-
/// Returns the information on what can be assumed present at run time when
258-
/// running code contained in this context if it were to be inlined,
259-
/// without considering the minimum deployment target.
260-
const AvailabilityContext &getAvailabilityInfoExplicit() const {
261-
return AvailabilityInfoExplicit;
262-
}
263-
264248
/// Adds a child refinement context.
265249
void addChild(TypeRefinementContext *Child) {
266250
assert(Child->getSourceRange().isValid());

include/swift/Demangling/TypeLookupError.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ class TypeLookupError {
150150
delete castContext;
151151
return nullptr;
152152
}
153+
llvm_unreachable("unhandled command!");
153154
};
154155
}
155156

include/swift/Sema/ConstraintSystem.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1907,6 +1907,7 @@ class SolutionApplicationTarget {
19071907
case Kind::patternBinding:
19081908
return patternBinding;
19091909
}
1910+
llvm_unreachable("invalid case label type");
19101911
}
19111912

19121913
VarDecl *getAsUninitializedWrappedVar() const {
@@ -1921,6 +1922,7 @@ class SolutionApplicationTarget {
19211922
case Kind::uninitializedWrappedVar:
19221923
return uninitializedWrappedVar;
19231924
}
1925+
llvm_unreachable("invalid case label type");
19241926
}
19251927

19261928
BraceStmt *getFunctionBody() const {

lib/AST/AutoDiff.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,7 @@ bool swift::operator==(const TangentPropertyInfo::Error &lhs,
462462
case TangentPropertyInfo::Error::Kind::TangentPropertyWrongType:
463463
return lhs.getType()->isEqual(rhs.getType());
464464
}
465+
llvm_unreachable("unhandled tangent property!");
465466
}
466467

467468
void swift::simple_display(llvm::raw_ostream &os, TangentPropertyInfo info) {

lib/AST/Availability.cpp

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,8 @@ static bool isBetterThan(const AvailableAttr *newAttr,
144144
return true;
145145

146146
// If they belong to the same platform, the one that introduces later wins.
147-
if (prevAttr->Platform == newAttr->Platform) {
148-
if (newAttr->isUnconditionallyUnavailable())
149-
return true;
150-
if (prevAttr->isUnconditionallyUnavailable())
151-
return false;
147+
if (prevAttr->Platform == newAttr->Platform)
152148
return prevAttr->Introduced.getValue() < newAttr->Introduced.getValue();
153-
}
154149

155150
// If the new attribute's platform inherits from the old one, it wins.
156151
return inheritsAvailabilityFromPlatform(newAttr->Platform,
@@ -163,12 +158,10 @@ AvailabilityInference::annotatedAvailableRange(const Decl *D, ASTContext &Ctx) {
163158

164159
for (auto Attr : D->getAttrs()) {
165160
auto *AvailAttr = dyn_cast<AvailableAttr>(Attr);
166-
if (AvailAttr == nullptr ||
161+
if (AvailAttr == nullptr || !AvailAttr->Introduced.hasValue() ||
167162
!AvailAttr->isActivePlatform(Ctx) ||
168163
AvailAttr->isLanguageVersionSpecific() ||
169-
AvailAttr->isPackageDescriptionVersionSpecific() ||
170-
(!AvailAttr->Introduced.hasValue() &&
171-
!AvailAttr->isUnconditionallyUnavailable())) {
164+
AvailAttr->isPackageDescriptionVersionSpecific()) {
172165
continue;
173166
}
174167

@@ -179,9 +172,6 @@ AvailabilityInference::annotatedAvailableRange(const Decl *D, ASTContext &Ctx) {
179172
if (!bestAvailAttr)
180173
return None;
181174

182-
if (bestAvailAttr->isUnconditionallyUnavailable())
183-
return AvailabilityContext(VersionRange::empty());
184-
185175
return AvailabilityContext{
186176
VersionRange::allGTE(bestAvailAttr->Introduced.getValue())};
187177
}

lib/AST/ClangTypeConverter.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ const clang::Type *ClangTypeConverter::getFunctionType(
207207
case SILFunctionType::Representation::Closure:
208208
llvm_unreachable("Expected a C-compatible representation.");
209209
}
210+
llvm_unreachable("unhandled representation!");
210211
}
211212

212213
clang::QualType ClangTypeConverter::convertMemberType(NominalTypeDecl *DC,

lib/AST/TypeCheckRequests.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,8 +1467,12 @@ void swift::simple_display(llvm::raw_ostream &out, CustomAttrTypeKind value) {
14671467
out << "non-generic";
14681468
return;
14691469

1470-
case CustomAttrTypeKind::PropertyDelegate:
1471-
out << "property-delegate";
1470+
case CustomAttrTypeKind::PropertyWrapper:
1471+
out << "property-wrapper";
1472+
return;
1473+
1474+
case CustomAttrTypeKind::GlobalActor:
1475+
out << "global-actor";
14721476
return;
14731477
}
14741478
llvm_unreachable("bad kind");
@@ -1497,6 +1501,7 @@ bool ActorIsolation::requiresSubstitution() const {
14971501
case GlobalActor:
14981502
return getGlobalActor()->hasTypeParameter();
14991503
}
1504+
llvm_unreachable("unhandled actor isolation kind!");
15001505
}
15011506

15021507
ActorIsolation ActorIsolation::subst(SubstitutionMap subs) const {
@@ -1509,6 +1514,7 @@ ActorIsolation ActorIsolation::subst(SubstitutionMap subs) const {
15091514
case GlobalActor:
15101515
return forGlobalActor(getGlobalActor().subst(subs));
15111516
}
1517+
llvm_unreachable("unhandled actor isolation kind!");
15121518
}
15131519

15141520
void swift::simple_display(

lib/AST/TypeRefinementContext.cpp

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,12 @@ using namespace swift;
2828
TypeRefinementContext::TypeRefinementContext(ASTContext &Ctx, IntroNode Node,
2929
TypeRefinementContext *Parent,
3030
SourceRange SrcRange,
31-
const AvailabilityContext &Info,
32-
const AvailabilityContext &InfoExplicit)
33-
: Node(Node), SrcRange(SrcRange), AvailabilityInfo(Info),
34-
AvailabilityInfoExplicit(InfoExplicit) {
31+
const AvailabilityContext &Info)
32+
: Node(Node), SrcRange(SrcRange), AvailabilityInfo(Info) {
3533
if (Parent) {
3634
assert(SrcRange.isValid());
3735
Parent->addChild(this);
38-
assert(InfoExplicit.isContainedIn(Parent->getAvailabilityInfoExplicit()));
36+
assert(Info.isContainedIn(Parent->getAvailabilityInfo()));
3937
}
4038
Ctx.addDestructorCleanup(Children);
4139
}
@@ -48,20 +46,18 @@ TypeRefinementContext::createRoot(SourceFile *SF,
4846
ASTContext &Ctx = SF->getASTContext();
4947
return new (Ctx)
5048
TypeRefinementContext(Ctx, SF,
51-
/*Parent=*/nullptr, SourceRange(), Info,
52-
AvailabilityContext::alwaysAvailable());
49+
/*Parent=*/nullptr, SourceRange(), Info);
5350
}
5451

5552
TypeRefinementContext *
5653
TypeRefinementContext::createForDecl(ASTContext &Ctx, Decl *D,
5754
TypeRefinementContext *Parent,
5855
const AvailabilityContext &Info,
59-
const AvailabilityContext &InfoExplicit,
6056
SourceRange SrcRange) {
6157
assert(D);
6258
assert(Parent);
6359
return new (Ctx)
64-
TypeRefinementContext(Ctx, D, Parent, SrcRange, Info, InfoExplicit);
60+
TypeRefinementContext(Ctx, D, Parent, SrcRange, Info);
6561
}
6662

6763
TypeRefinementContext *
@@ -72,7 +68,7 @@ TypeRefinementContext::createForIfStmtThen(ASTContext &Ctx, IfStmt *S,
7268
assert(Parent);
7369
return new (Ctx)
7470
TypeRefinementContext(Ctx, IntroNode(S, /*IsThen=*/true), Parent,
75-
S->getThenStmt()->getSourceRange(), Info, Info);
71+
S->getThenStmt()->getSourceRange(), Info);
7672
}
7773

7874
TypeRefinementContext *
@@ -83,7 +79,7 @@ TypeRefinementContext::createForIfStmtElse(ASTContext &Ctx, IfStmt *S,
8379
assert(Parent);
8480
return new (Ctx)
8581
TypeRefinementContext(Ctx, IntroNode(S, /*IsThen=*/false), Parent,
86-
S->getElseStmt()->getSourceRange(), Info, Info);
82+
S->getElseStmt()->getSourceRange(), Info);
8783
}
8884

8985
TypeRefinementContext *
@@ -96,7 +92,7 @@ TypeRefinementContext::createForConditionFollowingQuery(ASTContext &Ctx,
9692
assert(Parent);
9793
SourceRange Range(PAI->getEndLoc(), LastElement.getEndLoc());
9894
return new (Ctx) TypeRefinementContext(Ctx, PAI, Parent, Range,
99-
Info, Info);
95+
Info);
10096
}
10197

10298
TypeRefinementContext *
@@ -111,7 +107,7 @@ TypeRefinementContext::createForGuardStmtFallthrough(ASTContext &Ctx,
111107
SourceRange Range(RS->getEndLoc(), ContainingBraceStmt->getEndLoc());
112108
return new (Ctx) TypeRefinementContext(Ctx,
113109
IntroNode(RS, /*IsFallthrough=*/true),
114-
Parent, Range, Info, Info);
110+
Parent, Range, Info);
115111
}
116112

117113
TypeRefinementContext *
@@ -122,7 +118,7 @@ TypeRefinementContext::createForGuardStmtElse(ASTContext &Ctx, GuardStmt *RS,
122118
assert(Parent);
123119
return new (Ctx)
124120
TypeRefinementContext(Ctx, IntroNode(RS, /*IsFallthrough=*/false), Parent,
125-
RS->getBody()->getSourceRange(), Info, Info);
121+
RS->getBody()->getSourceRange(), Info);
126122
}
127123

128124
TypeRefinementContext *
@@ -132,7 +128,7 @@ TypeRefinementContext::createForWhileStmtBody(ASTContext &Ctx, WhileStmt *S,
132128
assert(S);
133129
assert(Parent);
134130
return new (Ctx) TypeRefinementContext(
135-
Ctx, S, Parent, S->getBody()->getSourceRange(), Info, Info);
131+
Ctx, S, Parent, S->getBody()->getSourceRange(), Info);
136132
}
137133

138134
// Only allow allocation of TypeRefinementContext using the allocator in
@@ -300,7 +296,6 @@ void TypeRefinementContext::print(raw_ostream &OS, SourceManager &SrcMgr,
300296
OS << "(" << getReasonName(getReason());
301297

302298
OS << " versions=" << AvailabilityInfo.getOSVersion().getAsString();
303-
OS << " explicit=" << AvailabilityInfoExplicit.getOSVersion().getAsString();
304299

305300
if (getReason() == Reason::Decl) {
306301
Decl *D = Node.getAsDecl();

lib/ClangImporter/ImportDecl.cpp

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1817,27 +1817,18 @@ static void applyAvailableAttribute(Decl *decl, AvailabilityContext &info,
18171817
if (info.isAlwaysAvailable())
18181818
return;
18191819

1820-
PlatformAgnosticAvailabilityKind platformAgnosticAvailability;
1821-
llvm::VersionTuple introducedVersion;
1822-
if (info.isKnownUnreachable()) {
1823-
platformAgnosticAvailability = PlatformAgnosticAvailabilityKind::Unavailable;
1824-
} else {
1825-
platformAgnosticAvailability = PlatformAgnosticAvailabilityKind::None;
1826-
introducedVersion = info.getOSVersion().getLowerEndpoint();
1827-
}
1828-
18291820
llvm::VersionTuple noVersion;
18301821
auto AvAttr = new (C) AvailableAttr(SourceLoc(), SourceRange(),
18311822
targetPlatform(C.LangOpts),
18321823
/*Message=*/StringRef(),
18331824
/*Rename=*/StringRef(),
1834-
introducedVersion,
1825+
info.getOSVersion().getLowerEndpoint(),
18351826
/*IntroducedRange*/SourceRange(),
18361827
/*Deprecated=*/noVersion,
18371828
/*DeprecatedRange*/SourceRange(),
18381829
/*Obsoleted=*/noVersion,
18391830
/*ObsoletedRange*/SourceRange(),
1840-
platformAgnosticAvailability,
1831+
PlatformAgnosticAvailabilityKind::None,
18411832
/*Implicit=*/false);
18421833

18431834
decl->getAttrs().add(AvAttr);

lib/Driver/DarwinToolChains.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ bool jobMatchesFilter(LinkKind jobKind, BackDeployLibFilter filter) {
364364
case BackDeployLibFilter::all:
365365
return true;
366366
}
367+
llvm_unreachable("unhandled back deploy lib filter!");
367368
}
368369

369370
}

lib/IDE/APIDigesterData.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ StringRef swift::ide::api::getDeclKindStr(const DeclKind Value, bool lower) {
5656
}
5757
#include "swift/AST/DeclNodes.def"
5858
}
59+
llvm_unreachable("Unhandled DeclKind in switch.");
5960
} else {
6061
return getDeclKindStrRaw(Value);
6162
}

lib/IRGen/GenCall.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,7 @@ namespace {
10151015
llvm::Type *convertVectorType(clang::CanQual<clang::VectorType> type) {
10161016
auto eltTy =
10171017
convertBuiltinType(type->getElementType().castAs<clang::BuiltinType>());
1018-
return llvm::VectorType::get(eltTy, type->getNumElements());
1018+
return llvm::FixedVectorType::get(eltTy, type->getNumElements());
10191019
}
10201020

10211021
llvm::Type *convertBuiltinType(clang::CanQual<clang::BuiltinType> type) {

lib/IRGen/GenType.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,7 +1216,7 @@ TypeConverter::createPrimitiveForAlignedPointer(llvm::PointerType *type,
12161216
Alignment align,
12171217
Alignment pointerAlignment) {
12181218
SpareBitVector spareBits = IGM.TargetInfo.PointerSpareBits;
1219-
for (unsigned bit = 0; Alignment(1 << bit) != pointerAlignment; ++bit) {
1219+
for (unsigned bit = 0; Alignment(1ull << bit) != pointerAlignment; ++bit) {
12201220
spareBits.setBit(bit);
12211221
}
12221222

@@ -1872,7 +1872,7 @@ convertPrimitiveBuiltin(IRGenModule &IGM, CanType canTy) {
18721872
= convertPrimitiveBuiltin(IGM,
18731873
vecTy->getElementType()->getCanonicalType());
18741874

1875-
auto llvmVecTy = llvm::VectorType::get(elementTy, vecTy->getNumElements());
1875+
auto llvmVecTy = llvm::FixedVectorType::get(elementTy, vecTy->getNumElements());
18761876
unsigned bitSize = size.getValue() * vecTy->getNumElements() * 8;
18771877
if (!llvm::isPowerOf2_32(bitSize))
18781878
bitSize = llvm::NextPowerOf2(bitSize);

0 commit comments

Comments
 (0)