[llvm] d788814 - Suppress a few -Wunreachable-code warnings.
Nico Weber via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 25 10:55:57 PDT 2020
Author: Nico Weber
Date: 2020-03-25T13:55:42-04:00
New Revision: d7888149aa813fb543d562d0891739b1f85f5622
URL: https://github.com/llvm/llvm-project/commit/d7888149aa813fb543d562d0891739b1f85f5622
DIFF: https://github.com/llvm/llvm-project/commit/d7888149aa813fb543d562d0891739b1f85f5622.diff
LOG: Suppress a few -Wunreachable-code warnings.
No behavior change. Also fix a comment to say match reality.
Added:
Modified:
clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
llvm/lib/TextAPI/MachO/TextStub.cpp
llvm/tools/llvm-lipo/llvm-lipo.cpp
llvm/utils/PerfectShuffle/PerfectShuffle.cpp
llvm/utils/TableGen/CodeGenSchedule.cpp
Removed:
################################################################################
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<const ExplodedNode*> 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,
diff erent compile units may have
diff erent 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<const InterfaceFile *> {
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<ArchitectureSet> 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<OwningBinary<Binary>> InputBinaries,
reportError("input file " +
InputBinaries.front().getBinary()->getFileName() +
" must be a fat file when the -extract option is specified");
- exit(EXIT_FAILURE);
}
SmallVector<std::unique_ptr<MachOObjectFile>, 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");
More information about the llvm-commits
mailing list