diff options
author | Chris Lattner <sabre@nondot.org> | 2001-09-28 22:56:31 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2001-09-28 22:56:31 +0000 |
commit | 3ff4387113d7e74a8aa73f80c3518cb95f09a64b (patch) | |
tree | 7e55b84e841721d133477294b2fee246ee6ceaed /include/llvm/Type.h | |
parent | c56d779501901e22103a1236768cb97fd9b5c9b0 (diff) |
Pull iterators out of CFG.h and CFGdecls and put them in Support directory
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@664 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Type.h')
-rw-r--r-- | include/llvm/Type.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/include/llvm/Type.h b/include/llvm/Type.h index ed39d120ec..5854062df0 100644 --- a/include/llvm/Type.h +++ b/include/llvm/Type.h @@ -27,6 +27,7 @@ #define LLVM_TYPE_H #include "llvm/Value.h" +#include "llvm/Support/GraphTraits.h" class DerivedType; class MethodType; @@ -264,4 +265,34 @@ inline Type::TypeIterator Type::subtype_end() const { return TypeIterator(this, getNumContainedTypes()); } + +// Provide specializations of GraphTraits to be able to treat a type as a +// graph of sub types... + +template <> struct GraphTraits<Type*> { + typedef Type NodeType; + typedef Type::subtype_iterator ChildIteratorType; + + static inline NodeType *getEntryNode(Type *T) { return T; } + static inline ChildIteratorType child_begin(NodeType *N) { + return N->subtype_begin(); + } + static inline ChildIteratorType child_end(NodeType *N) { + return N->subtype_end(); + } +}; + +template <> struct GraphTraits<const Type*> { + typedef const Type NodeType; + typedef Type::subtype_iterator ChildIteratorType; + + static inline NodeType *getEntryNode(const Type *T) { return T; } + static inline ChildIteratorType child_begin(NodeType *N) { + return N->subtype_begin(); + } + static inline ChildIteratorType child_end(NodeType *N) { + return N->subtype_end(); + } +}; + #endif |