Skip to content

Commit c139bb4

Browse files
authored
Merge pull request #37804 from compnerd/run-for-cover
mark some switches as covered (NFCI)
2 parents 4bd7a2f + 25f437e commit c139bb4

26 files changed

+39
-1
lines changed

include/swift/SIL/ApplySite.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,7 @@ class ApplySite {
377377
case SILArgumentConvention::Indirect_Out:
378378
llvm_unreachable("partial_apply cannot have an @out operand");
379379
}
380+
llvm_unreachable("covered switch");
380381
}
381382

382383
/// Return true if 'self' is an applied argument.
@@ -454,7 +455,9 @@ class ApplySite {
454455
case ApplySiteKind::PartialApplyInst:
455456
return ApplyOptions();
456457
}
458+
llvm_unreachable("covered switch");
457459
}
460+
458461
/// Return whether the given apply is of a formally-throwing function
459462
/// which is statically known not to throw.
460463
bool isNonThrowing() const {

include/swift/SIL/DebugUtils.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ struct DebugVarCarryingInst {
290290
case Kind::AllocBox:
291291
return cast<AllocBoxInst>(inst)->getDecl();
292292
}
293+
llvm_unreachable("covered switch");
293294
}
294295

295296
Optional<SILDebugVariable> getVarInfo() const {
@@ -305,6 +306,7 @@ struct DebugVarCarryingInst {
305306
case Kind::AllocBox:
306307
return cast<AllocBoxInst>(inst)->getVarInfo();
307308
}
309+
llvm_unreachable("covered switch");
308310
}
309311
};
310312

include/swift/SIL/DynamicCasts.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ struct SILDynamicCastInst {
168168
return SILDynamicCastInst(cast<ID>(inst));
169169
#include "swift/SIL/SILNodes.def"
170170
}
171+
llvm_unreachable("covered switch");
171172
}
172173

173174
SILDynamicCastKind getKind() const {
@@ -359,6 +360,7 @@ struct SILDynamicCastInst {
359360
case SILDynamicCastKind::UnconditionalCheckedCastValueInst:
360361
return cast<UnconditionalCheckedCastValueInst>(inst)->getSourceLoweredType();
361362
}
363+
llvm_unreachable("covered switch");
362364
}
363365

364366
CanType getTargetFormalType() const {

include/swift/SIL/MemAccessUtils.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,7 @@ class AccessedStorage {
464464
case AccessedStorage::Tail:
465465
return getObject();
466466
}
467+
llvm_unreachable("covered switch");
467468
}
468469

469470
/// Visit all access roots. If any roots are visited then the original memory

include/swift/SIL/OwnershipUtils.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,7 @@ struct InteriorPointerOperand {
752752
return InteriorPointerOperand(op, kind);
753753
}
754754
}
755+
llvm_unreachable("covered switch");
755756
}
756757

757758
/// Return the end scope of all borrow introducers of the parent value of this
@@ -1035,6 +1036,7 @@ struct OwnedValueIntroducer {
10351036
case OwnedValueIntroducerKind::AllocRefInit:
10361037
return false;
10371038
}
1039+
llvm_unreachable("covered switch");
10381040
}
10391041

10401042
bool operator==(const OwnedValueIntroducer &other) const {

include/swift/SIL/SILLocation.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ class SILLocation {
207207
case FilenameAndLocationKind:
208208
llvm_unreachable("location type has no AST node");
209209
}
210+
llvm_unreachable("covered switch");
210211
}
211212

212213
/// Returns true if the location has a separate AST node for debugging.
@@ -300,6 +301,7 @@ class SILLocation {
300301
case FilenameAndLocationKind: return storage.filePositionLoc == nullptr;;
301302
case SourceLocKind: return storage.sourceLoc.isInvalid();
302303
}
304+
llvm_unreachable("covered switch");
303305
}
304306
explicit operator bool() const { return !isNull(); }
305307

@@ -313,6 +315,7 @@ class SILLocation {
313315
case FilenameAndLocationKind:
314316
return false;
315317
}
318+
llvm_unreachable("covered switch");
316319
}
317320

318321
/// Returns true if this location came from a SIL file.

include/swift/SIL/SILValue.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -875,6 +875,7 @@ inline OwnershipConstraint OperandOwnership::getOwnershipConstraint() {
875875
case OperandOwnership::Reborrow:
876876
return {OwnershipKind::Guaranteed, UseLifetimeConstraint::LifetimeEnding};
877877
}
878+
llvm_unreachable("covered switch");
878879
}
879880

