More dead code removal (using -Wunreachable-code)

llvm-svn: 148577
This commit is contained in:
David Blaikie 2012-01-20 21:50:17 +00:00
parent f2a2f5f2bf
commit e4d798f078
50 changed files with 107 additions and 223 deletions

View File

@ -332,7 +332,6 @@ static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context,
} }
llvm_unreachable("Invalid template argument kind"); llvm_unreachable("Invalid template argument kind");
return true;
} }
/// \brief Determine structural equivalence for the common part of array /// \brief Determine structural equivalence for the common part of array
@ -1357,8 +1356,8 @@ QualType ASTNodeImporter::VisitBuiltinType(const BuiltinType *T) {
// wchar_t? // wchar_t?
return Importer.getToContext().WCharTy; return Importer.getToContext().WCharTy;
} }
return QualType(); llvm_unreachable("Invalid BuiltinType Kind!");
} }
QualType ASTNodeImporter::VisitComplexType(const ComplexType *T) { QualType ASTNodeImporter::VisitComplexType(const ComplexType *T) {
@ -1983,7 +1982,6 @@ ASTNodeImporter::ImportTemplateArgument(const TemplateArgument &From) {
} }
llvm_unreachable("Invalid template argument kind"); llvm_unreachable("Invalid template argument kind");
return TemplateArgument();
} }
bool ASTNodeImporter::ImportTemplateArguments(const TemplateArgument *FromArgs, bool ASTNodeImporter::ImportTemplateArguments(const TemplateArgument *FromArgs,
@ -4214,7 +4212,6 @@ NestedNameSpecifier *ASTImporter::Import(NestedNameSpecifier *FromNNS) {
} }
llvm_unreachable("Invalid nested name specifier kind"); llvm_unreachable("Invalid nested name specifier kind");
return 0;
} }
NestedNameSpecifierLoc ASTImporter::Import(NestedNameSpecifierLoc FromNNS) { NestedNameSpecifierLoc ASTImporter::Import(NestedNameSpecifierLoc FromNNS) {
@ -4309,7 +4306,6 @@ TemplateName ASTImporter::Import(TemplateName From) {
} }
llvm_unreachable("Invalid template name kind"); llvm_unreachable("Invalid template name kind");
return TemplateName();
} }
SourceLocation ASTImporter::Import(SourceLocation FromLoc) { SourceLocation ASTImporter::Import(SourceLocation FromLoc) {
@ -4453,8 +4449,7 @@ DeclarationName ASTImporter::Import(DeclarationName FromName) {
return DeclarationName::getUsingDirectiveName(); return DeclarationName::getUsingDirectiveName();
} }
// Silence bogus GCC warning llvm_unreachable("Invalid DeclarationName Kind!");
return DeclarationName();
} }
IdentifierInfo *ASTImporter::Import(const IdentifierInfo *FromId) { IdentifierInfo *ASTImporter::Import(const IdentifierInfo *FromId) {

View File

@ -48,8 +48,6 @@ static llvm::Optional<Visibility> getVisibilityOf(const Decl *D) {
case VisibilityAttr::Protected: case VisibilityAttr::Protected:
return ProtectedVisibility; return ProtectedVisibility;
} }
return DefaultVisibility;
} }
// If we're on Mac OS X, an 'availability' for Mac OS X attribute // If we're on Mac OS X, an 'availability' for Mac OS X attribute
@ -1141,7 +1139,6 @@ const char *VarDecl::getStorageClassSpecifierString(StorageClass SC) {
} }
llvm_unreachable("Invalid storage class"); llvm_unreachable("Invalid storage class");
return 0;
} }
VarDecl *VarDecl::Create(ASTContext &C, DeclContext *DC, VarDecl *VarDecl::Create(ASTContext &C, DeclContext *DC,

View File

@ -529,7 +529,7 @@ unsigned Decl::getIdentifierNamespaceForKind(Kind DeclKind) {
return 0; return 0;
} }
return 0; llvm_unreachable("Invalid DeclKind!");
} }
void Decl::setAttrs(const AttrVec &attrs) { void Decl::setAttrs(const AttrVec &attrs) {

View File

@ -125,8 +125,8 @@ int DeclarationName::compare(DeclarationName LHS, DeclarationName RHS) {
case DeclarationName::CXXUsingDirective: case DeclarationName::CXXUsingDirective:
return 0; return 0;
} }
return 0; llvm_unreachable("Invalid DeclarationName Kind!");
} }
} // end namespace clang } // end namespace clang
@ -189,7 +189,6 @@ DeclarationName::NameKind DeclarationName::getNameKind() const {
return ObjCMultiArgSelector; return ObjCMultiArgSelector;
} }
break;
} }
// Can't actually get here. // Can't actually get here.

View File

@ -165,7 +165,6 @@ static StringRef getTypeKindName(Type *T) {
} }
llvm_unreachable("unknown type kind!"); llvm_unreachable("unknown type kind!");
return "unknown_type";
} }
struct XMLDumper : public XMLDeclVisitor<XMLDumper>, struct XMLDumper : public XMLDeclVisitor<XMLDumper>,

View File

@ -124,7 +124,6 @@ SourceLocation Expr::getExprLoc() const {
#include "clang/AST/StmtNodes.inc" #include "clang/AST/StmtNodes.inc"
} }
llvm_unreachable("unknown statement kind"); llvm_unreachable("unknown statement kind");
return SourceLocation();
} }
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
@ -1213,7 +1212,6 @@ const char *CastExpr::getCastKindName() const {
} }
llvm_unreachable("Unhandled cast kind!"); llvm_unreachable("Unhandled cast kind!");
return 0;
} }
Expr *CastExpr::getSubExprAsWritten() { Expr *CastExpr::getSubExprAsWritten() {
@ -1255,7 +1253,6 @@ CXXBaseSpecifier **CastExpr::path_buffer() {
#include "clang/AST/StmtNodes.inc" #include "clang/AST/StmtNodes.inc"
default: default:
llvm_unreachable("non-cast expressions not possible here"); llvm_unreachable("non-cast expressions not possible here");
return 0;
} }
} }
@ -1343,7 +1340,7 @@ const char *BinaryOperator::getOpcodeStr(Opcode Op) {
case BO_Comma: return ","; case BO_Comma: return ",";
} }
return ""; llvm_unreachable("Invalid OpCode!");
} }
BinaryOperatorKind BinaryOperatorKind
@ -3015,7 +3012,7 @@ SourceRange ObjCMessageExpr::getReceiverRange() const {
return getSuperLoc(); return getSuperLoc();
} }
return SourceLocation(); llvm_unreachable("Invalid ReceiverKind!");
} }
Selector ObjCMessageExpr::getSelector() const { Selector ObjCMessageExpr::getSelector() const {
@ -3064,8 +3061,8 @@ StringRef ObjCBridgedCastExpr::getBridgeKindName() const {
case OBC_BridgeRetained: case OBC_BridgeRetained:
return "__bridge_retained"; return "__bridge_retained";
} }
return "__bridge"; llvm_unreachable("Invalid BridgeKind!");
} }
bool ChooseExpr::isConditionTrue(const ASTContext &C) const { bool ChooseExpr::isConditionTrue(const ASTContext &C) const {

View File

@ -47,7 +47,6 @@ static Cl::Kinds ClassifyExprValueKind(const LangOptions &Lang,
return Cl::CL_XValue; return Cl::CL_XValue;
} }
llvm_unreachable("Invalid value category of implicit cast."); llvm_unreachable("Invalid value category of implicit cast.");
return Cl::CL_PRValue;
} }
Cl Expr::ClassifyImpl(ASTContext &Ctx, SourceLocation *Loc) const { Cl Expr::ClassifyImpl(ASTContext &Ctx, SourceLocation *Loc) const {
@ -99,7 +98,6 @@ static Cl::Kinds ClassifyInternal(ASTContext &Ctx, const Expr *E) {
#define EXPR(Kind, Base) #define EXPR(Kind, Base)
#include "clang/AST/StmtNodes.inc" #include "clang/AST/StmtNodes.inc"
llvm_unreachable("cannot classify a statement"); llvm_unreachable("cannot classify a statement");
break;
// First come the expressions that are always lvalues, unconditionally. // First come the expressions that are always lvalues, unconditionally.
case Expr::ObjCIsaExprClass: case Expr::ObjCIsaExprClass:
@ -371,7 +369,6 @@ static Cl::Kinds ClassifyInternal(ASTContext &Ctx, const Expr *E) {
} }
llvm_unreachable("unhandled expression kind in classification"); llvm_unreachable("unhandled expression kind in classification");
return Cl::CL_LValue;
} }
/// ClassifyDecl - Return the classification of an expression referencing the /// ClassifyDecl - Return the classification of an expression referencing the

