More dead code removal (using -Wunreachable-code)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148577 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/ASTImporter.cpp b/lib/AST/ASTImporter.cpp
index 10f5a20..abf214a 100644
--- a/lib/AST/ASTImporter.cpp
+++ b/lib/AST/ASTImporter.cpp
@@ -332,7 +332,6 @@
   }
   
   llvm_unreachable("Invalid template argument kind");
-  return true;
 }
 
 /// \brief Determine structural equivalence for the common part of array 
@@ -1357,8 +1356,8 @@
     // wchar_t?
     return Importer.getToContext().WCharTy;
   }
-  
-  return QualType();
+
+  llvm_unreachable("Invalid BuiltinType Kind!");
 }
 
 QualType ASTNodeImporter::VisitComplexType(const ComplexType *T) {
@@ -1983,7 +1982,6 @@
   }
   
   llvm_unreachable("Invalid template argument kind");
-  return TemplateArgument();
 }
 
 bool ASTNodeImporter::ImportTemplateArguments(const TemplateArgument *FromArgs,
@@ -4214,7 +4212,6 @@
   }
 
   llvm_unreachable("Invalid nested name specifier kind");
-  return 0;
 }
 
 NestedNameSpecifierLoc ASTImporter::Import(NestedNameSpecifierLoc FromNNS) {
@@ -4309,7 +4306,6 @@
   }
   
   llvm_unreachable("Invalid template name kind");
-  return TemplateName();
 }
 
 SourceLocation ASTImporter::Import(SourceLocation FromLoc) {
@@ -4453,8 +4449,7 @@
     return DeclarationName::getUsingDirectiveName();
   }
 
-  // Silence bogus GCC warning
-  return DeclarationName();
+  llvm_unreachable("Invalid DeclarationName Kind!");
 }
 
 IdentifierInfo *ASTImporter::Import(const IdentifierInfo *FromId) {
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index 001620a..49227e9 100644
--- a/lib/AST/Decl.cpp
+++ b/lib/AST/Decl.cpp
@@ -48,8 +48,6 @@
     case VisibilityAttr::Protected:
       return ProtectedVisibility;
     }
-
-    return DefaultVisibility;
   }
 
   // If we're on Mac OS X, an 'availability' for Mac OS X attribute
@@ -1141,7 +1139,6 @@
   }
 
   llvm_unreachable("Invalid storage class");
-  return 0;
 }
 
 VarDecl *VarDecl::Create(ASTContext &C, DeclContext *DC,
diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp
index 3763ebd..da54a44 100644
--- a/lib/AST/DeclBase.cpp
+++ b/lib/AST/DeclBase.cpp
@@ -529,7 +529,7 @@
       return 0;
   }
 
-  return 0;
+  llvm_unreachable("Invalid DeclKind!");
 }
 
 void Decl::setAttrs(const AttrVec &attrs) {
diff --git a/lib/AST/DeclarationName.cpp b/lib/AST/DeclarationName.cpp
index bf647ed..a5488e6 100644
--- a/lib/AST/DeclarationName.cpp
+++ b/lib/AST/DeclarationName.cpp
@@ -125,8 +125,8 @@
   case DeclarationName::CXXUsingDirective:
     return 0;
   }
-              
-  return 0;
+
+  llvm_unreachable("Invalid DeclarationName Kind!");
 }
 
 } // end namespace clang
@@ -189,7 +189,6 @@
 
       return ObjCMultiArgSelector;
     }
-    break;
   }
 
   // Can't actually get here.
diff --git a/lib/AST/DumpXML.cpp b/lib/AST/DumpXML.cpp
index 9dd5a01..c5e23cc 100644
--- a/lib/AST/DumpXML.cpp
+++ b/lib/AST/DumpXML.cpp
@@ -165,7 +165,6 @@
   }
 
   llvm_unreachable("unknown type kind!");
-  return "unknown_type";
 }
 
 struct XMLDumper : public XMLDeclVisitor<XMLDumper>,
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp
index 7fc0700..a92dafb 100644
--- a/lib/AST/Expr.cpp
+++ b/lib/AST/Expr.cpp
@@ -124,7 +124,6 @@
 #include "clang/AST/StmtNodes.inc"
   }
   llvm_unreachable("unknown statement kind");
-  return SourceLocation();
 }
 
 //===----------------------------------------------------------------------===//
