Add 'llvm_unreachable' to passify GCC's understanding of the constraints

of several newly un-defaulted switches. This also helps optimizers
(including LLVM's) recognize that every case is covered, and we should
assume as much.

llvm-svn: 147861
This commit is contained in:
Chandler Carruth 2012-01-10 18:08:01 +00:00
parent 8d4a2204b7
commit f3e8502cc1
13 changed files with 18 additions and 0 deletions

View File

@ -20,6 +20,7 @@
#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/SmallVector.h"
#include "llvm/Support/DataTypes.h" #include "llvm/Support/DataTypes.h"
#include "llvm/Support/ErrorHandling.h"
#include <cassert> #include <cassert>
namespace llvm { namespace llvm {
@ -122,6 +123,7 @@ public:
case Blob: case Blob:
return false; return false;
} }
llvm_unreachable("Invalid encoding");
} }
/// isChar6 - Return true if this character is legal in the Char6 encoding. /// isChar6 - Return true if this character is legal in the Char6 encoding.

View File

@ -117,6 +117,7 @@ public:
// Extend by copying the sign bit. // Extend by copying the sign bit.
return ISD::SIGN_EXTEND; return ISD::SIGN_EXTEND;
} }
llvm_unreachable("Invalid content kind");
} }
/// NOTE: The constructor takes ownership of TLOF. /// NOTE: The constructor takes ownership of TLOF.

View File

@ -2549,6 +2549,7 @@ bool LLParser::ConvertValIDToValue(Type *Ty, ValID &ID, Value *&V,
return Error(ID.Loc, "constant expression type mismatch"); return Error(ID.Loc, "constant expression type mismatch");
return false; return false;
} }
llvm_unreachable("Invalid ValID");
} }
bool LLParser::ParseValue(Type *Ty, Value *&V, PerFunctionState *PFS) { bool LLParser::ParseValue(Type *Ty, Value *&V, PerFunctionState *PFS) {

View File

@ -134,6 +134,7 @@ static unsigned GetEncodedOrdering(AtomicOrdering Ordering) {
case AcquireRelease: return bitc::ORDERING_ACQREL; case AcquireRelease: return bitc::ORDERING_ACQREL;
case SequentiallyConsistent: return bitc::ORDERING_SEQCST; case SequentiallyConsistent: return bitc::ORDERING_SEQCST;
} }
llvm_unreachable("Invalid ordering");
} }
static unsigned GetEncodedSynchScope(SynchronizationScope SynchScope) { static unsigned GetEncodedSynchScope(SynchronizationScope SynchScope) {
@ -141,6 +142,7 @@ static unsigned GetEncodedSynchScope(SynchronizationScope SynchScope) {
case SingleThread: return bitc::SYNCHSCOPE_SINGLETHREAD; case SingleThread: return bitc::SYNCHSCOPE_SINGLETHREAD;
case CrossThread: return bitc::SYNCHSCOPE_CROSSTHREAD; case CrossThread: return bitc::SYNCHSCOPE_CROSSTHREAD;
} }
llvm_unreachable("Invalid synch scope");
} }
static void WriteStringRecord(unsigned Code, StringRef Str, static void WriteStringRecord(unsigned Code, StringRef Str,
@ -372,6 +374,7 @@ static unsigned getEncodedLinkage(const GlobalValue *GV) {
case GlobalValue::LinkerPrivateWeakLinkage: return 14; case GlobalValue::LinkerPrivateWeakLinkage: return 14;
case GlobalValue::LinkerPrivateWeakDefAutoLinkage: return 15; case GlobalValue::LinkerPrivateWeakDefAutoLinkage: return 15;
} }
llvm_unreachable("Invalid linkage");
} }
static unsigned getEncodedVisibility(const GlobalValue *GV) { static unsigned getEncodedVisibility(const GlobalValue *GV) {
@ -380,6 +383,7 @@ static unsigned getEncodedVisibility(const GlobalValue *GV) {
case GlobalValue::HiddenVisibility: return 1; case GlobalValue::HiddenVisibility: return 1;
case GlobalValue::ProtectedVisibility: return 2; case GlobalValue::ProtectedVisibility: return 2;
} }
llvm_unreachable("Invalid visibility");
} }
// Emit top-level description of module, including target triple, inline asm, // Emit top-level description of module, including target triple, inline asm,

