Allow autoconversion from ilist_iterator<T> to T* in a dyn_cast and friends
authorChris Lattner <sabre@nondot.org>
Wed, 23 Apr 2003 16:17:53 +0000 (16:17 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 23 Apr 2003 16:17:53 +0000 (16:17 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5862 91177308-0d34-0410-b5e6-96231b3b80d8

include/Support/ilist
include/llvm/ADT/ilist

index 26a2a2569ba9f8c641bdb54ae6d950b61f2e6f1c..1d868f8a4a4218f0fafbac703dbb87e9216f2842 100644 (file)
@@ -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;
+  }
+};
+
 
 //===----------------------------------------------------------------------===//
 //
index 26a2a2569ba9f8c641bdb54ae6d950b61f2e6f1c..1d868f8a4a4218f0fafbac703dbb87e9216f2842 100644 (file)
@@ -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;
+  }
+};
+
 
 //===----------------------------------------------------------------------===//
 //