Index: include/llvm/CodeGen/MachineDominators.h =================================================================== --- include/llvm/CodeGen/MachineDominators.h +++ include/llvm/CodeGen/MachineDominators.h @@ -246,36 +246,29 @@ /// iterable by generic graph iterators. /// -template struct GraphTraits; +template +struct MachineDomTreeGraphTraitsBase { + typedef Node NodeType; + typedef ChildIterator ChildIteratorType; -template <> struct GraphTraits { - typedef MachineDomTreeNode NodeType; - typedef NodeType::iterator ChildIteratorType; - - static NodeType *getEntryNode(NodeType *N) { - return N; - } - static inline ChildIteratorType child_begin(NodeType* N) { + static NodeType *getEntryNode(NodeType *N) { return N; } + static inline ChildIteratorType child_begin(NodeType *N) { return N->begin(); } - static inline ChildIteratorType child_end(NodeType* N) { - return N->end(); - } + static inline ChildIteratorType child_end(NodeType *N) { return N->end(); } }; -template <> struct GraphTraits { - typedef const MachineDomTreeNode NodeType; - typedef NodeType::const_iterator ChildIteratorType; +template struct GraphTraits; - static NodeType *getEntryNode(NodeType *N) { - return N; - } - static inline ChildIteratorType child_begin(NodeType* N) { - return N->begin(); - } - static inline ChildIteratorType child_end(NodeType* N) { - return N->end(); - } +template <> +struct GraphTraits + : public MachineDomTreeGraphTraitsBase {}; + +template <> +struct GraphTraits + : public MachineDomTreeGraphTraitsBase { }; template <> struct GraphTraits Index: include/llvm/IR/Dominators.h =================================================================== --- include/llvm/IR/Dominators.h +++ include/llvm/IR/Dominators.h @@ -125,55 +125,34 @@ // DominatorTree GraphTraits specializations so the DominatorTree can be // iterable by generic graph iterators. -template <> struct GraphTraits { - typedef DomTreeNode NodeType; - typedef NodeType::iterator ChildIteratorType; +template struct DomTreeGraphTraitsBase { + typedef Node NodeType; + typedef ChildIterator ChildIteratorType; + typedef df_iterator> nodes_iterator; - static NodeType *getEntryNode(NodeType *N) { - return N; - } + static NodeType *getEntryNode(NodeType *N) { return N; } static inline ChildIteratorType child_begin(NodeType *N) { return N->begin(); } - static inline ChildIteratorType child_end(NodeType *N) { - return N->end(); - } + static inline ChildIteratorType child_end(NodeType *N) { return N->end(); } - typedef df_iterator nodes_iterator; - - static nodes_iterator nodes_begin(DomTreeNode *N) { + static nodes_iterator nodes_begin(NodeType *N) { return df_begin(getEntryNode(N)); } - static nodes_iterator nodes_end(DomTreeNode *N) { + static nodes_iterator nodes_end(NodeType *N) { return df_end(getEntryNode(N)); } }; -template <> struct GraphTraits { - typedef const DomTreeNode NodeType; - typedef NodeType::const_iterator ChildIteratorType; - - static NodeType *getEntryNode(NodeType *N) { - return N; - } - static inline ChildIteratorType child_begin(NodeType *N) { - return N->begin(); - } - static inline ChildIteratorType child_end(NodeType *N) { - return N->end(); - } - - typedef df_iterator nodes_iterator; - - static nodes_iterator nodes_begin(const DomTreeNode *N) { - return df_begin(getEntryNode(N)); - } +template <> +struct GraphTraits + : public DomTreeGraphTraitsBase {}; - static nodes_iterator nodes_end(const DomTreeNode *N) { - return df_end(getEntryNode(N)); - } -}; +template <> +struct GraphTraits + : public DomTreeGraphTraitsBase {}; template <> struct GraphTraits : public GraphTraits {