File indexing completed on 2026-05-10 08:43:06
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef LLVM_ADT_ILIST_NODE_OPTIONS_H
0010 #define LLVM_ADT_ILIST_NODE_OPTIONS_H
0011
0012 #include "llvm/Config/abi-breaking.h"
0013
0014 #include <type_traits>
0015
0016 namespace llvm {
0017
0018 template <bool EnableSentinelTracking, class ParentTy> class ilist_node_base;
0019 template <bool EnableSentinelTracking, class ParentTy> class ilist_base;
0020
0021
0022
0023
0024
0025
0026 template <bool EnableSentinelTracking> struct ilist_sentinel_tracking {};
0027
0028
0029
0030
0031
0032 template <class Tag> struct ilist_tag {};
0033
0034
0035
0036
0037
0038
0039
0040 template <bool ExtraIteratorBits> struct ilist_iterator_bits {};
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053 template <class ParentTy> struct ilist_parent {};
0054
0055 namespace ilist_detail {
0056
0057
0058 template <bool IsExplicit> struct explicitness {
0059 static const bool is_explicit = IsExplicit;
0060 };
0061 typedef explicitness<true> is_explicit;
0062 typedef explicitness<false> is_implicit;
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075 template <class Option> struct is_valid_option : std::false_type {};
0076
0077
0078
0079
0080
0081 template <class... Options> struct extract_sentinel_tracking;
0082 template <bool EnableSentinelTracking, class... Options>
0083 struct extract_sentinel_tracking<
0084 ilist_sentinel_tracking<EnableSentinelTracking>, Options...>
0085 : std::integral_constant<bool, EnableSentinelTracking>, is_explicit {};
0086 template <class Option1, class... Options>
0087 struct extract_sentinel_tracking<Option1, Options...>
0088 : extract_sentinel_tracking<Options...> {};
0089 #if LLVM_ENABLE_ABI_BREAKING_CHECKS
0090 template <> struct extract_sentinel_tracking<> : std::true_type, is_implicit {};
0091 #else
0092 template <>
0093 struct extract_sentinel_tracking<> : std::false_type, is_implicit {};
0094 #endif
0095 template <bool EnableSentinelTracking>
0096 struct is_valid_option<ilist_sentinel_tracking<EnableSentinelTracking>>
0097 : std::true_type {};
0098
0099
0100
0101
0102
0103 template <class... Options> struct extract_tag;
0104 template <class Tag, class... Options>
0105 struct extract_tag<ilist_tag<Tag>, Options...> {
0106 typedef Tag type;
0107 };
0108 template <class Option1, class... Options>
0109 struct extract_tag<Option1, Options...> : extract_tag<Options...> {};
0110 template <> struct extract_tag<> {
0111 typedef void type;
0112 };
0113 template <class Tag> struct is_valid_option<ilist_tag<Tag>> : std::true_type {};
0114
0115
0116
0117
0118
0119 template <class... Options> struct extract_iterator_bits;
0120 template <bool IteratorBits, class... Options>
0121 struct extract_iterator_bits<ilist_iterator_bits<IteratorBits>, Options...>
0122 : std::integral_constant<bool, IteratorBits> {};
0123 template <class Option1, class... Options>
0124 struct extract_iterator_bits<Option1, Options...>
0125 : extract_iterator_bits<Options...> {};
0126 template <> struct extract_iterator_bits<> : std::false_type, is_implicit {};
0127 template <bool IteratorBits>
0128 struct is_valid_option<ilist_iterator_bits<IteratorBits>> : std::true_type {};
0129
0130
0131
0132
0133
0134 template <class... Options> struct extract_parent;
0135 template <class ParentTy, class... Options>
0136 struct extract_parent<ilist_parent<ParentTy>, Options...> {
0137 typedef ParentTy type;
0138 };
0139 template <class Option1, class... Options>
0140 struct extract_parent<Option1, Options...> : extract_parent<Options...> {};
0141 template <> struct extract_parent<> { typedef void type; };
0142 template <class ParentTy>
0143 struct is_valid_option<ilist_parent<ParentTy>> : std::true_type {};
0144
0145
0146
0147
0148 template <class... Options> struct check_options;
0149 template <> struct check_options<> : std::true_type {};
0150 template <class Option1, class... Options>
0151 struct check_options<Option1, Options...>
0152 : std::integral_constant<bool, is_valid_option<Option1>::value &&
0153 check_options<Options...>::value> {};
0154
0155
0156
0157
0158 template <class T, bool EnableSentinelTracking, bool IsSentinelTrackingExplicit,
0159 class TagT, bool HasIteratorBits, class ParentTy>
0160 struct node_options {
0161 typedef T value_type;
0162 typedef T *pointer;
0163 typedef T &reference;
0164 typedef const T *const_pointer;
0165 typedef const T &const_reference;
0166
0167 static const bool enable_sentinel_tracking = EnableSentinelTracking;
0168 static const bool is_sentinel_tracking_explicit = IsSentinelTrackingExplicit;
0169 static const bool has_iterator_bits = HasIteratorBits;
0170 typedef TagT tag;
0171 typedef ParentTy parent_ty;
0172 typedef ilist_node_base<enable_sentinel_tracking, parent_ty> node_base_type;
0173 typedef ilist_base<enable_sentinel_tracking, parent_ty> list_base_type;
0174 };
0175
0176 template <class T, class... Options> struct compute_node_options {
0177 typedef node_options<T, extract_sentinel_tracking<Options...>::value,
0178 extract_sentinel_tracking<Options...>::is_explicit,
0179 typename extract_tag<Options...>::type,
0180 extract_iterator_bits<Options...>::value,
0181 typename extract_parent<Options...>::type>
0182 type;
0183 };
0184
0185 }
0186 }
0187
0188 #endif