Added partial specialization of GraphTraits for the DominatorTree class.
authorJoel Stanley <jstanley@cs.uiuc.edu>
Wed, 16 Oct 2002 23:26:00 +0000 (23:26 +0000)
committerJoel Stanley <jstanley@cs.uiuc.edu>
Wed, 16 Oct 2002 23:26:00 +0000 (23:26 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4205 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Analysis/Dominators.h

index 815be7dfaf35cebf74c0ab19c207c816611e5374..3304ad330c160c8ce557aca7758deb37956800e6 100644 (file)
@@ -19,6 +19,7 @@
 #define LLVM_ANALYSIS_DOMINATORS_H
 
 #include "llvm/Pass.h"
+#include "Support/GraphTraits.h"
 #include <set>
 class Instruction;
 
@@ -341,6 +342,24 @@ private:
   void calculate(const DominatorSet &DS);
 };
 
+//===-------------------------------------
+// DominatorTree GraphTraits specialization so the DominatorTree can be
+// iterable by generic graph iterators.
+
+template <> struct GraphTraits<DominatorTree*> {
+  typedef DominatorTree::Node NodeType;
+  typedef NodeType::iterator  ChildIteratorType;
+
+  static NodeType *getEntryNode(DominatorTree *DT) {
+    return DT->getNode(DT->getRoot());
+  }
+  static inline ChildIteratorType child_begin(NodeType* N) {
+    return N->begin();
+  }
+  static inline ChildIteratorType child_end(NodeType* N) {
+    return N->end();
+  }
+};
 
 //===----------------------------------------------------------------------===//
 //