Skip to content

Commit c9bdd3a

Browse files
authored
Merge pull request #25199 from compnerd/fam-gonna-reach
2 parents c2a09cc + 731c31f commit c9bdd3a

28 files changed

+53
-0
lines changed

include/swift/SIL/ApplySite.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ class ApplySite {
102102
case ApplySiteKind::PartialApplyInst:
103103
return ApplySite(cast<PartialApplyInst>(node));
104104
}
105+
llvm_unreachable("covered switch");
105106
}
106107

107108
ApplySiteKind getKind() const { return ApplySiteKind(Inst->getKind()); }
@@ -126,6 +127,7 @@ class ApplySite {
126127
case ApplySiteKind::TryApplyInst: \
127128
return cast<TryApplyInst>(Inst)->OPERATION; \
128129
} \
130+
llvm_unreachable("covered switch"); \
129131
} while (0)
130132

131133
/// Return the callee operand.
@@ -293,6 +295,7 @@ class ApplySite {
293295
// apply pa2(a)
294296
return getSubstCalleeConv().getNumSILArguments() - getNumArguments();
295297
}
298+
llvm_unreachable("covered switch");
296299
}
297300

298301
/// Return the callee's function argument index corresponding to the given
@@ -325,6 +328,7 @@ class ApplySite {
325328
case ApplySiteKind::PartialApplyInst:
326329
llvm_unreachable("unhandled case");
327330
}
331+
llvm_unreachable("covered switch");
328332
}
329333

330334
/// Return the applied 'self' argument value.
@@ -339,6 +343,7 @@ class ApplySite {
339343
case ApplySiteKind::PartialApplyInst:
340344
llvm_unreachable("unhandled case");
341345
}
346+
llvm_unreachable("covered switch");
342347
}
343348

344349
/// Return the 'self' apply operand.
@@ -353,6 +358,7 @@ class ApplySite {
353358
case ApplySiteKind::PartialApplyInst:
354359
llvm_unreachable("Unhandled cast");
355360
}
361+
llvm_unreachable("covered switch");
356362
}
357363

358364
/// Return a list of applied arguments without self.
@@ -367,6 +373,7 @@ class ApplySite {
367373
case ApplySiteKind::PartialApplyInst:
368374
llvm_unreachable("Unhandled case");
369375
}
376+
llvm_unreachable("covered switch");
370377
}
371378

372379
/// Return whether the given apply is of a formally-throwing function
@@ -466,6 +473,7 @@ class FullApplySite : public ApplySite {
466473
case FullApplySiteKind::TryApplyInst:
467474
return FullApplySite(cast<TryApplyInst>(node));
468475
}
476+
llvm_unreachable("covered switch");
469477
}
470478

471479
FullApplySiteKind getKind() const {

include/swift/SIL/Consumption.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ inline bool shouldDestroyOnFailure(CastConsumptionKind kind) {
6666
case CastConsumptionKind::BorrowAlways:
6767
return false;
6868
}
69+
llvm_unreachable("covered switch");
6970
}
7071

7172
/// Should the source value be taken if the cast succeeds?
@@ -78,6 +79,7 @@ inline IsTake_t shouldTakeOnSuccess(CastConsumptionKind kind) {
7879
case CastConsumptionKind::BorrowAlways:
7980
return IsNotTake;
8081
}
82+
llvm_unreachable("covered switch");
8183
}
8284

8385
} // end namespace swift

include/swift/SIL/DynamicCasts.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ struct SILDynamicCastInst {
198198
case SILDynamicCastKind::UnconditionalCheckedCastValueInst:
199199
llvm_unreachable("unsupported");
200200
}
201+
llvm_unreachable("covered switch");
201202
}
202203

203204
CastConsumptionKind getConsumptionKind() const {
@@ -226,6 +227,7 @@ struct SILDynamicCastInst {
226227
case SILDynamicCastKind::UnconditionalCheckedCastValueInst:
227228
llvm_unreachable("unsupported");
228229
}
230+
llvm_unreachable("covered switch");
229231
}
230232

231233
Optional<ProfileCounter> getSuccessBlockCount() {
@@ -242,6 +244,7 @@ struct SILDynamicCastInst {
242244
case SILDynamicCastKind::UnconditionalCheckedCastValueInst:
243245
llvm_unreachable("unsupported");
244246
}
247+
llvm_unreachable("covered switch");
245248
}
246249