@@ -1213,7 +1212,6 @@
   }
 
   llvm_unreachable("Unhandled cast kind!");
-  return 0;
 }
 
 Expr *CastExpr::getSubExprAsWritten() {
@@ -1255,7 +1253,6 @@
 #include "clang/AST/StmtNodes.inc"
   default:
     llvm_unreachable("non-cast expressions not possible here");
-    return 0;
   }
 }
 
@@ -1343,7 +1340,7 @@
   case BO_Comma:     return ",";
   }
 
-  return "";
+  llvm_unreachable("Invalid OpCode!");
 }
 
 BinaryOperatorKind
@@ -3015,7 +3012,7 @@
     return getSuperLoc();
   }
 
-  return SourceLocation();
+  llvm_unreachable("Invalid ReceiverKind!");
 }
 
 Selector ObjCMessageExpr::getSelector() const {
@@ -3064,8 +3061,8 @@
   case OBC_BridgeRetained:
     return "__bridge_retained";
   }
-  
-  return "__bridge";
+
+  llvm_unreachable("Invalid BridgeKind!");
 }
 
 bool ChooseExpr::isConditionTrue(const ASTContext &C) const {
diff --git a/lib/AST/ExprClassification.cpp b/lib/AST/ExprClassification.cpp
index 60e6f96..311b805 100644
--- a/lib/AST/ExprClassification.cpp
+++ b/lib/AST/ExprClassification.cpp
@@ -47,7 +47,6 @@
     return Cl::CL_XValue;
   }
   llvm_unreachable("Invalid value category of implicit cast.");
-  return Cl::CL_PRValue;
 }
 
 Cl Expr::ClassifyImpl(ASTContext &Ctx, SourceLocation *Loc) const {
@@ -99,7 +98,6 @@
 #define EXPR(Kind, Base)
 #include "clang/AST/StmtNodes.inc"
     llvm_unreachable("cannot classify a statement");
-    break;
 
     // First come the expressions that are always lvalues, unconditionally.
   case Expr::ObjCIsaExprClass:
@@ -371,7 +369,6 @@
   }
 
   llvm_unreachable("unhandled expression kind in classification");
-  return Cl::CL_LValue;
 }
 
 /// ClassifyDecl - Return the classification of an expression referencing the
diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp
index 5d61406..bdedb16 100644
--- a/lib/AST/ExprConstant.cpp
+++ b/lib/AST/ExprConstant.cpp
@@ -3756,7 +3756,6 @@
     return union_type_class;
   else  // FIXME: offset_type_class, method_type_class, & lang_type_class?
     llvm_unreachable("CallExpr::isBuiltinClassifyType(): unimplemented type");
-  return -1;
 }
 
 /// EvaluateBuiltinConstantPForLValue - Determine the result of
@@ -4385,7 +4384,6 @@
   }
 
   llvm_unreachable("unknown expr/type trait");
-  return Error(E);
 }
 
 bool IntExprEvaluator::VisitOffsetOfExpr(const OffsetOfExpr *OOE) {
@@ -4427,7 +4425,6 @@
 
     case OffsetOfExpr::OffsetOfNode::Identifier:
       llvm_unreachable("dependent __builtin_offsetof");
-      return Error(OOE);
 
     case OffsetOfExpr::OffsetOfNode::Base: {
       CXXBaseSpecifier *BaseSpec = ON.getBase();
@@ -4618,7 +4615,6 @@
   }
 
   llvm_unreachable("unknown cast resulting in integral value");
-  return Error(E);
 }
 
 bool IntExprEvaluator::VisitUnaryReal(const UnaryOperator *E) {
@@ -4881,8 +4877,6 @@
     return true;
   }
   }
-
-  return Error(E);
 }
 
 //===----------------------------------------------------------------------===//
@@ -5092,7 +5086,6 @@
   }
 
   llvm_unreachable("unknown cast resulting in complex value");
-  return Error(E);
 }
 
 bool ComplexExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
@@ -5928,8 +5921,7 @@
   }
   }
 
-  // Silence a GCC warning
-  return ICEDiag(2, E->getLocStart());
+  llvm_unreachable("Invalid StmtClass!");
 }
 
 /// Evaluate an expression as a C++11 integral constant expression.