880881
/// Return true if this use can accept Unowned values.
@@ -900,6 +901,7 @@ inline bool canAcceptUnownedValue(OperandOwnership operandOwnership) {
900901
case OperandOwnership::Reborrow:
901902
return false;
902903
}
904+
llvm_unreachable("covered switch");
903905
}
904906

905907
/// Return the OperandOwnership for a forwarded operand when the forwarding

lib/Basic/LangOptions.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,7 @@ llvm::StringRef swift::getFeatureName(Feature feature) {
391391
case Feature::FeatureName: return #FeatureName;
392392
#include "swift/Basic/Features.def"
393393
}
394+
llvm_unreachable("covered switch");
394395
}
395396

396397
DiagnosticBehavior LangOptions::getAccessNoteFailureLimit() const {
@@ -405,4 +406,5 @@ DiagnosticBehavior LangOptions::getAccessNoteFailureLimit() const {
405406
case AccessNoteDiagnosticBehavior::ErrorOnFailureRemarkOnSuccess:
406407
return DiagnosticBehavior::Error;
407408
}
409+
llvm_unreachable("covered switch");
408410
}

lib/IRGen/Callee.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ namespace irgen {
228228
// future.
229229
return false;
230230
}
231+
llvm_unreachable("covered switch");
231232
}
232233

233234
friend bool operator==(Kind lhs, Kind rhs) {

lib/IRGen/GenClass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2712,7 +2712,7 @@ FunctionPointer irgen::emitVirtualMethodValue(IRGenFunction &IGF,
27122712
signature);
27132713
}
27142714
}
2715-
2715+
llvm_unreachable("covered switch");
27162716
}
27172717

27182718
FunctionPointer

lib/IRGen/GenMeta.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2950,6 +2950,7 @@ namespace {
29502950
swift::irgen::ConstantReference::Direct);
29512951
}
29522952
}
2953+
llvm_unreachable("covered switch");
29532954
}
29542955

29552956
void addValueWitnessTable() {
@@ -3008,6 +3009,7 @@ namespace {
30083009
case ClassMetadataStrategy::Fixed:
30093010
return false;
30103011
}
3012+
llvm_unreachable("covered switch");
30113013
}
30123014

30133015
void addSuperclass() {

lib/IRGen/NecessaryBindings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ class NecessaryBindings {
9494
case Kind::AsyncFunction:
9595
return RequirementsVector[i];
9696
}
97+
llvm_unreachable("covered switch");
9798
}
9899

99100
ProtocolConformanceRef

lib/SIL/IR/AbstractionPattern.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,7 @@ AbstractionPattern::getObjCMethodAsyncCompletionHandlerType(
661661
case Kind::ObjCCompletionHandlerArgumentsType:
662662
swift_unreachable("not appropriate for this kind");
663663
}
664+
llvm_unreachable("covered switch");
664665
}
665666

666667
AbstractionPattern

lib/SIL/IR/OperandOwnership.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,7 @@ static OperandOwnership getFunctionArgOwnership(SILArgumentConvention argConv,
431431
case SILArgumentConvention::Indirect_InoutAliasable:
432432
llvm_unreachable("Illegal convention for non-address types");
433433
}
434+
llvm_unreachable("covered switch");
434435
}
435436

436437
OperandOwnership
@@ -511,6 +512,7 @@ OperandOwnership OperandOwnershipClassifier::visitReturnInst(ReturnInst *i) {
511512
case OwnershipKind::Owned:
512513
return OperandOwnership::ForwardingConsume;
513514
}
515+
llvm_unreachable("covered switch");
514516
}
515517

516518
OperandOwnership OperandOwnershipClassifier::visitAssignInst(AssignInst *i) {

lib/SIL/IR/SILValue.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ StringRef OwnershipKind::asString() const {
156156
case OwnershipKind::None:
157157
return "none";
158158
}
159+
llvm_unreachable("covered switch");
159160
}
160161

161162
//===----------------------------------------------------------------------===//
@@ -389,6 +390,7 @@ StringRef OperandOwnership::asString() const {
389390
case OperandOwnership::Reborrow:
390391
return "reborrow";
391392
}
393+
llvm_unreachable("covered switch");
392394
}
393395

394396
llvm::raw_ostream &swift::operator<<(llvm::raw_ostream &os,

lib/SIL/Utils/OptimizationRemark.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ static SourceLoc getLocForPresentation(SILLocation loc,
158158
case SourceLocPresentationKind::EndRange:
159159
return loc.getEndSourceLoc();
160160
}
161+
llvm_unreachable("covered switch");
161162
}
162163

163164
/// The user has passed us an instruction that for some reason has a source loc