View File

@ -3756,7 +3756,6 @@ static int EvaluateBuiltinClassifyType(const CallExpr *E) {
return union_type_class; return union_type_class;
else // FIXME: offset_type_class, method_type_class, & lang_type_class? else // FIXME: offset_type_class, method_type_class, & lang_type_class?
llvm_unreachable("CallExpr::isBuiltinClassifyType(): unimplemented type"); llvm_unreachable("CallExpr::isBuiltinClassifyType(): unimplemented type");
return -1;
} }
/// EvaluateBuiltinConstantPForLValue - Determine the result of /// EvaluateBuiltinConstantPForLValue - Determine the result of
@ -4385,7 +4384,6 @@ bool IntExprEvaluator::VisitUnaryExprOrTypeTraitExpr(
} }
llvm_unreachable("unknown expr/type trait"); llvm_unreachable("unknown expr/type trait");
return Error(E);
} }
bool IntExprEvaluator::VisitOffsetOfExpr(const OffsetOfExpr *OOE) { bool IntExprEvaluator::VisitOffsetOfExpr(const OffsetOfExpr *OOE) {
@ -4427,7 +4425,6 @@ bool IntExprEvaluator::VisitOffsetOfExpr(const OffsetOfExpr *OOE) {
case OffsetOfExpr::OffsetOfNode::Identifier: case OffsetOfExpr::OffsetOfNode::Identifier:
llvm_unreachable("dependent __builtin_offsetof"); llvm_unreachable("dependent __builtin_offsetof");
return Error(OOE);
case OffsetOfExpr::OffsetOfNode::Base: { case OffsetOfExpr::OffsetOfNode::Base: {
CXXBaseSpecifier *BaseSpec = ON.getBase(); CXXBaseSpecifier *BaseSpec = ON.getBase();
@ -4618,7 +4615,6 @@ bool IntExprEvaluator::VisitCastExpr(const CastExpr *E) {
} }
llvm_unreachable("unknown cast resulting in integral value"); llvm_unreachable("unknown cast resulting in integral value");
return Error(E);
} }
bool IntExprEvaluator::VisitUnaryReal(const UnaryOperator *E) { bool IntExprEvaluator::VisitUnaryReal(const UnaryOperator *E) {
@ -4881,8 +4877,6 @@ bool FloatExprEvaluator::VisitCastExpr(const CastExpr *E) {
return true; return true;
} }
} }
return Error(E);
} }
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
@ -5092,7 +5086,6 @@ bool ComplexExprEvaluator::VisitCastExpr(const CastExpr *E) {
} }
llvm_unreachable("unknown cast resulting in complex value"); llvm_unreachable("unknown cast resulting in complex value");
return Error(E);
} }
bool ComplexExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) { bool ComplexExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
@ -5928,8 +5921,7 @@ static ICEDiag CheckICE(const Expr* E, ASTContext &Ctx) {
} }
} }
// Silence a GCC warning llvm_unreachable("Invalid StmtClass!");
return ICEDiag(2, E->getLocStart());
} }
/// Evaluate an expression as a C++11 integral constant expression. /// Evaluate an expression as a C++11 integral constant expression.

View File

