From 011ce8d2e401855877803fb6d972a6f6c22242a5 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 23 Apr 2003 16:17:53 +0000 Subject: [PATCH] Allow autoconversion from ilist_iterator to T* in a dyn_cast and friends git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5862 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/Support/ilist | 20 ++++++++++++++++++++ include/llvm/ADT/ilist | 20 ++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/include/Support/ilist b/include/Support/ilist index 26a2a2569ba..1d868f8a4a4 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 struct simplify_type; + +template struct simplify_type > { + typedef NodeTy* SimpleType; + + static SimpleType getSimplifiedValue(const ilist_iterator &Node) { + return &*Node; + } +}; +template struct simplify_type > { + typedef NodeTy* SimpleType; + + static SimpleType getSimplifiedValue(const ilist_iterator &Node) { + return &*Node; + } +}; + //===----------------------------------------------------------------------===// // diff --git a/include/llvm/ADT/ilist b/include/llvm/ADT/ilist index 26a2a2569ba..1d868f8a4a4 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 struct simplify_type; + +template struct simplify_type > { + typedef NodeTy* SimpleType; + + static SimpleType getSimplifiedValue(const ilist_iterator &Node) { + return &*Node; + } +}; +template struct simplify_type > { + typedef NodeTy* SimpleType; + + static SimpleType getSimplifiedValue(const ilist_iterator &Node) { + return &*Node; + } +}; + //===----------------------------------------------------------------------===// //