forked from OSchip/llvm-project
[llvm-readobj] Simplify startswith+drop_front pattern with consume_front. NFC
This commit is contained in:
parent
c579ab53bd
commit
124d9fc958
|
@ -1423,12 +1423,12 @@ static std::string getGNUPtType(unsigned Arch, unsigned Type) {
|
|||
return std::string("<unknown>: ") + to_string(format_hex(Type, 1));
|
||||
|
||||
// E.g. "PT_ARM_EXIDX" -> "EXIDX".
|
||||
if (Seg.startswith("PT_ARM_"))
|
||||
return Seg.drop_front(7).str();
|
||||
if (Seg.consume_front("PT_ARM_"))
|
||||
return Seg.str();
|
||||
|
||||
// E.g. "PT_MIPS_REGINFO" -> "REGINFO".
|
||||
if (Seg.startswith("PT_MIPS_"))
|
||||
return Seg.drop_front(8).str();
|
||||
if (Seg.consume_front("PT_MIPS_"))
|
||||
return Seg.str();
|
||||
|
||||
// E.g. "PT_LOAD" -> "LOAD".
|
||||
assert(Seg.startswith("PT_"));
|
||||
|
@ -3641,18 +3641,18 @@ static std::string getSectionTypeString(unsigned Machine, unsigned Type) {
|
|||
StringRef Name = getELFSectionTypeName(Machine, Type);
|
||||
|
||||
// Handle SHT_GNU_* type names.
|
||||
if (Name.startswith("SHT_GNU_")) {
|
||||
if (Name == "SHT_GNU_HASH")
|
||||
if (Name.consume_front("SHT_GNU_")) {
|
||||
if (Name == "HASH")
|
||||
return "GNU_HASH";
|
||||
// E.g. SHT_GNU_verneed -> VERNEED.
|
||||
return Name.drop_front(8).upper();
|
||||
return Name.upper();
|
||||
}
|
||||
|
||||
if (Name == "SHT_SYMTAB_SHNDX")
|
||||
return "SYMTAB SECTION INDICES";
|
||||
|
||||
if (Name.startswith("SHT_"))
|
||||
return Name.drop_front(4).str();
|
||||
if (Name.consume_front("SHT_"))
|
||||
return Name.str();
|
||||
return getSectionTypeOffsetString(Type);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue