Index: llvm/include/llvm/ADT/BreadthFirstIterator.h =================================================================== --- llvm/include/llvm/ADT/BreadthFirstIterator.h +++ llvm/include/llvm/ADT/BreadthFirstIterator.h @@ -44,11 +44,15 @@ class SetType = bf_iterator_default_set::NodeRef>, class GT = GraphTraits> -class bf_iterator - : public std::iterator, - public bf_iterator_storage { - using super = std::iterator; +class bf_iterator : public bf_iterator_storage { +public: + using iterator_category = std::forward_iterator_tag; + using value_type = typename GT::NodeRef; + using difference_type = std::ptrdiff_t; + using pointer = value_type *; + using reference = value_type &; +private: using NodeRef = typename GT::NodeRef; using ChildItTy = typename GT::ChildIteratorType; @@ -107,8 +111,6 @@ } public: - using pointer = typename super::pointer; - // Provide static begin and end methods as our public "constructors" static bf_iterator begin(const GraphT &G) { return bf_iterator(GT::getEntryNode(G)); Index: llvm/include/llvm/ADT/DepthFirstIterator.h =================================================================== --- llvm/include/llvm/ADT/DepthFirstIterator.h +++ llvm/include/llvm/ADT/DepthFirstIterator.h @@ -82,10 +82,15 @@ class SetType = df_iterator_default_set::NodeRef>, bool ExtStorage = false, class GT = GraphTraits> -class df_iterator - : public std::iterator, - public df_iterator_storage { - using super = std::iterator; +class df_iterator : public df_iterator_storage { +public: + using iterator_category = std::forward_iterator_tag; + using value_type = typename GT::NodeRef; + using difference_type = std::ptrdiff_t; + using pointer = value_type *; + using reference = value_type &; + +private: using NodeRef = typename GT::NodeRef; using ChildItTy = typename GT::ChildIteratorType; @@ -144,8 +149,6 @@ } public: - using pointer = typename super::pointer; - // Provide static begin and end methods as our public "constructors" static df_iterator begin(const GraphT &G) { return df_iterator(GT::getEntryNode(G)); Index: llvm/include/llvm/ADT/EquivalenceClasses.h =================================================================== --- llvm/include/llvm/ADT/EquivalenceClasses.h +++ llvm/include/llvm/ADT/EquivalenceClasses.h @@ -248,19 +248,18 @@ return It != member_end() && It == findLeader(V2); } - class member_iterator : public std::iterator { + class member_iterator { friend class EquivalenceClasses; - using super = std::iterator; - const ECValue *Node; public: + using iterator_category = std::forward_iterator_tag; + using value_type = ElemTy; using size_type = size_t; - using pointer = typename super::pointer; - using reference = typename super::reference; + using difference_type = std::ptrdiff_t; + using pointer = const value_type *; + using reference = const value_type &; explicit member_iterator() = default; explicit member_iterator(const ECValue *N) : Node(N) {} Index: llvm/include/llvm/ADT/ImmutableSet.h =================================================================== --- llvm/include/llvm/ADT/ImmutableSet.h +++ llvm/include/llvm/ADT/ImmutableSet.h @@ -646,12 +646,16 @@ //===----------------------------------------------------------------------===// template -class ImutAVLTreeGenericIterator - : public std::iterator> { +class ImutAVLTreeGenericIterator { SmallVector stack; public: + using iterator_category = std::bidirectional_iterator_tag; + using value_type = ImutAVLTree; + using difference_type = std::ptrdiff_t; + using pointer = value_type *; + using reference = value_type &; + enum VisitFlag { VisitedNone=0x0, VisitedLeft=0x1, VisitedRight=0x3, Flags=0x3 }; @@ -757,14 +761,18 @@ }; template -class ImutAVLTreeInOrderIterator - : public std::iterator> { +class ImutAVLTreeInOrderIterator { using InternalIteratorTy = ImutAVLTreeGenericIterator; InternalIteratorTy InternalItr; public: + using iterator_category = std::bidirectional_iterator_tag; + using value_type = ImutAVLTree; + using difference_type = std::ptrdiff_t; + using pointer = value_type *; + using reference = value_type &; + using TreeTy = ImutAVLTree; ImutAVLTreeInOrderIterator(const TreeTy* Root) : InternalItr(Root) { Index: llvm/include/llvm/ADT/IntervalMap.h =================================================================== --- llvm/include/llvm/ADT/IntervalMap.h +++ llvm/include/llvm/ADT/IntervalMap.h @@ -63,9 +63,14 @@ // }; // // template -// class IntervalMap::const_iterator : -// public std::iterator { +// class IntervalMap::const_iterator { // public: +// using iterator_category = std::bidirectional_iterator_tag; +// using value_type = ValT; +// using difference_type = std::ptrdiff_t; +// using pointer = value_type *; +// using reference = value_type &; +// // bool operator==(const const_iterator &) const; // bool operator!=(const const_iterator &) const; // bool valid() const; @@ -1293,8 +1298,13 @@ //===----------------------------------------------------------------------===// template -class IntervalMap::const_iterator : - public std::iterator { +class IntervalMap::const_iterator { +public: + using iterator_category = std::bidirectional_iterator_tag; + using value_type = ValT; + using difference_type = std::ptrdiff_t; + using pointer = value_type *; + using reference = value_type &; protected: friend class IntervalMap; Index: llvm/include/llvm/ADT/PostOrderIterator.h =================================================================== --- llvm/include/llvm/ADT/PostOrderIterator.h +++ llvm/include/llvm/ADT/PostOrderIterator.h @@ -92,10 +92,15 @@ class SetType = SmallPtrSet::NodeRef, 8>, bool ExtStorage = false, class GT = GraphTraits> -class po_iterator - : public std::iterator, - public po_iterator_storage { - using super = std::iterator; +class po_iterator : public po_iterator_storage { +public: + using iterator_category = std::forward_iterator_tag; + using value_type = typename GT::NodeRef; + using difference_type = std::ptrdiff_t; + using pointer = value_type *; + using reference = value_type &; + +private: using NodeRef = typename GT::NodeRef; using ChildItTy = typename GT::ChildIteratorType; @@ -134,8 +139,6 @@ } public: - using pointer = typename super::pointer; - // Provide static "constructors"... static po_iterator begin(GraphT G) { return po_iterator(GT::getEntryNode(G)); Index: llvm/include/llvm/ADT/SparseMultiSet.h =================================================================== --- llvm/include/llvm/ADT/SparseMultiSet.h +++ llvm/include/llvm/ADT/SparseMultiSet.h @@ -217,10 +217,17 @@ /// Our iterators are iterators over the collection of objects that share a /// key. template - class iterator_base : public std::iterator { + class iterator_base { friend class SparseMultiSet; + public: + using iterator_category = std::bidirectional_iterator_tag; + using value_type = ValueT; + using difference_type = std::ptrdiff_t; + using pointer = value_type *; + using reference = value_type &; + + private: SMSPtrTy SMS; unsigned Idx; unsigned SparseIdx; @@ -247,12 +254,6 @@ void setNext(unsigned N) { SMS->Dense[Idx].Next = N; } public: - using super = std::iterator; - using value_type = typename super::value_type; - using difference_type = typename super::difference_type; - using pointer = typename super::pointer; - using reference = typename super::reference; - reference operator*() const { assert(isKeyed() && SMS->sparseIndex(SMS->Dense[Idx].Data) == SparseIdx && "Dereferencing iterator of invalid key or index"); @@ -411,7 +412,7 @@ RangePair equal_range(const KeyT &K) { iterator B = find(K); iterator E = iterator(this, SMSNode::INVALID, B.SparseIdx); - return make_pair(B, E); + return std::make_pair(B, E); } /// Insert a new element at the tail of the subset list. Returns an iterator Index: llvm/include/llvm/ADT/iterator.h =================================================================== --- llvm/include/llvm/ADT/iterator.h +++ llvm/include/llvm/ADT/iterator.h @@ -64,9 +64,14 @@ template -class iterator_facade_base - : public std::iterator { +class iterator_facade_base { +public: + using iterator_category = IteratorCategoryT; + using value_type = T; + using difference_type = DifferenceTypeT; + using pointer = PointerT; + using reference = ReferenceT; + protected: enum { IsRandomAccess = std::is_base_of { + class iterator { PointerRec *CurNode; public: + using iterator_category = std::forward_iterator_tag; + using value_type = PointerRec; + using difference_type = std::ptrdiff_t; + using pointer = value_type *; + using reference = value_type &; + explicit iterator(PointerRec *CN = nullptr) : CurNode(CN) {} bool operator==(const iterator& x) const { Index: llvm/include/llvm/Analysis/MemorySSA.h =================================================================== --- llvm/include/llvm/Analysis/MemorySSA.h +++ llvm/include/llvm/Analysis/MemorySSA.h @@ -1104,7 +1104,7 @@ return MP->getIncomingBlock(ArgNo); } - typename BaseT::iterator::pointer operator*() const { + typename std::iterator_traits::pointer operator*() const { assert(Access && "Tried to access past the end of our iterator"); // Go to the first argument for phis, and the defining access for everything // else. @@ -1198,7 +1198,7 @@ return DefIterator == Other.DefIterator; } - BaseT::iterator::reference operator*() const { + typename std::iterator_traits::reference operator*() const { assert(DefIterator != OriginalAccess->defs_end() && "Tried to access past the end of our iterator"); return CurrentPair; Index: llvm/include/llvm/Analysis/RegionIterator.h =================================================================== --- llvm/include/llvm/Analysis/RegionIterator.h +++ llvm/include/llvm/Analysis/RegionIterator.h @@ -36,9 +36,15 @@ /// For a subregion RegionNode there is just one successor. The RegionNode /// representing the exit of the subregion. template -class RNSuccIterator - : public std::iterator { - using super = std::iterator; +class RNSuccIterator { +public: + using iterator_category = std::forward_iterator_tag; + using value_type = NodeRef; + using difference_type = std::ptrdiff_t; + using pointer = value_type *; + using reference = value_type &; + +private: using BlockTraits = GraphTraits; using SuccIterTy = typename BlockTraits::ChildIteratorType; @@ -99,7 +105,6 @@ public: using Self = RNSuccIterator; - using value_type = typename super::value_type; /// Create begin iterator of a RegionNode. inline RNSuccIterator(NodeRef node) @@ -163,9 +168,15 @@ /// are contained in the Region and its subregions. This is close to a virtual /// control flow graph of the Region. template -class RNSuccIterator, BlockT, RegionT> - : public std::iterator { - using super = std::iterator; +class RNSuccIterator, BlockT, RegionT> { +public: + using iterator_category = std::forward_iterator_tag; + using value_type = NodeRef; + using difference_type = std::ptrdiff_t; + using pointer = value_type *; + using reference = value_type &; + +private: using BlockTraits = GraphTraits; using SuccIterTy = typename BlockTraits::ChildIteratorType; @@ -174,7 +185,6 @@ public: using Self = RNSuccIterator, BlockT, RegionT>; - using value_type = typename super::value_type; /// Create the iterator from a RegionNode. /// Index: llvm/include/llvm/CodeGen/MachineRegisterInfo.h =================================================================== --- llvm/include/llvm/CodeGen/MachineRegisterInfo.h +++ llvm/include/llvm/CodeGen/MachineRegisterInfo.h @@ -967,10 +967,17 @@ /// when incrementing. template - class defusechain_iterator - : public std::iterator { + class defusechain_iterator { friend class MachineRegisterInfo; + public: + using iterator_category = std::forward_iterator_tag; + using value_type = MachineInstr; + using difference_type = std::ptrdiff_t; + using pointer = value_type *; + using reference = value_type &; + + private: MachineOperand *Op = nullptr; explicit defusechain_iterator(MachineOperand *op) : Op(op) { @@ -1005,11 +1012,6 @@ } public: - using reference = std::iterator::reference; - using pointer = std::iterator::pointer; - defusechain_iterator() = default; bool operator==(const defusechain_iterator &x) const { @@ -1073,10 +1075,17 @@ /// when incrementing. template - class defusechain_instr_iterator - : public std::iterator { + class defusechain_instr_iterator { friend class MachineRegisterInfo; + public: + using iterator_category = std::forward_iterator_tag; + using value_type = MachineInstr; + using difference_type = std::ptrdiff_t; + using pointer = value_type *; + using reference = value_type &; + + private: MachineOperand *Op = nullptr; explicit defusechain_instr_iterator(MachineOperand *op) : Op(op) { @@ -1111,11 +1120,6 @@ } public: - using reference = std::iterator::reference; - using pointer = std::iterator::pointer; - defusechain_instr_iterator() = default; bool operator==(const defusechain_instr_iterator &x) const { Index: llvm/include/llvm/CodeGen/ScheduleDAG.h =================================================================== --- llvm/include/llvm/CodeGen/ScheduleDAG.h +++ llvm/include/llvm/CodeGen/ScheduleDAG.h @@ -614,14 +614,19 @@ const MCInstrDesc *getNodeDesc(const SDNode *Node) const; }; - class SUnitIterator : public std::iterator { + class SUnitIterator { SUnit *Node; unsigned Operand; SUnitIterator(SUnit *N, unsigned Op) : Node(N), Operand(Op) {} public: + using iterator_category = std::forward_iterator_tag; + using value_type = SUnit; + using difference_type = std::ptrdiff_t; + using pointer = value_type *; + using reference = value_type &; + bool operator==(const SUnitIterator& x) const { return Operand == x.Operand; } Index: llvm/include/llvm/CodeGen/SelectionDAGNodes.h =================================================================== --- llvm/include/llvm/CodeGen/SelectionDAGNodes.h +++ llvm/include/llvm/CodeGen/SelectionDAGNodes.h @@ -767,8 +767,7 @@ /// This class provides iterator support for SDUse /// operands that use a specific SDNode. - class use_iterator - : public std::iterator { + class use_iterator { friend class SDNode; SDUse *Op = nullptr; @@ -776,10 +775,11 @@ explicit use_iterator(SDUse *op) : Op(op) {} public: - using reference = std::iterator::reference; - using pointer = std::iterator::pointer; + using iterator_category = std::forward_iterator_tag; + using value_type = SDUse; + using difference_type = std::ptrdiff_t; + using pointer = value_type *; + using reference = value_type &; use_iterator() = default; use_iterator(const use_iterator &I) : Op(I.Op) {} @@ -2515,14 +2515,19 @@ } }; -class SDNodeIterator : public std::iterator { +class SDNodeIterator { const SDNode *Node; unsigned Operand; SDNodeIterator(const SDNode *N, unsigned Op) : Node(N), Operand(Op) {} public: + using iterator_category = std::forward_iterator_tag; + using value_type = SDNode; + using difference_type = std::ptrdiff_t; + using pointer = value_type *; + using reference = value_type &; + bool operator==(const SDNodeIterator& x) const { return Operand == x.Operand; } Index: llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h =================================================================== --- llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h +++ llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h @@ -140,7 +140,7 @@ friend class ValueIterator; }; - class ValueIterator : public std::iterator { + class ValueIterator { const AppleAcceleratorTable *AccelTable = nullptr; Entry Current; ///< The current entry. uint64_t DataOffset = 0; ///< Offset into the section. @@ -150,6 +150,12 @@ /// Advance the iterator. void Next(); public: + using iterator_category = std::input_iterator_tag; + using value_type = Entry; + using difference_type = std::ptrdiff_t; + using pointer = value_type *; + using reference = value_type &; + /// Construct a new iterator for the entries at \p DataOffset. ValueIterator(const AppleAcceleratorTable &AccelTable, uint64_t DataOffset); /// End marker. @@ -467,8 +473,15 @@ friend class DWARFDebugNames; }; - class ValueIterator : public std::iterator { + class ValueIterator { + public: + using iterator_category = std::input_iterator_tag; + using value_type = Entry; + using difference_type = std::ptrdiff_t; + using pointer = value_type *; + using reference = value_type &; + private: /// The Name Index we are currently iterating through. The implementation /// relies on the fact that this can also be used as an iterator into the /// "NameIndices" vector in the Accelerator section. Index: llvm/include/llvm/IR/CFG.h =================================================================== --- llvm/include/llvm/IR/CFG.h +++ llvm/include/llvm/IR/CFG.h @@ -39,10 +39,15 @@ //===----------------------------------------------------------------------===// template // Predecessor Iterator -class PredIterator : public std::iterator { - using super = - std::iterator; +class PredIterator { +public: + using iterator_category = std::forward_iterator_tag; + using value_type = Ptr; + using difference_type = std::ptrdiff_t; + using pointer = Ptr *; + using reference = Ptr *; + +private: using Self = PredIterator; USE_iterator It; @@ -58,9 +63,6 @@ } public: - using pointer = typename super::pointer; - using reference = typename super::reference; - PredIterator() = default; explicit inline PredIterator(Ptr *bb) : It(bb->user_begin()) { advancePastNonTerminators(); Index: llvm/include/llvm/IR/DebugInfoMetadata.h =================================================================== --- llvm/include/llvm/IR/DebugInfoMetadata.h +++ llvm/include/llvm/IR/DebugInfoMetadata.h @@ -80,11 +80,16 @@ return cast_or_null(N->getOperand(I)); } - class iterator : std::iterator { + class iterator { MDNode::op_iterator I = nullptr; public: + using iterator_category = std::input_iterator_tag; + using value_type = DIType *; + using difference_type = std::ptrdiff_t; + using pointer = void; + using reference = DIType *; + iterator() = default; explicit iterator(MDNode::op_iterator I) : I(I) {} @@ -2374,11 +2379,16 @@ }; /// An iterator for expression operands. - class expr_op_iterator - : public std::iterator { + class expr_op_iterator { ExprOperand Op; public: + using iterator_category = std::input_iterator_tag; + using value_type = ExprOperand; + using difference_type = std::ptrdiff_t; + using pointer = value_type *; + using reference = value_type &; + expr_op_iterator() = default; explicit expr_op_iterator(element_iterator I) : Op(I) {} Index: llvm/include/llvm/IR/GetElementPtrTypeIterator.h =================================================================== --- llvm/include/llvm/IR/GetElementPtrTypeIterator.h +++ llvm/include/llvm/IR/GetElementPtrTypeIterator.h @@ -28,10 +28,7 @@ namespace llvm { template - class generic_gep_type_iterator - : public std::iterator { - using super = std::iterator; - + class generic_gep_type_iterator { ItTy OpIt; PointerUnion CurTy; enum : uint64_t { Unbounded = -1ull }; @@ -40,6 +37,12 @@ generic_gep_type_iterator() = default; public: + using iterator_category = std::forward_iterator_tag; + using value_type = Type *; + using difference_type = std::ptrdiff_t; + using pointer = value_type *; + using reference = value_type &; + static generic_gep_type_iterator begin(Type *Ty, ItTy It) { generic_gep_type_iterator I; I.CurTy = Ty; Index: llvm/include/llvm/IR/Metadata.h =================================================================== --- llvm/include/llvm/IR/Metadata.h +++ llvm/include/llvm/IR/Metadata.h @@ -1188,12 +1188,16 @@ /// An iterator that transforms an \a MDNode::iterator into an iterator over a /// particular Metadata subclass. template -class TypedMDOperandIterator - : public std::iterator { +class TypedMDOperandIterator { MDNode::op_iterator I = nullptr; public: + using iterator_category = std::input_iterator_tag; + using value_type = T *; + using difference_type = std::ptrdiff_t; + using pointer = void; + using reference = T *; + TypedMDOperandIterator() = default; explicit TypedMDOperandIterator(MDNode::op_iterator I) : I(I) {} @@ -1335,8 +1339,7 @@ explicit NamedMDNode(const Twine &N); template - class op_iterator_impl : - public std::iterator { + class op_iterator_impl { friend class NamedMDNode; const NamedMDNode *Node = nullptr; @@ -1345,6 +1348,12 @@ op_iterator_impl(const NamedMDNode *N, unsigned i) : Node(N), Idx(i) {} public: + using iterator_category = std::bidirectional_iterator_tag; + using value_type = T2; + using difference_type = std::ptrdiff_t; + using pointer = value_type *; + using reference = value_type &; + op_iterator_impl() = default; bool operator==(const op_iterator_impl &o) const { return Idx == o.Idx; } Index: llvm/include/llvm/IR/Module.h =================================================================== --- llvm/include/llvm/IR/Module.h +++ llvm/include/llvm/IR/Module.h @@ -728,14 +728,19 @@ } /// An iterator for DICompileUnits that skips those marked NoDebug. - class debug_compile_units_iterator - : public std::iterator { + class debug_compile_units_iterator { NamedMDNode *CUs; unsigned Idx; void SkipNoDebugCUs(); public: + using iterator_category = std::input_iterator_tag; + using value_type = DICompileUnit *; + using difference_type = std::ptrdiff_t; + using pointer = value_type *; + using reference = value_type &; + explicit debug_compile_units_iterator(NamedMDNode *CUs, unsigned Idx) : CUs(CUs), Idx(Idx) { SkipNoDebugCUs(); Index: llvm/include/llvm/IR/Value.h =================================================================== --- llvm/include/llvm/IR/Value.h +++ llvm/include/llvm/IR/Value.h @@ -122,8 +122,7 @@ private: template // UseT == 'Use' or 'const Use' - class use_iterator_impl - : public std::iterator { + class use_iterator_impl { friend class Value; UseT *U; @@ -131,6 +130,12 @@ explicit use_iterator_impl(UseT *u) : U(u) {} public: + using iterator_category = std::forward_iterator_tag; + using value_type = UseT *; + using difference_type = std::ptrdiff_t; + using pointer = value_type *; + using reference = value_type &; + use_iterator_impl() : U() {} bool operator==(const use_iterator_impl &x) const { return U == x.U; } @@ -161,13 +166,18 @@ }; template // UserTy == 'User' or 'const User' - class user_iterator_impl - : public std::iterator { + class user_iterator_impl { use_iterator_impl UI; explicit user_iterator_impl(Use *U) : UI(U) {} friend class Value; public: + using iterator_category = std::forward_iterator_tag; + using value_type = UserTy *; + using difference_type = std::ptrdiff_t; + using pointer = value_type *; + using reference = value_type &; + user_iterator_impl() = default; bool operator==(const user_iterator_impl &x) const { return UI == x.UI; } Index: llvm/include/llvm/IR/ValueMap.h =================================================================== --- llvm/include/llvm/IR/ValueMap.h +++ llvm/include/llvm/IR/ValueMap.h @@ -324,16 +324,19 @@ }; template -class ValueMapIterator : - public std::iterator, - ptrdiff_t> { +class ValueMapIterator { using BaseT = typename DenseMapT::iterator; using ValueT = typename DenseMapT::mapped_type; BaseT I; public: + using iterator_category = std::forward_iterator_tag; + using value_type = std::pair; + using difference_type = std::ptrdiff_t; + using pointer = value_type *; + using reference = value_type &; + ValueMapIterator() : I() {} ValueMapIterator(BaseT I) : I(I) {} @@ -376,16 +379,19 @@ }; template -class ValueMapConstIterator : - public std::iterator, - ptrdiff_t> { +class ValueMapConstIterator { using BaseT = typename DenseMapT::const_iterator; using ValueT = typename DenseMapT::mapped_type; BaseT I; public: + using iterator_category = std::forward_iterator_tag; + using value_type = std::pair; + using difference_type = std::ptrdiff_t; + using pointer = value_type *; + using reference = value_type &; + ValueMapConstIterator() : I() {} ValueMapConstIterator(BaseT I) : I(I) {} ValueMapConstIterator(ValueMapIterator Other) Index: llvm/include/llvm/Object/ELFTypes.h =================================================================== --- llvm/include/llvm/Object/ELFTypes.h +++ llvm/include/llvm/Object/ELFTypes.h @@ -622,8 +622,13 @@ }; template -class Elf_Note_Iterator_Impl - : std::iterator> { +class Elf_Note_Iterator_Impl { + using iterator_category = std::forward_iterator_tag; + using value_type = Elf_Note_Impl; + using difference_type = std::ptrdiff_t; + using pointer = value_type *; + using reference = value_type &; + // Nhdr being a nullptr marks the end of iteration. const Elf_Nhdr_Impl *Nhdr = nullptr; size_t RemainingSize = 0u; Index: llvm/include/llvm/Object/SymbolicFile.h =================================================================== --- llvm/include/llvm/Object/SymbolicFile.h +++ llvm/include/llvm/Object/SymbolicFile.h @@ -66,11 +66,16 @@ } template -class content_iterator - : public std::iterator { +class content_iterator { content_type Current; public: + using iterator_category = std::forward_iterator_tag; + using value_type = content_type; + using difference_type = std::ptrdiff_t; + using pointer = value_type *; + using reference = value_type &; + content_iterator(content_type symb) : Current(std::move(symb)) {} const content_type *operator->() const { return &Current; } Index: llvm/include/llvm/ProfileData/Coverage/CoverageMappingReader.h =================================================================== --- llvm/include/llvm/ProfileData/Coverage/CoverageMappingReader.h +++ llvm/include/llvm/ProfileData/Coverage/CoverageMappingReader.h @@ -41,8 +41,7 @@ }; /// A file format agnostic iterator over coverage mapping data. -class CoverageMappingIterator - : public std::iterator { +class CoverageMappingIterator { CoverageMappingReader *Reader; CoverageMappingRecord Record; coveragemap_error ReadErr; @@ -50,6 +49,12 @@ void increment(); public: + using iterator_category = std::input_iterator_tag; + using value_type = CoverageMappingRecord; + using difference_type = std::ptrdiff_t; + using pointer = value_type *; + using reference = value_type &; + CoverageMappingIterator() : Reader(nullptr), Record(), ReadErr(coveragemap_error::success) {} Index: llvm/include/llvm/ProfileData/InstrProfReader.h =================================================================== --- llvm/include/llvm/ProfileData/InstrProfReader.h +++ llvm/include/llvm/ProfileData/InstrProfReader.h @@ -38,8 +38,15 @@ class InstrProfReader; /// A file format agnostic iterator over profiling data. -class InstrProfIterator : public std::iterator { +class InstrProfIterator { +public: + using iterator_category = std::input_iterator_tag; + using value_type = NamedInstrProfRecord; + using difference_type = std::ptrdiff_t; + using pointer = value_type *; + using reference = value_type &; + +private: InstrProfReader *Reader = nullptr; value_type Record; Index: llvm/include/llvm/Support/LineIterator.h =================================================================== --- llvm/include/llvm/Support/LineIterator.h +++ llvm/include/llvm/Support/LineIterator.h @@ -28,8 +28,7 @@ /// character. /// /// Note that this iterator requires the buffer to be nul terminated. -class line_iterator - : public std::iterator { +class line_iterator { const MemoryBuffer *Buffer; char CommentMarker; bool SkipBlanks; @@ -38,6 +37,12 @@ StringRef CurrentLine; public: + using iterator_category = std::forward_iterator_tag; + using value_type = StringRef; + using difference_type = std::ptrdiff_t; + using pointer = value_type *; + using reference = value_type &; + /// Default construct an "end" iterator. line_iterator() : Buffer(nullptr) {} Index: llvm/include/llvm/Support/TargetRegistry.h =================================================================== --- llvm/include/llvm/Support/TargetRegistry.h +++ llvm/include/llvm/Support/TargetRegistry.h @@ -600,8 +600,7 @@ // function). TargetRegistry() = delete; - class iterator - : public std::iterator { + class iterator { friend struct TargetRegistry; const Target *Current = nullptr; @@ -609,6 +608,12 @@ explicit iterator(Target *T) : Current(T) {} public: + using iterator_category = std::forward_iterator_tag; + using value_type = Target; + using difference_type = std::ptrdiff_t; + using pointer = value_type *; + using reference = value_type &; + iterator() = default; bool operator==(const iterator &x) const { return Current == x.Current; } Index: llvm/include/llvm/Support/YAMLParser.h =================================================================== --- llvm/include/llvm/Support/YAMLParser.h +++ llvm/include/llvm/Support/YAMLParser.h @@ -320,9 +320,14 @@ /// BaseT must have a ValueT* member named CurrentEntry and a member function /// increment() which must set CurrentEntry to 0 to create an end iterator. template -class basic_collection_iterator - : public std::iterator { +class basic_collection_iterator { public: + using iterator_category = std::input_iterator_tag; + using value_type = ValueT; + using difference_type = std::ptrdiff_t; + using pointer = value_type *; + using reference = value_type &; + basic_collection_iterator() = default; basic_collection_iterator(BaseT *B) : Base(B) {} Index: llvm/include/llvm/TextAPI/MachO/ArchitectureSet.h =================================================================== --- llvm/include/llvm/TextAPI/MachO/ArchitectureSet.h +++ llvm/include/llvm/TextAPI/MachO/ArchitectureSet.h @@ -60,8 +60,14 @@ ArchSetType rawValue() const { return ArchSet; } template - class arch_iterator - : public std::iterator { + class arch_iterator { + public: + using iterator_category = std::forward_iterator_tag; + using value_type = Architecture; + using difference_type = std::size_t; + using pointer = value_type *; + using reference = value_type &; + private: ArchSetType Index; Ty *ArchSet; Index: llvm/include/llvm/Transforms/Scalar/GVNExpression.h =================================================================== --- llvm/include/llvm/Transforms/Scalar/GVNExpression.h +++ llvm/include/llvm/Transforms/Scalar/GVNExpression.h @@ -240,14 +240,19 @@ } }; -class op_inserter - : public std::iterator { +class op_inserter { private: using Container = BasicExpression; Container *BE; public: + using iterator_category = std::output_iterator_tag; + using value_type = void; + using difference_type = void; + using pointer = void; + using reference = void; + explicit op_inserter(BasicExpression &E) : BE(&E) {} explicit op_inserter(BasicExpression *E) : BE(E) {} @@ -478,14 +483,19 @@ } }; -class int_op_inserter - : public std::iterator { +class int_op_inserter { private: using Container = AggregateValueExpression; Container *AVE; public: + using iterator_category = std::output_iterator_tag; + using value_type = void; + using difference_type = void; + using pointer = void; + using reference = void; + explicit int_op_inserter(AggregateValueExpression &E) : AVE(&E) {} explicit int_op_inserter(AggregateValueExpression *E) : AVE(E) {} Index: llvm/lib/IR/BasicBlock.cpp =================================================================== --- llvm/lib/IR/BasicBlock.cpp +++ llvm/lib/IR/BasicBlock.cpp @@ -301,7 +301,7 @@ void BasicBlock::removePredecessor(BasicBlock *Pred, bool KeepOneInputPHIs) { assert((hasNUsesOrMore(16)||// Reduce cost of this assertion for complex CFGs. - find(pred_begin(this), pred_end(this), Pred) != pred_end(this)) && + std::find(pred_begin(this), pred_end(this), Pred) != pred_end(this)) && "removePredecessor: BB is not a predecessor!"); if (InstList.empty()) return; Index: llvm/tools/llvm-objdump/MachODump.cpp =================================================================== --- llvm/tools/llvm-objdump/MachODump.cpp +++ llvm/tools/llvm-objdump/MachODump.cpp @@ -469,7 +469,7 @@ if (isExtern) { symbol_iterator SI = O->symbol_begin(); - advance(SI, Val); + std::advance(SI, Val); S = unwrapOrError(SI->getName(), FileName); } else { section_iterator SI = O->section_begin(); @@ -481,7 +481,7 @@ uint32_t I = Val - 1; while (I != 0 && SI != O->section_end()) { --I; - advance(SI, 1); + std::advance(SI, 1); } if (SI == O->section_end()) { Fmt << Val << " (?,?)"; Index: llvm/unittests/ADT/IteratorTest.cpp =================================================================== --- llvm/unittests/ADT/IteratorTest.cpp +++ llvm/unittests/ADT/IteratorTest.cpp @@ -19,8 +19,13 @@ template struct Shadow; -struct WeirdIter : std::iterator, Shadow<1>, - Shadow<2>, Shadow<3>> {}; +struct WeirdIter { + using iterator_category = std::input_iterator_tag; + using value_type = Shadow<0>; + using difference_type = Shadow<1>; + using pointer = Shadow<2>; + using reference = Shadow<3>; +}; struct AdaptedIter : iterator_adaptor_base {};