diff --git a/lib/AST/ItaniumMangle.cpp b/lib/AST/ItaniumMangle.cpp
index 7f2d562..427be32 100644
--- a/lib/AST/ItaniumMangle.cpp
+++ b/lib/AST/ItaniumMangle.cpp
@@ -1370,7 +1370,6 @@
 
   case TemplateName::OverloadedTemplate:
     llvm_unreachable("can't mangle an overloaded template name as a <type>");
-    break;
 
   case TemplateName::DependentTemplate: {
     const DependentTemplateName *Dependent = TN.getAsDependentTemplateName();
@@ -1741,7 +1740,6 @@
 #include "clang/AST/BuiltinTypes.def"
   case BuiltinType::Dependent:
     llvm_unreachable("mangling a placeholder type");
-    break;
   case BuiltinType::ObjCId: Out << "11objc_object"; break;
   case BuiltinType::ObjCClass: Out << "10objc_class"; break;
   case BuiltinType::ObjCSel: Out << "13objc_selector"; break;
@@ -2226,7 +2224,6 @@
   case Expr::ParenListExprClass:
   case Expr::CXXScalarValueInitExprClass:
     llvm_unreachable("unexpected statement kind");
-    break;
 
   // FIXME: invent manglings for all these.
   case Expr::BlockExprClass:
diff --git a/lib/AST/NestedNameSpecifier.cpp b/lib/AST/NestedNameSpecifier.cpp
index 858cf12..c59d40a 100644
--- a/lib/AST/NestedNameSpecifier.cpp
+++ b/lib/AST/NestedNameSpecifier.cpp
@@ -130,7 +130,7 @@
     return TypeSpecWithTemplate;
   }
 
-  return Global;
+  llvm_unreachable("Invalid NNS Kind!");
 }
 
 /// \brief Retrieve the namespace stored in this nested name
@@ -170,8 +170,7 @@
     return getAsType()->isDependentType();
   }
 
-  // Necessary to suppress a GCC warning.
-  return false;
+  llvm_unreachable("Invalid NNS Kind!");
 }
 
 /// \brief Whether this nested name specifier refers to a dependent
@@ -191,9 +190,8 @@
   case TypeSpecWithTemplate:
     return getAsType()->isInstantiationDependentType();
   }
-  
-  // Necessary to suppress a GCC warning.
-  return false;
+
+  llvm_unreachable("Invalid NNS Kind!");
 }
 
 bool NestedNameSpecifier::containsUnexpandedParameterPack() const {
@@ -211,8 +209,7 @@
     return getAsType()->containsUnexpandedParameterPack();
   }
 
-  // Necessary to suppress a GCC warning.
-  return false;  
+  llvm_unreachable("Invalid NNS Kind!");
 }
 
 /// \brief Print this nested name specifier to the given output
@@ -382,8 +379,8 @@
                        LoadSourceLocation(Data, Offset + sizeof(void*)));
   }
   }
-  
-  return SourceRange();
+
+  llvm_unreachable("Invalid NNS Kind!");
 }
 
 TypeLoc NestedNameSpecifierLoc::getTypeLoc() const {
diff --git a/lib/AST/Stmt.cpp b/lib/AST/Stmt.cpp
index e7b87e4..8b2e353 100644
--- a/lib/AST/Stmt.cpp
+++ b/lib/AST/Stmt.cpp
@@ -164,7 +164,6 @@
 #include "clang/AST/StmtNodes.inc"
   }
   llvm_unreachable("unknown statement kind!");
-  return child_range();
 }
 
 SourceRange Stmt::getSourceRange() const {
@@ -177,7 +176,6 @@
 #include "clang/AST/StmtNodes.inc"
   }
   llvm_unreachable("unknown statement kind!");
-  return SourceRange();
 }
 
 void CompoundStmt::setStmts(ASTContext &C, Stmt **Stmts, unsigned NumStmts) {
diff --git a/lib/AST/StmtProfile.cpp b/lib/AST/StmtProfile.cpp
index 5a6b771..2fb67d9 100644
--- a/lib/AST/StmtProfile.cpp
+++ b/lib/AST/StmtProfile.cpp
@@ -503,7 +503,6 @@
   case OO_Conditional:
   case NUM_OVERLOADED_OPERATORS:
     llvm_unreachable("Invalid operator call kind");
-    return Stmt::ArraySubscriptExprClass;
       
   case OO_Plus:
     if (S->getNumArgs() == 1) {
diff --git a/lib/AST/TemplateBase.cpp b/lib/AST/TemplateBase.cpp
index 0c011a8..57df8a4 100644
--- a/lib/AST/TemplateBase.cpp
+++ b/lib/AST/TemplateBase.cpp
@@ -100,7 +100,7 @@
     return false;
   }
 
-  return false;
+  llvm_unreachable("Invalid TemplateArgument Kind!");
 }
 
 bool TemplateArgument::isInstantiationDependent() const {
@@ -137,8 +137,8 @@
     
     return false;
   }