@ -1370,7 +1370,6 @@ void CXXNameMangler::mangleType(TemplateName TN) {
case TemplateName::OverloadedTemplate: case TemplateName::OverloadedTemplate:
llvm_unreachable("can't mangle an overloaded template name as a <type>"); llvm_unreachable("can't mangle an overloaded template name as a <type>");
break;
case TemplateName::DependentTemplate: { case TemplateName::DependentTemplate: {
const DependentTemplateName *Dependent = TN.getAsDependentTemplateName(); const DependentTemplateName *Dependent = TN.getAsDependentTemplateName();
@ -1741,7 +1740,6 @@ void CXXNameMangler::mangleType(const BuiltinType *T) {
#include "clang/AST/BuiltinTypes.def" #include "clang/AST/BuiltinTypes.def"
case BuiltinType::Dependent: case BuiltinType::Dependent:
llvm_unreachable("mangling a placeholder type"); llvm_unreachable("mangling a placeholder type");
break;
case BuiltinType::ObjCId: Out << "11objc_object"; break; case BuiltinType::ObjCId: Out << "11objc_object"; break;
case BuiltinType::ObjCClass: Out << "10objc_class"; break; case BuiltinType::ObjCClass: Out << "10objc_class"; break;
case BuiltinType::ObjCSel: Out << "13objc_selector"; break; case BuiltinType::ObjCSel: Out << "13objc_selector"; break;
@ -2226,7 +2224,6 @@ recurse:
case Expr::ParenListExprClass: case Expr::ParenListExprClass:
case Expr::CXXScalarValueInitExprClass: case Expr::CXXScalarValueInitExprClass:
llvm_unreachable("unexpected statement kind"); llvm_unreachable("unexpected statement kind");
break;
// FIXME: invent manglings for all these. // FIXME: invent manglings for all these.
case Expr::BlockExprClass: case Expr::BlockExprClass:

View File

@ -130,7 +130,7 @@ NestedNameSpecifier::SpecifierKind NestedNameSpecifier::getKind() const {
return TypeSpecWithTemplate; return TypeSpecWithTemplate;
} }
return Global; llvm_unreachable("Invalid NNS Kind!");
} }
/// \brief Retrieve the namespace stored in this nested name /// \brief Retrieve the namespace stored in this nested name
@ -170,8 +170,7 @@ bool NestedNameSpecifier::isDependent() const {
return getAsType()->isDependentType(); return getAsType()->isDependentType();
} }
// Necessary to suppress a GCC warning. llvm_unreachable("Invalid NNS Kind!");
return false;
} }
/// \brief Whether this nested name specifier refers to a dependent /// \brief Whether this nested name specifier refers to a dependent
@ -191,9 +190,8 @@ bool NestedNameSpecifier::isInstantiationDependent() const {
case TypeSpecWithTemplate: case TypeSpecWithTemplate:
return getAsType()->isInstantiationDependentType(); return getAsType()->isInstantiationDependentType();
} }
// Necessary to suppress a GCC warning. llvm_unreachable("Invalid NNS Kind!");
return false;
} }
bool NestedNameSpecifier::containsUnexpandedParameterPack() const { bool NestedNameSpecifier::containsUnexpandedParameterPack() const {
@ -211,8 +209,7 @@ bool NestedNameSpecifier::containsUnexpandedParameterPack() const {
return getAsType()->containsUnexpandedParameterPack(); return getAsType()->containsUnexpandedParameterPack();
} }
// Necessary to suppress a GCC warning. llvm_unreachable("Invalid NNS Kind!");
return false;
} }
/// \brief Print this nested name specifier to the given output /// \brief Print this nested name specifier to the given output
@ -382,8 +379,8 @@ SourceRange NestedNameSpecifierLoc::getLocalSourceRange() const {
LoadSourceLocation(Data, Offset + sizeof(void*))); LoadSourceLocation(Data, Offset + sizeof(void*)));
} }
} }
return SourceRange(); llvm_unreachable("Invalid NNS Kind!");
} }
TypeLoc NestedNameSpecifierLoc::getTypeLoc() const { TypeLoc NestedNameSpecifierLoc::getTypeLoc() const {

View File

@ -164,7 +164,6 @@ Stmt::child_range Stmt::children() {
#include "clang/AST/StmtNodes.inc" #include "clang/AST/StmtNodes.inc"
} }
llvm_unreachable("unknown statement kind!"); llvm_unreachable("unknown statement kind!");
return child_range();
} }
SourceRange Stmt::getSourceRange() const { SourceRange Stmt::getSourceRange() const {
@ -177,7 +176,6 @@ SourceRange Stmt::getSourceRange() const {
#include "clang/AST/StmtNodes.inc" #include "clang/AST/StmtNodes.inc"
} }
llvm_unreachable("unknown statement kind!"); llvm_unreachable("unknown statement kind!");
return SourceRange();
} }
void CompoundStmt::setStmts(ASTContext &C, Stmt **Stmts, unsigned NumStmts) { void CompoundStmt::setStmts(ASTContext &C, Stmt **Stmts, unsigned NumStmts) {

View File

@ -503,7 +503,6 @@ static Stmt::StmtClass DecodeOperatorCall(const CXXOperatorCallExpr *S,
case OO_Conditional: case OO_Conditional:
case NUM_OVERLOADED_OPERATORS: case NUM_OVERLOADED_OPERATORS:
llvm_unreachable("Invalid operator call kind"); llvm_unreachable("Invalid operator call kind");
return Stmt::ArraySubscriptExprClass;
case OO_Plus: case OO_Plus:
if (S->getNumArgs() == 1) { if (S->getNumArgs() == 1) {

View File

@ -100,7 +100,7 @@ bool TemplateArgument::isDependent() const {
return false; return false;
} }
return false; llvm_unreachable("Invalid TemplateArgument Kind!");
} }
bool TemplateArgument::isInstantiationDependent() const { bool TemplateArgument::isInstantiationDependent() const {
@ -137,8 +137,8 @@ bool TemplateArgument::isInstantiationDependent() const {
return false; return false;
} }
return false; llvm_unreachable("Invalid TemplateArgument Kind!");
} }
bool TemplateArgument::isPackExpansion() const { bool TemplateArgument::isPackExpansion() const {
@ -159,8 +159,8 @@ bool TemplateArgument::isPackExpansion() const {
case Expression: case Expression:
return isa<PackExpansionExpr>(getAsExpr()); return isa<PackExpansionExpr>(getAsExpr());
} }
return false; llvm_unreachable("Invalid TemplateArgument Kind!");
} }
bool TemplateArgument::containsUnexpandedParameterPack() const { bool TemplateArgument::containsUnexpandedParameterPack() const {
@ -278,8 +278,7 @@ bool TemplateArgument::structurallyEquals(const TemplateArgument &Other) const {
return true; return true;
} }
// Suppress warnings. llvm_unreachable("Invalid TemplateArgument Kind!");
return false;
} }
TemplateArgument TemplateArgument::getPackExpansionPattern() const { TemplateArgument TemplateArgument::getPackExpansionPattern() const {
@ -302,8 +301,8 @@ TemplateArgument TemplateArgument::getPackExpansionPattern() const {
case Template: case Template:
return TemplateArgument(); return TemplateArgument();
} }
return TemplateArgument(); llvm_unreachable("Invalid TemplateArgument Kind!");
} }
void TemplateArgument::print(const PrintingPolicy &Policy, void TemplateArgument::print(const PrintingPolicy &Policy,
@ -412,8 +411,7 @@ SourceRange TemplateArgumentLoc::getSourceRange() const {
return SourceRange(); return SourceRange();
} }
// Silence bonus gcc warning. llvm_unreachable("Invalid TemplateArgument Kind!");
return SourceRange();
} }
TemplateArgumentLoc TemplateArgumentLoc
@ -474,8 +472,8 @@ TemplateArgumentLoc::getPackExpansionPattern(SourceLocation &Ellipsis,
case TemplateArgument::Null: case TemplateArgument::Null:
return TemplateArgumentLoc(); return TemplateArgumentLoc();
} }
return TemplateArgumentLoc(); llvm_unreachable("Invalid TemplateArgument Kind!");
} }
const DiagnosticBuilder &clang::operator<<(const DiagnosticBuilder &DB, const DiagnosticBuilder &clang::operator<<(const DiagnosticBuilder &DB,
@ -525,8 +523,8 @@ const DiagnosticBuilder &clang::operator<<(const DiagnosticBuilder &DB,
return DB << OS.str(); return DB << OS.str();
} }
} }
return DB; llvm_unreachable("Invalid TemplateArgument Kind!");
} }
const ASTTemplateArgumentListInfo * const ASTTemplateArgumentListInfo *

View File

