Skip to content

Commit 5a6867a

Browse files
authored
Merge pull request #7889 from hughbe/unreachable-030317
Update unreachable control path annotations
2 parents 0f6aaef + 33f5f89 commit 5a6867a

File tree

7 files changed

+60
-0
lines changed

7 files changed

+60
-0
lines changed

include/swift/AST/GenericSignatureBuilder.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "llvm/ADT/STLExtras.h"
3333
#include "llvm/ADT/MapVector.h"
3434
#include "llvm/ADT/TinyPtrVector.h"
35+
#include "llvm/Support/ErrorHandling.h"
3536
#include "llvm/Support/TrailingObjects.h"
3637
#include <functional>
3738
#include <memory>
@@ -590,6 +591,8 @@ class GenericSignatureBuilder::RequirementSource final
590591
case Concrete:
591592
return 0;
592593
}
594+
595+
llvm_unreachable("Unhandled RequirementSourceKind in switch.");
593596
}
594597

595598
/// Determines whether we have been provided with an acceptable storage kind
@@ -618,6 +621,8 @@ class GenericSignatureBuilder::RequirementSource final
618621
case Concrete:
619622
return false;
620623
}
624+
625+
llvm_unreachable("Unhandled RequirementSourceKind in switch.");
621626
}
622627

623628
public:

include/swift/AST/Requirement.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
#include "swift/AST/Type.h"
2121
#include "llvm/ADT/PointerIntPair.h"
22+
#include "llvm/Support/ErrorHandling.h"
2223

2324
namespace swift {
2425

@@ -109,6 +110,8 @@ class Requirement {
109110
case RequirementKind::Layout:
110111
return Requirement(getKind(), newFirst, getLayoutConstraint());
111112
}
113+
114+
llvm_unreachable("Unhandled RequirementKind in switch.");
112115
}
113116

114117
/// \brief Retrieve the layout constraint.