247250
const SILBasicBlock *getSuccessBlock() const {
@@ -262,6 +265,7 @@ struct SILDynamicCastInst {
262265
case SILDynamicCastKind::UnconditionalCheckedCastValueInst:
263266
llvm_unreachable("unsupported");
264267
}
268+
llvm_unreachable("covered switch");
265269
}
266270

267271
Optional<ProfileCounter> getFailureBlockCount() {
@@ -278,6 +282,7 @@ struct SILDynamicCastInst {
278282
case SILDynamicCastKind::UnconditionalCheckedCastValueInst:
279283
llvm_unreachable("unsupported");
280284
}
285+
llvm_unreachable("covered switch");
281286
}
282287

283288
const SILBasicBlock *getFailureBlock() const {
@@ -299,6 +304,7 @@ struct SILDynamicCastInst {
299304
case SILDynamicCastKind::UnconditionalCheckedCastValueInst:
300305
llvm_unreachable("unsupported");
301306
}
307+
llvm_unreachable("covered switch");
302308
}
303309

304310
// Returns the success value.
@@ -320,6 +326,7 @@ struct SILDynamicCastInst {
320326
case SILDynamicCastKind::UnconditionalCheckedCastValueInst:
321327
llvm_unreachable("unimplemented");
322328
}
329+
llvm_unreachable("covered switch");
323330
}
324331

325332
CanType getSourceType() const {
@@ -337,6 +344,7 @@ struct SILDynamicCastInst {
337344
case SILDynamicCastKind::UnconditionalCheckedCastValueInst:
338345
llvm_unreachable("unsupported");
339346
}
347+
llvm_unreachable("covered switch");
340348
}
341349

342350
SILType getLoweredSourceType() const {
@@ -371,6 +379,7 @@ struct SILDynamicCastInst {
371379
case SILDynamicCastKind::UnconditionalCheckedCastValueInst:
372380
llvm_unreachable("unimplemented");
373381
}
382+
llvm_unreachable("covered switch");
374383
}
375384

376385
SILType getLoweredTargetType() const {
@@ -391,6 +400,7 @@ struct SILDynamicCastInst {
391400
case SILDynamicCastKind::UnconditionalCheckedCastValueInst:
392401
llvm_unreachable("unsupported");
393402
}
403+
llvm_unreachable("covered switch");
394404
}
395405

396406
bool isSourceTypeExact() const {
@@ -404,6 +414,7 @@ struct SILDynamicCastInst {
404414
case SILDynamicCastKind::UnconditionalCheckedCastValueInst:
405415
llvm_unreachable("unsupported");
406416
}
417+
llvm_unreachable("covered switch");
407418
}
408419

409420
SILLocation getLocation() const { return inst->getLoc(); }
@@ -475,6 +486,7 @@ struct SILDynamicCastInst {
475486
case SILDynamicCastKind::UnconditionalCheckedCastValueInst:
476487
llvm_unreachable("unsupported");
477488
}
489+
llvm_unreachable("covered switch");
478490
}
479491

480492
bool canUseScalarCheckedCastInstructions() const {

include/swift/SIL/MemAccessUtils.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ class AccessedStorage {
239239
return value == other.value
240240
&& getElementIndex() == other.getElementIndex();
241241
}
242+
llvm_unreachable("covered switch");
242243
}
243244

244245
/// Return true if the storage is guaranteed local.

include/swift/SIL/SILValue.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ struct ValueOwnershipKind {
174174
case ValueOwnershipKind::Owned:
175175
return UseLifetimeConstraint::MustBeInvalidated;
176176
}
177+
llvm_unreachable("covered switch");
177178
}
178179

179180
/// Returns true if \p Other can be merged successfully with this, implying

lib/AST/ASTContext.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4470,6 +4470,7 @@ VarDecl *VarDecl::getOriginalWrappedProperty(
44704470
case PropertyWrapperSynthesizedPropertyKind::StorageWrapper:
44714471
return this == wrapperInfo.storageWrapperVar ? original : nullptr;
44724472
}
4473+
llvm_unreachable("covered switch");
44734474
}
44744475

44754476
void VarDecl::setOriginalWrappedProperty(VarDecl *originalProperty) {

lib/AST/ASTDemangler.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,7 @@ getParameterConvention(ImplParameterConvention conv) {
428428
case Demangle::ImplParameterConvention::Direct_Guaranteed:
429429
return ParameterConvention::Direct_Guaranteed;
430430
}
431+
llvm_unreachable("covered switch");
431432
}
432433