@ -1364,7 +1364,6 @@ TypeWithKeyword::getTagTypeKindForTypeSpec(unsigned TypeSpec) {
} }
llvm_unreachable("Type specifier is not a tag type kind."); llvm_unreachable("Type specifier is not a tag type kind.");
return TTK_Union;
} }
ElaboratedTypeKeyword ElaboratedTypeKeyword
@ -1419,7 +1418,6 @@ TypeWithKeyword::getKeywordName(ElaboratedTypeKeyword Keyword) {
} }
llvm_unreachable("Unknown elaborated type keyword."); llvm_unreachable("Unknown elaborated type keyword.");
return "";
} }
DependentTemplateSpecializationType::DependentTemplateSpecializationType( DependentTemplateSpecializationType::DependentTemplateSpecializationType(
@ -1479,7 +1477,6 @@ const char *Type::getTypeClassName() const {
} }
llvm_unreachable("Invalid type class."); llvm_unreachable("Invalid type class.");
return 0;
} }
const char *BuiltinType::getName(const PrintingPolicy &Policy) const { const char *BuiltinType::getName(const PrintingPolicy &Policy) const {
@ -1521,7 +1518,6 @@ const char *BuiltinType::getName(const PrintingPolicy &Policy) const {
} }
llvm_unreachable("Invalid builtin type."); llvm_unreachable("Invalid builtin type.");
return 0;
} }
QualType QualType::getNonLValueExprType(ASTContext &Context) const { QualType QualType::getNonLValueExprType(ASTContext &Context) const {
@ -1544,7 +1540,6 @@ StringRef FunctionType::getNameForCallConv(CallingConv CC) {
switch (CC) { switch (CC) {
case CC_Default: case CC_Default:
llvm_unreachable("no name for default cc"); llvm_unreachable("no name for default cc");
return "";
case CC_C: return "cdecl"; case CC_C: return "cdecl";
case CC_X86StdCall: return "stdcall"; case CC_X86StdCall: return "stdcall";
@ -1556,7 +1551,6 @@ StringRef FunctionType::getNameForCallConv(CallingConv CC) {
} }
llvm_unreachable("Invalid calling convention."); llvm_unreachable("Invalid calling convention.");
return "";
} }
FunctionProtoType::FunctionProtoType(QualType result, const QualType *args, FunctionProtoType::FunctionProtoType(QualType result, const QualType *args,

View File

@ -196,57 +196,54 @@ SourceRange TypeOfExprTypeLoc::getLocalSourceRange() const {
TypeSpecifierType BuiltinTypeLoc::getWrittenTypeSpec() const { TypeSpecifierType BuiltinTypeLoc::getWrittenTypeSpec() const {
if (needsExtraLocalData()) if (needsExtraLocalData())
return static_cast<TypeSpecifierType>(getWrittenBuiltinSpecs().Type); return static_cast<TypeSpecifierType>(getWrittenBuiltinSpecs().Type);
else { switch (getTypePtr()->getKind()) {
switch (getTypePtr()->getKind()) { case BuiltinType::Void:
case BuiltinType::Void: return TST_void;
return TST_void; case BuiltinType::Bool:
case BuiltinType::Bool: return TST_bool;
return TST_bool; case BuiltinType::Char_U:
case BuiltinType::Char_U: case BuiltinType::Char_S:
case BuiltinType::Char_S: return TST_char;
return TST_char; case BuiltinType::Char16:
case BuiltinType::Char16: return TST_char16;
return TST_char16; case BuiltinType::Char32:
case BuiltinType::Char32: return TST_char32;
return TST_char32; case BuiltinType::WChar_S:
case BuiltinType::WChar_S: case BuiltinType::WChar_U:
case BuiltinType::WChar_U: return TST_wchar;
return TST_wchar; case BuiltinType::UChar:
case BuiltinType::UShort:
case BuiltinType::UChar: case BuiltinType::UInt:
case BuiltinType::UShort: case BuiltinType::ULong:
case BuiltinType::UInt: case BuiltinType::ULongLong:
case BuiltinType::ULong: case BuiltinType::UInt128:
case BuiltinType::ULongLong: case BuiltinType::SChar:
case BuiltinType::UInt128: case BuiltinType::Short:
case BuiltinType::SChar: case BuiltinType::Int:
case BuiltinType::Short: case BuiltinType::Long:
case BuiltinType::Int: case BuiltinType::LongLong:
case BuiltinType::Long: case BuiltinType::Int128:
case BuiltinType::LongLong: case BuiltinType::Half:
case BuiltinType::Int128: case BuiltinType::Float:
case BuiltinType::Half: case BuiltinType::Double:
case BuiltinType::Float: case BuiltinType::LongDouble:
case BuiltinType::Double: llvm_unreachable("Builtin type needs extra local data!");
case BuiltinType::LongDouble: // Fall through, if the impossible happens.
llvm_unreachable("Builtin type needs extra local data!");
// Fall through, if the impossible happens. case BuiltinType::NullPtr:
case BuiltinType::Overload:
case BuiltinType::NullPtr: case BuiltinType::Dependent:
case BuiltinType::Overload: case BuiltinType::BoundMember:
case BuiltinType::Dependent: case BuiltinType::UnknownAny:
case BuiltinType::BoundMember: case BuiltinType::ARCUnbridgedCast:
case BuiltinType::UnknownAny: case BuiltinType::PseudoObject:
case BuiltinType::ARCUnbridgedCast: case BuiltinType::ObjCId:
case BuiltinType::PseudoObject: case BuiltinType::ObjCClass:
case BuiltinType::ObjCId: case BuiltinType::ObjCSel:
case BuiltinType::ObjCClass: return TST_unspecified;
case BuiltinType::ObjCSel:
return TST_unspecified;
}
} }
return TST_unspecified; llvm_unreachable("Invalid BuiltinType Kind!");
} }
TypeLoc TypeLoc::IgnoreParensImpl(TypeLoc TL) { TypeLoc TypeLoc::IgnoreParensImpl(TypeLoc TL) {

View File

@ -934,7 +934,7 @@ void TypePrinter::printAttributed(const AttributedType *T,
case AttributedType::attr_objc_ownership: case AttributedType::attr_objc_ownership:
S += "objc_ownership("; S += "objc_ownership(";
switch (T->getEquivalentType().getObjCLifetime()) { switch (T->getEquivalentType().getObjCLifetime()) {
case Qualifiers::OCL_None: llvm_unreachable("no ownership!"); break; case Qualifiers::OCL_None: llvm_unreachable("no ownership!");
case Qualifiers::OCL_ExplicitNone: S += "none"; break; case Qualifiers::OCL_ExplicitNone: S += "none"; break;
case Qualifiers::OCL_Strong: S += "strong"; break; case Qualifiers::OCL_Strong: S += "strong"; break;
case Qualifiers::OCL_Weak: S += "weak"; break; case Qualifiers::OCL_Weak: S += "weak"; break;

View File

@ -3090,7 +3090,6 @@ CFGImplicitDtor::getDestructorDecl(ASTContext &astContext) const {
return 0; return 0;
} }
llvm_unreachable("getKind() returned bogus value"); llvm_unreachable("getKind() returned bogus value");
return 0;
} }
bool CFGImplicitDtor::isNoReturn(ASTContext &astContext) const { bool CFGImplicitDtor::isNoReturn(ASTContext &astContext) const {

View File

@ -58,7 +58,6 @@ cocoa::NamingConvention cocoa::deriveNamingConvention(Selector S,
return CreateRule; return CreateRule;
} }
llvm_unreachable("unexpected naming convention"); llvm_unreachable("unexpected naming convention");
return NoConvention;
} }
bool cocoa::isRefType(QualType RetTy, StringRef Prefix, bool cocoa::isRefType(QualType RetTy, StringRef Prefix,
@ -176,6 +175,4 @@ bool coreFoundation::followsCreateRule(const FunctionDecl *fn) {
// If we matched a lowercase character, it isn't the end of the // If we matched a lowercase character, it isn't the end of the
// word. Keep scanning. // word. Keep scanning.
} }
return false;
} }

View File

@ -340,9 +340,7 @@ bool ArgTypeResult::matchesType(ASTContext &C, QualType argTy) const {
return argTy->getAs<ObjCObjectPointerType>() != NULL; return argTy->getAs<ObjCObjectPointerType>() != NULL;
} }
// FIXME: Should be unreachable, but Clang is currently emitting llvm_unreachable("Invalid ArgTypeResult Kind!");
// a warning.
return false;
} }
QualType ArgTypeResult::getRepresentativeType(ASTContext &C) const { QualType ArgTypeResult::getRepresentativeType(ASTContext &C) const {
@ -369,9 +367,7 @@ QualType ArgTypeResult::getRepresentativeType(ASTContext &C) const {
} }
} }
// FIXME: Should be unreachable, but Clang is currently emitting llvm_unreachable("Invalid ArgTypeResult Kind!");
// a warning.
return QualType();
} }
std::string ArgTypeResult::getRepresentativeTypeName(ASTContext &C) const { std::string ArgTypeResult::getRepresentativeTypeName(ASTContext &C) const {
@ -577,5 +573,5 @@ bool FormatSpecifier::hasValidLengthModifier() const {
return false; return false;
} }
} }
return false; llvm_unreachable("Invalid LengthModifier Kind!");
} }

View File

