Add copy and assignment operators for POIterator, and

static constructors.

llvm-svn: 387
This commit is contained in:
Vikram S. Adve 2001-08-28 21:34:56 +00:00
parent 88bee9f363
commit 586a1d73a9
1 changed files with 15 additions and 2 deletions

View File

@ -358,7 +358,8 @@ class POIterator : public std::forward_iterator<BBType, ptrdiff_t> {
void traverseChild() {
while (VisitStack.top().second != succ_end(VisitStack.top().first)) {
BBType *BB = *VisitStack.top().second++;
BBType *BB = *VisitStack.top().second;
++ VisitStack.top().second;
if (!Visited.count(BB)) { // If the block is not visited...
Visited.insert(BB);
VisitStack.push(make_pair(BB, succ_begin(BB)));
@ -373,8 +374,16 @@ public:
VisitStack.push(make_pair(BB, succ_begin(BB)));
traverseChild();
}
inline POIterator(const _Self& x)
: Visited(x.Visited), VisitStack(x.VisitStack) {
}
inline POIterator& operator=(const _Self& x) {
Visited = x.Visited;
VisitStack = x.VisitStack;
return *this;
}
inline POIterator() { /* End is when stack is empty */ }
inline bool operator==(const _Self& x) const {
return VisitStack == x.VisitStack;
}
@ -400,6 +409,10 @@ public:
inline _Self operator++(int) { // Postincrement
_Self tmp = *this; ++*this; return tmp;
}
// Provide default begin and end methods when nothing special is needed.
static inline _Self begin (BBType *BB) { return _Self(BB); }
static inline _Self end (BBType *BB) { return _Self(); }
};
inline po_iterator po_begin( Method *M) {