[llvm] r280109 - ADT: Clean up docs and formatting for ilist_traits, NFC
Duncan P. N. Exon Smith via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 30 10:01:05 PDT 2016
Author: dexonsmith
Date: Tue Aug 30 12:01:05 2016
New Revision: 280109
URL: http://llvm.org/viewvc/llvm-project?rev=280109&view=rev
Log:
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.
Modified:
llvm/trunk/include/llvm/ADT/ilist.h
Modified: llvm/trunk/include/llvm/ADT/ilist.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/ilist.h?rev=280109&r1=280108&r2=280109&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/ilist.h (original)
+++ llvm/trunk/include/llvm/ADT/ilist.h Tue Aug 30 12:01:05 2016
@@ -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> st
} // 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
More information about the llvm-commits
mailing list