diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2014-01-30 02:49:50 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2014-01-30 02:49:50 +0000 |
commit | efdbec8b0a49fb67c3844be703548fdc6c1dded0 (patch) | |
tree | 040894fc0c18d09dfdfec8693a253bcf998cb8c5 /include/llvm/Object/MachO.h | |
parent | 6bf3966f7fd92217360877d1c04ea8ffe47c11cc (diff) | |
download | llvm-efdbec8b0a49fb67c3844be703548fdc6c1dded0.tar.gz llvm-efdbec8b0a49fb67c3844be703548fdc6c1dded0.tar.bz2 llvm-efdbec8b0a49fb67c3844be703548fdc6c1dded0.tar.xz |
Simplify the handling of iterators in ObjectFile.
None of the object file formats reported error on iterator increment. In
retrospect, that is not too surprising: no object format stores symbols or
sections in a linked list or other structure that requires chasing pointers.
As a consequence, all error checking can be done on begin() and end().
This reduces the text segment of bin/llvm-readobj in my machine from 521233 to
518526 bytes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200442 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Object/MachO.h')
-rw-r--r-- | include/llvm/Object/MachO.h | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/include/llvm/Object/MachO.h b/include/llvm/Object/MachO.h index 731a07be60..fb548e3262 100644 --- a/include/llvm/Object/MachO.h +++ b/include/llvm/Object/MachO.h @@ -38,7 +38,7 @@ public: bool operator==(const DiceRef &Other) const; bool operator<(const DiceRef &Other) const; - error_code getNext(DiceRef &Result) const; + void moveNext(); error_code getOffset(uint32_t &Result) const; error_code getLength(uint16_t &Result) const; @@ -59,8 +59,7 @@ public: MachOObjectFile(MemoryBuffer *Object, bool IsLittleEndian, bool Is64Bits, error_code &EC, bool BufferOwned = true); - error_code getSymbolNext(DataRefImpl Symb, SymbolRef &Res) const - LLVM_OVERRIDE; + void moveSymbolNext(DataRefImpl &Symb) const LLVM_OVERRIDE; error_code getSymbolName(DataRefImpl Symb, StringRef &Res) const LLVM_OVERRIDE; error_code getSymbolAddress(DataRefImpl Symb, uint64_t &Res) const @@ -79,8 +78,7 @@ public: error_code getSymbolValue(DataRefImpl Symb, uint64_t &Val) const LLVM_OVERRIDE; - error_code getSectionNext(DataRefImpl Sec, SectionRef &Res) const - LLVM_OVERRIDE; + void moveSectionNext(DataRefImpl &Sec) const LLVM_OVERRIDE; error_code getSectionName(DataRefImpl Sec, StringRef &Res) const LLVM_OVERRIDE; error_code getSectionAddress(DataRefImpl Sec, uint64_t &Res) const @@ -104,8 +102,7 @@ public: relocation_iterator section_rel_begin(DataRefImpl Sec) const LLVM_OVERRIDE; relocation_iterator section_rel_end(DataRefImpl Sec) const LLVM_OVERRIDE; - error_code getRelocationNext(DataRefImpl Rel, RelocationRef &Res) const - LLVM_OVERRIDE; + void moveRelocationNext(DataRefImpl &Rel) const LLVM_OVERRIDE; error_code getRelocationAddress(DataRefImpl Rel, uint64_t &Res) const LLVM_OVERRIDE; error_code getRelocationOffset(DataRefImpl Rel, uint64_t &Res) const @@ -244,13 +241,10 @@ inline bool DiceRef::operator<(const DiceRef &Other) const { return DicePimpl < Other.DicePimpl; } -inline error_code DiceRef::getNext(DiceRef &Result) const { - DataRefImpl Rel = DicePimpl; +inline void DiceRef::moveNext() { const MachO::data_in_code_entry *P = - reinterpret_cast<const MachO::data_in_code_entry *>(Rel.p); - Rel.p = reinterpret_cast<uintptr_t>(P + 1); - Result = DiceRef(Rel, OwningObject); - return object_error::success; + reinterpret_cast<const MachO::data_in_code_entry *>(DicePimpl.p); + DicePimpl.p = reinterpret_cast<uintptr_t>(P + 1); } // Since a Mach-O data in code reference, a DiceRef, can only be created when |