@ -462,7 +462,7 @@ bool ScanfArgTypeResult::matchesType(ASTContext& C, QualType argTy) const {
} }
} }
return false; // Unreachable, but we still get a warning. llvm_unreachable("Invalid ScanfArgTypeResult Kind!");
} }
QualType ScanfArgTypeResult::getRepresentativeType(ASTContext &C) const { QualType ScanfArgTypeResult::getRepresentativeType(ASTContext &C) const {
@ -479,7 +479,7 @@ QualType ScanfArgTypeResult::getRepresentativeType(ASTContext &C) const {
return C.getPointerType(A.getRepresentativeType(C)); return C.getPointerType(A.getRepresentativeType(C));
} }
return QualType(); // Not reachable. llvm_unreachable("Invalid ScanfArgTypeResult Kind!");
} }
std::string ScanfArgTypeResult::getRepresentativeTypeName(ASTContext& C) const { std::string ScanfArgTypeResult::getRepresentativeTypeName(ASTContext& C) const {

View File

@ -4577,5 +4577,4 @@ Value *CodeGenFunction::EmitPPCBuiltinExpr(unsigned BuiltinID,
return Builder.CreateCall(F, Ops, ""); return Builder.CreateCall(F, Ops, "");
} }
} }
return 0;
} }

View File

@ -84,7 +84,6 @@ RValue DominatingValue<RValue>::saved_type::restore(CodeGenFunction &CGF) {
} }
llvm_unreachable("bad saved r-value kind"); llvm_unreachable("bad saved r-value kind");
return RValue();
} }
/// Push an entry of the given size onto this protected-scope stack. /// Push an entry of the given size onto this protected-scope stack.

View File

@ -1565,8 +1565,6 @@ static QualType UnwrapTypeForDebugInfo(QualType T) {
if (T == LastT) if (T == LastT)
return T; return T;
} while (true); } while (true);
return T;
} }
/// getType - Get the type from the cache or return null type if it doesn't exist. /// getType - Get the type from the cache or return null type if it doesn't exist.
@ -1677,7 +1675,6 @@ llvm::DIType CGDebugInfo::CreateTypeNode(QualType Ty, llvm::DIFile Unit) {
case Type::UnaryTransform: case Type::UnaryTransform:
case Type::Auto: case Type::Auto:
llvm_unreachable("type should have been unwrapped!"); llvm_unreachable("type should have been unwrapped!");
return llvm::DIType();
} }
assert(Diag && "Fall through without a diagnostic?"); assert(Diag && "Fall through without a diagnostic?");

View File

@ -636,8 +636,7 @@ static bool isNonEHScope(const EHScope &S) {
return false; return false;
} }
// Suppress warning. llvm_unreachable("Invalid EHScope Kind!");
return false;
} }
llvm::BasicBlock *CodeGenFunction::getInvokeDestImpl() { llvm::BasicBlock *CodeGenFunction::getInvokeDestImpl() {

View File

@ -1427,10 +1427,6 @@ LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) {
return EmitFunctionDeclLValue(*this, E, fn); return EmitFunctionDeclLValue(*this, E, fn);
llvm_unreachable("Unhandled DeclRefExpr"); llvm_unreachable("Unhandled DeclRefExpr");
// an invalid LValue, but the assert will
// ensure that this point is never reached.
return LValue();
} }
LValue CodeGenFunction::EmitBlockDeclRefLValue(const BlockDeclRefExpr *E) { LValue CodeGenFunction::EmitBlockDeclRefLValue(const BlockDeclRefExpr *E) {

View File

@ -349,7 +349,6 @@ void AggExprEmitter::VisitCastExpr(CastExpr *E) {
case CK_LValueBitCast: case CK_LValueBitCast:
llvm_unreachable("should not be emitting lvalue bitcast as rvalue"); llvm_unreachable("should not be emitting lvalue bitcast as rvalue");
break;
case CK_Dependent: case CK_Dependent:
case CK_BitCast: case CK_BitCast:

View File

@ -817,7 +817,6 @@ EmitComplexCompoundAssignmentLValue(const CompoundAssignOperator *E) {
default: default:
llvm_unreachable("unexpected complex compound assignment"); llvm_unreachable("unexpected complex compound assignment");
Op = 0;
} }
ComplexPairTy Val; // ignored ComplexPairTy Val; // ignored

View File

@ -1167,7 +1167,6 @@ Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) {
case CK_ConstructorConversion: case CK_ConstructorConversion:
case CK_ToUnion: case CK_ToUnion:
llvm_unreachable("scalar cast to non-scalar value"); llvm_unreachable("scalar cast to non-scalar value");
break;
case CK_LValueToRValue: case CK_LValueToRValue:
assert(CGF.getContext().hasSameUnqualifiedType(E->getType(), DestTy)); assert(CGF.getContext().hasSameUnqualifiedType(E->getType(), DestTy));
@ -1247,7 +1246,6 @@ Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) {
} }
llvm_unreachable("unknown scalar cast"); llvm_unreachable("unknown scalar cast");
return 0;
} }
Value *ScalarExprEmitter::VisitStmtExpr(const StmtExpr *E) { Value *ScalarExprEmitter::VisitStmtExpr(const StmtExpr *E) {
@ -1272,10 +1270,8 @@ EmitAddConsiderOverflowBehavior(const UnaryOperator *E,
switch (CGF.getContext().getLangOptions().getSignedOverflowBehavior()) { switch (CGF.getContext().getLangOptions().getSignedOverflowBehavior()) {
case LangOptions::SOB_Undefined: case LangOptions::SOB_Undefined:
return Builder.CreateNSWAdd(InVal, NextVal, IsInc ? "inc" : "dec"); return Builder.CreateNSWAdd(InVal, NextVal, IsInc ? "inc" : "dec");
break;
case LangOptions::SOB_Defined: case LangOptions::SOB_Defined:
return Builder.CreateAdd(InVal, NextVal, IsInc ? "inc" : "dec"); return Builder.CreateAdd(InVal, NextVal, IsInc ? "inc" : "dec");
break;
case LangOptions::SOB_Trapping: case LangOptions::SOB_Trapping:
BinOpInfo BinOp; BinOpInfo BinOp;
BinOp.LHS = InVal; BinOp.LHS = InVal;
@ -1875,7 +1871,6 @@ Value *ScalarExprEmitter::EmitOverflowCheckedBinOp(const BinOpInfo &Ops) {
break; break;
default: default:
llvm_unreachable("Unsupported operation for overflow detection"); llvm_unreachable("Unsupported operation for overflow detection");
IID = 0;
} }
OpID <<= 1; OpID <<= 1;
OpID |= 1; OpID |= 1;
@ -2175,36 +2170,28 @@ static llvm::Intrinsic::ID GetIntrinsic(IntrinsicType IT,
case BuiltinType::UChar: case BuiltinType::UChar:
return (IT == VCMPEQ) ? llvm::Intrinsic::ppc_altivec_vcmpequb_p : return (IT == VCMPEQ) ? llvm::Intrinsic::ppc_altivec_vcmpequb_p :
llvm::Intrinsic::ppc_altivec_vcmpgtub_p; llvm::Intrinsic::ppc_altivec_vcmpgtub_p;
break;
case BuiltinType::Char_S: case BuiltinType::Char_S:
case BuiltinType::SChar: case BuiltinType::SChar:
return (IT == VCMPEQ) ? llvm::Intrinsic::ppc_altivec_vcmpequb_p : return (IT == VCMPEQ) ? llvm::Intrinsic::ppc_altivec_vcmpequb_p :
llvm::Intrinsic::ppc_altivec_vcmpgtsb_p; llvm::Intrinsic::ppc_altivec_vcmpgtsb_p;
break;
case BuiltinType::UShort: case BuiltinType::UShort:
return (IT == VCMPEQ) ? llvm::Intrinsic::ppc_altivec_vcmpequh_p : return (IT == VCMPEQ) ? llvm::Intrinsic::ppc_altivec_vcmpequh_p :
llvm::Intrinsic::ppc_altivec_vcmpgtuh_p; llvm::Intrinsic::ppc_altivec_vcmpgtuh_p;
break;
case BuiltinType::Short: case BuiltinType::Short:
return (IT == VCMPEQ) ? llvm::Intrinsic::ppc_altivec_vcmpequh_p : return (IT == VCMPEQ) ? llvm::Intrinsic::ppc_altivec_vcmpequh_p :
llvm::Intrinsic::ppc_altivec_vcmpgtsh_p; llvm::Intrinsic::ppc_altivec_vcmpgtsh_p;
break;
case BuiltinType::UInt: case BuiltinType::UInt:
case BuiltinType::ULong: case BuiltinType::ULong:
return (IT == VCMPEQ) ? llvm::Intrinsic::ppc_altivec_vcmpequw_p : return (IT == VCMPEQ) ? llvm::Intrinsic::ppc_altivec_vcmpequw_p :
llvm::Intrinsic::ppc_altivec_vcmpgtuw_p; llvm::Intrinsic::ppc_altivec_vcmpgtuw_p;
break;
case BuiltinType::Int: case BuiltinType::Int:
case BuiltinType::Long: case BuiltinType::Long:
return (IT == VCMPEQ) ? llvm::Intrinsic::ppc_altivec_vcmpequw_p : return (IT == VCMPEQ) ? llvm::Intrinsic::ppc_altivec_vcmpequw_p :
llvm::Intrinsic::ppc_altivec_vcmpgtsw_p; llvm::Intrinsic::ppc_altivec_vcmpgtsw_p;
break;
case BuiltinType::Float: case BuiltinType::Float:
return (IT == VCMPEQ) ? llvm::Intrinsic::ppc_altivec_vcmpeqfp_p : return (IT == VCMPEQ) ? llvm::Intrinsic::ppc_altivec_vcmpeqfp_p :
llvm::Intrinsic::ppc_altivec_vcmpgtfp_p; llvm::Intrinsic::ppc_altivec_vcmpgtfp_p;
break;
} }
return llvm::Intrinsic::not_intrinsic;
} }
Value *ScalarExprEmitter::EmitCompare(const BinaryOperator *E,unsigned UICmpOpc, Value *ScalarExprEmitter::EmitCompare(const BinaryOperator *E,unsigned UICmpOpc,

View File

@ -2086,7 +2086,6 @@ static TryEmitResult tryEmitARCRetainLoadOfScalar(CodeGenFunction &CGF,
} }
llvm_unreachable("impossible lifetime!"); llvm_unreachable("impossible lifetime!");
return TryEmitResult();
} }
static TryEmitResult tryEmitARCRetainLoadOfScalar(CodeGenFunction &CGF, static TryEmitResult tryEmitARCRetainLoadOfScalar(CodeGenFunction &CGF,

View File

@ -1516,7 +1516,6 @@ llvm::Constant *CGObjCMac::GetEHType(QualType T) {
return CGM.GetAddrOfRTTIDescriptor(T, /*ForEH=*/true); return CGM.GetAddrOfRTTIDescriptor(T, /*ForEH=*/true);
llvm_unreachable("asking for catch type for ObjC type in fragile runtime"); llvm_unreachable("asking for catch type for ObjC type in fragile runtime");
return 0;
} }
/// Generate a constant CFString object. /// Generate a constant CFString object.

View File

@ -207,9 +207,8 @@ static bool TypeInfoIsInStandardLibrary(const BuiltinType *Ty) {
case BuiltinType::ObjCSel: case BuiltinType::ObjCSel:
llvm_unreachable("FIXME: Objective-C types are unsupported!"); llvm_unreachable("FIXME: Objective-C types are unsupported!");
} }
// Silent gcc. llvm_unreachable("Invalid BuiltinType Kind!");
return false;
} }
static bool TypeInfoIsInStandardLibrary(const PointerType *PointerTy) { static bool TypeInfoIsInStandardLibrary(const PointerType *PointerTy) {
@ -345,7 +344,7 @@ getTypeInfoLinkage(CodeGenModule &CGM, QualType Ty) {
return llvm::GlobalValue::LinkOnceODRLinkage; return llvm::GlobalValue::LinkOnceODRLinkage;
} }
return llvm::GlobalValue::LinkOnceODRLinkage; llvm_unreachable("Invalid linkage!");
} }
// CanUseSingleInheritance - Return whether the given record decl has a "single, // CanUseSingleInheritance - Return whether the given record decl has a "single,

