[PATCH] D23522: [ADT] Change PostOrderIterator to use NodeRef. NFC.

Tim Shen via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 15 14:34:51 PDT 2016


timshen added inline comments.

================
Comment at: include/llvm/ADT/PostOrderIterator.h:93-95
@@ +92,5 @@
+class po_iterator
+    : public std::iterator<std::forward_iterator_tag, typename GT::NodeRef>,
+      public po_iterator_storage<SetType, ExtStorage> {
+  typedef std::iterator<std::forward_iterator_tag, typename GT::NodeRef> super;
+  typedef typename GT::NodeRef NodeRef;
----------------
Hey somehow I realized that it's only operator->() that is non-standard. I make std::iterator<...> normal, leaving operator->() returning NodeRef. If NodeRef isn't a pointer and the user never calls PoIterator->..., the user code still builds.

================
Comment at: include/llvm/ADT/PostOrderIterator.h:122
@@ -123,3 +121,3 @@
       : po_iterator_storage<SetType, ExtStorage>(S) {
-    if (this->insertEdge((NodeType*)nullptr, BB)) {
+    if (this->insertEdge(Optional<NodeRef>(), BB)) {
       VisitStack.push_back(std::make_pair(BB, GT::child_begin(BB)));
----------------
Yeah, the main reason I don't want that is it aggressively generalize the insertEdge's interface.


https://reviews.llvm.org/D23522





More information about the llvm-commits mailing list