[llvm-commits] CVS: llvm/include/llvm/Analysis/Dominators.h

Joel Stanley jstanley at cs.uiuc.edu
Wed Oct 16 18:27:00 PDT 2002


Changes in directory llvm/include/llvm/Analysis:

Dominators.h updated: 1.27 -> 1.28

---
Log message:

Added partial specialization of GraphTraits for the DominatorTree class.



---
Diffs of the changes:

Index: llvm/include/llvm/Analysis/Dominators.h
diff -u llvm/include/llvm/Analysis/Dominators.h:1.27 llvm/include/llvm/Analysis/Dominators.h:1.28
--- llvm/include/llvm/Analysis/Dominators.h:1.27	Tue Oct  8 14:12:05 2002
+++ llvm/include/llvm/Analysis/Dominators.h	Wed Oct 16 18:26:00 2002
@@ -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 @@
   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();
+  }
+};
 
 //===----------------------------------------------------------------------===//
 //





More information about the llvm-commits mailing list