From 31fce896458466a8dc06f592da93b8cd150c8982 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Sun, 7 Apr 2013 15:46:05 +0000 Subject: [PATCH] Remove two uses of getObject. llvm-svn: 178985 --- llvm/include/llvm/Object/MachO.h | 1 + llvm/lib/Object/MachOObjectFile.cpp | 3 +++ llvm/tools/llvm-readobj/MachODumper.cpp | 15 ++------------- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/llvm/include/llvm/Object/MachO.h b/llvm/include/llvm/Object/MachO.h index aeb6bd3dc8d2..2e504155ace3 100644 --- a/llvm/include/llvm/Object/MachO.h +++ b/llvm/include/llvm/Object/MachO.h @@ -160,6 +160,7 @@ public: getSymbol64TableEntry(DataRefImpl DRI) const; const MachOFormat::SymbolTableEntry * getSymbolTableEntry(DataRefImpl DRI) const; + bool is64Bit() const; const MachOObject *getObject() const { return MachOObj.get(); } diff --git a/llvm/lib/Object/MachOObjectFile.cpp b/llvm/lib/Object/MachOObjectFile.cpp index 94827693e998..86677231c4e6 100644 --- a/llvm/lib/Object/MachOObjectFile.cpp +++ b/llvm/lib/Object/MachOObjectFile.cpp @@ -41,6 +41,9 @@ MachOObjectFile::MachOObjectFile(MemoryBuffer *Object, MachOObject *MOO, } } +bool MachOObjectFile::is64Bit() const { + return MachOObj->is64Bit(); +} ObjectFile *ObjectFile::createMachOObjectFile(MemoryBuffer *Buffer) { error_code ec; diff --git a/llvm/tools/llvm-readobj/MachODumper.cpp b/llvm/tools/llvm-readobj/MachODumper.cpp index 8f37b9a18375..190baa229b5b 100644 --- a/llvm/tools/llvm-readobj/MachODumper.cpp +++ b/llvm/tools/llvm-readobj/MachODumper.cpp @@ -157,20 +157,10 @@ namespace { }; } -static bool is64BitLoadCommand(const MachOObject *MachOObj, DataRefImpl DRI) { - LoadCommandInfo LCI = MachOObj->getLoadCommandInfo(DRI.d.a); - if (LCI.Command.Type == macho::LCT_Segment64) - return true; - assert(LCI.Command.Type == macho::LCT_Segment && "Unexpected Type."); - return false; -} - static void getSection(const MachOObjectFile *Obj, DataRefImpl DRI, MachOSection &Section) { - const MachOObject *MachOObj = Obj->getObject(); - - if (is64BitLoadCommand(MachOObj, DRI)) { + if (Obj->is64Bit()) { const MachOFormat::Section64 *Sect = Obj->getSection64(DRI); Section.Address = Sect->Address; @@ -200,8 +190,7 @@ static void getSection(const MachOObjectFile *Obj, static void getSymbol(const MachOObjectFile *Obj, DataRefImpl DRI, MachOSymbol &Symbol) { - const MachOObject *MachOObj = Obj->getObject(); - if (MachOObj->is64Bit()) { + if (Obj->is64Bit()) { const MachOFormat::Symbol64TableEntry *Entry = Obj->getSymbol64TableEntry( DRI); Symbol.StringIndex = Entry->StringIndex;