433434
static ResultConvention getResultConvention(ImplResultConvention conv) {
@@ -443,6 +444,7 @@ static ResultConvention getResultConvention(ImplResultConvention conv) {
443444
case Demangle::ImplResultConvention::Autoreleased:
444445
return ResultConvention::Autoreleased;
445446
}
447+
llvm_unreachable("covered switch");
446448
}
447449

448450
Type ASTBuilder::createImplFunctionType(
@@ -539,6 +541,7 @@ getMetatypeRepresentation(ImplMetatypeRepresentation repr) {
539541
case Demangle::ImplMetatypeRepresentation::ObjC:
540542
return MetatypeRepresentation::ObjC;
541543
}
544+
llvm_unreachable("covered switch");
542545
}
543546

544547
Type ASTBuilder::createExistentialMetatypeType(Type instance,

lib/AST/Decl.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6472,6 +6472,7 @@ bool AbstractFunctionDecl::hasInlinableBodyText() const {
64726472
case BodyKind::MemberwiseInitializer:
64736473
return false;
64746474
}
6475+
llvm_unreachable("covered switch");
64756476
}
64766477

64776478
StringRef AbstractFunctionDecl::getInlinableBodyText(

lib/AST/DiagnosticConsumer.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ FileSpecificDiagnosticConsumer::findSubconsumer(
207207
case DiagnosticKind::Note:
208208
return SubconsumerForSubsequentNotes;
209209
}
210+
llvm_unreachable("covered switch");
210211
}
211212

212213
Optional<FileSpecificDiagnosticConsumer::Subconsumer *>

lib/IRGen/GenCast.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ getDynamicCastArguments(IRGenFunction &IGF,
159159
return llvm::makeArrayRef(argsBuf, n-3);
160160
break;
161161
}
162+
llvm_unreachable("covered switch");
162163
}
163164

164165
/// Emit a checked unconditional downcast of a class value.

lib/IRGen/GenMeta.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1721,6 +1721,7 @@ namespace {
17211721
case SILLinkage::PublicNonABI:
17221722
return false;
17231723
}
1724+
llvm_unreachable("covered switch");
17241725
}
17251726

17261727
GenericSignature *getGenericSignature() {

lib/Parse/Parser.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ static LexerMode sourceFileKindToLexerMode(SourceFileKind kind) {
356356
case swift::SourceFileKind::REPL:
357357
return LexerMode::Swift;
358358
}
359+
llvm_unreachable("covered switch");
359360
}
360361

361362
Parser::Parser(unsigned BufferID, SourceFile &SF, SILParserTUStateBase *SIL,

lib/SIL/SILConstants.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ SymbolicValue::Kind SymbolicValue::getKind() const {
139139
case RK_DerivedAddress:
140140
return Address;
141141
}
142+
llvm_unreachable("covered switch");
142143
}
143144

144145
/// Clone this SymbolicValue into the specified ASTContext and return the new
@@ -179,6 +180,7 @@ SymbolicValue::cloneInto(SymbolicValueAllocator &allocator) const {
179180
return getAddress(newMemObject, accessPath, allocator);
180181
}
181182
}
183+
llvm_unreachable("covered switch");
182184
}
183185

184186
//===----------------------------------------------------------------------===//

lib/SILGen/SILGen.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,6 +1372,7 @@ void SILGenModule::visitVarDecl(VarDecl *vd) {
13721372
#include "swift/AST/AccessorKinds.def"
13731373
llvm_unreachable("not an opaque accessor");
13741374
}
1375+
llvm_unreachable("covered switch");
13751376
}();
13761377
if (!shouldEmit) return;
13771378

lib/SILGen/SILGenConvert.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -985,6 +985,7 @@ SILGenFunction::emitOpenExistential(
985985
case ExistentialRepresentation::None:
986986
llvm_unreachable("not existential");
987987
}
988+
llvm_unreachable("covered switch");
988989
}
989990

990991
ManagedValue SILGenFunction::manageOpaqueValue(ManagedValue value,

lib/SILGen/SILGenExpr.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3240,6 +3240,7 @@ static ProtocolConformance *mapConformanceOutOfContext(
32403240
.mapReplacementTypesOutOfContext());
32413241
}
32423242
}
3243+
llvm_unreachable("covered switch");
32433244
}
32443245

32453246
/// Map the given protocol conformance out of context, replacing archetypes

lib/SILGen/SILGenPattern.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,6 +1370,7 @@ getManagedSubobject(SILGenFunction &SGF, SILValue value,
13701370
case CastConsumptionKind::TakeOnSuccess:
13711371
return {SGF.emitManagedRValueWithCleanup(value, valueTL), consumption};
13721372
}
1373+
llvm_unreachable("covered switch");
13731374
}
13741375