lib/SIL/Utils/OwnershipUtils.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,7 @@ BorrowedValue BorrowingOperand::getBorrowIntroducingUserResult() {
447447
return BorrowedValue(bi->getDestBB()->getArgument(op->getOperandNumber()));
448448
}
449449
}
450+
llvm_unreachable("covered switch");
450451
}
451452

452453
void BorrowingOperand::getImplicitUses(

lib/SILGen/SILGenApply.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1927,6 +1927,7 @@ buildBuiltinLiteralArgs(SILGenFunction &SGF, SGFContext C,
19271927
case MagicIdentifierLiteralExpr::DSOHandle:
19281928
llvm_unreachable("handled elsewhere");
19291929
}
1930+
llvm_unreachable("covered switch");
19301931
}
19311932

19321933
static inline PreparedArguments buildBuiltinLiteralArgs(SILGenFunction &SGF,

lib/SILGen/SILGenConstructor.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,6 +1036,7 @@ emitMemberInit(SILGenFunction &SGF, VarDecl *selfDecl, Pattern *pattern) {
10361036
#include "swift/AST/PatternNodes.def"
10371037
llvm_unreachable("Refutable pattern in stored property pattern binding");
10381038
}
1039+
llvm_unreachable("covered switch");
10391040
}
10401041

10411042
static std::pair<AbstractionPattern, CanType>

lib/SILGen/SILGenLValue.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2695,6 +2695,7 @@ static AccessKind mapAccessKind(SGFAccessKind accessKind) {
26952695
case SGFAccessKind::ReadWrite:
26962696
return AccessKind::ReadWrite;
26972697
}
2698+
llvm_unreachable("covered switch");
26982699
}
26992700

27002701
void LValue::addNonMemberVarComponent(SILGenFunction &SGF, SILLocation loc,

lib/SILGen/SILGenProlog.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,7 @@ Optional<SILValue> SILGenFunction::emitExecutor(
666666
case ActorIsolation::GlobalActorUnsafe:
667667
return emitLoadGlobalActorExecutor(isolation.getGlobalActor());
668668
}
669+
llvm_unreachable("covered switch");
669670
}
670671

671672
void SILGenFunction::emitPreconditionCheckExpectedExecutor(

lib/SILOptimizer/SemanticARC/OwnershipLiveRange.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ static SILValue convertIntroducerToGuaranteed(OwnedValueIntroducer introducer) {
283283
case OwnedValueIntroducerKind::AllocRefInit:
284284
return SILValue();
285285
}
286+
llvm_unreachable("covered switch");
286287
}
287288

288289
void OwnershipLiveRange::convertJoinedLiveRangePhiToGuaranteed(

lib/SILOptimizer/Utils/CanonicalOSSALifetime.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,7 @@ endsAccessOverlappingPrunedBoundary(SILInstruction *inst) {
666666
return domInfo->properlyDominates(beginAccess->getParent(),
667667
getCurrentDef()->getParentBlock());
668668
}
669+
llvm_unreachable("covered switch");
669670
}
670671

671672
// Find all overlapping access scopes and extend pruned liveness to cover them:
@@ -1208,6 +1209,7 @@ bool CanonicalizeOSSALifetime::canonicalizeValueLifetime(SILValue def) {
12081209
consumes.clear();
12091210
return true;
12101211
}
1212+
llvm_unreachable("covered switch");
12111213
}
12121214

12131215
//===----------------------------------------------------------------------===//

lib/SILOptimizer/Utils/PerformanceInlinerUtils.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,7 @@ SemanticFunctionLevel swift::getSemanticFunctionLevel(SILFunction *function) {
616616
return SemanticFunctionLevel::Transient;
617617

618618
} // end switch
619+
llvm_unreachable("covered switch");
619620
}
620621

621622
/// Return true if \p apply calls into an optimizable semantic function from

lib/SILOptimizer/Utils/PrunedLiveness.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ PrunedLiveBlocks::IsLive PrunedLiveBlocks::updateForUse(SILInstruction *user) {
6666
return getBlockLiveness(bb);
6767
}
6868
}
69+
llvm_unreachable("covered switch");
6970
}
7071

7172
//===----------------------------------------------------------------------===//

lib/Serialization/SerializeSIL.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ toStableDifferentiabilityKind(swift::DifferentiabilityKind kind) {
108108
case swift::DifferentiabilityKind::Linear:
109109
return (unsigned)serialization::DifferentiabilityKind::Linear;
110110
}
111+
llvm_unreachable("covered switch");
111112
}
112113

113114
namespace {

0 commit comments

Comments
 (0)