Remove two uses of getObject.
authorRafael Espindola <rafael.espindola@gmail.com>
Sun, 7 Apr 2013 15:46:05 +0000 (15:46 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Sun, 7 Apr 2013 15:46:05 +0000 (15:46 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178985 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Object/MachO.h
lib/Object/MachOObjectFile.cpp
tools/llvm-readobj/MachODumper.cpp

index aeb6bd3dc8d2307ecf61d0ca60b3eba7c7a0f2a0..2e504155ace3eda7f9ed3844353534e3366cf646 100644 (file)
@@ -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(); }
 
index 94827693e9983e083479e6ce4c2397b61951e0d2..86677231c4e6d09ee500dbc591d3e3bfda1732fd 100644 (file)
@@ -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;
index 8f37b9a183756e1b06b75e2889c5bfe21b658115..190baa229b5b4040e55b0ec3aed7508eabbb0c6c 100644 (file)
@@ -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;