Skip to content

Update unreachable control path annotations #7889

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
Mar 4, 2017
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
5 changes: 5 additions & 0 deletions include/swift/AST/GenericSignatureBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/MapVector.h"
#include "llvm/ADT/TinyPtrVector.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/TrailingObjects.h"
#include <functional>
#include <memory>
Expand Down Expand Up @@ -590,6 +591,8 @@ class GenericSignatureBuilder::RequirementSource final
case Concrete:
return 0;
}

llvm_unreachable("Unhandled RequirementSourceKind in switch.");
}

/// Determines whether we have been provided with an acceptable storage kind
Expand Down Expand Up @@ -618,6 +621,8 @@ class GenericSignatureBuilder::RequirementSource final
case Concrete:
return false;
}

llvm_unreachable("Unhandled RequirementSourceKind in switch.");
}

public:
Expand Down
3 changes: 3 additions & 0 deletions include/swift/AST/Requirement.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include "swift/AST/Type.h"
#include "llvm/ADT/PointerIntPair.h"
#include "llvm/Support/ErrorHandling.h"

namespace swift {

Expand Down Expand Up @@ -109,6 +110,8 @@ class Requirement {
case RequirementKind::Layout:
return Requirement(getKind(), newFirst, getLayoutConstraint());
}

llvm_unreachable("Unhandled RequirementKind in switch.");
}

/// \brief Retrieve the layout constraint.
Expand Down
33 changes: 33 additions & 0 deletions lib/AST/ASTDumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Process.h"
#include "llvm/Support/SaveAndRestore.h"
#include "llvm/Support/raw_ostream.h"
Expand Down Expand Up @@ -207,6 +208,8 @@ getSILFunctionTypeRepresentationString(SILFunctionType::Representation value) {
case SILFunctionType::Representation::WitnessMethod: return "witness_method";
case SILFunctionType::Representation::Closure: return "closure";
}

