[llvm] 7aeb153 - [llvm-objdump] addPltEntries: reduce indentation. NFC
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Wed May 3 21:20:59 PDT 2023
Author: Fangrui Song
Date: 2023-05-03T21:20:54-07:00
New Revision: 7aeb1536a1a1c1b9ffd6180a8d3824c7a1d7b2cf
URL: https://github.com/llvm/llvm-project/commit/7aeb1536a1a1c1b9ffd6180a8d3824c7a1d7b2cf
DIFF: https://github.com/llvm/llvm-project/commit/7aeb1536a1a1c1b9ffd6180a8d3824c7a1d7b2cf.diff
LOG: [llvm-objdump] addPltEntries: reduce indentation. NFC
Added:
Modified:
llvm/tools/llvm-objdump/llvm-objdump.cpp
Removed:
################################################################################
diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp
index 5abcdcc78844..8e372cb98b16 100644
--- a/llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -914,6 +914,9 @@ addMissingWasmCodeSymbols(const WasmObjectFile &Obj,
static void addPltEntries(const ObjectFile &Obj,
std::map<SectionRef, SectionSymbolsTy> &AllSymbols,
StringSaver &Saver) {
+ auto *ElfObj = dyn_cast<ELFObjectFileBase>(&Obj);
+ if (!ElfObj)
+ return;
std::optional<SectionRef> Plt;
for (const SectionRef &Section : Obj.sections()) {
Expected<StringRef> SecNameOrErr = Section.getName();
@@ -926,26 +929,24 @@ static void addPltEntries(const ObjectFile &Obj,
}
if (!Plt)
return;
- if (auto *ElfObj = dyn_cast<ELFObjectFileBase>(&Obj)) {
- for (auto PltEntry : ElfObj->getPltAddresses()) {
- if (PltEntry.first) {
- SymbolRef Symbol(*PltEntry.first, ElfObj);
- uint8_t SymbolType = getElfSymbolType(Obj, Symbol);
- if (Expected<StringRef> NameOrErr = Symbol.getName()) {
- if (!NameOrErr->empty())
- AllSymbols[*Plt].emplace_back(
- PltEntry.second, Saver.save((*NameOrErr + "@plt").str()),
- SymbolType);
- continue;
- } else {
- // The warning has been reported in disassembleObject().
- consumeError(NameOrErr.takeError());
- }
+ for (auto PltEntry : ElfObj->getPltAddresses()) {
+ if (PltEntry.first) {
+ SymbolRef Symbol(*PltEntry.first, ElfObj);
+ uint8_t SymbolType = getElfSymbolType(Obj, Symbol);
+ if (Expected<StringRef> NameOrErr = Symbol.getName()) {
+ if (!NameOrErr->empty())
+ AllSymbols[*Plt].emplace_back(
+ PltEntry.second, Saver.save((*NameOrErr + "@plt").str()),
+ SymbolType);
+ continue;
+ } else {
+ // The warning has been reported in disassembleObject().
+ consumeError(NameOrErr.takeError());
}
- reportWarning("PLT entry at 0x" + Twine::utohexstr(PltEntry.second) +
- " references an invalid symbol",
- Obj.getFileName());
}
+ reportWarning("PLT entry at 0x" + Twine::utohexstr(PltEntry.second) +
+ " references an invalid symbol",
+ Obj.getFileName());
}
}
More information about the llvm-commits
mailing list