-  
-  return false;
+
+  llvm_unreachable("Invalid TemplateArgument Kind!");
 }
 
 bool TemplateArgument::isPackExpansion() const {
@@ -159,8 +159,8 @@
   case Expression:
     return isa<PackExpansionExpr>(getAsExpr());
   }
-  
-  return false;
+
+  llvm_unreachable("Invalid TemplateArgument Kind!");
 }
 
 bool TemplateArgument::containsUnexpandedParameterPack() const {
@@ -278,8 +278,7 @@
     return true;
   }
 
-  // Suppress warnings.
-  return false;
+  llvm_unreachable("Invalid TemplateArgument Kind!");
 }
 
 TemplateArgument TemplateArgument::getPackExpansionPattern() const {
@@ -302,8 +301,8 @@
   case Template:
     return TemplateArgument();
   }
-  
-  return TemplateArgument();
+
+  llvm_unreachable("Invalid TemplateArgument Kind!");
 }
 
 void TemplateArgument::print(const PrintingPolicy &Policy, 
@@ -412,8 +411,7 @@
     return SourceRange();
   }
 
-  // Silence bonus gcc warning.
-  return SourceRange();
+  llvm_unreachable("Invalid TemplateArgument Kind!");
 }
 
 TemplateArgumentLoc 
@@ -474,8 +472,8 @@
   case TemplateArgument::Null:
     return TemplateArgumentLoc();
   }
-  
-  return TemplateArgumentLoc();
+
+  llvm_unreachable("Invalid TemplateArgument Kind!");
 }
 
 const DiagnosticBuilder &clang::operator<<(const DiagnosticBuilder &DB,
@@ -525,8 +523,8 @@
     return DB << OS.str();
   }
   }
-  
-  return DB;
+
+  llvm_unreachable("Invalid TemplateArgument Kind!");
 }
 
 const ASTTemplateArgumentListInfo *
diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp
index 7fd83b5..7b30c50 100644
--- a/lib/AST/Type.cpp
+++ b/lib/AST/Type.cpp
@@ -1364,7 +1364,6 @@
   }
   
   llvm_unreachable("Type specifier is not a tag type kind.");
-  return TTK_Union;
 }
 
 ElaboratedTypeKeyword
@@ -1419,7 +1418,6 @@
   }
 
   llvm_unreachable("Unknown elaborated type keyword.");
-  return "";
 }
 
 DependentTemplateSpecializationType::DependentTemplateSpecializationType(
@@ -1479,7 +1477,6 @@
   }
   
   llvm_unreachable("Invalid type class.");
-  return 0;
 }
 
 const char *BuiltinType::getName(const PrintingPolicy &Policy) const {
@@ -1521,7 +1518,6 @@
   }
   
   llvm_unreachable("Invalid builtin type.");
