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
This commit is contained in:
Chris Lattner
2001-09-28 22:56:31 +00:00
parent c56d779501
commit 3ff4387113
24 changed files with 284 additions and 458 deletions

View File

@ -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