Add support to BasicBlocks for iterating backwards over the
authorChandler Carruth <chandlerc@gmail.com>
Thu, 27 Dec 2012 12:00:56 +0000 (12:00 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Thu, 27 Dec 2012 12:00:56 +0000 (12:00 +0000)
instructions. This just exposes the already present reverse iterators of
the instruction ilist.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171159 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/BasicBlock.h

index ba8406e3974ce77865be800312a7e4c9e3100fb7..e9001021f52e516cc964bca417a561a60588bc1e 100644 (file)
@@ -93,8 +93,10 @@ public:
   LLVMContext &getContext() const;
 
   /// Instruction iterators...
-  typedef InstListType::iterator                              iterator;
-  typedef InstListType::const_iterator                  const_iterator;
+  typedef InstListType::iterator iterator;
+  typedef InstListType::const_iterator const_iterator;
+  typedef InstListType::reverse_iterator reverse_iterator;
+  typedef InstListType::const_reverse_iterator const_reverse_iterator;
 
   /// Create - Creates a new BasicBlock. If the Parent parameter is specified,
   /// the basic block is automatically inserted at either the end of the
@@ -191,6 +193,11 @@ public:
   inline iterator                end  ()       { return InstList.end();   }
   inline const_iterator          end  () const { return InstList.end();   }
 
+  inline reverse_iterator        rbegin()       { return InstList.rbegin(); }
+  inline const_reverse_iterator  rbegin() const { return InstList.rbegin(); }
+  inline reverse_iterator        rend  ()       { return InstList.rend();   }
+  inline const_reverse_iterator  rend  () const { return InstList.rend();   }
+
   inline size_t                   size() const { return InstList.size();  }
   inline bool                    empty() const { return InstList.empty(); }
   inline const Instruction      &front() const { return InstList.front(); }