-template<class SetType, bool External> // Non-external set
-class po_iterator_storage {
-public:
- SetType Visited;
-};
-
-template<class SetType>
-class po_iterator_storage<SetType, true> {
-public:
- po_iterator_storage(SetType &VSet) : Visited(VSet) {}
- po_iterator_storage(const po_iterator_storage &S) : Visited(S.Visited) {}
- SetType &Visited;
-};
-
-template<class GraphT,
- class SetType = std::set<typename GraphTraits<GraphT>::NodeType*>,
- bool ExtStorage = false,
- class GT = GraphTraits<GraphT> >
-class po_iterator : public forward_iterator<typename GT::NodeType, ptrdiff_t>,
- public po_iterator_storage<SetType, ExtStorage> {
- typedef forward_iterator<typename GT::NodeType, ptrdiff_t> super;
+template<class SetType, bool External> // Non-external set
+class po_iterator_storage {
+public:
+ SetType Visited;
+};
+
+/// DFSetTraits - Allow the SetType used to record depth-first search results to
+/// optionally record node postorder.
+template<class SetType>
+struct DFSetTraits {
+ static void finishPostorder(
+ typename SetType::iterator::value_type, SetType &) {}
+};
+
+template<class SetType>
+class po_iterator_storage<SetType, true> {
+public:
+ po_iterator_storage(SetType &VSet) : Visited(VSet) {}
+ po_iterator_storage(const po_iterator_storage &S) : Visited(S.Visited) {}
+ SetType &Visited;
+};
+
+template<class GraphT,
+ class SetType = llvm::SmallPtrSet<typename GraphTraits<GraphT>::NodeType*, 8>,
+ bool ExtStorage = false,
+ class GT = GraphTraits<GraphT> >
+class po_iterator : public std::iterator<std::forward_iterator_tag,
+ typename GT::NodeType, ptrdiff_t>,
+ public po_iterator_storage<SetType, ExtStorage> {
+ typedef std::iterator<std::forward_iterator_tag,
+ typename GT::NodeType, ptrdiff_t> super;