Skip to content

Commit

Permalink
Remove two uses of getObject.
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178985 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
espindola committed Apr 7, 2013
1 parent 1efa604 commit 0be4eaf
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
1 change: 1 addition & 0 deletions include/llvm/Object/MachO.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ class MachOObjectFile : public ObjectFile {
getSymbol64TableEntry(DataRefImpl DRI) const;
const MachOFormat::SymbolTableEntry *
getSymbolTableEntry(DataRefImpl DRI) const;
bool is64Bit() const;

const MachOObject *getObject() const { return MachOObj.get(); }

Expand Down
3 changes: 3 additions & 0 deletions lib/Object/MachOObjectFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
15 changes: 2 additions & 13 deletions tools/llvm-readobj/MachODumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 0be4eaf

Please sign in to comment.