llvm_unreachable("Unhandled SILFunctionTypeRepresentation in switch.");
}
static StringRef
getAbstractStorageDeclKindString(AbstractStorageDecl::StorageKindTy value) {
Expand All @@ -230,6 +233,8 @@ getAbstractStorageDeclKindString(AbstractStorageDecl::StorageKindTy value) {
case AbstractStorageDecl::Computed:
return "computed";
}

llvm_unreachable("Unhandled AbstractStorageDecl in switch.");
}
static StringRef getImportKindString(ImportKind value) {
switch (value) {
Expand All @@ -242,6 +247,8 @@ static StringRef getImportKindString(ImportKind value) {
case ImportKind::Var: return "var";
case ImportKind::Func: return "func";
}

llvm_unreachable("Unhandled ImportKind in switch.");
}
static StringRef getAccessibilityString(Accessibility value) {
switch (value) {
Expand All @@ -251,6 +258,8 @@ static StringRef getAccessibilityString(Accessibility value) {
case Accessibility::Public: return "public";
case Accessibility::Open: return "open";
}

llvm_unreachable("Unhandled Accessibility in switch.");
}
static StringRef
getForeignErrorConventionKindString(ForeignErrorConvention::Kind value) {
Expand All @@ -261,6 +270,8 @@ getForeignErrorConventionKindString(ForeignErrorConvention::Kind value) {
case ForeignErrorConvention::NilResult: return "NilResult";
case ForeignErrorConvention::NonNilError: return "NonNilError";
}

llvm_unreachable("Unhandled ForeignErrorConvention in switch.");
}
static StringRef getDefaultArgumentKindString(DefaultArgumentKind value) {
switch (value) {
Expand All @@ -276,6 +287,8 @@ static StringRef getDefaultArgumentKindString(DefaultArgumentKind value) {
case DefaultArgumentKind::EmptyDictionary: return "[:]";
case DefaultArgumentKind::Normal: return "normal";
}

llvm_unreachable("Unhandled DefaultArgumentKind in switch.");
}
static StringRef getAccessorKindString(AccessorKind value) {
switch (value) {
Expand All @@ -288,13 +301,17 @@ static StringRef getAccessorKindString(AccessorKind value) {
case AccessorKind::IsAddressor: return "addressor";
case AccessorKind::IsMutableAddressor: return "mutableAddressor";
}

llvm_unreachable("Unhandled AccessorKind in switch.");
}
static StringRef getAccessKindString(AccessKind value) {
switch (value) {
case AccessKind::Read: return "read";
case AccessKind::Write: return "write";
case AccessKind::ReadWrite: return "readwrite";
}

llvm_unreachable("Unhandled AccessKind in switch.");
}
static StringRef
getMagicIdentifierLiteralExprKindString(MagicIdentifierLiteralExpr::Kind value) {
Expand All @@ -305,6 +322,8 @@ getMagicIdentifierLiteralExprKindString(MagicIdentifierLiteralExpr::Kind value)
case MagicIdentifierLiteralExpr::Column: return "#column";
case MagicIdentifierLiteralExpr::DSOHandle: return "#dsohandle";
}

llvm_unreachable("Unhandled MagicIdentifierLiteralExpr in switch.");
}
static StringRef
getObjCSelectorExprKindString(ObjCSelectorExpr::ObjCSelectorKind value) {
Expand All @@ -313,6 +332,8 @@ getObjCSelectorExprKindString(ObjCSelectorExpr::ObjCSelectorKind value) {
case ObjCSelectorExpr::Getter: return "getter";
case ObjCSelectorExpr::Setter: return "setter";
}

llvm_unreachable("Unhandled ObjCSelectorExpr in switch.");
}
static StringRef getAccessSemanticsString(AccessSemantics value) {
switch (value) {
Expand All @@ -321,13 +342,17 @@ static StringRef getAccessSemanticsString(AccessSemantics value) {
case AccessSemantics::DirectToAccessor: return "direct_to_accessor";
case AccessSemantics::BehaviorInitialization: return "behavior_init";
}

llvm_unreachable("Unhandled AccessSemantics in switch.");
}
static StringRef getMetatypeRepresentationString(MetatypeRepresentation value) {
switch (value) {
case MetatypeRepresentation::Thin: return "thin";
case MetatypeRepresentation::Thick: return "thick";
case MetatypeRepresentation::ObjC: return "@objc";
}

llvm_unreachable("Unhandled MetatypeRepresentation in switch.");
}
static StringRef
getStringLiteralExprEncodingString(StringLiteralExpr::Encoding value) {
Expand All @@ -336,6 +361,8 @@ getStringLiteralExprEncodingString(StringLiteralExpr::Encoding value) {
case StringLiteralExpr::UTF16: return "utf16";
case StringLiteralExpr::OneUnicodeScalar: return "unicodeScalar";
}

llvm_unreachable("Unhandled StringLiteral in switch.");
}
static StringRef getCtorInitializerKindString(CtorInitializerKind value) {
switch (value) {
Expand All @@ -344,20 +371,26 @@ static StringRef getCtorInitializerKindString(CtorInitializerKind value) {
case CtorInitializerKind::ConvenienceFactory: return "convenience_factory";
case CtorInitializerKind::Factory: return "factory";
}

llvm_unreachable("Unhandled CtorInitializerKind in switch.");
}
static StringRef getOptionalTypeKindString(OptionalTypeKind value) {
switch (value) {
case OTK_None: return "none";
case OTK_Optional: return "Optional";
case OTK_ImplicitlyUnwrappedOptional: return "ImplicitlyUnwrappedOptional";
}

llvm_unreachable("Unhandled OptionalTypeKind in switch.");
}
static StringRef getAssociativityString(Associativity value) {
switch (value) {
case Associativity::None: return "none";
case Associativity::Left: return "left";
case Associativity::Right: return "right";
}

llvm_unreachable("Unhandled Associativity in switch.");
}

//===----------------------------------------------------------------------===//
Expand Down
10 changes: 10 additions & 0 deletions lib/AST/GenericSignatureBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ bool RequirementSource::isAcceptableStorageKind(Kind kind,
return false;
}
}

llvm_unreachable("Unhandled RequirementSourceKind in switch.");
}

const void *RequirementSource::getOpaqueStorage() const {
Expand All @@ -182,6 +184,8 @@ const void *RequirementSource::getOpaqueStorage() const {
case StorageKind::AssociatedTypeDecl:
return storage.assocType;
}

llvm_unreachable("Unhandled StorageKind in switch.");
}

const void *RequirementSource::getExtraOpaqueStorage() const {
Expand Down Expand Up @@ -210,6 +214,8 @@ bool RequirementSource::isDerivedRequirement() const {
// need to keep them for the requirement signature.
return parent->kind != RequirementSignatureSelf;
}

llvm_unreachable("Unhandled RequirementSourceKind in switch.");
}

bool RequirementSource::isDerivedViaConcreteConformance() const {
Expand Down Expand Up @@ -418,6 +424,8 @@ ProtocolDecl *RequirementSource::getProtocolDecl() const {
case StorageKind::AssociatedTypeDecl:
return storage.assocType->getProtocol();
}

llvm_unreachable("Unhandled StorageKind in switch.");
}

SourceLoc RequirementSource::getLoc() const {
Expand Down Expand Up @@ -569,6 +577,8 @@ const RequirementSource *FloatingRequirementSource::getSource(
case Inferred:
return RequirementSource::forInferred(pa, storage.get<const TypeRepr *>());
}

llvm_unreachable("Unhandled FloatingPointRequirementSourceKind in switch.");
}

SourceLoc FloatingRequirementSource::getLoc() const {
Expand Down
3 changes: 3 additions & 0 deletions lib/ClangImporter/ImportName.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "clang/Sema/Lookup.h"
#include "clang/Sema/Sema.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/ErrorHandling.h"
#include <algorithm>
#include <memory>

Expand Down Expand Up @@ -79,6 +80,8 @@ unsigned importer::majorVersionNumberForNameVersion(ImportNameVersion version) {
case ImportNameVersion::Swift4:
return 4;
}

llvm_unreachable("Unhandled ImportNameVersion in switch.");
}


Expand Down
3 changes: 3 additions & 0 deletions lib/Sema/TypeCheckGeneric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "swift/AST/GenericEnvironment.h"
#include "swift/AST/Types.h"
#include "swift/Basic/Defer.h"
#include "llvm/Support/ErrorHandling.h"

using namespace swift;

Expand Down Expand Up @@ -399,6 +400,8 @@ bool TypeChecker::validateRequirement(SourceLoc whereLoc, RequirementRepr &req,
return false;
}
}

llvm_unreachable("Unhandled RequirementKind in switch.");
}

void
Expand Down
3 changes: 3 additions & 0 deletions lib/Syntax/SyntaxData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "swift/Syntax/TypeSyntax.h"
#include "swift/Syntax/StmtSyntax.h"
#include "swift/Syntax/UnknownSyntax.h"
#include "llvm/Support/ErrorHandling.h"

using namespace swift;
using namespace swift::syntax;
Expand Down Expand Up @@ -44,6 +45,8 @@ RC<SyntaxData> SyntaxData::makeDataFromRaw(RC<RawSyntax> Raw,
case SyntaxKind::Token:
llvm_unreachable("Can't make a SyntaxData from a Token!");
}

llvm_unreachable("Unhandled SyntaxKind in switch.");
}

bool SyntaxData::isType() const {
Expand Down