Skip to content

Commit 4baa775

Browse files
authored
Merge pull request #19297 from compnerd/unreachable
litter the tree with `llvm_unreachable`
2 parents f4818ea + d281b98 commit 4baa775

File tree

79 files changed

+167
-18
lines changed

Some content is hidden

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

79 files changed

+167
-18
lines changed

include/swift/AST/Attr.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,6 +1289,7 @@ class ClangImporterSynthesizedTypeAttr : public DeclAttribute {
12891289
case Kind::NSErrorWrapperAnon:
12901290
return "E";
12911291
}
1292+
llvm_unreachable("unhandled kind");
12921293
}
12931294

12941295
static bool classof(const DeclAttribute *DA) {

include/swift/AST/Decl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4624,6 +4624,7 @@ class VarDecl : public AbstractStorageDecl {
46244624
case Specifier::InOut:
46254625
return false;
46264626
}
4627+
llvm_unreachable("unhandled specifier");
46274628
}
46284629
/// Is this an immutable 'let' property?
46294630
bool isLet() const { return getSpecifier() == Specifier::Let; }
@@ -4645,6 +4646,7 @@ class VarDecl : public AbstractStorageDecl {
46454646
case Specifier::Owned:
46464647
return ValueOwnership::Owned;
46474648
}
4649+
llvm_unreachable("unhandled specifier");
46484650
}
46494651

46504652
/// Is this an element in a capture list?