View File

@ -57,7 +57,6 @@ static CGCXXABI &createCXXABI(CodeGenModule &CGM) {
} }
llvm_unreachable("invalid C++ ABI kind"); llvm_unreachable("invalid C++ ABI kind");
return *CreateItaniumCXXABI(CGM);
} }
@ -1340,9 +1339,8 @@ CodeGenModule::getVTableLinkage(const CXXRecordDecl *RD) {
case TSK_ExplicitInstantiationDefinition: case TSK_ExplicitInstantiationDefinition:
return llvm::GlobalVariable::WeakODRLinkage; return llvm::GlobalVariable::WeakODRLinkage;
} }
// Silence GCC warning. llvm_unreachable("Invalid TemplateSpecializationKind!");
return llvm::GlobalVariable::LinkOnceODRLinkage;
} }
CharUnits CodeGenModule::GetTargetTypeStoreSize(llvm::Type *Ty) const { CharUnits CodeGenModule::GetTargetTypeStoreSize(llvm::Type *Ty) const {

View File

@ -469,7 +469,6 @@ public:
case ProtectedVisibility: return llvm::GlobalValue::ProtectedVisibility; case ProtectedVisibility: return llvm::GlobalValue::ProtectedVisibility;
} }
llvm_unreachable("unknown visibility!"); llvm_unreachable("unknown visibility!");
return llvm::GlobalValue::DefaultVisibility;
} }
llvm::Constant *GetAddrOfGlobal(GlobalDecl GD) { llvm::Constant *GetAddrOfGlobal(GlobalDecl GD) {

View File

@ -305,7 +305,6 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) {
#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) case Type::Class: #define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) case Type::Class:
#include "clang/AST/TypeNodes.def" #include "clang/AST/TypeNodes.def"
llvm_unreachable("Non-canonical or dependent types aren't possible."); llvm_unreachable("Non-canonical or dependent types aren't possible.");
break;
case Type::Builtin: { case Type::Builtin: {
switch (cast<BuiltinType>(Ty)->getKind()) { switch (cast<BuiltinType>(Ty)->getKind()) {
@ -374,7 +373,6 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) {
case BuiltinType::Id: case BuiltinType::Id:
#include "clang/AST/BuiltinTypes.def" #include "clang/AST/BuiltinTypes.def"
llvm_unreachable("Unexpected placeholder builtin type!"); llvm_unreachable("Unexpected placeholder builtin type!");
break;
} }
break; break;
} }

View File

@ -2847,7 +2847,6 @@ void PTXABIInfo::computeInfo(CGFunctionInfo &FI) const {
llvm::Value *PTXABIInfo::EmitVAArg(llvm::Value *VAListAddr, QualType Ty, llvm::Value *PTXABIInfo::EmitVAArg(llvm::Value *VAListAddr, QualType Ty,
CodeGenFunction &CFG) const { CodeGenFunction &CFG) const {
llvm_unreachable("PTX does not support varargs"); llvm_unreachable("PTX does not support varargs");
return 0;
} }
void PTXTargetCodeGenInfo::SetTargetAttributes(const Decl *D, void PTXTargetCodeGenInfo::SetTargetAttributes(const Decl *D,

View File

@ -395,7 +395,6 @@ static const char *getInputKindName(InputKind Kind) {
} }
llvm_unreachable("Unexpected language kind!"); llvm_unreachable("Unexpected language kind!");
return 0;
} }
static const char *getActionName(frontend::ActionKind Kind) { static const char *getActionName(frontend::ActionKind Kind) {
@ -433,7 +432,6 @@ static const char *getActionName(frontend::ActionKind Kind) {
} }
llvm_unreachable("Unexpected language kind!"); llvm_unreachable("Unexpected language kind!");
return 0;
} }
static void FileSystemOptsToArgs(const FileSystemOptions &Opts, static void FileSystemOptsToArgs(const FileSystemOptions &Opts,

View File

@ -50,8 +50,8 @@ Decl *ASTLocation::getReferencedDecl() {
case N_Stmt: case N_Stmt:
return getDeclFromExpr(Stm); return getDeclFromExpr(Stm);
} }
return 0; llvm_unreachable("Invalid ASTLocation Kind!");
} }
SourceRange ASTLocation::getSourceRange() const { SourceRange ASTLocation::getSourceRange() const {
@ -68,8 +68,8 @@ SourceRange ASTLocation::getSourceRange() const {
case N_Type: case N_Type:
return AsTypeLoc().getLocalSourceRange(); return AsTypeLoc().getLocalSourceRange();
} }
return SourceRange(); llvm_unreachable("Invalid ASTLocation Kind!");
} }
void ASTLocation::print(raw_ostream &OS) const { void ASTLocation::print(raw_ostream &OS) const {

View File

@ -2464,7 +2464,7 @@ ExprResult Parser::ParseArrayTypeTrait() {
T.getCloseLocation()); T.getCloseLocation());
} }
} }
return ExprError(); llvm_unreachable("Invalid ArrayTypeTrait!");
} }
/// ParseExpressionTrait - Parse built-in expression-trait /// ParseExpressionTrait - Parse built-in expression-trait