lib/AST/ASTDumper.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "llvm/ADT/Optional.h"
3030
#include "llvm/ADT/SmallString.h"
3131
#include "llvm/ADT/StringExtras.h"
32+
#include "llvm/Support/ErrorHandling.h"
3233
#include "llvm/Support/Process.h"
3334
#include "llvm/Support/SaveAndRestore.h"
3435
#include "llvm/Support/raw_ostream.h"
@@ -207,6 +208,8 @@ getSILFunctionTypeRepresentationString(SILFunctionType::Representation value) {
207208
case SILFunctionType::Representation::WitnessMethod: return "witness_method";
208209
case SILFunctionType::Representation::Closure: return "closure";
209210
}
211+
212+
llvm_unreachable("Unhandled SILFunctionTypeRepresentation in switch.");
210213
}
211214
static StringRef
212215
getAbstractStorageDeclKindString(AbstractStorageDecl::StorageKindTy value) {
@@ -230,6 +233,8 @@ getAbstractStorageDeclKindString(AbstractStorageDecl::StorageKindTy value) {
230233
case AbstractStorageDecl::Computed:
231234
return "computed";
232235
}
236+
237+
llvm_unreachable("Unhandled AbstractStorageDecl in switch.");
233238
}
234239
static StringRef getImportKindString(ImportKind value) {
235240
switch (value) {
@@ -242,6 +247,8 @@ static StringRef getImportKindString(ImportKind value) {
242247
case ImportKind::Var: return "var";
243248
case ImportKind::Func: return "func";
244249
}
250+
251+
llvm_unreachable("Unhandled ImportKind in switch.");
245252
}
246253
static StringRef getAccessibilityString(Accessibility value) {
247254
switch (value) {
@@ -251,6 +258,8 @@ static StringRef getAccessibilityString(Accessibility value) {
251258
case Accessibility::Public: return "public";
252259
case Accessibility::Open: return "open";
253260
}
261+
262+
llvm_unreachable("Unhandled Accessibility in switch.");
254263
}
255264
static StringRef
256265
getForeignErrorConventionKindString(ForeignErrorConvention::Kind value) {
@@ -261,6 +270,8 @@ getForeignErrorConventionKindString(ForeignErrorConvention::Kind value) {
261270
case ForeignErrorConvention::NilResult: return "NilResult";
262271
case ForeignErrorConvention::NonNilError: return "NonNilError";
263272
}
273+
274+
llvm_unreachable("Unhandled ForeignErrorConvention in switch.");
264275
}
265276
static StringRef getDefaultArgumentKindString(DefaultArgumentKind value) {
266277
switch (value) {
@@ -276,6 +287,8 @@ static StringRef getDefaultArgumentKindString(DefaultArgumentKind value) {
276287
case DefaultArgumentKind::EmptyDictionary: return "[:]";
277288
case DefaultArgumentKind::Normal: return "normal";
278289
}
290+
291+
llvm_unreachable("Unhandled DefaultArgumentKind in switch.");
279292
}
280293
static StringRef getAccessorKindString(AccessorKind value) {
281294
switch (value) {
@@ -288,13 +301,17 @@ static StringRef getAccessorKindString(AccessorKind value) {
288301
case AccessorKind::IsAddressor: return "addressor";
289302
case AccessorKind::IsMutableAddressor: return "mutableAddressor";
290303
}
304+
305+
llvm_unreachable("Unhandled AccessorKind in switch.");
291306
}
292307
static StringRef getAccessKindString(AccessKind value) {
293308
switch (value) {
294309
case AccessKind::Read: return "read";
295310
case AccessKind::Write: return "write";
296311
case AccessKind::ReadWrite: return "readwrite";
297312
}
313+
314+
llvm_unreachable("Unhandled AccessKind in switch.");
298315
}
299316
static StringRef
300317
getMagicIdentifierLiteralExprKindString(MagicIdentifierLiteralExpr::Kind value) {
@@ -305,6 +322,8 @@ getMagicIdentifierLiteralExprKindString(MagicIdentifierLiteralExpr::Kind value)
305322
case MagicIdentifierLiteralExpr::Column: return "#column";
306323
case MagicIdentifierLiteralExpr::DSOHandle: return "#dsohandle";
307324
}
325+
326+
llvm_unreachable("Unhandled MagicIdentifierLiteralExpr in switch.");
308327
}
309328
static StringRef
310329
getObjCSelectorExprKindString(ObjCSelectorExpr::ObjCSelectorKind value) {
@@ -313,6 +332,8 @@ getObjCSelectorExprKindString(ObjCSelectorExpr::ObjCSelectorKind value) {
313332
case ObjCSelectorExpr::Getter: return "getter";
314333
case ObjCSelectorExpr::Setter: return "setter";
315334
}
335+
336+
llvm_unreachable("Unhandled ObjCSelectorExpr in switch.");
316337
}
317338
static StringRef getAccessSemanticsString(AccessSemantics value) {
318339
switch (value) {
@@ -321,13 +342,17 @@ static StringRef getAccessSemanticsString(AccessSemantics value) {
321342
case AccessSemantics::DirectToAccessor: return "direct_to_accessor";
322343
case AccessSemantics::BehaviorInitialization: return "behavior_init";
323344
}
345+
346+
llvm_unreachable("Unhandled AccessSemantics in switch.");
324347
}
325348
static StringRef getMetatypeRepresentationString(MetatypeRepresentation value) {
326349
switch (value) {
327350
case MetatypeRepresentation::Thin: return "thin";
328351
case MetatypeRepresentation::Thick: return "thick";
329352
case MetatypeRepresentation::ObjC: return "@objc";
330353
}
354+
355+
llvm_unreachable("Unhandled MetatypeRepresentation in switch.");
331356
}
332357
static StringRef
333358
getStringLiteralExprEncodingString(StringLiteralExpr::Encoding value) {
@@ -336,6 +361,8 @@ getStringLiteralExprEncodingString(StringLiteralExpr::Encoding value) {
336361
case StringLiteralExpr::UTF16: return "utf16";
337362
case StringLiteralExpr::OneUnicodeScalar: return "unicodeScalar";
338363
}
364+
365+
llvm_unreachable("Unhandled StringLiteral in switch.");
339366
}
340367
static StringRef getCtorInitializerKindString(CtorInitializerKind value) {
341368
switch (value) {
@@ -344,20 +371,26 @@ static StringRef getCtorInitializerKindString(CtorInitializerKind value) {
344371
case CtorInitializerKind::ConvenienceFactory: return "convenience_factory";
345372
case CtorInitializerKind::Factory: return "factory";
346373
}
374+
375+
llvm_unreachable("Unhandled CtorInitializerKind in switch.");
347376
}
348377
static StringRef getOptionalTypeKindString(OptionalTypeKind value) {
349378
switch (value) {
350379
case OTK_None: return "none";
351380
case OTK_Optional: return "Optional";
352381
case OTK_ImplicitlyUnwrappedOptional: return "ImplicitlyUnwrappedOptional";
353382
}
383+
384+
llvm_unreachable("Unhandled OptionalTypeKind in switch.");
354385
}
355386
static StringRef getAssociativityString(Associativity value) {
356387
switch (value) {
357388
case Associativity::None: return "none";
358389
case Associativity::Left: return "left";
359390
case Associativity::Right: return "right";
360391
}
392+
393+
llvm_unreachable("Unhandled Associativity in switch.");
361394
}
362395

363396
//===----------------------------------------------------------------------===//

lib/AST/GenericSignatureBuilder.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ bool RequirementSource::isAcceptableStorageKind(Kind kind,
160160
return false;
161161
}
162162
}
163+
164+
llvm_unreachable("Unhandled RequirementSourceKind in switch.");
163165
}
164166

165167
const void *RequirementSource::getOpaqueStorage() const {
@@ -182,6 +184,8 @@ const void *RequirementSource::getOpaqueStorage() const {
182184
case StorageKind::AssociatedTypeDecl:
183185
return storage.assocType;
184186
}
187+
188+
llvm_unreachable("Unhandled StorageKind in switch.");
185189
}
186190

187191
const void *RequirementSource::getExtraOpaqueStorage() const {
@@ -210,6 +214,8 @@ bool RequirementSource::isDerivedRequirement() const {
210214
// need to keep them for the requirement signature.
211215
return parent->kind != RequirementSignatureSelf;
212216
}
217+
218+
llvm_unreachable("Unhandled RequirementSourceKind in switch.");
213219
}
214220

215221
bool RequirementSource::isDerivedViaConcreteConformance() const {
@@ -418,6 +424,8 @@ ProtocolDecl *RequirementSource::getProtocolDecl() const {
418424
case StorageKind::AssociatedTypeDecl:
419425
return storage.assocType->getProtocol();
420426
}
427+
428+
llvm_unreachable("Unhandled StorageKind in switch.");
421429
}
422430

423431
SourceLoc RequirementSource::getLoc() const {
@@ -569,6 +577,8 @@ const RequirementSource *FloatingRequirementSource::getSource(
569577
case Inferred:
570578
return RequirementSource::forInferred(pa, storage.get<const TypeRepr *>());
571579
}
580+
581+
llvm_unreachable("Unhandled FloatingPointRequirementSourceKind in switch.");
572582
}
573583

574584
SourceLoc FloatingRequirementSource::getLoc() const {

lib/ClangImporter/ImportName.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include "clang/Sema/Lookup.h"
3838
#include "clang/Sema/Sema.h"
3939
#include "llvm/ADT/STLExtras.h"
40+
#include "llvm/Support/ErrorHandling.h"
4041
#include <algorithm>
4142
#include <memory>
4243

@@ -79,6 +80,8 @@ unsigned importer::majorVersionNumberForNameVersion(ImportNameVersion version) {
7980
case ImportNameVersion::Swift4:
8081
return 4;
8182
}
83+
84+
llvm_unreachable("Unhandled ImportNameVersion in switch.");
8285
}
8386

8487

lib/Sema/TypeCheckGeneric.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "swift/AST/GenericEnvironment.h"
2121
#include "swift/AST/Types.h"
2222
#include "swift/Basic/Defer.h"
23+
#include "llvm/Support/ErrorHandling.h"
2324

2425
using namespace swift;
2526

@@ -399,6 +400,8 @@ bool TypeChecker::validateRequirement(SourceLoc whereLoc, RequirementRepr &req,
399400
return false;
400401
}
401402
}
403+
404+
llvm_unreachable("Unhandled RequirementKind in switch.");
402405
}
403406

404407
void

lib/Syntax/SyntaxData.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "swift/Syntax/TypeSyntax.h"
1717
#include "swift/Syntax/StmtSyntax.h"
1818
#include "swift/Syntax/UnknownSyntax.h"
19+
#include "llvm/Support/ErrorHandling.h"
1920

2021
using namespace swift;
2122
using namespace swift::syntax;
@@ -44,6 +45,8 @@ RC<SyntaxData> SyntaxData::makeDataFromRaw(RC<RawSyntax> Raw,
4445
case SyntaxKind::Token:
4546
llvm_unreachable("Can't make a SyntaxData from a Token!");
4647
}
48+
49+
llvm_unreachable("Unhandled SyntaxKind in switch.");
4750
}
4851

4952
bool SyntaxData::isType() const {

0 commit comments

Comments
 (0)