Skip to content

MSVC: litter the code with llvm_unreachable (NFC) #25199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions include/swift/SIL/ApplySite.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class ApplySite {
case ApplySiteKind::PartialApplyInst:
return ApplySite(cast<PartialApplyInst>(node));
}
llvm_unreachable("covered switch");
}

ApplySiteKind getKind() const { return ApplySiteKind(Inst->getKind()); }
Expand All @@ -126,6 +127,7 @@ class ApplySite {
case ApplySiteKind::TryApplyInst: \
return cast<TryApplyInst>(Inst)->OPERATION; \
} \
llvm_unreachable("covered switch"); \
} while (0)

/// Return the callee operand.
Expand Down Expand Up @@ -293,6 +295,7 @@ class ApplySite {
// apply pa2(a)
return getSubstCalleeConv().getNumSILArguments() - getNumArguments();
}
llvm_unreachable("covered switch");
}

/// Return the callee's function argument index corresponding to the given
Expand Down Expand Up @@ -325,6 +328,7 @@ class ApplySite {
case ApplySiteKind::PartialApplyInst:
llvm_unreachable("unhandled case");
}
llvm_unreachable("covered switch");
}

/// Return the applied 'self' argument value.
Expand All @@ -339,6 +343,7 @@ class ApplySite {
case ApplySiteKind::PartialApplyInst:
llvm_unreachable("unhandled case");
}
llvm_unreachable("covered switch");
}

/// Return the 'self' apply operand.
Expand All @@ -353,6 +358,7 @@ class ApplySite {
case ApplySiteKind::PartialApplyInst:
llvm_unreachable("Unhandled cast");
}
llvm_unreachable("covered switch");
}

/// Return a list of applied arguments without self.
Expand All @@ -367,6 +373,7 @@ class ApplySite {
case ApplySiteKind::PartialApplyInst:
llvm_unreachable("Unhandled case");
}
llvm_unreachable("covered switch");
}

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

FullApplySiteKind getKind() const {
Expand Down
2 changes: 2 additions & 0 deletions include/swift/SIL/Consumption.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ inline bool shouldDestroyOnFailure(CastConsumptionKind kind) {
case CastConsumptionKind::BorrowAlways:
return false;
}
llvm_unreachable("covered switch");
}

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

} // end namespace swift
Expand Down
12 changes: 12 additions & 0 deletions include/swift/SIL/DynamicCasts.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ struct SILDynamicCastInst {
case SILDynamicCastKind::UnconditionalCheckedCastValueInst:
llvm_unreachable("unsupported");
}
llvm_unreachable("covered switch");
}

CastConsumptionKind getConsumptionKind() const {
Expand Down Expand Up @@ -226,6 +227,7 @@ struct SILDynamicCastInst {
case SILDynamicCastKind::UnconditionalCheckedCastValueInst:
llvm_unreachable("unsupported");
}
llvm_unreachable("covered switch");
}

Optional<ProfileCounter> getSuccessBlockCount() {
Expand All @@ -242,6 +244,7 @@ struct SILDynamicCastInst {
case SILDynamicCastKind::UnconditionalCheckedCastValueInst:
llvm_unreachable("unsupported");
}
llvm_unreachable("covered switch");
}

const SILBasicBlock *getSuccessBlock() const {
Expand All @@ -262,6 +265,7 @@ struct SILDynamicCastInst {
case SILDynamicCastKind::UnconditionalCheckedCastValueInst:
llvm_unreachable("unsupported");
}
llvm_unreachable("covered switch");
}

Optional<ProfileCounter> getFailureBlockCount() {
Expand All @@ -278,6 +282,7 @@ struct SILDynamicCastInst {
case SILDynamicCastKind::UnconditionalCheckedCastValueInst:
llvm_unreachable("unsupported");
}
llvm_unreachable("covered switch");
}

const SILBasicBlock *getFailureBlock() const {
Expand All @@ -299,6 +304,7 @@ struct SILDynamicCastInst {
case SILDynamicCastKind::UnconditionalCheckedCastValueInst:
llvm_unreachable("unsupported");
}
llvm_unreachable("covered switch");
}

