From 2bd7c60ff75a6cfdb771881b43647329f5f8f74f Mon Sep 17 00:00:00 2001 From: George Rimar Date: Mon, 29 Apr 2019 12:25:01 +0000 Subject: [PATCH] [yaml2obj] - Simplify and reduce the code. NFC. This inlines 2 single line static methods and simplifies the code. It is also possible to remove the `Is64Bit` variable since it is used only once, but I am not sure it will be better for readability. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@359445 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/yaml2obj/yaml2elf.cpp | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/tools/yaml2obj/yaml2elf.cpp b/tools/yaml2obj/yaml2elf.cpp index ba07c9c100c..cb12cdd5385 100644 --- a/tools/yaml2obj/yaml2elf.cpp +++ b/tools/yaml2obj/yaml2elf.cpp @@ -933,24 +933,15 @@ std::vector ELFState::implicitSectionNames() const { return {".symtab", ".strtab", ".shstrtab", ".dynsym", ".dynstr"}; } -static bool is64Bit(const ELFYAML::Object &Doc) { - return Doc.Header.Class == ELFYAML::ELF_ELFCLASS(ELF::ELFCLASS64); -} - -static bool isLittleEndian(const ELFYAML::Object &Doc) { - return Doc.Header.Data == ELFYAML::ELF_ELFDATA(ELF::ELFDATA2LSB); -} - int yaml2elf(llvm::ELFYAML::Object &Doc, raw_ostream &Out) { - if (is64Bit(Doc)) { - if (isLittleEndian(Doc)) + bool IsLE = Doc.Header.Data == ELFYAML::ELF_ELFDATA(ELF::ELFDATA2LSB); + bool Is64Bit = Doc.Header.Class == ELFYAML::ELF_ELFCLASS(ELF::ELFCLASS64); + if (Is64Bit) { + if (IsLE) return ELFState::writeELF(Out, Doc); - else - return ELFState::writeELF(Out, Doc); - } else { - if (isLittleEndian(Doc)) - return ELFState::writeELF(Out, Doc); - else - return ELFState::writeELF(Out, Doc); + return ELFState::writeELF(Out, Doc); } + if (IsLE) + return ELFState::writeELF(Out, Doc); + return ELFState::writeELF(Out, Doc); } -- 2.40.0