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 | f81c893d1fff8f76bb606037c3dec8ab0c9ba746 (patch) | |
tree | be87391db334c22708e411843c0fe1a8855854c7 /include | |
parent | f1f27bb03ebdb14a56ffec2f0a51d18b52f9b9d8 (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@280109 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/ADT/ilist.h | 67 |
1 files changed, 33 insertions, 34 deletions
diff --git a/include/llvm/ADT/ilist.h b/include/llvm/ADT/ilist.h index 137d4ec4146..36e075cff3f 100644 --- a/include/llvm/ADT/ilist.h +++ b/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 |