include/swift/AST/Expr.h

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4925,32 +4925,33 @@ class KeyPathExpr : public Expr {
49254925
bool isValid() const {
49264926
return getKind() != Kind::Invalid;
49274927
}
4928-
4928+
49294929
bool isResolved() const {
49304930
if (!getComponentType())
49314931
return false;
4932-
4932+
49334933
switch (getKind()) {
49344934
case Kind::Subscript:
49354935
case Kind::OptionalChain:
49364936
case Kind::OptionalWrap:
49374937
case Kind::OptionalForce:
49384938
case Kind::Property:
49394939
return true;
4940-
4940+
49414941
case Kind::UnresolvedSubscript:
49424942
case Kind::UnresolvedProperty:
49434943
case Kind::Invalid:
49444944
return false;
49454945
}
4946+
llvm_unreachable("unhandled kind");
49464947
}
4947-
4948+
49484949
Expr *getIndexExpr() const {
49494950
switch (getKind()) {
49504951
case Kind::Subscript:
49514952
case Kind::UnresolvedSubscript:
49524953
return SubscriptIndexExprAndKind.getPointer();
4953-
4954+
49544955
case Kind::Invalid:
49554956
case Kind::OptionalChain:
49564957
case Kind::OptionalWrap:
@@ -4959,14 +4960,15 @@ class KeyPathExpr : public Expr {
49594960
case Kind::Property:
49604961
return nullptr;
49614962
}
4963+
llvm_unreachable("unhandled kind");
49624964
}
49634965

49644966
ArrayRef<Identifier> getSubscriptLabels() const {
49654967
switch (getKind()) {
49664968
case Kind::Subscript:
49674969
case Kind::UnresolvedSubscript:
49684970
return SubscriptLabels;
4969-
4971+
49704972
case Kind::Invalid:
49714973
case Kind::OptionalChain:
49724974
case Kind::OptionalWrap:
@@ -4975,14 +4977,15 @@ class KeyPathExpr : public Expr {
49754977
case Kind::Property:
49764978
llvm_unreachable("no subscript labels for this kind");
49774979
}
4980+
llvm_unreachable("unhandled kind");
49784981
}
4979-
4982+
49804983
ArrayRef<ProtocolConformanceRef>
49814984
getSubscriptIndexHashableConformances() const {
49824985
switch (getKind()) {
49834986
case Kind::Subscript:
49844987
return SubscriptHashableConformances;
4985-
4988+
49864989
case Kind::UnresolvedSubscript:
49874990
case Kind::Invalid:
49884991
case Kind::OptionalChain:
@@ -4992,8 +4995,9 @@ class KeyPathExpr : public Expr {
49924995
case Kind::Property:
49934996
return {};
49944997
}
4998+
llvm_unreachable("unhandled kind");
49954999
}
4996-
5000+
49975001
void setSubscriptIndexHashableConformances(
49985002
ArrayRef<ProtocolConformanceRef> hashables);
49995003

@@ -5011,8 +5015,9 @@ class KeyPathExpr : public Expr {
50115015
case Kind::Property:
50125016
llvm_unreachable("no unresolved name for this kind");
50135017
}
5018+
llvm_unreachable("unhandled kind");
50145019
}
5015-
5020+
50165021
ConcreteDeclRef getDeclRef() const {
50175022
switch (getKind()) {
50185023
case Kind::Property:
@@ -5027,8 +5032,9 @@ class KeyPathExpr : public Expr {
50275032
case Kind::OptionalForce:
50285033
llvm_unreachable("no decl ref for this kind");
50295034
}
5035+
llvm_unreachable("unhandled kind");
50305036
}
5031-
5037+
50325038
Type getComponentType() const {
50335039
return ComponentType;
50345040
}

include/swift/AST/GenericSignatureBuilder.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1732,6 +1732,7 @@ inline bool isErrorResult(GenericSignatureBuilder::ConstraintResult result) {
17321732
case GenericSignatureBuilder::ConstraintResult::Unresolved:
17331733
return false;
17341734
}
1735+
llvm_unreachable("unhandled result");
17351736
}
17361737

17371738
/// Canonical ordering for dependent types.

include/swift/AST/Identifier.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ class DeclBaseName {
297297
case Kind::Destructor:
298298
return "deinit";
299299
}
300+
llvm_unreachable("unhandled kind");
300301
}
301302

302303
int compare(DeclBaseName other) const {

include/swift/SIL/MemAccessUtils.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ class AccessedStorage {
237237
case Class:
238238
return objProj == other.objProj;
239239
}
240+
llvm_unreachable("unhandled kind");
240241
}
241242

242243
/// Return true if the storage is guaranteed local.
@@ -253,6 +254,7 @@ class AccessedStorage {
253254
case Unidentified:
254255
return false;
255256
}
257+
llvm_unreachable("unhandled kind");
256258
}
257259

258260
bool isUniquelyIdentified() const {
@@ -268,6 +270,7 @@ class AccessedStorage {
268270
case Unidentified:
269271
return false;
270272
}
273+
llvm_unreachable("unhandled kind");
271274
}
272275

273276
bool isDistinctFrom(const AccessedStorage &other) const {

include/swift/SIL/SILInstruction.h

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2411,8 +2411,9 @@ class KeyPathPatternComponent {
24112411
case Unpacked:
24122412
return (Kind)((uintptr_t)ValueAndKind.getPointer() >> KindPackingBits);
24132413
}
2414+
llvm_unreachable("unhandled kind");
24142415
}
2415-
2416+
24162417
CanType getComponentType() const {
24172418
return ComponentType;
24182419
}
@@ -2430,7 +2431,7 @@ class KeyPathPatternComponent {
24302431
}
24312432
llvm_unreachable("unhandled kind");
24322433
}
2433-
2434+
24342435
ComputedPropertyId getComputedPropertyId() const {
24352436
switch (getKind()) {
24362437
case Kind::StoredProperty:
@@ -2445,7 +2446,7 @@ class KeyPathPatternComponent {
24452446
}
24462447
llvm_unreachable("unhandled kind");
24472448
}
2448-
2449+
24492450
SILFunction *getComputedPropertyGetter() const {
24502451
switch (getKind()) {
24512452
case Kind::StoredProperty:
@@ -2473,7 +2474,7 @@ class KeyPathPatternComponent {
24732474
}
24742475
llvm_unreachable("unhandled kind");
24752476
}
2476-
2477+
24772478
ArrayRef<Index> getSubscriptIndices() const {
24782479
switch (getKind()) {
24792480
case Kind::StoredProperty:
@@ -2485,8 +2486,9 @@ class KeyPathPatternComponent {
24852486
case Kind::SettableProperty:
24862487
return Indices;
24872488
}
2489+
llvm_unreachable("unhandled kind");
24882490
}
2489-
2491+
24902492
SILFunction *getSubscriptIndexEquals() const {
24912493
switch (getKind()) {
24922494
case Kind::StoredProperty:
@@ -2498,6 +2500,7 @@ class KeyPathPatternComponent {
24982500
case Kind::SettableProperty:
24992501
return IndexEquality.Equal;
25002502
}
2503+
llvm_unreachable("unhandled kind");
25012504
}
25022505
SILFunction *getSubscriptIndexHash() const {
25032506
switch (getKind()) {
@@ -2510,8 +2513,9 @@ class KeyPathPatternComponent {
25102513
case Kind::SettableProperty:
25112514
return IndexEquality.Hash;
25122515
}
2516+
llvm_unreachable("unhandled kind");
25132517
}
2514-
2518+
25152519
bool isComputedSettablePropertyMutating() const;
25162520

25172521
static KeyPathPatternComponent forStoredProperty(VarDecl *property,
@@ -2530,8 +2534,9 @@ class KeyPathPatternComponent {
25302534
case Kind::SettableProperty:
25312535
return ExternalStorage;
25322536
}
2537+
llvm_unreachable("unhandled kind");
25332538
}
2534-
2539+
25352540
SubstitutionMap getExternalSubstitutions() const {
25362541
switch (getKind()) {
25372542
case Kind::StoredProperty:
@@ -2543,6 +2548,7 @@ class KeyPathPatternComponent {
25432548
case Kind::SettableProperty:
25442549
return ExternalSubstitutions;
25452550
}
2551+
llvm_unreachable("unhandled kind");
25462552
}
25472553

25482554
static KeyPathPatternComponent

include/swift/SIL/TypeLowering.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,7 @@ class TypeLowering {
496496
case TypeExpansionKind::MostDerivedDescendents:
497497
return emitLoweredCopyValueMostDerivedDescendents(B, loc, value);
498498
}
499+
llvm_unreachable("unhandled style");
499500
}
500501

501502
/// Allocate a new TypeLowering using the TypeConverter's allocator.

include/swift/Syntax/Serialization/SyntaxSerialization.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ struct ScalarReferenceTraits<syntax::SourcePresence> {
4747
case syntax::SourcePresence::Missing:
4848
return "\"Missing\"";
4949
}
50+
llvm_unreachable("unhandled presence");
5051
}
5152

5253
static bool mustQuote(StringRef) {
@@ -243,6 +244,7 @@ template <>
243244
case syntax::SourcePresence::Missing: return 0;
244245
case syntax::SourcePresence::Present: return 1;
245246
}
247+
llvm_unreachable("unhandled presence");
246248
}
247249

248250
static void write(ByteTreeWriter &Writer,
@@ -330,12 +332,14 @@ struct ObjectTraits<syntax::RawSyntax> {
330332
case Layout: return 6;
331333
case Omitted: return 2;
332334
}
335+
llvm_unreachable("unhandled kind");
333336
} else {
334337
switch (nodeKind(Syntax, UserInfo)) {
335338
case Token: return 6;
336339
case Layout: return 5;
337340
case Omitted: return 2;
338341
}
342+
llvm_unreachable("unhandled kind");
339343
}
340344
}
341345

include/swift/Syntax/SyntaxKind.h.gyb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ struct WrapperTypeTraits<syntax::SyntaxKind> {
9696
% end
9797
% end
9898
}
99+
llvm_unreachable("unhandled kind");
99100
}
100101

101102
static void write(ByteTreeWriter &Writer, const syntax::SyntaxKind &Kind,
@@ -122,6 +123,7 @@ struct ScalarReferenceTraits<syntax::SyntaxKind> {
122123
return "\"${node.syntax_kind}\"";
123124
% end
124125
}
126+
llvm_unreachable("unhandled kind");
125127
}
126128

127129
static bool mustQuote(StringRef) {

include/swift/Syntax/Trivia.h.gyb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ public:
171171
% end
172172
% end
173173
}
174+
llvm_unreachable("unhandled kind");
174175
}
175176