View File

@ -2673,8 +2673,8 @@ struct BaseAndFieldInfo {
case IIK_Default: case IIK_Default:
return false; return false;
} }
return false; llvm_unreachable("Invalid ImplicitInitializerKind!");
} }
}; };
} }

View File

@ -1732,7 +1732,6 @@ bool Sema::DiagnoseAmbiguousLookup(LookupResult &Result) {
} }
llvm_unreachable("unknown ambiguity kind"); llvm_unreachable("unknown ambiguity kind");
return true;
} }
namespace { namespace {

View File

@ -278,7 +278,7 @@ checkDeducedTemplateArguments(ASTContext &Context,
return X; return X;
} }
return DeducedTemplateArgument(); llvm_unreachable("Invalid TemplateArgument Kind!");
} }
/// \brief Deduce the value of the given non-type template parameter /// \brief Deduce the value of the given non-type template parameter
@ -1529,7 +1529,7 @@ DeduceTemplateArgumentsByTypeMatch(Sema &S,
return Sema::TDK_Success; return Sema::TDK_Success;
} }
return Sema::TDK_Success; llvm_unreachable("Invalid Type Class!");
} }
static Sema::TemplateDeductionResult static Sema::TemplateDeductionResult
@ -1570,7 +1570,6 @@ DeduceTemplateArguments(Sema &S,
case TemplateArgument::TemplateExpansion: case TemplateArgument::TemplateExpansion:
llvm_unreachable("caller should handle pack expansions"); llvm_unreachable("caller should handle pack expansions");
break;
case TemplateArgument::Declaration: case TemplateArgument::Declaration:
if (Arg.getKind() == TemplateArgument::Declaration && if (Arg.getKind() == TemplateArgument::Declaration &&
@ -1630,7 +1629,7 @@ DeduceTemplateArguments(Sema &S,
llvm_unreachable("Argument packs should be expanded by the caller!"); llvm_unreachable("Argument packs should be expanded by the caller!");
} }
return Sema::TDK_Success; llvm_unreachable("Invalid TemplateArgument Kind!");
} }
/// \brief Determine whether there is a template argument to be used for /// \brief Determine whether there is a template argument to be used for
@ -1880,7 +1879,7 @@ static bool isSameTemplateArg(ASTContext &Context,
return true; return true;
} }
return false; llvm_unreachable("Invalid TemplateArgument Kind!");
} }
/// \brief Allocate a TemplateArgumentLoc where all locations have /// \brief Allocate a TemplateArgumentLoc where all locations have
@ -1905,7 +1904,6 @@ getTrivialTemplateArgumentLoc(Sema &S,
switch (Arg.getKind()) { switch (Arg.getKind()) {
case TemplateArgument::Null: case TemplateArgument::Null:
llvm_unreachable("Can't get a NULL template argument here"); llvm_unreachable("Can't get a NULL template argument here");
break;
case TemplateArgument::Type: case TemplateArgument::Type:
return TemplateArgumentLoc(Arg, return TemplateArgumentLoc(Arg,
@ -1950,7 +1948,7 @@ getTrivialTemplateArgumentLoc(Sema &S,
return TemplateArgumentLoc(Arg, TemplateArgumentLocInfo()); return TemplateArgumentLoc(Arg, TemplateArgumentLocInfo());
} }
return TemplateArgumentLoc(); llvm_unreachable("Invalid TemplateArgument Kind!");
} }

View File

@ -388,7 +388,6 @@ Sema::ActOnPackExpansion(const ParsedTemplateArgument &Arg,
return Arg.getTemplatePackExpansion(EllipsisLoc); return Arg.getTemplatePackExpansion(EllipsisLoc);
} }
llvm_unreachable("Unhandled template argument kind?"); llvm_unreachable("Unhandled template argument kind?");
return ParsedTemplateArgument();
} }
TypeResult Sema::ActOnPackExpansion(ParsedType Type, TypeResult Sema::ActOnPackExpansion(ParsedType Type,
@ -632,7 +631,6 @@ unsigned Sema::getNumArgumentsInExpansion(QualType T,
} }
llvm_unreachable("No unexpanded parameter packs in type expansion."); llvm_unreachable("No unexpanded parameter packs in type expansion.");
return 0;
} }
bool Sema::containsUnexpandedParameterPacks(Declarator &D) { bool Sema::containsUnexpandedParameterPacks(Declarator &D) {
@ -695,7 +693,6 @@ bool Sema::containsUnexpandedParameterPacks(Declarator &D) {
// declarator-id (conceptually), so the parser should not invoke this // declarator-id (conceptually), so the parser should not invoke this
// routine at this time. // routine at this time.
llvm_unreachable("Could not have seen this kind of declarator chunk"); llvm_unreachable("Could not have seen this kind of declarator chunk");
break;
case DeclaratorChunk::MemberPointer: case DeclaratorChunk::MemberPointer:
if (Chunk.Mem.Scope().getScopeRep() && if (Chunk.Mem.Scope().getScopeRep() &&

View File

@ -1794,10 +1794,8 @@ static QualType GetDeclSpecTypeForDeclarator(TypeProcessingState &state,
switch (D.getContext()) { switch (D.getContext()) {
case Declarator::KNRTypeListContext: case Declarator::KNRTypeListContext:
llvm_unreachable("K&R type lists aren't allowed in C++"); llvm_unreachable("K&R type lists aren't allowed in C++");
break;
case Declarator::LambdaExprContext: case Declarator::LambdaExprContext:
llvm_unreachable("Can't specify a type specifier in lambda grammar"); llvm_unreachable("Can't specify a type specifier in lambda grammar");
break;
case Declarator::ObjCParameterContext: case Declarator::ObjCParameterContext:
case Declarator::ObjCResultContext: case Declarator::ObjCResultContext:
case Declarator::PrototypeContext: case Declarator::PrototypeContext:
@ -2327,7 +2325,6 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state,
case NestedNameSpecifier::NamespaceAlias: case NestedNameSpecifier::NamespaceAlias:
case NestedNameSpecifier::Global: case NestedNameSpecifier::Global:
llvm_unreachable("Nested-name-specifier must name a type"); llvm_unreachable("Nested-name-specifier must name a type");
break;
case NestedNameSpecifier::TypeSpec: case NestedNameSpecifier::TypeSpec:
case NestedNameSpecifier::TypeSpecWithTemplate: case NestedNameSpecifier::TypeSpecWithTemplate:
@ -2659,7 +2656,7 @@ static void transferARCOwnershipToDeclaratorChunk(TypeProcessingState &state,
const char *attrStr = 0; const char *attrStr = 0;
switch (ownership) { switch (ownership) {
case Qualifiers::OCL_None: llvm_unreachable("no ownership!"); break; case Qualifiers::OCL_None: llvm_unreachable("no ownership!");
case Qualifiers::OCL_ExplicitNone: attrStr = "none"; break; case Qualifiers::OCL_ExplicitNone: attrStr = "none"; break;
case Qualifiers::OCL_Strong: attrStr = "strong"; break; case Qualifiers::OCL_Strong: attrStr = "strong"; break;
case Qualifiers::OCL_Weak: attrStr = "weak"; break; case Qualifiers::OCL_Weak: attrStr = "weak"; break;
@ -2780,7 +2777,6 @@ static AttributeList::Kind getAttrListKind(AttributedType::Kind kind) {
return AttributeList::AT_pcs; return AttributeList::AT_pcs;
} }
llvm_unreachable("unexpected attribute kind!"); llvm_unreachable("unexpected attribute kind!");
return AttributeList::Kind();
} }
static void fillAttributedTypeLoc(AttributedTypeLoc TL, static void fillAttributedTypeLoc(AttributedTypeLoc TL,
@ -3055,7 +3051,6 @@ namespace {
case NestedNameSpecifier::NamespaceAlias: case NestedNameSpecifier::NamespaceAlias:
case NestedNameSpecifier::Global: case NestedNameSpecifier::Global:
llvm_unreachable("Nested-name-specifier must name a type"); llvm_unreachable("Nested-name-specifier must name a type");
break;
} }
// Finally fill in MemberPointerLocInfo fields. // Finally fill in MemberPointerLocInfo fields.
@ -3572,7 +3567,6 @@ namespace {
} }
llvm_unreachable("unknown wrapping kind"); llvm_unreachable("unknown wrapping kind");
return QualType();
} }
}; };
} }

View File

@ -225,14 +225,11 @@ GenericTaintChecker::TaintPropagationRule::getTaintPropagationRule(
case Builtin::BIstrncpy: case Builtin::BIstrncpy:
case Builtin::BIstrncat: case Builtin::BIstrncat:
return TaintPropagationRule(1, 2, 0, true); return TaintPropagationRule(1, 2, 0, true);
break;
case Builtin::BIstrlcpy: case Builtin::BIstrlcpy:
case Builtin::BIstrlcat: case Builtin::BIstrlcat:
return TaintPropagationRule(1, 2, 0, false); return TaintPropagationRule(1, 2, 0, false);
break;
case Builtin::BIstrndup: case Builtin::BIstrndup:
return TaintPropagationRule(0, 1, ReturnValueIndex); return TaintPropagationRule(0, 1, ReturnValueIndex);
break;
default: default:
break; break;

View File

@ -135,7 +135,6 @@ void PthreadLockChecker::AcquireLock(CheckerContext &C, const CallExpr *CE,
break; break;
default: default:
llvm_unreachable("Unknown tryLock locking semantics"); llvm_unreachable("Unknown tryLock locking semantics");
break;
} }
assert(lockFail && lockSucc); assert(lockFail && lockSucc);
C.addTransition(lockFail); C.addTransition(lockFail);

View File

@ -56,13 +56,10 @@ bool CheckerContext::isCLibraryFunction(const FunctionDecl *FD,
} }
StringRef CheckerContext::getMacroNameOrSpelling(SourceLocation &Loc) { StringRef CheckerContext::getMacroNameOrSpelling(SourceLocation &Loc) {
if (!Loc.isMacroID()) { if (Loc.isMacroID())
SmallVector<char, 16> buf;
return Lexer::getSpelling(Loc, buf, getSourceManager(), getLangOptions());
} else {
return Lexer::getImmediateMacroName(Loc, getSourceManager(), return Lexer::getImmediateMacroName(Loc, getSourceManager(),
getLangOptions()); getLangOptions());
} SmallVector<char, 16> buf;
return StringRef(); return Lexer::getSpelling(Loc, buf, getSourceManager(), getLangOptions());
} }

View File

@ -59,7 +59,6 @@ SVal Environment::getSVal(const EnvironmentEntry &Entry,
case Stmt::GenericSelectionExprClass: case Stmt::GenericSelectionExprClass:
llvm_unreachable("ParenExprs and GenericSelectionExprs should " llvm_unreachable("ParenExprs and GenericSelectionExprs should "
"have been handled by IgnoreParens()"); "have been handled by IgnoreParens()");
return UnknownVal();
case Stmt::CharacterLiteralClass: { case Stmt::CharacterLiteralClass: {
const CharacterLiteral* C = cast<CharacterLiteral>(E); const CharacterLiteral* C = cast<CharacterLiteral>(E);
return svalBuilder.makeIntVal(C->getValue(), C->getType()); return svalBuilder.makeIntVal(C->getValue(), C->getType());

View File

@ -211,8 +211,6 @@ void ExprEngine::processCFGElement(const CFGElement E, ExplodedNode *Pred,
ProcessImplicitDtor(*E.getAs<CFGImplicitDtor>(), Pred); ProcessImplicitDtor(*E.getAs<CFGImplicitDtor>(), Pred);
return; return;
} }
currentStmtIdx = 0;
currentBuilderContext = 0;
} }
static bool shouldRemoveDeadBindings(AnalysisManager &AMgr, static bool shouldRemoveDeadBindings(AnalysisManager &AMgr,
@ -529,7 +527,6 @@ void ExprEngine::Visit(const Stmt *S, ExplodedNode *Pred,
case Stmt::WhileStmtClass: case Stmt::WhileStmtClass:
case Expr::MSDependentExistsStmtClass: case Expr::MSDependentExistsStmtClass:
llvm_unreachable("Stmt should not be in analyzer evaluation loop"); llvm_unreachable("Stmt should not be in analyzer evaluation loop");
break;
case Stmt::GNUNullExprClass: { case Stmt::GNUNullExprClass: {
// GNU __null is a pointer-width integer, not an actual pointer. // GNU __null is a pointer-width integer, not an actual pointer.

View File

@ -231,16 +231,12 @@ static llvm::APSInt computeAdjustment(const SymExpr *LHS,
switch (SE->getOpcode()) { switch (SE->getOpcode()) {
case BO_Add: case BO_Add:
return SE->getRHS(); return SE->getRHS();
break;
case BO_Sub: case BO_Sub:
return -SE->getRHS(); return -SE->getRHS();
break;
default: default:
// We cannot simplify non-additive operators. // We cannot simplify non-additive operators.
return DefaultAdjustment; return DefaultAdjustment;
} }
return DefaultAdjustment;
} }
const ProgramState *SimpleConstraintManager::assumeSymRel(const ProgramState *state, const ProgramState *SimpleConstraintManager::assumeSymRel(const ProgramState *state,

View File

@ -141,8 +141,7 @@ CXString clang_getCompletionChunkText(CXCompletionString completion_string,
return createCXString(""); return createCXString("");
} }
// Should be unreachable, but let's be careful. llvm_unreachable("Invalid CodeCompletionString Kind!");
return createCXString((const char*)0);
} }