llvm.org GIT mirror llvm / be884e2
[ADT] Partial re-commit of r303383. Fix some Clang-tidy modernize-use-using and Include What You Use warnings; other minor fixes (NFC). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305419 91177308-0d34-0410-b5e6-96231b3b80d8 Eugene Zelenko 2 years ago
11 changed file(s) with 221 addition(s) and 191 deletion(s). Raw diff Collapse all Expand all
6262 template
6363 class ImmutableList {
6464 public:
65 typedef T value_type;
66 typedef ImmutableListFactory Factory;
65 using value_type = T;
66 using Factory = ImmutableListFactory;
6767
6868 private:
6969 const ImmutableListImpl* X;
140140
141141 template
142142 class ImmutableListFactory {
143 typedef ImmutableListImpl ListTy;
144 typedef FoldingSet CacheTy;
143 using ListTy = ImmutableListImpl;
144 using CacheTy = FoldingSet;
145145
146146 CacheTy Cache;
147147 uintptr_t Allocator;
2525 /// only the first element (the key) is used by isEqual and isLess.
2626 template
2727 struct ImutKeyValueInfo {
28 typedef const std::pair value_type;
29 typedef const value_type& value_type_ref;
30 typedef const T key_type;
31 typedef const T& key_type_ref;
32 typedef const S data_type;
33 typedef const S& data_type_ref;
28 using value_type = const std::pair;
29 using value_type_ref = const value_type&;
30 using key_type = const T;
31 using key_type_ref = const T&;
32 using data_type = const S;
33 using data_type_ref = const S&;
3434
3535 static inline key_type_ref KeyOfValue(value_type_ref V) {
3636 return V.first;
6161 typename ValInfo = ImutKeyValueInfo>
6262 class ImmutableMap {
6363 public:
64 typedef typename ValInfo::value_type value_type;
65 typedef typename ValInfo::value_type_ref value_type_ref;
66 typedef typename ValInfo::key_type key_type;
67 typedef typename ValInfo::key_type_ref key_type_ref;
68 typedef typename ValInfo::data_type data_type;
69 typedef typename ValInfo::data_type_ref data_type_ref;
70 typedef ImutAVLTree TreeTy;
64 using value_type = typename ValInfo::value_type;
65 using value_type_ref = typename ValInfo::value_type_ref;
66 using key_type = typename ValInfo::key_type;
67 using key_type_ref = typename ValInfo::key_type_ref;
68 using data_type = typename ValInfo::data_type;
69 using data_type_ref = typename ValInfo::data_type_ref;
70 using TreeTy = ImutAVLTree;
7171
7272 protected:
7373 TreeTy* Root;
8585 if (Root) { Root->retain(); }
8686 }
8787
88 ~ImmutableMap() {
89 if (Root) { Root->release(); }
90 }
91
8892 ImmutableMap &operator=(const ImmutableMap &X) {
8993 if (Root != X.Root) {
9094 if (X.Root) { X.Root->retain(); }
9498 return *this;
9599 }
96100
97 ~ImmutableMap() {
98 if (Root) { Root->release(); }
99 }
100
101101 class Factory {
102102 typename TreeTy::Factory F;
103103 const bool Canonicalize;
165165 template
166166 struct CBWrapper {
167167 Callback C;
168
168169 void operator()(value_type_ref V) { C(V.first,V.second); }
169170 };
170171
171172 template
172173 struct CBWrapperRef {
173174 Callback &C;
175
174176 CBWrapperRef(Callback& c) : C(c) {}
175177
176178 void operator()(value_type_ref V) { C(V.first,V.second); }
253255 typename ValInfo = ImutKeyValueInfo>
254256 class ImmutableMapRef {
255257 public:
256 typedef typename ValInfo::value_type value_type;
257 typedef typename ValInfo::value_type_ref value_type_ref;
258 typedef typename ValInfo::key_type key_type;
259 typedef typename ValInfo::key_type_ref key_type_ref;
260 typedef typename ValInfo::data_type data_type;
261 typedef typename ValInfo::data_type_ref data_type_ref;
262 typedef ImutAVLTree TreeTy;
263 typedef typename TreeTy::Factory FactoryTy;
258 using value_type = typename ValInfo::value_type;
259 using value_type_ref = typename ValInfo::value_type_ref;
260 using key_type = typename ValInfo::key_type;
261 using key_type_ref = typename ValInfo::key_type_ref;
262 using data_type = typename ValInfo::data_type;
263 using data_type_ref = typename ValInfo::data_type_ref;
264 using TreeTy = ImutAVLTree;
265 using FactoryTy = typename TreeTy::Factory;
264266
265267 protected:
266268 TreeTy *Root;
291293 }
292294 }
293295
296 ~ImmutableMapRef() {
297 if (Root)
298 Root->release();
299 }
300
294301 ImmutableMapRef &operator=(const ImmutableMapRef &X) {
295302 if (Root != X.Root) {
296303 if (X.Root)
303310 Factory = X.Factory;
304311 }
305312 return *this;
306 }
307
308 ~ImmutableMapRef() {
309 if (Root)
310 Root->release();
311313 }
312314
313315 static inline ImmutableMapRef getEmptyMap(FactoryTy *F) {
4040 template
4141 class ImutAVLTree {
4242 public:
43 typedef typename ImutInfo::key_type_ref key_type_ref;
44 typedef typename ImutInfo::value_type value_type;
45 typedef typename ImutInfo::value_type_ref value_type_ref;
46
47 typedef ImutAVLFactory Factory;
43 using key_type_ref = typename ImutInfo::key_type_ref;
44 using value_type = typename ImutInfo::value_type;
45 using value_type_ref = typename ImutInfo::value_type_ref;
46 using Factory = ImutAVLFactory;
47 using iterator = ImutAVLTreeInOrderIterator;
48
4849 friend class ImutAVLFactory;
4950 friend class ImutIntervalAVLFactory;
50
5151 friend class ImutAVLTreeGenericIterator;
52
53 typedef ImutAVLTreeInOrderIterator iterator;
5452
5553 //===----------------------------------------------------===//
5654 // Public Interface.
224222 Factory *factory;
225223 ImutAVLTree *left;
226224 ImutAVLTree *right;
227 ImutAVLTree *prev;
228 ImutAVLTree *next;
229
230 unsigned height : 28;
231 unsigned IsMutable : 1;
232 unsigned IsDigestCached : 1;
233 unsigned IsCanonicalized : 1;
225 ImutAVLTree *prev = nullptr;
226 ImutAVLTree *next = nullptr;
227
228 unsigned height : 28;
229 bool IsMutable : 1;
230 bool IsDigestCached : 1;
231 bool IsCanonicalized : 1;
234232
235233 value_type value;
236 uint32_t digest;
237 uint32_t refCount;
234 uint32_t digest = 0;
235 uint32_t refCount = 0;
238236
239237 //===----------------------------------------------------===//
240238 // Internal methods (node manipulation; used by Factory).
245243 /// ImutAVLFactory.
246244 ImutAVLTree(Factory *f, ImutAVLTree* l, ImutAVLTree* r, value_type_ref v,
247245 unsigned height)
248 : factory(f), left(l), right(r), prev(nullptr), next(nullptr),
249 height(height), IsMutable(true), IsDigestCached(false),
250 IsCanonicalized(0), value(v), digest(0), refCount(0)
246 : factory(f), left(l), right(r), height(height), IsMutable(true),
247 IsDigestCached(false), IsCanonicalized(false), value(v)
251248 {
252249 if (left) left->retain();
253250 if (right) right->retain();
368365 template
369366 class ImutAVLFactory {
370367 friend class ImutAVLTree;
371 typedef ImutAVLTree TreeTy;
372 typedef typename TreeTy::value_type_ref value_type_ref;
373 typedef typename TreeTy::key_type_ref key_type_ref;
374
375 typedef DenseMap CacheTy;
368
369 using TreeTy = ImutAVLTree;
370 using value_type_ref = typename TreeTy::value_type_ref;
371 using key_type_ref = typename TreeTy::key_type_ref;
372 using CacheTy = DenseMap;
376373
377374 CacheTy Cache;
378375 uintptr_t Allocator;
658655 enum VisitFlag { VisitedNone=0x0, VisitedLeft=0x1, VisitedRight=0x3,
659656 Flags=0x3 };
660657
661 typedef ImutAVLTree TreeTy;
658 using TreeTy = ImutAVLTree;
662659
663660 ImutAVLTreeGenericIterator() = default;
664661 ImutAVLTreeGenericIterator(const TreeTy *Root) {
763760 class ImutAVLTreeInOrderIterator
764761 : public std::iterator
765762 ImutAVLTree> {
766 typedef ImutAVLTreeGenericIterator InternalIteratorTy;
763 using InternalIteratorTy = ImutAVLTreeGenericIterator;
764
767765 InternalIteratorTy InternalItr;
768766
769767 public:
770 typedef ImutAVLTree TreeTy;
768 using TreeTy = ImutAVLTree;
771769
772770 ImutAVLTreeInOrderIterator(const TreeTy* Root) : InternalItr(Root) {
773771 if (Root)
839837 /// and generic handling of pointers is done below.
840838 template
841839 struct ImutProfileInfo {
842 typedef const T value_type;
843 typedef const T& value_type_ref;
840 using value_type = const T;
841 using value_type_ref = const T&;
844842
845843 static void Profile(FoldingSetNodeID &ID, value_type_ref X) {
846844 FoldingSetTrait::Profile(X,ID);
850848 /// Profile traits for integers.
851849 template
852850 struct ImutProfileInteger {
853 typedef const T value_type;
854 typedef const T& value_type_ref;
851 using value_type = const T;
852 using value_type_ref = const T&;
855853
856854 static void Profile(FoldingSetNodeID &ID, value_type_ref X) {
857855 ID.AddInteger(X);
877875 /// Profile traits for booleans.
878876 template <>
879877 struct ImutProfileInfo {
880 typedef const bool value_type;
881 typedef const bool& value_type_ref;
878 using value_type = const bool;
879 using value_type_ref = const bool&;
882880
883881 static void Profile(FoldingSetNodeID &ID, value_type_ref X) {
884882 ID.AddBoolean(X);
889887 /// references to unique objects.
890888 template
891889 struct ImutProfileInfo {
892 typedef const T* value_type;
893 typedef value_type value_type_ref;
890 using value_type = const T*;
891 using value_type_ref = value_type;
894892
895893 static void Profile(FoldingSetNodeID &ID, value_type_ref X) {
896894 ID.AddPointer(X);
909907 /// std::equal_to<> and std::less<> to perform comparison of elements.
910908 template
911909 struct ImutContainerInfo : public ImutProfileInfo {
912 typedef typename ImutProfileInfo::value_type value_type;
913 typedef typename ImutProfileInfo::value_type_ref value_type_ref;
914 typedef value_type key_type;
915 typedef value_type_ref key_type_ref;
916 typedef bool data_type;
917 typedef bool data_type_ref;
910 using value_type = typename ImutProfileInfo::value_type;
911 using value_type_ref = typename ImutProfileInfo::value_type_ref;
912 using key_type = value_type;
913 using key_type_ref = value_type_ref;
914 using data_type = bool;
915 using data_type_ref = bool;
918916
919917 static key_type_ref KeyOfValue(value_type_ref D) { return D; }
920918 static data_type_ref DataOfValue(value_type_ref) { return true; }
935933 /// their addresses.
936934 template
937935 struct ImutContainerInfo : public ImutProfileInfo {
938 typedef typename ImutProfileInfo::value_type value_type;
939 typedef typename ImutProfileInfo::value_type_ref value_type_ref;
940 typedef value_type key_type;
941 typedef value_type_ref key_type_ref;
942 typedef bool data_type;
943 typedef bool data_type_ref;
936 using value_type = typename ImutProfileInfo::value_type;
937 using value_type_ref = typename ImutProfileInfo::value_type_ref;
938 using key_type = value_type;
939 using key_type_ref = value_type_ref;
940 using data_type = bool;
941 using data_type_ref = bool;
944942
945943 static key_type_ref KeyOfValue(value_type_ref D) { return D; }
946944 static data_type_ref DataOfValue(value_type_ref) { return true; }
959957 template >
960958 class ImmutableSet {
961959 public:
962 typedef typename ValInfo::value_type value_type;
963 typedef typename ValInfo::value_type_ref value_type_ref;
964 typedef ImutAVLTree TreeTy;
960 using value_type = typename ValInfo::value_type;
961 using value_type_ref = typename ValInfo::value_type_ref;
962 using TreeTy = ImutAVLTree;
965963
966964 private:
967965 TreeTy *Root;
979977 if (Root) { Root->retain(); }
980978 }
981979
980 ~ImmutableSet() {
981 if (Root) { Root->release(); }
982 }
983
982984 ImmutableSet &operator=(const ImmutableSet &X) {
983985 if (Root != X.Root) {
984986 if (X.Root) { X.Root->retain(); }
986988 Root = X.Root;
987989 }
988990 return *this;
989 }
990
991 ~ImmutableSet() {
992 if (Root) { Root->release(); }
993991 }
994992
995993 class Factory {
10831081 // Iterators.
10841082 //===--------------------------------------------------===//
10851083
1086 typedef ImutAVLValueIterator iterator;
1084 using iterator = ImutAVLValueIterator;
10871085
10881086 iterator begin() const { return iterator(Root); }
10891087 iterator end() const { return iterator(); }
11111109 template >
11121110 class ImmutableSetRef {
11131111 public:
1114 typedef typename ValInfo::value_type value_type;
1115 typedef typename ValInfo::value_type_ref value_type_ref;
1116 typedef ImutAVLTree TreeTy;
1117 typedef typename TreeTy::Factory FactoryTy;
1112 using value_type = typename ValInfo::value_type;
1113 using value_type_ref = typename ValInfo::value_type_ref;
1114 using TreeTy = ImutAVLTree;
1115 using FactoryTy = typename TreeTy::Factory;
11181116
11191117 private:
11201118 TreeTy *Root;
11371135 if (Root) { Root->retain(); }
11381136 }
11391137
1138 ~ImmutableSetRef() {
1139 if (Root) { Root->release(); }
1140 }
1141
11401142 ImmutableSetRef &operator=(const ImmutableSetRef &X) {
11411143 if (Root != X.Root) {
11421144 if (X.Root) { X.Root->retain(); }
11461148 }
11471149 return *this;
11481150 }
1149 ~ImmutableSetRef() {
1150 if (Root) { Root->release(); }
1151 }
11521151
11531152 static ImmutableSetRef getEmptySet(FactoryTy *F) {
11541153 return ImmutableSetRef(0, F);
11951194 // Iterators.
11961195 //===--------------------------------------------------===//
11971196
1198 typedef ImutAVLValueIterator iterator;
1197 using iterator = ImutAVLValueIterator;
11991198
12001199 iterator begin() const { return iterator(Root); }
12011200 iterator end() const { return iterator(); }
1919 #ifndef LLVM_ADT_INDEXEDMAP_H
2020 #define LLVM_ADT_INDEXEDMAP_H
2121
22 #include "llvm/ADT/SmallVector.h"
2223 #include "llvm/ADT/STLExtras.h"
23 #include "llvm/ADT/SmallVector.h"
2424 #include
25 #include
2625
2726 namespace llvm {
2827
29 template llvm::identity >
28 template identity>
3029 class IndexedMap {
31 typedef typename ToIndexT::argument_type IndexT;
30 using IndexT = typename ToIndexT::argument_type;
3231 // Prefer SmallVector with zero inline storage over std::vector. IndexedMaps
3332 // can grow very large and SmallVector grows more efficiently as long as T
3433 // is trivially copyable.
35 typedef SmallVector StorageT;
34 using StorageT = SmallVector;
35
3636 StorageT storage_;
3737 T nullVal_;
3838 ToIndexT toIndex_;
3939
4040 public:
41 IndexedMap() : nullVal_(T()) { }
41 IndexedMap() : nullVal_(T()) {}
4242
43 explicit IndexedMap(const T& val) : nullVal_(val) { }
43 explicit IndexedMap(const T& val) : nullVal_(val) {}
4444
4545 typename StorageT::reference operator[](IndexT n) {
4646 assert(toIndex_(n) < storage_.size() && "index out of bounds!");
7979 }
8080 };
8181
82 } // End llvm namespace
82 } // end namespace llvm
8383
84 #endif
84 #endif // LLVM_ADT_INDEXEDMAP_H
105105 #include "llvm/Support/RecyclingAllocator.h"
106106 #include
107107 #include
108 #include
108109 #include
109110 #include
110111 #include
185186 /// It should be considered private to the implementation.
186187 namespace IntervalMapImpl {
187188
188 typedef std::pair IdxPair;
189 using IdxPair = std::pair;
189190
190191 //===----------------------------------------------------------------------===//
191192 //--- IntervalMapImpl::NodeBase ---//
444445 LeafSize = DesiredLeafSize > MinLeafSize ? DesiredLeafSize : MinLeafSize
445446 };
446447
447 typedef NodeBase, ValT, LeafSize> LeafBase;
448 using LeafBase = NodeBase, ValT, LeafSize>;
448449
449450 enum {
450451 // Now that we have the leaf branching factor, compute the actual allocation
460461 /// This typedef is very likely to be identical for all IntervalMaps with
461462 /// reasonably sized entries, so the same allocator can be shared among
462463 /// different kinds of maps.
463 typedef RecyclingAllocator
464 AllocBytes, CacheLineBytes> Allocator;
464 using Allocator =
465 RecyclingAllocator;
465466 };
466467
467468 //===----------------------------------------------------------------------===//
929930 unsigned N = IntervalMapImpl::NodeSizer::LeafSize,
930931 typename Traits = IntervalMapInfo>
931932 class IntervalMap {
932 typedef IntervalMapImpl::NodeSizer Sizer;
933 typedef IntervalMapImpl::LeafNode Leaf;
934 typedef IntervalMapImpl::BranchNode
935 Branch;
936 typedef IntervalMapImpl::LeafNode RootLeaf;
937 typedef IntervalMapImpl::IdxPair IdxPair;
933 using Sizer = IntervalMapImpl::NodeSizer;
934 using Leaf = IntervalMapImpl::LeafNode;
935 using Branch =
936 IntervalMapImpl::BranchNode;
937 using RootLeaf = IntervalMapImpl::LeafNode;
938 using IdxPair = IntervalMapImpl::IdxPair;
938939
939940 // The RootLeaf capacity is given as a template parameter. We must compute the
940941 // corresponding RootBranch capacity.
944945 RootBranchCap = DesiredRootBranchCap ? DesiredRootBranchCap : 1
945946 };
946947
947 typedef IntervalMapImpl::BranchNode
948 RootBranch;
948 using RootBranch =
949 IntervalMapImpl::BranchNode;
949950
950951 // When branched, we store a global start key as well as the branch node.
951952 struct RootBranchData {
954955 };
955956
956957 public:
957 typedef typename Sizer::Allocator Allocator;
958 typedef KeyT KeyType;
959 typedef ValT ValueType;
960 typedef Traits KeyTraits;
958 using Allocator = typename Sizer::Allocator;
959 using KeyType = KeyT;
960 using ValueType = ValT;
961 using KeyTraits = Traits;
961962
962963 private:
963964 // The root data is either a RootLeaf or a RootBranchData instance.
12891290 friend class IntervalMap;
12901291
12911292 // The map referred to.
1292 IntervalMap *map;
1293 IntervalMap *map = nullptr;
12931294
12941295 // We store a full path from the root to the current position.
12951296 // The path may be partially filled, but never between iterator calls.
13371338
13381339 public:
13391340 /// const_iterator - Create an iterator that isn't pointing anywhere.
1340 const_iterator() : map(nullptr) {}
1341 const_iterator() = default;
13411342
13421343 /// setMap - Change the map iterated over. This call must be followed by a
13431344 /// call to goToBegin(), goToEnd(), or find()
15081509 template
15091510 class IntervalMap::iterator : public const_iterator {
15101511 friend class IntervalMap;
1511 typedef IntervalMapImpl::IdxPair IdxPair;
1512
1513 using IdxPair = IntervalMapImpl::IdxPair;
15121514
15131515 explicit iterator(IntervalMap &map) : const_iterator(map) {}
15141516
20022004 // Elements have been rearranged, now update node sizes and stops.
20032005 bool SplitRoot = false;
20042006 unsigned Pos = 0;
2005 for (;;) {
2007 while (true) {
20062008 KeyT Stop = Node[Pos]->stop(NewSize[Pos]-1);
20072009 if (NewNode && Pos == NewNode) {
20082010 SplitRoot = insertNode(Level, NodeRef(Node[Pos], NewSize[Pos]), Stop);
20442046 ///
20452047 template
20462048 class IntervalMapOverlaps {
2047 typedef typename MapA::KeyType KeyType;
2048 typedef typename MapA::KeyTraits Traits;
2049 using KeyType = typename MapA::KeyType;
2050 using Traits = typename MapA::KeyTraits;
2051
20492052 typename MapA::const_iterator posA;
20502053 typename MapB::const_iterator posB;
20512054
20702073 // Already overlapping.
20712074 return;
20722075
2073 for (;;) {
2076 while (true) {
20742077 // Make a.end > b.start.
20752078 posA.advanceTo(posB.start());
20762079 if (!posA.valid() || !Traits::stopLess(posB.stop(), posA.start()))
None //== llvm/ADT/IntrusiveRefCntPtr.h - Smart Refcounting Pointer ---*- C++ -*-==//
0 //==- llvm/ADT/IntrusiveRefCntPtr.h - Smart Refcounting Pointer --*- C++ -*-==//
11 //
22 // The LLVM Compiler Infrastructure
33 //
7272
7373 public:
7474 RefCountedBase() = default;
75 RefCountedBase(const RefCountedBase &) : RefCount(0) {}
75 RefCountedBase(const RefCountedBase &) {}
7676
7777 void Retain() const { ++RefCount; }
78
7879 void Release() const {
7980 assert(RefCount > 0 && "Reference count is already zero.");
8081 if (--RefCount == 0)
135136 T *Obj = nullptr;
136137
137138 public:
138 typedef T element_type;
139 using element_type = T;
139140
140141 explicit IntrusiveRefCntPtr() = default;
141142 IntrusiveRefCntPtr(T *obj) : Obj(obj) { retain(); }
152153 retain();
153154 }
154155
156 ~IntrusiveRefCntPtr() { release(); }
157
155158 IntrusiveRefCntPtr &operator=(IntrusiveRefCntPtr S) {
156159 swap(S);
157160 return *this;
158161 }
159
160 ~IntrusiveRefCntPtr() { release(); }
161162
162163 T &operator*() const { return *Obj; }
163164 T *operator->() const { return Obj; }
182183 if (Obj)
183184 IntrusiveRefCntPtrInfo::retain(Obj);
184185 }
186
185187 void release() {
186188 if (Obj)
187189 IntrusiveRefCntPtrInfo::release(Obj);
247249 template struct simplify_type;
248250
249251 template struct simplify_type> {
250 typedef T *SimpleType;
252 using SimpleType = T *;
253
251254 static SimpleType getSimplifiedValue(IntrusiveRefCntPtr &Val) {
252255 return Val.get();
253256 }
254257 };
255258
256259 template struct simplify_type> {
257 typedef /*const*/ T *SimpleType;
260 using SimpleType = /*const*/ T *;
261
258262 static SimpleType getSimplifiedValue(const IntrusiveRefCntPtr &Val) {
259263 return Val.get();
260264 }
1818
1919 #include "llvm/ADT/DenseMap.h"
2020 #include "llvm/ADT/SmallVector.h"
21 #include
22 #include
23 #include
24 #include
25 #include
26 #include
2127 #include
2228
2329 namespace llvm {
2632 /// in a deterministic order. The values are kept in a std::vector and the
2733 /// mapping is done with DenseMap from Keys to indexes in that vector.
2834 template
29 typename MapType = llvm::DenseMap,
30 typename VectorType = std::vector > >
35 typename MapType = DenseMap,
36 typename VectorType = std::vector>>
3137 class MapVector {
32 typedef typename VectorType::value_type value_type;
33 typedef typename VectorType::size_type size_type;
38 using value_type = typename VectorType::value_type;
39 using size_type = typename VectorType::size_type;
3440
3541 MapType Map;
3642 VectorType Vector;
3743
3844 public:
39 typedef typename VectorType::iterator iterator;
40 typedef typename VectorType::const_iterator const_iterator;
41 typedef typename VectorType::reverse_iterator reverse_iterator;
42 typedef typename VectorType::const_reverse_iterator const_reverse_iterator;
45 using iterator = typename VectorType::iterator;
46 using const_iterator = typename VectorType::const_iterator;
47 using reverse_iterator = typename VectorType::reverse_iterator;
48 using const_reverse_iterator = typename VectorType::const_reverse_iterator;
4349
4450 /// Clear the MapVector and return the underlying vector.
4551 VectorType takeVector() {
219225
220226 } // end namespace llvm
221227
222 #endif
228 #endif // LLVM_ADT_MAPVECTOR_H
None //===-- Optional.h - Simple variant for passing optional values ---*- C++ -*-=//
0 //===- Optional.h - Simple variant for passing optional values --*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
1818 #include "llvm/ADT/None.h"
1919 #include "llvm/Support/AlignOf.h"
2020 #include "llvm/Support/Compiler.h"
21 #include "llvm/Support/type_traits.h"
22 #include
2123 #include
2224 #include
2325 #include
2729 template
2830 class Optional {
2931 AlignedCharArrayUnion storage;
30 bool hasVal;
32 bool hasVal = false;
33
3134 public:
32 typedef T value_type;
33
34 Optional(NoneType) : hasVal(false) {}
35 explicit Optional() : hasVal(false) {}
35 using value_type = T;
36
37 Optional(NoneType) {}
38 explicit Optional() {}
39
3640 Optional(const T &y) : hasVal(true) {
3741 new (storage.buffer) T(y);
3842 }
43
3944 Optional(const Optional &O) : hasVal(O.hasVal) {
4045 if (hasVal)
4146 new (storage.buffer) T(*O);
4449 Optional(T &&y) : hasVal(true) {
4550 new (storage.buffer) T(std::forward(y));
4651 }
52
4753 Optional(Optional &&O) : hasVal(O) {
4854 if (O) {
4955 new (storage.buffer) T(std::move(*O));
5056 O.reset();
5157 }
5258 }
59
60 ~Optional() {
61 reset();
62 }
63
5364 Optional &operator=(T &&y) {
5465 if (hasVal)
5566 **this = std::move(y);
5970 }
6071 return *this;
6172 }
73
6274 Optional &operator=(Optional &&O) {
6375 if (!O)
6476 reset();
111123 }
112124 }
113125
114 ~Optional() {
115 reset();
116 }
117
118126 const T* getPointer() const { assert(hasVal); return reinterpret_cast(storage.buffer); }
119127 T* getPointer() { assert(hasVal); return reinterpret_cast(storage.buffer); }
120128 const T& getValue() const LLVM_LVALUE_FUNCTION { assert(hasVal); return *getPointer(); }
143151 #endif
144152 };
145153
146 template struct isPodLike;
147 template struct isPodLike > {
154 template struct isPodLike> {
148155 // An Optional is pod-like if T is.
149156 static const bool value = isPodLike::value;
150157 };
283290 return !(X < Y);
284291 }
285292
286 } // end llvm namespace
287
288 #endif
293 } // end namespace llvm
294
295 #endif // LLVM_ADT_OPTIONAL_H
7575 class PackedVector : public PackedVectorBase
7676 std::numeric_limits::is_signed> {
7777 BitVectorTy Bits;
78 typedef PackedVectorBase
79 std::numeric_limits::is_signed> base;
78 using base = PackedVectorBase
79 std::numeric_limits::is_signed>;
8080
8181 public:
8282 class reference {
9898 };
9999
100100 PackedVector() = default;
101 explicit PackedVector(unsigned size) : Bits(size << (BitNum-1)) { }
101 explicit PackedVector(unsigned size) : Bits(size << (BitNum-1)) {}
102102
103103 bool empty() const { return Bits.empty(); }
104104
1212 #include "llvm/ADT/DenseMapInfo.h"
1313 #include "llvm/Support/MathExtras.h"
1414 #include "llvm/Support/PointerLikeTypeTraits.h"
15 #include
1516 #include
17 #include
18 #include
1619
1720 namespace llvm {
1821
2831 /// Also, the default constructed value zero initializes the integer.
2932 template
3033 class PointerEmbeddedInt {
31 uintptr_t Value;
34 uintptr_t Value = 0;
3235
3336 // Note: This '<' is correct; using '<=' would result in some shifts
3437 // overflowing their storage types.
5356 explicit PointerEmbeddedInt(uintptr_t Value, RawValueTag) : Value(Value) {}
5457
5558 public:
56 PointerEmbeddedInt() : Value(0) {}
59 PointerEmbeddedInt() = default;
5760
58 PointerEmbeddedInt(IntT I) {
59 *this = I;
60 }
61 PointerEmbeddedInt(IntT I) { *this = I; }
6162
6263 PointerEmbeddedInt &operator=(IntT I) {
63 assert((std::is_signed::value ? llvm::isInt(I)
64 : llvm::isUInt(I)) &&
64 assert((std::is_signed::value ? isInt(I) : isUInt(I)) &&
6565 "Integer has bits outside those preserved!");
6666 Value = static_cast(I) << Shift;
6767 return *this;
8080 // types.
8181 template
8282 class PointerLikeTypeTraits> {
83 typedef PointerEmbeddedInt T;
83 using T = PointerEmbeddedInt;
8484
8585 public:
8686 static inline void *getAsVoidPointer(const T &P) {
8787 return reinterpret_cast(P.Value);
8888 }
89
8990 static inline T getFromVoidPointer(void *P) {
9091 return T(reinterpret_cast(P), typename T::RawValueTag());
9192 }
93
9294 static inline T getFromVoidPointer(const void *P) {
9395 return T(reinterpret_cast(P), typename T::RawValueTag());
9496 }
100102 // itself can be a key.
101103 template
102104 struct DenseMapInfo> {
103 typedef PointerEmbeddedInt T;
104
105 typedef DenseMapInfo IntInfo;
105 using T = PointerEmbeddedInt;
106 using IntInfo = DenseMapInfo;
106107
107108 static inline T getEmptyKey() { return IntInfo::getEmptyKey(); }
108109 static inline T getTombstoneKey() { return IntInfo::getTombstoneKey(); }
110
109111 static unsigned getHashValue(const T &Arg) {
110112 return IntInfo::getHashValue(Arg);
111113 }
114
112115 static bool isEqual(const T &LHS, const T &RHS) { return LHS == RHS; }
113116 };
114 }
115117
116 #endif
118 } // end namespace llvm
119
120 #endif // LLVM_ADT_POINTEREMBEDDEDINT_H
1212 #include "llvm/ADT/ilist_base.h"
1313 #include "llvm/ADT/ilist_iterator.h"
1414 #include "llvm/ADT/ilist_node.h"
15 #include "llvm/ADT/ilist_node_options.h"
16 #include "llvm/Support/Compiler.h"
1517 #include
1618 #include
1719 #include
20 #include
21 #include
22 #include
1823
1924 namespace llvm {
2025
7681 typename ilist_detail::compute_node_options::type> {
7782 static_assert(ilist_detail::check_options::value,
7883 "Unrecognized node option!");
79 typedef
80 typename ilist_detail::compute_node_options::type OptionsT;
81 typedef typename OptionsT::list_base_type list_base_type;
84 using OptionsT =
85 typename ilist_detail::compute_node_options::type;
86 using list_base_type = typename OptionsT::list_base_type;
8287 ilist_sentinel Sentinel;
8388
8489 public:
85 typedef typename OptionsT::value_type value_type;
86 typedef typename OptionsT::pointer pointer;
87 typedef typename OptionsT::reference reference;
88 typedef typename OptionsT::const_pointer const_pointer;
89 typedef typename OptionsT::const_reference const_reference;
90 typedef ilist_iterator iterator;
91 typedef ilist_iterator const_iterator;
92 typedef ilist_iterator reverse_iterator;
93 typedef ilist_iterator const_reverse_iterator;
94 typedef size_t size_type;
95 typedef ptrdiff_t difference_type;
90 using value_type = typename OptionsT::value_type;
91 using pointer = typename OptionsT::pointer;
92 using reference = typename OptionsT::reference;
93 using const_pointer = typename OptionsT::const_pointer;
94 using const_reference = typename OptionsT::const_reference;
95 using iterator = ilist_iterator;
96 using const_iterator = ilist_iterator;
97 using reverse_iterator = ilist_iterator;
98 using const_reverse_iterator = ilist_iterator;
99 using size_type = size_t;
100 using difference_type = ptrdiff_t;
96101
97102 simple_ilist() = default;
98103 ~simple_ilist() = default;