diff options
| author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2016-08-30 17:01:05 +0000 |
|---|---|---|
| committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2016-08-30 17:01:05 +0000 |
| commit | d476312f493e4a6b1750271a6c4f4d4949bf080c (patch) | |
| tree | 10e9894f65cf893a733d6f233b90e23adecf7280 /llvm | |
| parent | 0e4c73b24dfe5ba7406b1ab0cb20fbe89d50d264 (diff) | |
| download | bcm5719-llvm-d476312f493e4a6b1750271a6c4f4d4949bf080c.tar.gz bcm5719-llvm-d476312f493e4a6b1750271a6c4f4d4949bf080c.zip | |
ADT: Clean up docs and formatting for ilist_traits, NFC
This is a prep commit before splitting up ilist_node_traits and
updating/simplifying call sites.
- Move to top of file (I considered moving to a different file,
llvm/ADT/ilist_traits.h, but it's really not much code).
- Clang-format.
- Convert comments to doxygen, clean them up, and add TODOs for what I'm
doing next.
llvm-svn: 280109
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/include/llvm/ADT/ilist.h | 67 |
1 files changed, 33 insertions, 34 deletions
diff --git a/llvm/include/llvm/ADT/ilist.h b/llvm/include/llvm/ADT/ilist.h index 137d4ec4146..36e075cff3f 100644 --- a/llvm/include/llvm/ADT/ilist.h +++ b/llvm/include/llvm/ADT/ilist.h @@ -33,7 +33,39 @@ namespace llvm { -template<typename NodeTy, typename Traits> class iplist; +/// A fragment for template traits for intrusive list that provides default +/// node related operations. +/// +/// TODO: Split up (alloc vs. callback) and delete. +template <typename NodeTy> struct ilist_node_traits { + static NodeTy *createNode(const NodeTy &V) { return new NodeTy(V); } + static void deleteNode(NodeTy *V) { delete V; } + + void addNodeToList(NodeTy *) {} + void removeNodeFromList(NodeTy *) {} + void transferNodesFromList(ilist_node_traits & /*SrcTraits*/, + ilist_iterator<NodeTy> /*first*/, + ilist_iterator<NodeTy> /*last*/) {} +}; + +/// Default template traits for intrusive list. +/// +/// By inheriting from this, you can easily use default implementations for all +/// common operations. +/// +/// TODO: Remove this customization point. Specializing ilist_traits is +/// already fully general. +template <typename NodeTy> +struct ilist_default_traits : public ilist_node_traits<NodeTy> {}; + +/// Template traits for intrusive list. +/// +/// Customize callbacks and allocation semantics. +template <typename NodeTy> +struct ilist_traits : public ilist_default_traits<NodeTy> {}; + +/// Const traits should never be instantiated. +template <typename Ty> struct ilist_traits<const Ty> {}; namespace ilist_detail { @@ -75,39 +107,6 @@ template <class TraitsT, class NodeT> struct HasObsoleteCustomization { } // end namespace ilist_detail -template <typename NodeTy> struct ilist_traits; - -/// ilist_node_traits - A fragment for template traits for intrusive list -/// that provides default node related operations. -/// -template<typename NodeTy> -struct ilist_node_traits { - static NodeTy *createNode(const NodeTy &V) { return new NodeTy(V); } - static void deleteNode(NodeTy *V) { delete V; } - - void addNodeToList(NodeTy *) {} - void removeNodeFromList(NodeTy *) {} - void transferNodesFromList(ilist_node_traits & /*SrcTraits*/, - ilist_iterator<NodeTy> /*first*/, - ilist_iterator<NodeTy> /*last*/) {} -}; - -/// ilist_default_traits - Default template traits for intrusive list. -/// By inheriting from this, you can easily use default implementations -/// for all common operations. -/// -template <typename NodeTy> -struct ilist_default_traits : public ilist_node_traits<NodeTy> {}; - -// Template traits for intrusive list. By specializing this template class, you -// can change what next/prev fields are used to store the links... -template<typename NodeTy> -struct ilist_traits : public ilist_default_traits<NodeTy> {}; - -// Const traits are the same as nonconst traits... -template<typename Ty> -struct ilist_traits<const Ty> : public ilist_traits<Ty> {}; - //===----------------------------------------------------------------------===// // /// The subset of list functionality that can safely be used on nodes of |

