Skip to content

Commit 25f437e

Browse files
committed
mark some switches as covered (NFCI)
Unfortunately, MSVC does not detect covered switches as clang. Mark some of the switches as covered to avoid an unnecessary warning from MSVC.
1 parent 0634ffc commit 25f437e

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

0 commit comments

Comments
 (0)