summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMichael J. Spencer <bigcheesegs@gmail.com>2011-11-02 19:33:12 +0000
committerMichael J. Spencer <bigcheesegs@gmail.com>2011-11-02 19:33:12 +0000
commitc8a55a660e93bb7a4854969b4c5814bf7bb0101b (patch)
tree8ea39727d52c9dc92231a0640addd025fe714abd /include
parente07cd5e40ac06fabfb9d33ea7c79542f138f45ce (diff)
downloadllvm-c8a55a660e93bb7a4854969b4c5814bf7bb0101b.tar.gz
llvm-c8a55a660e93bb7a4854969b4c5814bf7bb0101b.tar.bz2
llvm-c8a55a660e93bb7a4854969b4c5814bf7bb0101b.tar.xz
Object/Archive: Add symbol table iteration.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143561 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/Object/Archive.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/include/llvm/Object/Archive.h b/include/llvm/Object/Archive.h
index d72037020a..b12b17e1f5 100644
--- a/include/llvm/Object/Archive.h
+++ b/include/llvm/Object/Archive.h
@@ -50,6 +50,7 @@ public:
class child_iterator {
Child child;
public:
+ child_iterator() : child(Child(0, StringRef())) {}
child_iterator(const Child &c) : child(c) {}
const Child* operator->() const {
return &child;
@@ -69,11 +70,55 @@ public:
}
};
+ class Symbol {
+ const Archive *Parent;
+ uint32_t SymbolIndex;
+ uint32_t StringIndex; // Extra index to the string.
+
+ public:
+ bool operator ==(const Symbol &other) const {
+ return (Parent == other.Parent) && (SymbolIndex == other.SymbolIndex);
+ }
+
+ Symbol(const Archive *p, uint32_t symi, uint32_t stri)
+ : Parent(p)
+ , SymbolIndex(symi)
+ , StringIndex(stri) {}
+ error_code getName(StringRef &Result) const;
+ error_code getMember(child_iterator &Result) const;
+ Symbol getNext() const;
+ };
+
+ class symbol_iterator {
+ Symbol symbol;
+ public:
+ symbol_iterator(const Symbol &s) : symbol(s) {}
+ const Symbol *operator->() const {
+ return &symbol;
+ }
+
+ bool operator==(const symbol_iterator &other) const {
+ return symbol == other.symbol;
+ }
+
+ bool operator!=(const symbol_iterator &other) const {
+ return !(*this == other);
+ }
+
+ symbol_iterator& operator++() { // Preincrement
+ symbol = symbol.getNext();
+ return *this;
+ }
+ };
+
Archive(MemoryBuffer *source, error_code &ec);
child_iterator begin_children(bool skip_internal = true) const;
child_iterator end_children() const;
+ symbol_iterator begin_symbols() const;
+ symbol_iterator end_symbols() const;
+
// Cast methods.
static inline bool classof(Archive const *v) { return true; }
static inline bool classof(Binary const *v) {
@@ -81,6 +126,7 @@ public:
}
private:
+ child_iterator SymbolTable;
child_iterator StringTable;
};