summaryrefslogtreecommitdiffstats
path: root/lld/include
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2015-04-08 21:59:06 +0000
committerRui Ueyama <ruiu@google.com>2015-04-08 21:59:06 +0000
commitae0299f040baf591b21aec3f4df533795a802a4d (patch)
treeb1edf264becd3a67b4fd0dc563ace37cfbde3047 /lld/include
parent1a6ec936161eedc5c7b7cb36bfed5bec65bd1e06 (diff)
downloadbcm5719-llvm-ae0299f040baf591b21aec3f4df533795a802a4d.tar.gz
bcm5719-llvm-ae0299f040baf591b21aec3f4df533795a802a4d.zip
Replace atom_iterator with a template alias.
llvm-svn: 234444
Diffstat (limited to 'lld/include')
-rw-r--r--lld/include/lld/Core/File.h63
1 files changed, 6 insertions, 57 deletions
diff --git a/lld/include/lld/Core/File.h b/lld/include/lld/Core/File.h
index 48da03276ab..688b92d0f2a 100644
--- a/lld/include/lld/Core/File.h
+++ b/lld/include/lld/Core/File.h
@@ -86,79 +86,28 @@ public:
/// Sets the command line order of the file.
void setOrdinal(uint64_t ordinal) const { _ordinal = ordinal; }
- template <typename T> class atom_iterator; // forward reference
-
/// For allocating any objects owned by this File.
llvm::BumpPtrAllocator &allocator() const {
return _allocator;
}
+ template <typename T>
+ using atom_iterator = typename std::vector<const T *>::const_iterator;
+
/// \brief Different object file readers may instantiate and manage atoms with
/// different data structures. This class is a collection abstraction.
/// Each concrete File instance must implement these atom_collection
/// methods to enable clients to interate the File's atoms.
template <typename T> class atom_collection {
public:
- atom_iterator<T> begin() const {
- const void *it = _atoms.data();
- return atom_iterator<T>(*this, it);
- }
-
- atom_iterator<T> end() const {
- const void *it = _atoms.data() + _atoms.size();
- return atom_iterator<T>(*this, it);
- }
-
- const T *deref(const void *it) const {
- return *reinterpret_cast<const T *const *>(it);
- }
-
- void next(const void *&it) const {
- const T *const *p = reinterpret_cast<const T *const *>(it);
- ++p;
- it = reinterpret_cast<const void *>(p);
- }
-
+ atom_iterator<T> begin() const { return _atoms.begin(); }
+ atom_iterator<T> end() const { return _atoms.end(); }
uint64_t size() const { return _atoms.size(); }
- bool empty() const { return size() == 0; }
+ bool empty() const { return _atoms.empty(); }
std::vector<const T *> _atoms;
};
- /// \brief The class is the iterator type used to iterate through a File's
- /// Atoms. This iterator delegates the work to the associated atom_collection
- /// object. There are four kinds of Atoms, so this iterator is templated on
- /// the four base Atom kinds.
- template <typename T>
- class atom_iterator : public std::iterator<std::forward_iterator_tag, T> {
- public:
- atom_iterator(const atom_collection<T> &c, const void *it)
- : _collection(&c), _it(it) { }
-
- const T *operator*() const {
- return _collection->deref(_it);
- }
- const T *operator->() const {
- return _collection->deref(_it);
- }
-
- friend bool operator==(const atom_iterator<T> &lhs, const atom_iterator<T> &rhs) {
- return lhs._it == rhs._it;
- }
-
- friend bool operator!=(const atom_iterator<T> &lhs, const atom_iterator<T> &rhs) {
- return !(lhs == rhs);
- }
-
- atom_iterator<T> &operator++() {
- _collection->next(_it);
- return *this;
- }
- private:
- const atom_collection<T> *_collection;
- const void *_it;
- };
-
/// \brief Must be implemented to return the atom_collection object for
/// all DefinedAtoms in this File.
virtual const atom_collection<DefinedAtom> &defined() const = 0;
OpenPOWER on IntegriCloud