From 858143816d43e58b17bfd11cb1b57afbd7f0f893 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Tue, 7 Feb 2012 05:05:23 +0000 Subject: Convert assert(0) to llvm_unreachable git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149967 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/ConstantFolding.cpp | 4 ++-- lib/Analysis/DebugInfo.cpp | 6 ++---- lib/Analysis/InstructionSimplify.cpp | 9 +++------ lib/AsmParser/LLParser.cpp | 2 +- lib/ExecutionEngine/ExecutionEngine.cpp | 4 ++-- lib/ExecutionEngine/JIT/JIT.cpp | 5 ++--- lib/ExecutionEngine/JIT/JITEmitter.cpp | 6 +++--- lib/ExecutionEngine/MCJIT/MCJIT.cpp | 3 +-- lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp | 11 +++-------- lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp | 2 +- lib/Linker/LinkModules.cpp | 2 +- lib/MC/MCAsmStreamer.cpp | 4 ++-- lib/MC/MCAssembler.cpp | 12 ++++-------- lib/MC/MCDisassembler/EDMain.cpp | 2 +- lib/MC/MCDwarf.cpp | 3 +-- lib/MC/MCELFStreamer.cpp | 19 +++++++++---------- lib/MC/MCExpr.cpp | 8 +++----- lib/MC/MCInstPrinter.cpp | 3 ++- lib/MC/MCMachOStreamer.cpp | 15 +++++++-------- lib/MC/MCParser/AsmParser.cpp | 3 +-- lib/MC/MCStreamer.cpp | 2 +- lib/Support/ConstantRange.cpp | 2 +- lib/Support/Triple.cpp | 5 ++--- lib/TableGen/Record.cpp | 2 +- lib/TableGen/TGParser.cpp | 8 ++++---- lib/Transforms/InstCombine/InstCombineAndOrXor.cpp | 2 +- lib/Transforms/InstCombine/InstCombineShifts.cpp | 2 +- lib/Transforms/Instrumentation/AddressSanitizer.cpp | 3 +-- lib/Transforms/Scalar/DeadStoreElimination.cpp | 4 ++-- lib/Transforms/Utils/CmpInstAnalysis.cpp | 2 +- 30 files changed, 66 insertions(+), 89 deletions(-) diff --git a/lib/Analysis/ConstantFolding.cpp b/lib/Analysis/ConstantFolding.cpp index 6e2a8d4756..7a0a4e1e82 100644 --- a/lib/Analysis/ConstantFolding.cpp +++ b/lib/Analysis/ConstantFolding.cpp @@ -862,7 +862,7 @@ Constant *llvm::ConstantFoldInstOperands(unsigned Opcode, Type *DestTy, switch (Opcode) { default: return 0; case Instruction::ICmp: - case Instruction::FCmp: assert(0 && "Invalid for compares"); + case Instruction::FCmp: llvm_unreachable("Invalid for compares"); case Instruction::Call: if (Function *F = dyn_cast(Ops.back())) if (canConstantFoldCallTo(F)) @@ -1390,7 +1390,7 @@ llvm::ConstantFoldCall(Function *F, ArrayRef Operands, APInt Res; bool Overflow; switch (F->getIntrinsicID()) { - default: assert(0 && "Invalid case"); + default: llvm_unreachable("Invalid case"); case Intrinsic::sadd_with_overflow: Res = Op1->getValue().sadd_ov(Op2->getValue(), Overflow); break; diff --git a/lib/Analysis/DebugInfo.cpp b/lib/Analysis/DebugInfo.cpp index 5cbd15e4c7..405ed31d32 100644 --- a/lib/Analysis/DebugInfo.cpp +++ b/lib/Analysis/DebugInfo.cpp @@ -583,8 +583,7 @@ StringRef DIScope::getFilename() const { return DIType(DbgNode).getFilename(); if (isFile()) return DIFile(DbgNode).getFilename(); - assert(0 && "Invalid DIScope!"); - return StringRef(); + llvm_unreachable("Invalid DIScope!"); } StringRef DIScope::getDirectory() const { @@ -604,8 +603,7 @@ StringRef DIScope::getDirectory() const { return DIType(DbgNode).getDirectory(); if (isFile()) return DIFile(DbgNode).getDirectory(); - assert(0 && "Invalid DIScope!"); - return StringRef(); + llvm_unreachable("Invalid DIScope!"); } DIArray DICompileUnit::getEnumTypes() const { diff --git a/lib/Analysis/InstructionSimplify.cpp b/lib/Analysis/InstructionSimplify.cpp index 6605586654..bce7e79318 100644 --- a/lib/Analysis/InstructionSimplify.cpp +++ b/lib/Analysis/InstructionSimplify.cpp @@ -1595,8 +1595,7 @@ static Value *SimplifyICmpInst(unsigned Predicate, Value *LHS, Value *RHS, if (match(RHS, m_Zero())) { bool LHSKnownNonNegative, LHSKnownNegative; switch (Pred) { - default: - assert(false && "Unknown ICmp predicate!"); + default: llvm_unreachable("Unknown ICmp predicate!"); case ICmpInst::ICMP_ULT: return getFalse(ITy); case ICmpInst::ICMP_UGE: @@ -1766,8 +1765,7 @@ static Value *SimplifyICmpInst(unsigned Predicate, Value *LHS, Value *RHS, // there. Use this to work out the result of the comparison. if (RExt != CI) { switch (Pred) { - default: - assert(false && "Unknown ICmp predicate!"); + default: llvm_unreachable("Unknown ICmp predicate!"); // LHS getContext()); case ICmpInst::ICMP_NE: diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp index 81bad631cf..068be3d47c 100644 --- a/lib/AsmParser/LLParser.cpp +++ b/lib/AsmParser/LLParser.cpp @@ -2837,7 +2837,7 @@ bool LLParser::ParseBasicBlock(PerFunctionState &PFS) { } switch (ParseInstruction(Inst, BB, PFS)) { - default: assert(0 && "Unknown ParseInstruction result!"); + default: llvm_unreachable("Unknown ParseInstruction result!"); case InstError: return true; case InstNormal: BB->getInstList().push_back(Inst); diff --git a/lib/ExecutionEngine/ExecutionEngine.cpp b/lib/ExecutionEngine/ExecutionEngine.cpp index b9356dcd0a..2890174bc9 100644 --- a/lib/ExecutionEngine/ExecutionEngine.cpp +++ b/lib/ExecutionEngine/ExecutionEngine.cpp @@ -1149,6 +1149,6 @@ void ExecutionEngineState::AddressMapConfig::onDelete(ExecutionEngineState *EES, void ExecutionEngineState::AddressMapConfig::onRAUW(ExecutionEngineState *, const GlobalValue *, const GlobalValue *) { - assert(false && "The ExecutionEngine doesn't know how to handle a" - " RAUW on a value it has a global mapping for."); + llvm_unreachable("The ExecutionEngine doesn't know how to handle a" + " RAUW on a value it has a global mapping for."); } diff --git a/lib/ExecutionEngine/JIT/JIT.cpp b/lib/ExecutionEngine/JIT/JIT.cpp index eb2e19d392..f715f6f3a2 100644 --- a/lib/ExecutionEngine/JIT/JIT.cpp +++ b/lib/ExecutionEngine/JIT/JIT.cpp @@ -706,9 +706,8 @@ void *JIT::getPointerToBasicBlock(BasicBlock *BB) { if (I != getBasicBlockAddressMap(locked).end()) { return I->second; } else { - assert(0 && "JIT does not have BB address for address-of-label, was" - " it eliminated by optimizer?"); - return 0; + llvm_unreachable("JIT does not have BB address for address-of-label, was" + " it eliminated by optimizer?"); } } diff --git a/lib/ExecutionEngine/JIT/JITEmitter.cpp b/lib/ExecutionEngine/JIT/JITEmitter.cpp index 26201c397d..504c8bdffd 100644 --- a/lib/ExecutionEngine/JIT/JITEmitter.cpp +++ b/lib/ExecutionEngine/JIT/JITEmitter.cpp @@ -76,8 +76,8 @@ namespace { struct NoRAUWValueMapConfig : public ValueMapConfig { typedef JITResolverState *ExtraData; static void onRAUW(JITResolverState *, Value *Old, Value *New) { - assert(false && "The JIT doesn't know how to handle a" - " RAUW on a value it has emitted."); + llvm_unreachable("The JIT doesn't know how to handle a" + " RAUW on a value it has emitted."); } }; @@ -1162,7 +1162,7 @@ void JITEmitter::emitJumpTableInfo(MachineJumpTableInfo *MJTI) { break; } case MachineJumpTableInfo::EK_GPRel64BlockAddress: - assert(false && + llvm_unreachable( "JT Info emission not implemented for GPRel64BlockAddress yet."); } } diff --git a/lib/ExecutionEngine/MCJIT/MCJIT.cpp b/lib/ExecutionEngine/MCJIT/MCJIT.cpp index 6982e74562..5f93a8d3ca 100644 --- a/lib/ExecutionEngine/MCJIT/MCJIT.cpp +++ b/lib/ExecutionEngine/MCJIT/MCJIT.cpp @@ -213,6 +213,5 @@ GenericValue MCJIT::runFunction(Function *F, } } - assert(0 && "Full-featured argument passing not supported yet!"); - return GenericValue(); + llvm_unreachable("Full-featured argument passing not supported yet!"); } diff --git a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp index c0845fbbb2..e15b200c5e 100644 --- a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp +++ b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp @@ -185,9 +185,7 @@ void RuntimeDyldELF::resolveX86_64Relocation(StringRef Name, } switch (RE.Type) { - default: - assert(0 && ("Relocation type not implemented yet!")); - break; + default: llvm_unreachable("Relocation type not implemented yet!"); case ELF::R_X86_64_64: { uint8_t **Target = reinterpret_cast(TargetAddr); *Target = Addr + RE.Addend; @@ -249,8 +247,7 @@ void RuntimeDyldELF::resolveX86Relocation(StringRef Name, default: // There are other relocation types, but it appears these are the // only ones currently used by the LLVM ELF object writer - assert(0 && ("Relocation type not implemented yet!")); - break; + llvm_unreachable("Relocation type not implemented yet!"); } } @@ -272,9 +269,7 @@ void RuntimeDyldELF::resolveRelocation(StringRef Name, case Triple::arm: resolveArmRelocation(Name, Addr, RE); break; - default: - assert(0 && "Unsupported CPU type!"); - break; + default: llvm_unreachable("Unsupported CPU type!"); } } diff --git a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp index 669ff4c6f8..4be91d347b 100644 --- a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp +++ b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp @@ -26,7 +26,7 @@ resolveRelocation(uint8_t *Address, uint64_t Value, bool isPCRel, unsigned Type, unsigned Size, int64_t Addend) { // This just dispatches to the proper target specific routine. switch (CPUType) { - default: assert(0 && "Unsupported CPU type!"); + default: llvm_unreachable("Unsupported CPU type!"); case mach::CTM_x86_64: return resolveX86_64Relocation((uintptr_t)Address, (uintptr_t)Value, isPCRel, Type, Size, Addend); diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp index 60fa9a76e2..73ae6ad8c2 100644 --- a/lib/Linker/LinkModules.cpp +++ b/lib/Linker/LinkModules.cpp @@ -267,7 +267,7 @@ Type *TypeMapTy::getImpl(Type *Ty) { // Otherwise, rebuild a modified type. switch (Ty->getTypeID()) { - default: assert(0 && "unknown derived type to remap"); + default: llvm_unreachable("unknown derived type to remap"); case Type::ArrayTyID: return *Entry = ArrayType::get(ElementTypes[0], cast(Ty)->getNumElements()); diff --git a/lib/MC/MCAsmStreamer.cpp b/lib/MC/MCAsmStreamer.cpp index ba6dee7cc2..f7c6765ff3 100644 --- a/lib/MC/MCAsmStreamer.cpp +++ b/lib/MC/MCAsmStreamer.cpp @@ -394,7 +394,7 @@ void MCAsmStreamer::EmitDwarfAdvanceFrameAddr(const MCSymbol *LastLabel, void MCAsmStreamer::EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) { switch (Attribute) { - case MCSA_Invalid: assert(0 && "Invalid symbol attribute"); + case MCSA_Invalid: llvm_unreachable("Invalid symbol attribute"); case MCSA_ELF_TypeFunction: /// .type _foo, STT_FUNC # aka @function case MCSA_ELF_TypeIndFunction: /// .type _foo, STT_GNU_IFUNC case MCSA_ELF_TypeObject: /// .type _foo, STT_OBJECT # aka @object @@ -406,7 +406,7 @@ void MCAsmStreamer::EmitSymbolAttribute(MCSymbol *Symbol, OS << "\t.type\t" << *Symbol << ',' << ((MAI.getCommentString()[0] != '@') ? '@' : '%'); switch (Attribute) { - default: assert(0 && "Unknown ELF .type"); + default: llvm_unreachable("Unknown ELF .type"); case MCSA_ELF_TypeFunction: OS << "function"; break; case MCSA_ELF_TypeIndFunction: OS << "gnu_indirect_function"; break; case MCSA_ELF_TypeObject: OS << "object"; break; diff --git a/lib/MC/MCAssembler.cpp b/lib/MC/MCAssembler.cpp index 0087f67b43..c041f65640 100644 --- a/lib/MC/MCAssembler.cpp +++ b/lib/MC/MCAssembler.cpp @@ -348,8 +348,7 @@ uint64_t MCAssembler::computeFragmentSize(const MCAsmLayout &Layout, return cast(F).getContents().size(); } - assert(0 && "invalid fragment kind"); - return 0; + llvm_unreachable("invalid fragment kind"); } void MCAsmLayout::LayoutFragment(MCFragment *F) { @@ -414,8 +413,7 @@ static void WriteFragmentData(const MCAssembler &Asm, const MCAsmLayout &Layout, // Otherwise, write out in multiples of the value size. for (uint64_t i = 0; i != Count; ++i) { switch (AF.getValueSize()) { - default: - assert(0 && "Invalid size!"); + default: llvm_unreachable("Invalid size!"); case 1: OW->Write8 (uint8_t (AF.getValue())); break; case 2: OW->Write16(uint16_t(AF.getValue())); break; case 4: OW->Write32(uint32_t(AF.getValue())); break; @@ -439,8 +437,7 @@ static void WriteFragmentData(const MCAssembler &Asm, const MCAsmLayout &Layout, for (uint64_t i = 0, e = FF.getSize() / FF.getValueSize(); i != e; ++i) { switch (FF.getValueSize()) { - default: - assert(0 && "Invalid size!"); + default: llvm_unreachable("Invalid size!"); case 1: OW->Write8 (uint8_t (FF.getValue())); break; case 2: OW->Write16(uint16_t(FF.getValue())); break; case 4: OW->Write32(uint32_t(FF.getValue())); break; @@ -496,8 +493,7 @@ void MCAssembler::writeSectionData(const MCSectionData *SD, for (MCSectionData::const_iterator it = SD->begin(), ie = SD->end(); it != ie; ++it) { switch (it->getKind()) { - default: - assert(0 && "Invalid fragment in virtual section!"); + default: llvm_unreachable("Invalid fragment in virtual section!"); case MCFragment::FT_Data: { // Check that we aren't trying to write a non-zero contents (or fixups) // into a virtual section. This is to support clients which use standard diff --git a/lib/MC/MCDisassembler/EDMain.cpp b/lib/MC/MCDisassembler/EDMain.cpp index 3fd355b4bc..c658717b02 100644 --- a/lib/MC/MCDisassembler/EDMain.cpp +++ b/lib/MC/MCDisassembler/EDMain.cpp @@ -23,7 +23,7 @@ int EDGetDisassembler(EDDisassemblerRef *disassembler, EDAssemblySyntax_t syntax) { EDDisassembler::AssemblySyntax Syntax; switch (syntax) { - default: assert(0 && "Unknown assembly syntax!"); + default: llvm_unreachable("Unknown assembly syntax!"); case kEDAssemblySyntaxX86Intel: Syntax = EDDisassembler::kEDAssemblySyntaxX86Intel; break; diff --git a/lib/MC/MCDwarf.cpp b/lib/MC/MCDwarf.cpp index 65f1ad1e17..1b6dbdc3a3 100644 --- a/lib/MC/MCDwarf.cpp +++ b/lib/MC/MCDwarf.cpp @@ -765,8 +765,7 @@ static unsigned getSizeForEncoding(MCStreamer &streamer, MCContext &context = streamer.getContext(); unsigned format = symbolEncoding & 0x0f; switch (format) { - default: - assert(0 && "Unknown Encoding"); + default: llvm_unreachable("Unknown Encoding"); case dwarf::DW_EH_PE_absptr: case dwarf::DW_EH_PE_signed: return context.getAsmInfo().getPointerSize(); diff --git a/lib/MC/MCELFStreamer.cpp b/lib/MC/MCELFStreamer.cpp index 42a7ebf7d4..607e01cd82 100644 --- a/lib/MC/MCELFStreamer.cpp +++ b/lib/MC/MCELFStreamer.cpp @@ -60,24 +60,24 @@ public: virtual void EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol); virtual void EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute); virtual void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) { - assert(0 && "ELF doesn't support this directive"); + llvm_unreachable("ELF doesn't support this directive"); } virtual void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment); virtual void BeginCOFFSymbolDef(const MCSymbol *Symbol) { - assert(0 && "ELF doesn't support this directive"); + llvm_unreachable("ELF doesn't support this directive"); } virtual void EmitCOFFSymbolStorageClass(int StorageClass) { - assert(0 && "ELF doesn't support this directive"); + llvm_unreachable("ELF doesn't support this directive"); } virtual void EmitCOFFSymbolType(int Type) { - assert(0 && "ELF doesn't support this directive"); + llvm_unreachable("ELF doesn't support this directive"); } virtual void EndCOFFSymbolDef() { - assert(0 && "ELF doesn't support this directive"); + llvm_unreachable("ELF doesn't support this directive"); } virtual void EmitELFSize(MCSymbol *Symbol, const MCExpr *Value) { @@ -90,11 +90,11 @@ public: virtual void EmitZerofill(const MCSection *Section, MCSymbol *Symbol = 0, unsigned Size = 0, unsigned ByteAlignment = 0) { - assert(0 && "ELF doesn't support this directive"); + llvm_unreachable("ELF doesn't support this directive"); } virtual void EmitTBSSSymbol(const MCSection *Section, MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment = 0) { - assert(0 && "ELF doesn't support this directive"); + llvm_unreachable("ELF doesn't support this directive"); } virtual void EmitBytes(StringRef Data, unsigned AddrSpace); virtual void EmitValueToAlignment(unsigned ByteAlignment, int64_t Value = 0, @@ -180,7 +180,7 @@ void MCELFStreamer::EmitAssemblerFlag(MCAssemblerFlag Flag) { return; } - assert(0 && "invalid assembler flag!"); + llvm_unreachable("invalid assembler flag!"); } void MCELFStreamer::EmitThumbFunc(MCSymbol *Func) { @@ -250,8 +250,7 @@ void MCELFStreamer::EmitSymbolAttribute(MCSymbol *Symbol, case MCSA_WeakDefAutoPrivate: case MCSA_Invalid: case MCSA_IndirectSymbol: - assert(0 && "Invalid symbol attribute for ELF!"); - break; + llvm_unreachable("Invalid symbol attribute for ELF!"); case MCSA_ELF_TypeGnuUniqueObject: // Ignore for now. diff --git a/lib/MC/MCExpr.cpp b/lib/MC/MCExpr.cpp index 9a19f6deba..ccdccdf514 100644 --- a/lib/MC/MCExpr.cpp +++ b/lib/MC/MCExpr.cpp @@ -132,7 +132,7 @@ void MCExpr::print(raw_ostream &OS) const { } } - assert(0 && "Invalid expression kind!"); + llvm_unreachable("Invalid expression kind!"); } void MCExpr::dump() const { @@ -576,8 +576,7 @@ bool MCExpr::EvaluateAsRelocatableImpl(MCValue &Res, } } - assert(0 && "Invalid assembly expression kind!"); - return false; + llvm_unreachable("Invalid assembly expression kind!"); } const MCSection *MCExpr::FindAssociatedSection() const { @@ -618,6 +617,5 @@ const MCSection *MCExpr::FindAssociatedSection() const { } } - assert(0 && "Invalid assembly expression kind!"); - return 0; + llvm_unreachable("Invalid assembly expression kind!"); } diff --git a/lib/MC/MCInstPrinter.cpp b/lib/MC/MCInstPrinter.cpp index 2317a2891f..3060ad6003 100644 --- a/lib/MC/MCInstPrinter.cpp +++ b/lib/MC/MCInstPrinter.cpp @@ -10,6 +10,7 @@ #include "llvm/MC/MCInstPrinter.h" #include "llvm/MC/MCAsmInfo.h" #include "llvm/ADT/StringRef.h" +#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; @@ -23,7 +24,7 @@ StringRef MCInstPrinter::getOpcodeName(unsigned Opcode) const { } void MCInstPrinter::printRegName(raw_ostream &OS, unsigned RegNo) const { - assert(0 && "Target should implement this"); + llvm_unreachable("Target should implement this"); } void MCInstPrinter::printAnnotation(raw_ostream &OS, StringRef Annot) { diff --git a/lib/MC/MCMachOStreamer.cpp b/lib/MC/MCMachOStreamer.cpp index bf659762fb..bc6cf77321 100644 --- a/lib/MC/MCMachOStreamer.cpp +++ b/lib/MC/MCMachOStreamer.cpp @@ -53,23 +53,23 @@ public: virtual void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment); virtual void BeginCOFFSymbolDef(const MCSymbol *Symbol) { - assert(0 && "macho doesn't support this directive"); + llvm_unreachable("macho doesn't support this directive"); } virtual void EmitCOFFSymbolStorageClass(int StorageClass) { - assert(0 && "macho doesn't support this directive"); + llvm_unreachable("macho doesn't support this directive"); } virtual void EmitCOFFSymbolType(int Type) { - assert(0 && "macho doesn't support this directive"); + llvm_unreachable("macho doesn't support this directive"); } virtual void EndCOFFSymbolDef() { - assert(0 && "macho doesn't support this directive"); + llvm_unreachable("macho doesn't support this directive"); } virtual void EmitELFSize(MCSymbol *Symbol, const MCExpr *Value) { - assert(0 && "macho doesn't support this directive"); + llvm_unreachable("macho doesn't support this directive"); } virtual void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment) { - assert(0 && "macho doesn't support this directive"); + llvm_unreachable("macho doesn't support this directive"); } virtual void EmitZerofill(const MCSection *Section, MCSymbol *Symbol = 0, unsigned Size = 0, unsigned ByteAlignment = 0); @@ -211,8 +211,7 @@ void MCMachOStreamer::EmitSymbolAttribute(MCSymbol *Symbol, case MCSA_Protected: case MCSA_Weak: case MCSA_Local: - assert(0 && "Invalid symbol attribute for Mach-O!"); - break; + llvm_unreachable("Invalid symbol attribute for Mach-O!"); case MCSA_Global: SD.setExternal(true); diff --git a/lib/MC/MCParser/AsmParser.cpp b/lib/MC/MCParser/AsmParser.cpp index dad72d2050..bd5956f9b4 100644 --- a/lib/MC/MCParser/AsmParser.cpp +++ b/lib/MC/MCParser/AsmParser.cpp @@ -805,8 +805,7 @@ AsmParser::ApplyModifierToExpr(const MCExpr *E, } } - assert(0 && "Invalid expression kind!"); - return 0; + llvm_unreachable("Invalid expression kind!"); } /// ParseExpression - Parse an expression and return it. diff --git a/lib/MC/MCStreamer.cpp b/lib/MC/MCStreamer.cpp index 50a5f8d169..6d53fb196c 100644 --- a/lib/MC/MCStreamer.cpp +++ b/lib/MC/MCStreamer.cpp @@ -600,7 +600,7 @@ void MCStreamer::EmitWin64EHEndProlog() { } void MCStreamer::EmitCOFFSecRel32(MCSymbol const *Symbol) { - assert(0 && "This file format doesn't support this directive"); + llvm_unreachable("This file format doesn't support this directive"); } void MCStreamer::EmitFnStart() { diff --git a/lib/Support/ConstantRange.cpp b/lib/Support/ConstantRange.cpp index 0432921b87..5206cf1f9b 100644 --- a/lib/Support/ConstantRange.cpp +++ b/lib/Support/ConstantRange.cpp @@ -55,7 +55,7 @@ ConstantRange ConstantRange::makeICmpRegion(unsigned Pred, uint32_t W = CR.getBitWidth(); switch (Pred) { - default: assert(0 && "Invalid ICmp predicate to makeICmpRegion()"); + default: llvm_unreachable("Invalid ICmp predicate to makeICmpRegion()"); case CmpInst::ICMP_EQ: return CR; case CmpInst::ICMP_NE: diff --git a/lib/Support/Triple.cpp b/lib/Support/Triple.cpp index 7c4da12bfe..f400c9969f 100644 --- a/lib/Support/Triple.cpp +++ b/lib/Support/Triple.cpp @@ -459,8 +459,7 @@ std::string Triple::normalize(StringRef Str) { bool Valid = false; StringRef Comp = Components[Idx]; switch (Pos) { - default: - assert(false && "unexpected component type!"); + default: llvm_unreachable("unexpected component type!"); case 0: Arch = ParseArch(Comp); Valid = Arch != UnknownArch; @@ -618,7 +617,7 @@ bool Triple::getMacOSXVersion(unsigned &Major, unsigned &Minor, getOSVersion(Major, Minor, Micro); switch (getOS()) { - default: assert(0 && "unexpected OS for Darwin triple"); + default: llvm_unreachable("unexpected OS for Darwin triple"); case Darwin: // Default to darwin8, i.e., MacOSX 10.4. if (Major == 0) diff --git a/lib/TableGen/Record.cpp b/lib/TableGen/Record.cpp index e8f23e4888..fece0df412 100644 --- a/lib/TableGen/Record.cpp +++ b/lib/TableGen/Record.cpp @@ -942,7 +942,7 @@ Init *BinOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) const { int64_t LHSv = LHSi->getValue(), RHSv = RHSi->getValue(); int64_t Result; switch (getOpcode()) { - default: assert(0 && "Bad opcode!"); + default: llvm_unreachable("Bad opcode!"); case SHL: Result = LHSv << RHSv; break; case SRA: Result = LHSv >> RHSv; break; case SRL: Result = (uint64_t)LHSv >> (uint64_t)RHSv; break; diff --git a/lib/TableGen/TGParser.cpp b/lib/TableGen/TGParser.cpp index 0f64f4bcda..c7cf097aee 100644 --- a/lib/TableGen/TGParser.cpp +++ b/lib/TableGen/TGParser.cpp @@ -729,7 +729,7 @@ Init *TGParser::ParseOperation(Record *CurRec) { RecTy *Type = 0; switch (Lex.getCode()) { - default: assert(0 && "Unhandled code!"); + default: llvm_unreachable("Unhandled code!"); case tgtok::XCast: Lex.Lex(); // eat the operation Code = UnOpInit::CAST; @@ -845,7 +845,7 @@ Init *TGParser::ParseOperation(Record *CurRec) { RecTy *Type = 0; switch (OpTok) { - default: assert(0 && "Unhandled code!"); + default: llvm_unreachable("Unhandled code!"); case tgtok::XConcat: Code = BinOpInit::CONCAT;Type = DagRecTy::get(); break; case tgtok::XSRA: Code = BinOpInit::SRA; Type = IntRecTy::get(); break; case tgtok::XSRL: Code = BinOpInit::SRL; Type = IntRecTy::get(); break; @@ -909,7 +909,7 @@ Init *TGParser::ParseOperation(Record *CurRec) { tgtok::TokKind LexCode = Lex.getCode(); Lex.Lex(); // eat the operation switch (LexCode) { - default: assert(0 && "Unhandled code!"); + default: llvm_unreachable("Unhandled code!"); case tgtok::XIf: Code = TernOpInit::IF; break; @@ -954,7 +954,7 @@ Init *TGParser::ParseOperation(Record *CurRec) { Lex.Lex(); // eat the ')' switch (LexCode) { - default: assert(0 && "Unhandled code!"); + default: llvm_unreachable("Unhandled code!"); case tgtok::XIf: { // FIXME: The `!if' operator doesn't handle non-TypedInit well at // all. This can be made much more robust. diff --git a/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp index d2298a0f7d..7cb56f8fe6 100644 --- a/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp +++ b/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp @@ -110,7 +110,7 @@ static Value *getFCmpValue(bool isordered, unsigned code, InstCombiner::BuilderTy *Builder) { CmpInst::Predicate Pred; switch (code) { - default: assert(0 && "Illegal FCmp code!"); + default: llvm_unreachable("Illegal FCmp code!"); case 0: Pred = isordered ? FCmpInst::FCMP_ORD : FCmpInst::FCMP_UNO; break; case 1: Pred = isordered ? FCmpInst::FCMP_OGT : FCmpInst::FCMP_UGT; break; case 2: Pred = isordered ? FCmpInst::FCMP_OEQ : FCmpInst::FCMP_UEQ; break; diff --git a/lib/Transforms/InstCombine/InstCombineShifts.cpp b/lib/Transforms/InstCombine/InstCombineShifts.cpp index a66e650895..b31049e59f 100644 --- a/lib/Transforms/InstCombine/InstCombineShifts.cpp +++ b/lib/Transforms/InstCombine/InstCombineShifts.cpp @@ -199,7 +199,7 @@ static Value *GetShiftedValue(Value *V, unsigned NumBits, bool isLeftShift, IC.Worklist.Add(I); switch (I->getOpcode()) { - default: assert(0 && "Inconsistency with CanEvaluateShifted"); + default: llvm_unreachable("Inconsistency with CanEvaluateShifted"); case Instruction::And: case Instruction::Or: case Instruction::Xor: diff --git a/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/lib/Transforms/Instrumentation/AddressSanitizer.cpp index b8ead89a8f..150868d577 100644 --- a/lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ b/lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -703,8 +703,7 @@ static uint64_t ValueForPoison(uint64_t PoisonByte, size_t ShadowRedzoneSize) { if (ShadowRedzoneSize == 4) return (PoisonByte << 24) + (PoisonByte << 16) + (PoisonByte << 8) + (PoisonByte); - assert(0 && "ShadowRedzoneSize is either 1, 2 or 4"); - return 0; + llvm_unreachable("ShadowRedzoneSize is either 1, 2 or 4"); } static void PoisonShadowPartialRightRedzone(uint8_t *Shadow, diff --git a/lib/Transforms/Scalar/DeadStoreElimination.cpp b/lib/Transforms/Scalar/DeadStoreElimination.cpp index 8729019705..c8c5360601 100644 --- a/lib/Transforms/Scalar/DeadStoreElimination.cpp +++ b/lib/Transforms/Scalar/DeadStoreElimination.cpp @@ -224,7 +224,7 @@ static bool isRemovable(Instruction *I) { IntrinsicInst *II = cast(I); switch (II->getIntrinsicID()) { - default: assert(0 && "doesn't pass 'hasMemoryWrite' predicate"); + default: llvm_unreachable("doesn't pass 'hasMemoryWrite' predicate"); case Intrinsic::lifetime_end: // Never remove dead lifetime_end's, e.g. because it is followed by a // free. @@ -268,7 +268,7 @@ static Value *getStoredPointerOperand(Instruction *I) { IntrinsicInst *II = cast(I); switch (II->getIntrinsicID()) { - default: assert(false && "Unexpected intrinsic!"); + default: llvm_unreachable("Unexpected intrinsic!"); case Intrinsic::init_trampoline: return II->getArgOperand(0); } diff --git a/lib/Transforms/Utils/CmpInstAnalysis.cpp b/lib/Transforms/Utils/CmpInstAnalysis.cpp index 8983e0c4f0..9b099150a7 100644 --- a/lib/Transforms/Utils/CmpInstAnalysis.cpp +++ b/lib/Transforms/Utils/CmpInstAnalysis.cpp @@ -72,7 +72,7 @@ unsigned llvm::getICmpCode(const ICmpInst *ICI, bool InvertPred) { Value *llvm::getICmpValue(bool Sign, unsigned Code, Value *LHS, Value *RHS, CmpInst::Predicate &NewICmpPred) { switch (Code) { - default: assert(0 && "Illegal ICmp code!"); + default: llvm_unreachable("Illegal ICmp code!"); case 0: // False. return ConstantInt::get(CmpInst::makeCmpResultType(LHS->getType()), 0); case 1: NewICmpPred = Sign ? ICmpInst::ICMP_SGT : ICmpInst::ICMP_UGT; break; -- cgit v1.2.3