-  return 0;
 }
 
 QualType QualType::getNonLValueExprType(ASTContext &Context) const {
@@ -1544,7 +1540,6 @@
   switch (CC) {
   case CC_Default: 
     llvm_unreachable("no name for default cc");
-    return "";
 
   case CC_C: return "cdecl";
   case CC_X86StdCall: return "stdcall";
@@ -1556,7 +1551,6 @@
   }
 
   llvm_unreachable("Invalid calling convention.");
-  return "";
 }
 
 FunctionProtoType::FunctionProtoType(QualType result, const QualType *args,
diff --git a/lib/AST/TypeLoc.cpp b/lib/AST/TypeLoc.cpp
index 97b0b50..ed7faa9 100644
--- a/lib/AST/TypeLoc.cpp
+++ b/lib/AST/TypeLoc.cpp
@@ -196,57 +196,54 @@
 TypeSpecifierType BuiltinTypeLoc::getWrittenTypeSpec() const {
   if (needsExtraLocalData())
     return static_cast<TypeSpecifierType>(getWrittenBuiltinSpecs().Type);
-  else {
-    switch (getTypePtr()->getKind()) {
-    case BuiltinType::Void:
-      return TST_void;
-    case BuiltinType::Bool:
-      return TST_bool;
-    case BuiltinType::Char_U:
-    case BuiltinType::Char_S:
-      return TST_char;
-    case BuiltinType::Char16:
-      return TST_char16;
-    case BuiltinType::Char32:
-      return TST_char32;
-    case BuiltinType::WChar_S:
-    case BuiltinType::WChar_U:
-      return TST_wchar;
-
-    case BuiltinType::UChar:
-    case BuiltinType::UShort:
-    case BuiltinType::UInt:
-    case BuiltinType::ULong:
-    case BuiltinType::ULongLong:
-    case BuiltinType::UInt128:
-    case BuiltinType::SChar:
-    case BuiltinType::Short:
-    case BuiltinType::Int:
-    case BuiltinType::Long:
-    case BuiltinType::LongLong:
-    case BuiltinType::Int128:
-    case BuiltinType::Half:
-    case BuiltinType::Float:
-    case BuiltinType::Double:
-    case BuiltinType::LongDouble:
-      llvm_unreachable("Builtin type needs extra local data!");
-      // Fall through, if the impossible happens.
-        
-    case BuiltinType::NullPtr:
-    case BuiltinType::Overload:
-    case BuiltinType::Dependent:
-    case BuiltinType::BoundMember:
-    case BuiltinType::UnknownAny:
-    case BuiltinType::ARCUnbridgedCast:
-    case BuiltinType::PseudoObject:
-    case BuiltinType::ObjCId:
-    case BuiltinType::ObjCClass:
-    case BuiltinType::ObjCSel:
-      return TST_unspecified;
-    }
+  switch (getTypePtr()->getKind()) {
+  case BuiltinType::Void:
+    return TST_void;
+  case BuiltinType::Bool:
+    return TST_bool;
+  case BuiltinType::Char_U:
+  case BuiltinType::Char_S:
+    return TST_char;
+  case BuiltinType::Char16:
+    return TST_char16;
+  case BuiltinType::Char32:
+    return TST_char32;
+  case BuiltinType::WChar_S:
+  case BuiltinType::WChar_U:
+    return TST_wchar;
+  case BuiltinType::UChar:
+  case BuiltinType::UShort:
+  case BuiltinType::UInt:
+  case BuiltinType::ULong:
+  case BuiltinType::ULongLong:
+  case BuiltinType::UInt128:
+  case BuiltinType::SChar:
+  case BuiltinType::Short:
+  case BuiltinType::Int:
+  case BuiltinType::Long:
+  case BuiltinType::LongLong:
+  case BuiltinType::Int128:
+  case BuiltinType::Half:
+  case BuiltinType::Float:
+  case BuiltinType::Double:
+  case BuiltinType::LongDouble:
+    llvm_unreachable("Builtin type needs extra local data!");
+    // Fall through, if the impossible happens.
+      
+  case BuiltinType::NullPtr:
+  case BuiltinType::Overload:
+  case BuiltinType::Dependent:
+  case BuiltinType::BoundMember:
+  case BuiltinType::UnknownAny:
+  case BuiltinType::ARCUnbridgedCast:
+  case BuiltinType::PseudoObject:
+  case BuiltinType::ObjCId:
+  case BuiltinType::ObjCClass:
+  case BuiltinType::ObjCSel:
+    return TST_unspecified;
   }
-  
-  return TST_unspecified;
+
+  llvm_unreachable("Invalid BuiltinType Kind!");
 }
 
 TypeLoc TypeLoc::IgnoreParensImpl(TypeLoc TL) {
diff --git a/lib/AST/TypePrinter.cpp b/lib/AST/TypePrinter.cpp
index 5dd4272..b6d7110 100644
--- a/lib/AST/TypePrinter.cpp
+++ b/lib/AST/TypePrinter.cpp
@@ -934,7 +934,7 @@
   case AttributedType::attr_objc_ownership:
     S += "objc_ownership(";
     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_Strong: S += "strong"; break;
     case Qualifiers::OCL_Weak: S += "weak"; break;