llvm.org GIT mirror llvm / 2bd7c60
[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 George Rimar 5 months ago
1 changed file(s) with 10 addition(s) and 19 deletion(s). Raw diff Collapse all Expand all
932932 return {".symtab", ".strtab", ".shstrtab", ".dynsym", ".dynstr"};
933933 }
934934
935 static bool is64Bit(const ELFYAML::Object &Doc) {
936 return Doc.Header.Class == ELFYAML::ELF_ELFCLASS(ELF::ELFCLASS64);
937 }
938
939 static bool isLittleEndian(const ELFYAML::Object &Doc) {
940 return Doc.Header.Data == ELFYAML::ELF_ELFDATA(ELF::ELFDATA2LSB);
941 }
942
943935 int yaml2elf(llvm::ELFYAML::Object &Doc, raw_ostream &Out) {
944 if (is64Bit(Doc)) {
945 if (isLittleEndian(Doc))
936 bool IsLE = Doc.Header.Data == ELFYAML::ELF_ELFDATA(ELF::ELFDATA2LSB);
937 bool Is64Bit = Doc.Header.Class == ELFYAML::ELF_ELFCLASS(ELF::ELFCLASS64);
938 if (Is64Bit) {
939 if (IsLE)
946940 return ELFState::writeELF(Out, Doc);
947 else
948 return ELFState::writeELF(Out, Doc);
949 } else {
950 if (isLittleEndian(Doc))
951 return ELFState::writeELF(Out, Doc);
952 else
953 return ELFState::writeELF(Out, Doc);
954 }
955 }
941 return ELFState::writeELF(Out, Doc);
942 }
943 if (IsLE)
944 return ELFState::writeELF(Out, Doc);
945 return ELFState::writeELF(Out, Doc);
946 }