// Returns the success value.
Expand All @@ -320,6 +326,7 @@ struct SILDynamicCastInst {
case SILDynamicCastKind::UnconditionalCheckedCastValueInst:
llvm_unreachable("unimplemented");
}
llvm_unreachable("covered switch");
}

CanType getSourceType() const {
Expand All @@ -337,6 +344,7 @@ struct SILDynamicCastInst {
case SILDynamicCastKind::UnconditionalCheckedCastValueInst:
llvm_unreachable("unsupported");
}
llvm_unreachable("covered switch");
}

SILType getLoweredSourceType() const {
Expand Down Expand Up @@ -371,6 +379,7 @@ struct SILDynamicCastInst {
case SILDynamicCastKind::UnconditionalCheckedCastValueInst:
llvm_unreachable("unimplemented");
}
llvm_unreachable("covered switch");
}

SILType getLoweredTargetType() const {
Expand All @@ -391,6 +400,7 @@ struct SILDynamicCastInst {
case SILDynamicCastKind::UnconditionalCheckedCastValueInst:
llvm_unreachable("unsupported");
}
llvm_unreachable("covered switch");
}

bool isSourceTypeExact() const {
Expand All @@ -404,6 +414,7 @@ struct SILDynamicCastInst {
case SILDynamicCastKind::UnconditionalCheckedCastValueInst:
llvm_unreachable("unsupported");
}
llvm_unreachable("covered switch");
}

SILLocation getLocation() const { return inst->getLoc(); }
Expand Down Expand Up @@ -475,6 +486,7 @@ struct SILDynamicCastInst {
case SILDynamicCastKind::UnconditionalCheckedCastValueInst:
llvm_unreachable("unsupported");
}
llvm_unreachable("covered switch");
}

bool canUseScalarCheckedCastInstructions() const {
Expand Down
1 change: 1 addition & 0 deletions include/swift/SIL/MemAccessUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ class AccessedStorage {
return value == other.value
&& getElementIndex() == other.getElementIndex();
}
llvm_unreachable("covered switch");
}

/// Return true if the storage is guaranteed local.
Expand Down
1 change: 1 addition & 0 deletions include/swift/SIL/SILValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ struct ValueOwnershipKind {
case ValueOwnershipKind::Owned:
return UseLifetimeConstraint::MustBeInvalidated;
}
llvm_unreachable("covered switch");
}

/// Returns true if \p Other can be merged successfully with this, implying
Expand Down
1 change: 1 addition & 0 deletions lib/AST/ASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4470,6 +4470,7 @@ VarDecl *VarDecl::getOriginalWrappedProperty(
case PropertyWrapperSynthesizedPropertyKind::StorageWrapper:
return this == wrapperInfo.storageWrapperVar ? original : nullptr;
}
llvm_unreachable("covered switch");
}

void VarDecl::setOriginalWrappedProperty(VarDecl *originalProperty) {
Expand Down
3 changes: 3 additions & 0 deletions lib/AST/ASTDemangler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ getParameterConvention(ImplParameterConvention conv) {
case Demangle::ImplParameterConvention::Direct_Guaranteed:
return ParameterConvention::Direct_Guaranteed;
}
llvm_unreachable("covered switch");
}

static ResultConvention getResultConvention(ImplResultConvention conv) {
Expand All @@ -443,6 +444,7 @@ static ResultConvention getResultConvention(ImplResultConvention conv) {
case Demangle::ImplResultConvention::Autoreleased:
return ResultConvention::Autoreleased;
}
llvm_unreachable("covered switch");
}

Type ASTBuilder::createImplFunctionType(
Expand Down Expand Up @@ -539,6 +541,7 @@ getMetatypeRepresentation(ImplMetatypeRepresentation repr) {
case Demangle::ImplMetatypeRepresentation::ObjC:
return MetatypeRepresentation::ObjC;
}
llvm_unreachable("covered switch");
}