13751376
static ConsumableManagedValue
@@ -1539,6 +1540,7 @@ emitTupleDispatch(ArrayRef<RowToSpecialize> rows, ConsumableManagedValue src,
15391540
"Borrow always can only occur along object only code paths");
15401541
}
15411542
}
1543+
llvm_unreachable("covered switch");
15421544
}());
15431545

15441546
// If we aren't loadable, add to the unforward array.

lib/SILOptimizer/IPO/ClosureSpecializer.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,6 +1048,7 @@ static bool canSpecializeFullApplySite(FullApplySiteKind kind) {
10481048
case FullApplySiteKind::BeginApplyInst:
10491049
return false;
10501050
}
1051+
llvm_unreachable("covered switch");
10511052
}
10521053

10531054
bool SILClosureSpecializerTransform::gatherCallSites(

lib/SILOptimizer/Mandatory/PMOMemoryUseCollector.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ bool ElementUseCollector::collectUses(SILValue Pointer) {
310310
case StoreOwnershipQualifier::Trivial:
311311
return PMOUseKind::InitOrAssign;
312312
}
313+
llvm_unreachable("covered switch");
313314
})();
314315
Uses.emplace_back(si, kind);
315316
continue;

lib/SILOptimizer/Mandatory/SemanticARCOpts.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ static bool isWrittenTo(SILFunction &f, SILValue value) {
388388
case AccessedStorage::Argument:
389389
return mayFunctionMutateArgument(storage, f);
390390
}
391+
llvm_unreachable("covered switch");
391392
}
392393

393394
// Convert a load [copy] from unique storage [read] that has all uses that can

lib/SILOptimizer/Utils/Devirtualize.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,7 @@ static ApplySite replaceApplySite(SILBuilder &B, SILLocation Loc,
636636
return replacePartialApplyInst(B, Loc, OldPAI, NewFn, NewSubs, NewArgs);
637637
}
638638
}
639+
llvm_unreachable("covered switch");
639640
}
640641

641642
/// Delete an apply site that's been successfully devirtualized.

lib/Sema/CSFix.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ bool AllowInvalidInitRef::diagnose(Expr *root, bool asNote) const {
345345
return failure.diagnose(asNote);
346346
}
347347
}
348+
llvm_unreachable("covered switch");
348349
}
349350

350351
AllowInvalidInitRef *AllowInvalidInitRef::dynamicOnMetatype(
@@ -478,6 +479,7 @@ bool AllowInvalidRefInKeyPath::diagnose(Expr *root, bool asNote) const {
478479
return failure.diagnose(asNote);
479480
}
480481
}
482+
llvm_unreachable("covered switch");
481483
}
482484

483485
AllowInvalidRefInKeyPath *

lib/Sema/CSFix.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -895,6 +895,7 @@ class AllowInvalidRefInKeyPath final : public ConstraintFix {
895895
case RefKind::Method:
896896
return "allow reference to a method as a key path component";
897897
}
898+
llvm_unreachable("covered switch");
898899
}
899900

900901
bool diagnose(Expr *root, bool asNote = false) const override;

lib/Sema/CSSimplify.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1998,6 +1998,7 @@ static ConstraintFix *fixRequirementFailure(ConstraintSystem &cs, Type type1,
19981998
case RequirementKind::Conformance:
19991999
return MissingConformance::forRequirement(cs, type1, type2, reqLoc);
20002000
}
2001+
llvm_unreachable("covered switch");
20012002
}
20022003

20032004
/// Attempt to repair typing failures and record fixes if needed.

lib/Sema/CSSolver.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2035,6 +2035,7 @@ static Constraint *tryOptimizeGenericDisjunction(
20352035
case Comparison::Unordered:
20362036
return nullptr;
20372037
}
2038+
llvm_unreachable("covered switch");
20382039
}
20392040

20402041
void ConstraintSystem::partitionDisjunction(

lib/Sema/TypeCheckDecl.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,6 +1181,7 @@ doesAccessorNeedDynamicAttribute(AccessorDecl *accessor, Evaluator &evaluator) {
11811181
return isStorageDynamic(evaluator, accessor);
11821182
return false;
11831183
}
1184+
llvm_unreachable("covered switch");
11841185
}
11851186

11861187
llvm::Expected<bool>

0 commit comments

Comments
 (0)