llvm.org GIT mirror llvm / 3ef437d
Add a new use_iterator::atEnd() method, which allows us to shrink pred_iterator down to a single ivar. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42859 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 12 years ago
2 changed file(s) with 8 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
2828 template // Predecessor Iterator
2929 class PredIterator : public forward_iterator<_Ptr, ptrdiff_t> {
3030 typedef forward_iterator<_Ptr, ptrdiff_t> super;
31 _Ptr *BB;
3231 _USE_iterator It;
3332 public:
3433 typedef PredIterator<_Ptr,_USE_iterator> _Self;
3635
3736 inline void advancePastNonTerminators() {
3837 // Loop to ignore non terminator uses (for example PHI nodes)...
39 while (It != BB->use_end() && !isa(*It))
38 while (!It.atEnd() && !isa(*It))
4039 ++It;
4140 }
4241
43 inline PredIterator(_Ptr *bb) : BB(bb), It(bb->use_begin()) {
42 inline PredIterator(_Ptr *bb) : It(bb->use_begin()) {
4443 advancePastNonTerminators();
4544 }
46 inline PredIterator(_Ptr *bb, bool) : BB(bb), It(bb->use_end()) {}
45 inline PredIterator(_Ptr *bb, bool) : It(bb->use_end()) {}
4746
4847 inline bool operator==(const _Self& x) const { return It == x.It; }
4948 inline bool operator!=(const _Self& x) const { return !operator==(x); }
5049
5150 inline pointer operator*() const {
52 assert(It != BB->use_end() && "pred_iterator out of range!");
51 assert(!It.atEnd() && "pred_iterator out of range!");
5352 return cast(*It)->getParent();
5453 }
5554 inline pointer *operator->() const { return &(operator*()); }
5655
5756 inline _Self& operator++() { // Preincrement
58 assert(It != BB->use_end() && "pred_iterator out of range!");
57 assert(!It.atEnd() && "pred_iterator out of range!");
5958 ++It; advancePastNonTerminators();
6059 return *this;
6160 }
119119 bool operator!=(const _Self &x) const {
120120 return !operator==(x);
121121 }
122
123 /// atEnd - return true if this iterator is equal to use_end() on the value.
124 bool atEnd() const { return U == 0; }
122125
123126 // Iterator traversal: forward iteration only
124127 _Self &operator++() { // Preincrement