Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit f81c893

Browse files
committed
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
1 parent f1f27bb commit f81c893

File tree

1 file changed

+33
-34
lines changed

1 file changed

+33
-34
lines changed

include/llvm/ADT/ilist.h

Lines changed: 33 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,39 @@
3333

3434
namespace llvm {
3535

36-
template<typename NodeTy, typename Traits> class iplist;
36+
/// A fragment for template traits for intrusive list that provides default
37+
/// node related operations.
38+
///
39+
/// TODO: Split up (alloc vs. callback) and delete.
40+
template <typename NodeTy> struct ilist_node_traits {
41+
static NodeTy *createNode(const NodeTy &V) { return new NodeTy(V); }
42+
static void deleteNode(NodeTy *V) { delete V; }
43+
44+
void addNodeToList(NodeTy *) {}
45+
void removeNodeFromList(NodeTy *) {}
46+
void transferNodesFromList(ilist_node_traits & /*SrcTraits*/,
47+
ilist_iterator<NodeTy> /*first*/,
48+
ilist_iterator<NodeTy> /*last*/) {}
49+
};
50+
51+
/// Default template traits for intrusive list.
52+
///
53+
/// By inheriting from this, you can easily use default implementations for all
54+
/// common operations.
55+
///
56+
/// TODO: Remove this customization point. Specializing ilist_traits is
57+
/// already fully general.
58+
template <typename NodeTy>
59+
struct ilist_default_traits : public ilist_node_traits<NodeTy> {};
60+
61+
/// Template traits for intrusive list.
62+
///
63+
/// Customize callbacks and allocation semantics.
64+
template <typename NodeTy>
65+
struct ilist_traits : public ilist_default_traits<NodeTy> {};
66+
67+
/// Const traits should never be instantiated.
68+
template <typename Ty> struct ilist_traits<const Ty> {};
3769

3870
namespace ilist_detail {
3971

@@ -75,39 +107,6 @@ template <class TraitsT, class NodeT> struct HasObsoleteCustomization {
75107

76108
} // end namespace ilist_detail
77109

78-
template <typename NodeTy> struct ilist_traits;
79-
80-
/// ilist_node_traits - A fragment for template traits for intrusive list
81-
/// that provides default node related operations.
82-
///
83-
template<typename NodeTy>
84-
struct ilist_node_traits {
85-
static NodeTy *createNode(const NodeTy &V) { return new NodeTy(V); }
86-
static void deleteNode(NodeTy *V) { delete V; }
87-
88-
void addNodeToList(NodeTy *) {}
89-
void removeNodeFromList(NodeTy *) {}
90-
void transferNodesFromList(ilist_node_traits & /*SrcTraits*/,
91-
ilist_iterator<NodeTy> /*first*/,
92-
ilist_iterator<NodeTy> /*last*/) {}
93-
};
94-
95-
/// ilist_default_traits - Default template traits for intrusive list.
96-
/// By inheriting from this, you can easily use default implementations
97-
/// for all common operations.
98-
///
99-
template <typename NodeTy>
100-
struct ilist_default_traits : public ilist_node_traits<NodeTy> {};
101-
102-
// Template traits for intrusive list. By specializing this template class, you
103-
// can change what next/prev fields are used to store the links...
104-
template<typename NodeTy>
105-
struct ilist_traits : public ilist_default_traits<NodeTy> {};
106-
107-
// Const traits are the same as nonconst traits...
108-
template<typename Ty>
109-
struct ilist_traits<const Ty> : public ilist_traits<Ty> {};
110-
111110
//===----------------------------------------------------------------------===//
112111
//
113112
/// The subset of list functionality that can safely be used on nodes of

0 commit comments

Comments
 (0)