Type ASTBuilder::createExistentialMetatypeType(Type instance,
Expand Down
1 change: 1 addition & 0 deletions lib/AST/Decl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6472,6 +6472,7 @@ bool AbstractFunctionDecl::hasInlinableBodyText() const {
case BodyKind::MemberwiseInitializer:
return false;
}
llvm_unreachable("covered switch");
}

StringRef AbstractFunctionDecl::getInlinableBodyText(
Expand Down
1 change: 1 addition & 0 deletions lib/AST/DiagnosticConsumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ FileSpecificDiagnosticConsumer::findSubconsumer(
case DiagnosticKind::Note:
return SubconsumerForSubsequentNotes;
}
llvm_unreachable("covered switch");
}

Optional<FileSpecificDiagnosticConsumer::Subconsumer *>
Expand Down
1 change: 1 addition & 0 deletions lib/IRGen/GenCast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ getDynamicCastArguments(IRGenFunction &IGF,
return llvm::makeArrayRef(argsBuf, n-3);
break;
}
llvm_unreachable("covered switch");
}

/// Emit a checked unconditional downcast of a class value.
Expand Down
1 change: 1 addition & 0 deletions lib/IRGen/GenMeta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1721,6 +1721,7 @@ namespace {
case SILLinkage::PublicNonABI:
return false;
}
llvm_unreachable("covered switch");
}

GenericSignature *getGenericSignature() {
Expand Down
1 change: 1 addition & 0 deletions lib/Parse/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ static LexerMode sourceFileKindToLexerMode(SourceFileKind kind) {
case swift::SourceFileKind::REPL:
return LexerMode::Swift;
}
llvm_unreachable("covered switch");
}

Parser::Parser(unsigned BufferID, SourceFile &SF, SILParserTUStateBase *SIL,
Expand Down
2 changes: 2 additions & 0 deletions lib/SIL/SILConstants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ SymbolicValue::Kind SymbolicValue::getKind() const {
case RK_DerivedAddress:
return Address;
}
llvm_unreachable("covered switch");
}

/// Clone this SymbolicValue into the specified ASTContext and return the new
Expand Down Expand Up @@ -179,6 +180,7 @@ SymbolicValue::cloneInto(SymbolicValueAllocator &allocator) const {
return getAddress(newMemObject, accessPath, allocator);
}
}
llvm_unreachable("covered switch");
}

//===----------------------------------------------------------------------===//
Expand Down
1 change: 1 addition & 0 deletions lib/SILGen/SILGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1372,6 +1372,7 @@ void SILGenModule::visitVarDecl(VarDecl *vd) {
#include "swift/AST/AccessorKinds.def"
llvm_unreachable("not an opaque accessor");
}
llvm_unreachable("covered switch");
}();
if (!shouldEmit) return;

Expand Down
1 change: 1 addition & 0 deletions lib/SILGen/SILGenConvert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,7 @@ SILGenFunction::emitOpenExistential(
case ExistentialRepresentation::None:
llvm_unreachable("not existential");
}
llvm_unreachable("covered switch");
}

ManagedValue SILGenFunction::manageOpaqueValue(ManagedValue value,
Expand Down
1 change: 1 addition & 0 deletions lib/SILGen/SILGenExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3240,6 +3240,7 @@ static ProtocolConformance *mapConformanceOutOfContext(
.mapReplacementTypesOutOfContext());
}
}
llvm_unreachable("covered switch");
}

/// Map the given protocol conformance out of context, replacing archetypes
Expand Down
2 changes: 2 additions & 0 deletions lib/SILGen/SILGenPattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1370,6 +1370,7 @@ getManagedSubobject(SILGenFunction &SGF, SILValue value,
case CastConsumptionKind::TakeOnSuccess:
return {SGF.emitManagedRValueWithCleanup(value, valueTL), consumption};
}
llvm_unreachable("covered switch");
}

