From 47138b2f833921f37781884080295d4b576ec920 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Wed, 25 Mar 2020 13:48:02 -0400 Subject: [PATCH] Suppress a few -Wunreachable-code warnings. No behavior change. Also fix a comment to say match reality. --- lib/DebugInfo/DWARF/DWARFContext.cpp | 10 +++----- lib/TextAPI/MachO/TextStub.cpp | 6 ++--- tools/llvm-lipo/llvm-lipo.cpp | 1 - utils/PerfectShuffle/PerfectShuffle.cpp | 4 +-- utils/TableGen/CodeGenSchedule.cpp | 34 ++++++++++++------------- 5 files changed, 23 insertions(+), 32 deletions(-) diff --git a/lib/DebugInfo/DWARF/DWARFContext.cpp b/lib/DebugInfo/DWARF/DWARFContext.cpp index 7541bb794c7..908128b0205 100644 --- a/lib/DebugInfo/DWARF/DWARFContext.cpp +++ b/lib/DebugInfo/DWARF/DWARFContext.cpp @@ -1931,14 +1931,10 @@ Error DWARFContext::loadRegisterInfo(const object::ObjectFile &Obj) { uint8_t DWARFContext::getCUAddrSize() { // In theory, different compile units may have different address byte // sizes, but for simplicity we just use the address byte size of the - // last compile unit. In practice the address size field is repeated across + // first compile unit. In practice the address size field is repeated across // various DWARF headers (at least in version 5) to make it easier to dump // them independently, not to enable varying the address size. - uint8_t Addr = 0; - for (const auto &CU : compile_units()) { - Addr = CU->getAddressByteSize(); - break; - } - return Addr; + unit_iterator_range CUs = compile_units(); + return CUs.empty() ? 0 : (*CUs.begin())->getAddressByteSize(); } diff --git a/lib/TextAPI/MachO/TextStub.cpp b/lib/TextAPI/MachO/TextStub.cpp index 5637639b8ef..3c6c5ac2530 100644 --- a/lib/TextAPI/MachO/TextStub.cpp +++ b/lib/TextAPI/MachO/TextStub.cpp @@ -450,10 +450,8 @@ template <> struct MappingTraits { if (File->isInstallAPI()) Flags |= TBDFlags::InstallAPI; - for (const auto &Iter : File->umbrellas()) { - ParentUmbrella = Iter.second; - break; - } + if (!File->umbrellas().empty()) + ParentUmbrella = File->umbrellas().begin()->second; std::set ArchSet; for (const auto &Library : File->allowableClients()) diff --git a/tools/llvm-lipo/llvm-lipo.cpp b/tools/llvm-lipo/llvm-lipo.cpp index e75327ee53a..8c2740d8c94 100644 --- a/tools/llvm-lipo/llvm-lipo.cpp +++ b/tools/llvm-lipo/llvm-lipo.cpp @@ -763,7 +763,6 @@ static void extractSlice(ArrayRef> InputBinaries, reportError("input file " + InputBinaries.front().getBinary()->getFileName() + " must be a fat file when the -extract option is specified"); - exit(EXIT_FAILURE); } SmallVector, 2> ExtractedObjects; diff --git a/utils/PerfectShuffle/PerfectShuffle.cpp b/utils/PerfectShuffle/PerfectShuffle.cpp index 0f2e6729840..d941cd685ec 100644 --- a/utils/PerfectShuffle/PerfectShuffle.cpp +++ b/utils/PerfectShuffle/PerfectShuffle.cpp @@ -423,7 +423,7 @@ int main() { } std::cout << " 0\n};\n"; - if (0) { + LLVM_DEBUG({ // Print out the table. for (unsigned i = 0; i != 0x8889; ++i) { if (!isValidMask(i)) continue; @@ -440,7 +440,7 @@ int main() { std::cerr << "\n"; } } - } + }) } diff --git a/utils/TableGen/CodeGenSchedule.cpp b/utils/TableGen/CodeGenSchedule.cpp index 09cbb234f89..67583c736cd 100644 --- a/utils/TableGen/CodeGenSchedule.cpp +++ b/utils/TableGen/CodeGenSchedule.cpp @@ -1082,15 +1082,14 @@ void CodeGenSchedModels::createInstRWClass(Record *InstRWDef) { for (Record *RWD : RWDefs) { if (RWD->getValueAsDef("SchedModel") == RWModelDef && RWModelDef->getValueAsBit("FullInstRWOverlapCheck")) { - for (Record *Inst : InstDefs) { - PrintFatalError - (InstRWDef->getLoc(), - "Overlapping InstRW definition for \"" + - Inst->getName() + - "\" also matches previous \"" + - RWD->getValue("Instrs")->getValue()->getAsString() + - "\"."); - } + assert(!InstDefs.empty()); // Checked at function start. + PrintFatalError + (InstRWDef->getLoc(), + "Overlapping InstRW definition for \"" + + InstDefs.front()->getName() + + "\" also matches previous \"" + + RWD->getValue("Instrs")->getValue()->getAsString() + + "\"."); } } LLVM_DEBUG(dbgs() << "InstRW: Reuse SC " << OldSCIdx << ":" @@ -1118,15 +1117,14 @@ void CodeGenSchedModels::createInstRWClass(Record *InstRWDef) { Record *RWModelDef = InstRWDef->getValueAsDef("SchedModel"); for (Record *OldRWDef : SchedClasses[OldSCIdx].InstRWs) { if (OldRWDef->getValueAsDef("SchedModel") == RWModelDef) { - for (Record *InstDef : InstDefs) { - PrintFatalError - (InstRWDef->getLoc(), - "Overlapping InstRW definition for \"" + - InstDef->getName() + - "\" also matches previous \"" + - OldRWDef->getValue("Instrs")->getValue()->getAsString() + - "\"."); - } + assert(!InstDefs.empty()); // Checked at function start. + PrintFatalError + (InstRWDef->getLoc(), + "Overlapping InstRW definition for \"" + + InstDefs.front()->getName() + + "\" also matches previous \"" + + OldRWDef->getValue("Instrs")->getValue()->getAsString() + + "\"."); } assert(OldRWDef != InstRWDef && "SchedClass has duplicate InstRW def");