From d7888149aa813fb543d562d0891739b1f85f5622 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. --- clang/lib/StaticAnalyzer/Core/ExprEngine.cpp | 3 +- llvm/lib/DebugInfo/DWARF/DWARFContext.cpp | 10 ++---- llvm/lib/TextAPI/MachO/TextStub.cpp | 6 ++-- llvm/tools/llvm-lipo/llvm-lipo.cpp | 1 - llvm/utils/PerfectShuffle/PerfectShuffle.cpp | 4 +-- llvm/utils/TableGen/CodeGenSchedule.cpp | 34 +++++++++----------- 6 files changed, 25 insertions(+), 33 deletions(-) diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp index b9adee87436a..5405c812faca 100644 --- a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp +++ b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -3173,9 +3173,10 @@ std::string ExprEngine::DumpGraph(bool trim, StringRef Filename) { /*Title=*/"Exploded Graph", /*Filename=*/std::string(Filename)); } -#endif +#else llvm::errs() << "Warning: dumping graph requires assertions" << "\n"; return ""; +#endif } std::string ExprEngine::DumpGraph(ArrayRef Nodes, diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp index 7541bb794c73..908128b0205c 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp +++ b/llvm/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/llvm/lib/TextAPI/MachO/TextStub.cpp b/llvm/lib/TextAPI/MachO/TextStub.cpp index 5637639b8ef8..3c6c5ac25308 100644 --- a/llvm/lib/TextAPI/MachO/TextStub.cpp +++ b/llvm/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/llvm/tools/llvm-lipo/llvm-lipo.cpp b/llvm/tools/llvm-lipo/llvm-lipo.cpp index e75327ee53ab..8c2740d8c94d 100644 --- a/llvm/tools/llvm-lipo/llvm-lipo.cpp +++ b/llvm/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/llvm/utils/PerfectShuffle/PerfectShuffle.cpp b/llvm/utils/PerfectShuffle/PerfectShuffle.cpp index 0f2e67298404..d941cd685ece 100644 --- a/llvm/utils/PerfectShuffle/PerfectShuffle.cpp +++ b/llvm/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/llvm/utils/TableGen/CodeGenSchedule.cpp b/llvm/utils/TableGen/CodeGenSchedule.cpp index 09cbb234f893..67583c736cd2 100644 --- a/llvm/utils/TableGen/CodeGenSchedule.cpp +++ b/llvm/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");