ADT: Do not inherit from std::iterator in ilist_iterator
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Sat, 3 Sep 2016 02:27:35 +0000 (02:27 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Sat, 3 Sep 2016 02:27:35 +0000 (02:27 +0000)
Inheriting from std::iterator uses more boiler-plate than manual
typedefs.  Avoid that in both ilist_iterator and
MachineInstrBundleIterator.

This has the side effect of removing ilist_iterator from certain ADL
lookups in namespace std; calls to std::next need to be qualified by
"std::" that didn't have to before.  The one case of this in-tree was
operating on a temporary, so I used the more compact operator++.

llvm-svn: 280570

llvm/include/llvm/ADT/ilist_iterator.h
llvm/include/llvm/CodeGen/MachineInstrBundleIterator.h
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

index 67c9fa7..d106d0c 100644 (file)
@@ -47,17 +47,13 @@ template <> struct IteratorHelper<true> {
 } // end namespace ilist_detail
 
 /// Iterator for intrusive lists  based on ilist_node.
-template <typename NodeTy, bool IsReverse>
-class ilist_iterator
-    : public std::iterator<std::bidirectional_iterator_tag, NodeTy, ptrdiff_t> {
+template <typename NodeTy, bool IsReverse> class ilist_iterator {
 public:
-  typedef std::iterator<std::bidirectional_iterator_tag, NodeTy, ptrdiff_t>
-      super;
-
-  typedef typename super::value_type value_type;
-  typedef typename super::difference_type difference_type;
-  typedef typename super::pointer pointer;
-  typedef typename super::reference reference;
+  typedef NodeTy value_type;
+  typedef value_type *pointer;
+  typedef value_type &reference;
+  typedef ptrdiff_t difference_type;
+  typedef std::bidirectional_iterator_tag iterator_category;
 
   typedef typename std::add_const<value_type>::type *const_pointer;
   typedef typename std::add_const<value_type>::type &const_reference;
index f493dbc..ac09d26 100644 (file)
@@ -21,18 +21,16 @@ namespace llvm {
 
 /// MachineBasicBlock iterator that automatically skips over MIs that are
 /// inside bundles (i.e. walk top level MIs only).
-template <typename Ty>
-class MachineInstrBundleIterator
-    : public std::iterator<std::bidirectional_iterator_tag, Ty, ptrdiff_t> {
-  typedef std::iterator<std::bidirectional_iterator_tag, Ty, ptrdiff_t> super;
+template <typename Ty> class MachineInstrBundleIterator {
   typedef ilist_iterator<Ty> instr_iterator;
   instr_iterator MII;
 
 public:
-  typedef typename super::value_type value_type;
-  typedef typename super::difference_type difference_type;
-  typedef typename super::pointer pointer;
-  typedef typename super::reference reference;
+  typedef typename instr_iterator::value_type value_type;
+  typedef typename instr_iterator::difference_type difference_type;
+  typedef typename instr_iterator::pointer pointer;
+  typedef typename instr_iterator::reference reference;
+  typedef std::bidirectional_iterator_tag iterator_category;
 
   typedef typename instr_iterator::const_pointer const_pointer;
   typedef typename instr_iterator::const_reference const_reference;
index 39d5294..6dabfca 100644 (file)
@@ -2226,7 +2226,7 @@ void BoUpSLP::setInsertPointAfterBundle(ArrayRef<Value *> VL) {
 
   // Set the insertion point after the last instruction in the bundle. Set the
   // debug location to Front.
-  Builder.SetInsertPoint(BB, next(BasicBlock::iterator(LastInst)));
+  Builder.SetInsertPoint(BB, ++LastInst->getIterator());
   Builder.SetCurrentDebugLocation(Front->getDebugLoc());
 }