aboutsummaryrefslogtreecommitdiff
path: root/include/clang/AST/UnresolvedSet.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/clang/AST/UnresolvedSet.h')
-rw-r--r--include/clang/AST/UnresolvedSet.h88
1 files changed, 22 insertions, 66 deletions
diff --git a/include/clang/AST/UnresolvedSet.h b/include/clang/AST/UnresolvedSet.h
index a11f22d201b7..26ee1cf71c81 100644
--- a/include/clang/AST/UnresolvedSet.h
+++ b/include/clang/AST/UnresolvedSet.h
@@ -19,74 +19,36 @@
#include "clang/Basic/LLVM.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/SmallVector.h"
-#include <iterator>
+#include "llvm/ADT/iterator.h"
namespace clang {
/// The iterator over UnresolvedSets. Serves as both the const and
/// non-const iterator.
-class UnresolvedSetIterator {
-private:
- typedef MutableArrayRef<DeclAccessPair> DeclsTy;
- typedef DeclsTy::iterator IteratorTy;
-
- IteratorTy ir;
-
+class UnresolvedSetIterator : public llvm::iterator_adaptor_base<
+ UnresolvedSetIterator, DeclAccessPair *,
+ std::random_access_iterator_tag, NamedDecl *,
+ std::ptrdiff_t, NamedDecl *, NamedDecl *> {
friend class UnresolvedSetImpl;
friend class ASTUnresolvedSet;
friend class OverloadExpr;
- explicit UnresolvedSetIterator(DeclsTy::iterator ir) : ir(ir) {}
- explicit UnresolvedSetIterator(DeclsTy::const_iterator ir) :
- ir(const_cast<DeclsTy::iterator>(ir)) {}
-
- IteratorTy getIterator() const { return ir; }
-
+
+ explicit UnresolvedSetIterator(DeclAccessPair *Iter)
+ : iterator_adaptor_base(Iter) {}
+ explicit UnresolvedSetIterator(const DeclAccessPair *Iter)
+ : iterator_adaptor_base(const_cast<DeclAccessPair *>(Iter)) {}
+
public:
UnresolvedSetIterator() {}
- typedef std::iterator_traits<IteratorTy>::difference_type difference_type;
- typedef NamedDecl *value_type;
- typedef NamedDecl **pointer;
- typedef NamedDecl *reference;
- typedef std::iterator_traits<IteratorTy>::iterator_category iterator_category;
-
- NamedDecl *getDecl() const { return ir->getDecl(); }
- void setDecl(NamedDecl *ND) const { return ir->setDecl(ND); }
- AccessSpecifier getAccess() const { return ir->getAccess(); }
- void setAccess(AccessSpecifier AS) { ir->setAccess(AS); }
- DeclAccessPair getPair() const { return *ir; }
+ NamedDecl *getDecl() const { return I->getDecl(); }
+ void setDecl(NamedDecl *ND) const { return I->setDecl(ND); }
+ AccessSpecifier getAccess() const { return I->getAccess(); }
+ void setAccess(AccessSpecifier AS) { I->setAccess(AS); }
+ const DeclAccessPair &getPair() const { return *I; }
NamedDecl *operator*() const { return getDecl(); }
-
- UnresolvedSetIterator &operator++() { ++ir; return *this; }
- UnresolvedSetIterator operator++(int) { return UnresolvedSetIterator(ir++); }
- UnresolvedSetIterator &operator--() { --ir; return *this; }
- UnresolvedSetIterator operator--(int) { return UnresolvedSetIterator(ir--); }
-
- UnresolvedSetIterator &operator+=(difference_type d) {
- ir += d; return *this;
- }
- UnresolvedSetIterator operator+(difference_type d) const {
- return UnresolvedSetIterator(ir + d);
- }
- UnresolvedSetIterator &operator-=(difference_type d) {
- ir -= d; return *this;
- }
- UnresolvedSetIterator operator-(difference_type d) const {
- return UnresolvedSetIterator(ir - d);
- }
- value_type operator[](difference_type d) const { return *(*this + d); }
-
- difference_type operator-(const UnresolvedSetIterator &o) const {
- return ir - o.ir;
- }
-
- bool operator==(const UnresolvedSetIterator &o) const { return ir == o.ir; }
- bool operator!=(const UnresolvedSetIterator &o) const { return ir != o.ir; }
- bool operator<(const UnresolvedSetIterator &o) const { return ir < o.ir; }
- bool operator<=(const UnresolvedSetIterator &o) const { return ir <= o.ir; }
- bool operator>=(const UnresolvedSetIterator &o) const { return ir >= o.ir; }
- bool operator>(const UnresolvedSetIterator &o) const { return ir > o.ir; }
+ NamedDecl *operator->() const { return **this; }
};
/// \brief A set of unresolved declarations.
@@ -132,21 +94,17 @@ public:
/// Replaces the declaration at the given iterator with the new one,
/// preserving the original access bits.
- void replace(iterator I, NamedDecl *New) {
- I.ir->setDecl(New);
- }
+ void replace(iterator I, NamedDecl *New) { I.I->setDecl(New); }
void replace(iterator I, NamedDecl *New, AccessSpecifier AS) {
- I.ir->set(New, AS);
+ I.I->set(New, AS);
}
void erase(unsigned I) { decls()[I] = decls().pop_back_val(); }
- void erase(iterator I) { *I.ir = decls().pop_back_val(); }
+ void erase(iterator I) { *I.I = decls().pop_back_val(); }
- void setAccess(iterator I, AccessSpecifier AS) {
- I.ir->setAccess(AS);
- }
+ void setAccess(iterator I, AccessSpecifier AS) { I.I->setAccess(AS); }
void clear() { decls().clear(); }
void set_size(unsigned N) { decls().set_size(N); }
@@ -154,9 +112,7 @@ public:
bool empty() const { return decls().empty(); }
unsigned size() const { return decls().size(); }
- void append(iterator I, iterator E) {
- decls().append(I.ir, E.ir);
- }
+ void append(iterator I, iterator E) { decls().append(I.I, E.I); }
DeclAccessPair &operator[](unsigned I) { return decls()[I]; }
const DeclAccessPair &operator[](unsigned I) const { return decls()[I]; }