static ConsumableManagedValue
Expand Down Expand Up @@ -1539,6 +1540,7 @@ emitTupleDispatch(ArrayRef<RowToSpecialize> rows, ConsumableManagedValue src,
"Borrow always can only occur along object only code paths");
}
}
llvm_unreachable("covered switch");
}());

// If we aren't loadable, add to the unforward array.
Expand Down
1 change: 1 addition & 0 deletions lib/SILOptimizer/IPO/ClosureSpecializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1048,6 +1048,7 @@ static bool canSpecializeFullApplySite(FullApplySiteKind kind) {
case FullApplySiteKind::BeginApplyInst:
return false;
}
llvm_unreachable("covered switch");
}

bool SILClosureSpecializerTransform::gatherCallSites(
Expand Down
1 change: 1 addition & 0 deletions lib/SILOptimizer/Mandatory/PMOMemoryUseCollector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ bool ElementUseCollector::collectUses(SILValue Pointer) {
case StoreOwnershipQualifier::Trivial:
return PMOUseKind::InitOrAssign;
}
llvm_unreachable("covered switch");
})();
Uses.emplace_back(si, kind);
continue;
Expand Down
1 change: 1 addition & 0 deletions lib/SILOptimizer/Mandatory/SemanticARCOpts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ static bool isWrittenTo(SILFunction &f, SILValue value) {
case AccessedStorage::Argument:
return mayFunctionMutateArgument(storage, f);
}
llvm_unreachable("covered switch");
}

// Convert a load [copy] from unique storage [read] that has all uses that can
Expand Down
1 change: 1 addition & 0 deletions lib/SILOptimizer/Utils/Devirtualize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,7 @@ static ApplySite replaceApplySite(SILBuilder &B, SILLocation Loc,
return replacePartialApplyInst(B, Loc, OldPAI, NewFn, NewSubs, NewArgs);
}
}
llvm_unreachable("covered switch");
}

/// Delete an apply site that's been successfully devirtualized.
Expand Down
2 changes: 2 additions & 0 deletions lib/Sema/CSFix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ bool AllowInvalidInitRef::diagnose(Expr *root, bool asNote) const {
return failure.diagnose(asNote);
}
}
llvm_unreachable("covered switch");
}

AllowInvalidInitRef *AllowInvalidInitRef::dynamicOnMetatype(
Expand Down Expand Up @@ -478,6 +479,7 @@ bool AllowInvalidRefInKeyPath::diagnose(Expr *root, bool asNote) const {
return failure.diagnose(asNote);
}
}
llvm_unreachable("covered switch");
}

AllowInvalidRefInKeyPath *
Expand Down
1 change: 1 addition & 0 deletions lib/Sema/CSFix.h
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,7 @@ class AllowInvalidRefInKeyPath final : public ConstraintFix {
case RefKind::Method:
return "allow reference to a method as a key path component";
}
llvm_unreachable("covered switch");
}

bool diagnose(Expr *root, bool asNote = false) const override;
Expand Down
1 change: 1 addition & 0 deletions lib/Sema/CSSimplify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1998,6 +1998,7 @@ static ConstraintFix *fixRequirementFailure(ConstraintSystem &cs, Type type1,
case RequirementKind::Conformance:
return MissingConformance::forRequirement(cs, type1, type2, reqLoc);
}
llvm_unreachable("covered switch");
}

/// Attempt to repair typing failures and record fixes if needed.
Expand Down
1 change: 1 addition & 0 deletions lib/Sema/CSSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2035,6 +2035,7 @@ static Constraint *tryOptimizeGenericDisjunction(
case Comparison::Unordered:
return nullptr;
}
llvm_unreachable("covered switch");
}

void ConstraintSystem::partitionDisjunction(
Expand Down
1 change: 1 addition & 0 deletions lib/Sema/TypeCheckDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1181,6 +1181,7 @@ doesAccessorNeedDynamicAttribute(AccessorDecl *accessor, Evaluator &evaluator) {
return isStorageDynamic(evaluator, accessor);
return false;
}
llvm_unreachable("covered switch");
}

llvm::Expected<bool>
Expand Down
Loading