[llvm-commits] [llvm] r42859 - in /llvm/trunk/include/llvm: Support/CFG.h Use.h

Chris Lattner sabre at nondot.org
Wed Oct 10 21:18:11 PDT 2007


Author: lattner
Date: Wed Oct 10 23:18:11 2007
New Revision: 42859

URL: http://llvm.org/viewvc/llvm-project?rev=42859&view=rev
Log:
Add a new use_iterator::atEnd() method, which allows us to shrink
pred_iterator down to a single ivar.

Modified:
    llvm/trunk/include/llvm/Support/CFG.h
    llvm/trunk/include/llvm/Use.h

Modified: llvm/trunk/include/llvm/Support/CFG.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/CFG.h?rev=42859&r1=42858&r2=42859&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Support/CFG.h (original)
+++ llvm/trunk/include/llvm/Support/CFG.h Wed Oct 10 23:18:11 2007
@@ -29,7 +29,6 @@
 template <class _Ptr,  class _USE_iterator> // Predecessor Iterator
 class PredIterator : public forward_iterator<_Ptr, ptrdiff_t> {
   typedef forward_iterator<_Ptr, ptrdiff_t> super;
-  _Ptr *BB;
   _USE_iterator It;
 public:
   typedef PredIterator<_Ptr,_USE_iterator> _Self;
@@ -37,26 +36,26 @@
 
   inline void advancePastNonTerminators() {
     // Loop to ignore non terminator uses (for example PHI nodes)...
-    while (It != BB->use_end() && !isa<TerminatorInst>(*It))
+    while (!It.atEnd() && !isa<TerminatorInst>(*It))
       ++It;
   }
 
-  inline PredIterator(_Ptr *bb) : BB(bb), It(bb->use_begin()) {
+  inline PredIterator(_Ptr *bb) : It(bb->use_begin()) {
     advancePastNonTerminators();
   }
-  inline PredIterator(_Ptr *bb, bool) : BB(bb), It(bb->use_end()) {}
+  inline PredIterator(_Ptr *bb, bool) : It(bb->use_end()) {}
 
   inline bool operator==(const _Self& x) const { return It == x.It; }
   inline bool operator!=(const _Self& x) const { return !operator==(x); }
 
   inline pointer operator*() const {
-    assert(It != BB->use_end() && "pred_iterator out of range!");
+    assert(!It.atEnd() && "pred_iterator out of range!");
     return cast<TerminatorInst>(*It)->getParent();
   }
   inline pointer *operator->() const { return &(operator*()); }
 
   inline _Self& operator++() {   // Preincrement
-    assert(It != BB->use_end() && "pred_iterator out of range!");
+    assert(!It.atEnd() && "pred_iterator out of range!");
     ++It; advancePastNonTerminators();
     return *this;
   }

Modified: llvm/trunk/include/llvm/Use.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Use.h?rev=42859&r1=42858&r2=42859&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Use.h (original)
+++ llvm/trunk/include/llvm/Use.h Wed Oct 10 23:18:11 2007
@@ -120,6 +120,9 @@
   bool operator!=(const _Self &x) const {
     return !operator==(x);
   }
+  
+  /// atEnd - return true if this iterator is equal to use_end() on the value.
+  bool atEnd() const { return U == 0; }
 
   // Iterator traversal: forward iteration only
   _Self &operator++() {          // Preincrement





More information about the llvm-commits mailing list