diff options
-rw-r--r-- | include/Support/ilist | 20 | ||||
-rw-r--r-- | include/llvm/ADT/ilist | 20 |
2 files changed, 40 insertions, 0 deletions
diff --git a/include/Support/ilist b/include/Support/ilist index 26a2a2569b..1d868f8a4a 100644 --- a/include/Support/ilist +++ b/include/Support/ilist @@ -151,6 +151,26 @@ public: pointer getNodePtrUnchecked() const { return NodePtr; } }; +// Allow ilist_iterators to convert into pointers to a node automatically when +// used by the dyn_cast, cast, isa mechanisms... + +template<typename From> struct simplify_type; + +template<typename NodeTy> struct simplify_type<ilist_iterator<NodeTy> > { + typedef NodeTy* SimpleType; + + static SimpleType getSimplifiedValue(const ilist_iterator<NodeTy> &Node) { + return &*Node; + } +}; +template<typename NodeTy> struct simplify_type<const ilist_iterator<NodeTy> > { + typedef NodeTy* SimpleType; + + static SimpleType getSimplifiedValue(const ilist_iterator<NodeTy> &Node) { + return &*Node; + } +}; + //===----------------------------------------------------------------------===// // diff --git a/include/llvm/ADT/ilist b/include/llvm/ADT/ilist index 26a2a2569b..1d868f8a4a 100644 --- a/include/llvm/ADT/ilist +++ b/include/llvm/ADT/ilist @@ -151,6 +151,26 @@ public: pointer getNodePtrUnchecked() const { return NodePtr; } }; +// Allow ilist_iterators to convert into pointers to a node automatically when +// used by the dyn_cast, cast, isa mechanisms... + +template<typename From> struct simplify_type; + +template<typename NodeTy> struct simplify_type<ilist_iterator<NodeTy> > { + typedef NodeTy* SimpleType; + + static SimpleType getSimplifiedValue(const ilist_iterator<NodeTy> &Node) { + return &*Node; + } +}; +template<typename NodeTy> struct simplify_type<const ilist_iterator<NodeTy> > { + typedef NodeTy* SimpleType; + + static SimpleType getSimplifiedValue(const ilist_iterator<NodeTy> &Node) { + return &*Node; + } +}; + //===----------------------------------------------------------------------===// // |