forked from OSchip/llvm-project
Object: Add range iterators for Archive children
No functional change intended. llvm-svn: 218471
This commit is contained in:
parent
f3a3fc5120
commit
eac48b61f4
|
@ -14,6 +14,7 @@
|
|||
#ifndef LLVM_OBJECT_ARCHIVE_H
|
||||
#define LLVM_OBJECT_ARCHIVE_H
|
||||
|
||||
#include "llvm/ADT/iterator_range.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/Object/Binary.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
|
@ -97,12 +98,12 @@ public:
|
|||
|
||||
class child_iterator {
|
||||
Child child;
|
||||
|
||||
public:
|
||||
child_iterator() : child(Child(nullptr, nullptr)) {}
|
||||
child_iterator(const Child &c) : child(c) {}
|
||||
const Child* operator->() const {
|
||||
return &child;
|
||||
}
|
||||
const Child *operator->() const { return &child; }
|
||||
const Child &operator*() const { return child; }
|
||||
|
||||
bool operator==(const child_iterator &other) const {
|
||||
return child == other.child;
|
||||
|
@ -112,11 +113,11 @@ public:
|
|||
return !(*this == other);
|
||||
}
|
||||
|
||||
bool operator <(const child_iterator &other) const {
|
||||
bool operator<(const child_iterator &other) const {
|
||||
return child < other.child;
|
||||
}
|
||||
|
||||
child_iterator& operator++() { // Preincrement
|
||||
child_iterator &operator++() { // Preincrement
|
||||
child = child.getNext();
|
||||
return *this;
|
||||
}
|
||||
|
@ -178,6 +179,10 @@ public:
|
|||
|
||||
child_iterator child_begin(bool SkipInternal = true) const;
|
||||
child_iterator child_end() const;
|
||||
iterator_range<child_iterator> children(bool SkipInternal = true) const {
|
||||
return iterator_range<child_iterator>(child_begin(SkipInternal),
|
||||
child_end());
|
||||
}
|
||||
|
||||
symbol_iterator symbol_begin() const;
|
||||
symbol_iterator symbol_end() const;
|
||||
|
|
|
@ -137,10 +137,8 @@ static void dumpVTables(const ObjectFile *Obj) {
|
|||
}
|
||||
|
||||
static void dumpArchive(const Archive *Arc) {
|
||||
for (Archive::child_iterator ArcI = Arc->child_begin(),
|
||||
ArcE = Arc->child_end();
|
||||
ArcI != ArcE; ++ArcI) {
|
||||
ErrorOr<std::unique_ptr<Binary>> ChildOrErr = ArcI->getAsBinary();
|
||||
for (const Archive::Child &ArcC : Arc->children()) {
|
||||
ErrorOr<std::unique_ptr<Binary>> ChildOrErr = ArcC.getAsBinary();
|
||||
if (std::error_code EC = ChildOrErr.getError()) {
|
||||
// Ignore non-object files.
|
||||
if (EC != object_error::invalid_file_type)
|
||||
|
|
Loading…
Reference in New Issue