[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.
llvm-svn: 359445
diff --git a/llvm/tools/yaml2obj/yaml2elf.cpp b/llvm/tools/yaml2obj/yaml2elf.cpp
index ba07c9c..cb12cdd 100644
--- a/llvm/tools/yaml2obj/yaml2elf.cpp
+++ b/llvm/tools/yaml2obj/yaml2elf.cpp
@@ -933,24 +933,15 @@
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<object::ELF64LE>::writeELF(Out, Doc);
- else
- return ELFState<object::ELF64BE>::writeELF(Out, Doc);
- } else {
- if (isLittleEndian(Doc))
- return ELFState<object::ELF32LE>::writeELF(Out, Doc);
- else
- return ELFState<object::ELF32BE>::writeELF(Out, Doc);
+ return ELFState<object::ELF64BE>::writeELF(Out, Doc);
}
+ if (IsLE)
+ return ELFState<object::ELF32LE>::writeELF(Out, Doc);
+ return ELFState<object::ELF32BE>::writeELF(Out, Doc);
}