View File

@ -148,6 +148,7 @@ static const char *DescKind(GC::PointKind Kind) {
case GC::PreCall: return "pre-call"; case GC::PreCall: return "pre-call";
case GC::PostCall: return "post-call"; case GC::PostCall: return "post-call";
} }
llvm_unreachable("Invalid point kind");
} }
bool Printer::runOnFunction(Function &F) { bool Printer::runOnFunction(Function &F) {

View File

@ -96,6 +96,7 @@ static bool getVerboseAsm() {
case cl::BOU_TRUE: return true; case cl::BOU_TRUE: return true;
case cl::BOU_FALSE: return false; case cl::BOU_FALSE: return false;
} }
llvm_unreachable("Invalid verbose asm state");
} }
// Enable or disable FastISel. Both options are needed, because // Enable or disable FastISel. Both options are needed, because

View File

@ -221,6 +221,7 @@ bool MachineOperand::isIdenticalTo(const MachineOperand &Other) const {
case MachineOperand::MO_Metadata: case MachineOperand::MO_Metadata:
return getMetadata() == Other.getMetadata(); return getMetadata() == Other.getMetadata();
} }
llvm_unreachable("Invalid machine operand type");
} }
/// print - Print the specified machine operand. /// print - Print the specified machine operand.

View File

@ -3016,6 +3016,7 @@ static unsigned getConstraintGenerality(TargetLowering::ConstraintType CT) {
case TargetLowering::C_Memory: case TargetLowering::C_Memory:
return 3; return 3;
} }
llvm_unreachable("Invalid constraint type");
} }
/// Examine constraint type and operand type and determine a weight value. /// Examine constraint type and operand type and determine a weight value.

View File

@ -194,4 +194,5 @@ llvm::Spiller* llvm::createSpiller(MachineFunctionPass &pass,
case trivial: return new TrivialSpiller(pass, mf, vrm); case trivial: return new TrivialSpiller(pass, mf, vrm);
case inline_: return createInlineSpiller(pass, mf, vrm); case inline_: return createInlineSpiller(pass, mf, vrm);
} }
llvm_unreachable("Invalid spiller optimization");
} }

View File

@ -17,6 +17,7 @@
#include "llvm/MC/MCSymbol.h" #include "llvm/MC/MCSymbol.h"
#include "llvm/MC/MCValue.h" #include "llvm/MC/MCValue.h"
#include "llvm/Support/Debug.h" #include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h" #include "llvm/Support/raw_ostream.h"
using namespace llvm; using namespace llvm;
@ -216,6 +217,7 @@ StringRef MCSymbolRefExpr::getVariantKindName(VariantKind Kind) {
case VK_Mips_GOT_PAGE: return "GOT_PAGE"; case VK_Mips_GOT_PAGE: return "GOT_PAGE";
case VK_Mips_GOT_OFST: return "GOT_OFST"; case VK_Mips_GOT_OFST: return "GOT_OFST";
} }
llvm_unreachable("Invalid variant kind");
} }
MCSymbolRefExpr::VariantKind MCSymbolRefExpr::VariantKind

View File

@ -1172,6 +1172,7 @@ APFloat::roundAwayFromZero(roundingMode rounding_mode,
case rmTowardNegative: case rmTowardNegative:
return sign == true; return sign == true;
} }
llvm_unreachable("Invalid rounding mode found");
} }
APFloat::opStatus APFloat::opStatus

View File

@ -240,6 +240,7 @@ SectionKind TargetLoweringObjectFile::getKindForGlobal(const GlobalValue *GV,
case Constant::GlobalRelocations: case Constant::GlobalRelocations:
return SectionKind::getDataRel(); return SectionKind::getDataRel();
} }
llvm_unreachable("Invalid relocation");
} }
/// SectionForGlobal - This method computes the appropriate section to emit /// SectionForGlobal - This method computes the appropriate section to emit

View File

@ -238,6 +238,7 @@ namespace {
MessagesStr << "compilation terminated.\n"; MessagesStr << "compilation terminated.\n";
return true; return true;
} }
llvm_unreachable("Invalid action");
} }