176177
bool isComment() const;
@@ -384,6 +385,7 @@ struct WrapperTypeTraits<syntax::TriviaKind> {
384385
case syntax::TriviaKind::${trivia.name}: return ${trivia.serialization_code};
385386
% end
386387
}
388+
llvm_unreachable("unhandled kind");
387389
}
388390

389391
static void write(ByteTreeWriter &Writer, const syntax::TriviaKind &Kind,
@@ -459,6 +461,7 @@ struct ScalarReferenceTraits<syntax::TriviaKind> {
459461
return "\"${trivia.name}\"";
460462
% end
461463
}
464+
llvm_unreachable("unhandled kind");
462465
}
463466

464467
static bool mustQuote(StringRef) {

lib/AST/ASTVerifier.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,7 @@ class Verifier : public ASTWalker {
501501

502502
return false;
503503
}
504+
llvm_unreachable("unhandled kind");
504505
}
505506

506507
// Default cases for cleaning up as we exit a node.

lib/AST/AccessRequests.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ AccessLevelRequest::evaluate(Evaluator &evaluator, ValueDecl *D) const {
119119
case DeclContextKind::ExtensionDecl:
120120
return cast<ExtensionDecl>(DC)->getDefaultAccessLevel();
121121
}
122+
llvm_unreachable("unhandled kind");
122123
}
123124

124125
void AccessLevelRequest::diagnoseCycle(DiagnosticEngine &diags) const {

lib/AST/Decl.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4857,6 +4857,7 @@ ParamDecl::getDefaultValueStringRepresentation(
48574857
case DefaultArgumentKind::EmptyArray: return "[]";
48584858
case DefaultArgumentKind::EmptyDictionary: return "[:]";
48594859
}
4860+
llvm_unreachable("unhandled kind");
48604861
}
48614862

48624863
void

lib/AST/GenericSignature.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ static unsigned getRequirementKindOrder(RequirementKind kind) {
186186
case RequirementKind::SameType: return 3;
187187
case RequirementKind::Layout: return 1;
188188
}
189+
llvm_unreachable("unhandled kind");
189190
}
190191
#endif
191192

@@ -585,6 +586,7 @@ bool GenericSignature::isRequirementSatisfied(Requirement requirement) {
585586
return true;
586587
}
587588
}
589+
llvm_unreachable("unhandled kind");
588590
}
589591

590592
SmallVector<Requirement, 4> GenericSignature::requirementsNotSatisfiedBy(

0 commit comments

Comments
 (0)