llvm.org GIT mirror llvm / 586584b
Revert "[ADT] Fix some Clang-tidy modernize-use-using warnings; other minor fixes (NFC)." This reverts commit r303383. This breaks the modules-enabled macOS build with: lib/Support/LockFileManager.cpp:86:7: error: declaration of 'gethostuuid' must be imported from module 'Darwin.POSIX.unistd' before it is required git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303402 91177308-0d34-0410-b5e6-96231b3b80d8 Adam Nemet 3 years ago
14 changed file(s) with 260 addition(s) and 312 deletion(s). Raw diff Collapse all Expand all
6262 template
6363 class ImmutableList {
6464 public:
65 using value_type = T;
66 using Factory = ImmutableListFactory;
65 typedef T value_type;
66 typedef ImmutableListFactory Factory;
6767
6868 private:
6969 const ImmutableListImpl* X;
140140
141141 template
142142 class ImmutableListFactory {
143 using ListTy = ImmutableListImpl;
144 using CacheTy = FoldingSet;
143 typedef ImmutableListImpl ListTy;
144 typedef FoldingSet CacheTy;
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 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&;
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;
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 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;
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;
7171
7272 protected:
7373 TreeTy* Root;
8585 if (Root) { Root->retain(); }
8686 }
8787
88 ~ImmutableMap() {
89 if (Root) { Root->release(); }
90 }
91
9288 ImmutableMap &operator=(const ImmutableMap &X) {
9389 if (Root != X.Root) {
9490 if (X.Root) { X.Root->retain(); }
9894 return *this;
9995 }
10096
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
169168 void operator()(value_type_ref V) { C(V.first,V.second); }
170169 };
171170
172171 template
173172 struct CBWrapperRef {
174173 Callback &C;
175
176174 CBWrapperRef(Callback& c) : C(c) {}
177175
178176 void operator()(value_type_ref V) { C(V.first,V.second); }
255253 typename ValInfo = ImutKeyValueInfo>
256254 class ImmutableMapRef {
257255 public:
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;
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;
266264
267265 protected:
268266 TreeTy *Root;
293291 }
294292 }
295293
296 ~ImmutableMapRef() {
297 if (Root)
298 Root->release();
299 }
300
301294 ImmutableMapRef &operator=(const ImmutableMapRef &X) {
302295 if (Root != X.Root) {
303296 if (X.Root)
310303 Factory = X.Factory;
311304 }
312305 return *this;
306 }
307
308 ~ImmutableMapRef() {
309 if (Root)
310 Root->release();
313311 }
314312
315313 static inline ImmutableMapRef getEmptyMap(FactoryTy *F) {
4040 template
4141 class ImutAVLTree {
4242 public:
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
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;
4948 friend class ImutAVLFactory;
5049 friend class ImutIntervalAVLFactory;
50
5151 friend class ImutAVLTreeGenericIterator;
52
53 typedef ImutAVLTreeInOrderIterator iterator;
5254
5355 //===----------------------------------------------------===//
5456 // Public Interface.
222224 Factory *factory;
223225 ImutAVLTree *left;
224226 ImutAVLTree *right;
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;
227 ImutAVLTree *prev;
228 ImutAVLTree *next;
229
230 unsigned height : 28;
231 unsigned IsMutable : 1;
232 unsigned IsDigestCached : 1;
233 unsigned IsCanonicalized : 1;
232234
233235 value_type value;
234 uint32_t digest = 0;
235 uint32_t refCount = 0;
236 uint32_t digest;
237 uint32_t refCount;
236238
237239 //===----------------------------------------------------===//
238240 // Internal methods (node manipulation; used by Factory).
243245 /// ImutAVLFactory.
244246 ImutAVLTree(Factory *f, ImutAVLTree* l, ImutAVLTree* r, value_type_ref v,
245247 unsigned height)
246 : factory(f), left(l), right(r), height(height), IsMutable(true),
247 IsDigestCached(false), IsCanonicalized(false), value(v)
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)
248251 {
249252 if (left) left->retain();
250253 if (right) right->retain();
365368 template
366369 class ImutAVLFactory {
367370 friend class ImutAVLTree;
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;
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;
373376
374377 CacheTy Cache;
375378 uintptr_t Allocator;
655658 enum VisitFlag { VisitedNone=0x0, VisitedLeft=0x1, VisitedRight=0x3,
656659 Flags=0x3 };
657660
658 using TreeTy = ImutAVLTree;
661 typedef ImutAVLTree TreeTy;
659662
660663 ImutAVLTreeGenericIterator() = default;
661664 ImutAVLTreeGenericIterator(const TreeTy *Root) {
760763 class ImutAVLTreeInOrderIterator
761764 : public std::iterator
762765 ImutAVLTree> {
763 using InternalIteratorTy = ImutAVLTreeGenericIterator;
764
766 typedef ImutAVLTreeGenericIterator InternalIteratorTy;
765767 InternalIteratorTy InternalItr;
766768
767769 public:
768 using TreeTy = ImutAVLTree;
770 typedef ImutAVLTree TreeTy;
769771
770772 ImutAVLTreeInOrderIterator(const TreeTy* Root) : InternalItr(Root) {
771773 if (Root)
837839 /// and generic handling of pointers is done below.
838840 template
839841 struct ImutProfileInfo {
840 using value_type = const T;
841 using value_type_ref = const T&;
842 typedef const T value_type;
843 typedef const T& value_type_ref;
842844
843845 static void Profile(FoldingSetNodeID &ID, value_type_ref X) {
844846 FoldingSetTrait::Profile(X,ID);
848850 /// Profile traits for integers.
849851 template
850852 struct ImutProfileInteger {
851 using value_type = const T;
852 using value_type_ref = const T&;
853 typedef const T value_type;
854 typedef const T& value_type_ref;
853855
854856 static void Profile(FoldingSetNodeID &ID, value_type_ref X) {
855857 ID.AddInteger(X);
875877 /// Profile traits for booleans.
876878 template <>
877879 struct ImutProfileInfo {
878 using value_type = const bool;
879 using value_type_ref = const bool&;
880 typedef const bool value_type;
881 typedef const bool& value_type_ref;
880882
881883 static void Profile(FoldingSetNodeID &ID, value_type_ref X) {
882884 ID.AddBoolean(X);
887889 /// references to unique objects.
888890 template
889891 struct ImutProfileInfo {
890 using value_type = const T*;
891 using value_type_ref = value_type;
892 typedef const T* value_type;
893 typedef value_type value_type_ref;
892894
893895 static void Profile(FoldingSetNodeID &ID, value_type_ref X) {
894896 ID.AddPointer(X);
907909 /// std::equal_to<> and std::less<> to perform comparison of elements.
908910 template
909911 struct ImutContainerInfo : public ImutProfileInfo {
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;
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;
916918
917919 static key_type_ref KeyOfValue(value_type_ref D) { return D; }
918920 static data_type_ref DataOfValue(value_type_ref) { return true; }
933935 /// their addresses.
934936 template
935937 struct ImutContainerInfo : public ImutProfileInfo {
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;
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;
942944
943945 static key_type_ref KeyOfValue(value_type_ref D) { return D; }
944946 static data_type_ref DataOfValue(value_type_ref) { return true; }
957959 template >
958960 class ImmutableSet {
959961 public:
960 using value_type = typename ValInfo::value_type;
961 using value_type_ref = typename ValInfo::value_type_ref;
962 using TreeTy = ImutAVLTree;
962 typedef typename ValInfo::value_type value_type;
963 typedef typename ValInfo::value_type_ref value_type_ref;
964 typedef ImutAVLTree TreeTy;
963965
964966 private:
965967 TreeTy *Root;
977979 if (Root) { Root->retain(); }
978980 }
979981
980 ~ImmutableSet() {
981 if (Root) { Root->release(); }
982 }
983
984982 ImmutableSet &operator=(const ImmutableSet &X) {
985983 if (Root != X.Root) {
986984 if (X.Root) { X.Root->retain(); }
988986 Root = X.Root;
989987 }
990988 return *this;
989 }
990
991 ~ImmutableSet() {
992 if (Root) { Root->release(); }
991993 }
992994
993995 class Factory {
10811083 // Iterators.
10821084 //===--------------------------------------------------===//
10831085
1084 using iterator = ImutAVLValueIterator;
1086 typedef ImutAVLValueIterator iterator;
10851087
10861088 iterator begin() const { return iterator(Root); }
10871089 iterator end() const { return iterator(); }
11091111 template >
11101112 class ImmutableSetRef {
11111113 public:
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;
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;
11161118
11171119 private:
11181120 TreeTy *Root;
11351137 if (Root) { Root->retain(); }
11361138 }
11371139
1138 ~ImmutableSetRef() {
1139 if (Root) { Root->release(); }
1140 }
1141
11421140 ImmutableSetRef &operator=(const ImmutableSetRef &X) {
11431141 if (Root != X.Root) {
11441142 if (X.Root) { X.Root->retain(); }
11481146 }
11491147 return *this;
11501148 }
1149 ~ImmutableSetRef() {
1150 if (Root) { Root->release(); }
1151 }
11511152
11521153 static ImmutableSetRef getEmptySet(FactoryTy *F) {
11531154 return ImmutableSetRef(0, F);
11941195 // Iterators.
11951196 //===--------------------------------------------------===//
11961197
1197 using iterator = ImutAVLValueIterator;
1198 typedef ImutAVLValueIterator iterator;
11981199
11991200 iterator begin() const { return iterator(Root); }
12001201 iterator end() const { return iterator(); }
2222 #include "llvm/ADT/STLExtras.h"
2323 #include "llvm/ADT/SmallVector.h"
2424 #include
25 #include
2526
2627 namespace llvm {
2728
28 template identity>
29 template llvm::identity >
2930 class IndexedMap {
30 using IndexT = typename ToIndexT::argument_type;
31 typedef typename ToIndexT::argument_type IndexT;
3132 // Prefer SmallVector with zero inline storage over std::vector. IndexedMaps
3233 // can grow very large and SmallVector grows more efficiently as long as T
3334 // is trivially copyable.
34 using StorageT = SmallVector;
35
35 typedef SmallVector StorageT;
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 namespace llvm
82 } // End llvm namespace
8383
84 #endif // LLVM_ADT_INDEXEDMAP_H
84 #endif
105105 #include "llvm/Support/RecyclingAllocator.h"
106106 #include
107107 #include
108 #include
109108 #include
110109 #include
111110 #include
186185 /// It should be considered private to the implementation.
187186 namespace IntervalMapImpl {
188187
189 using IdxPair = std::pair;
188 typedef std::pair IdxPair;
190189
191190 //===----------------------------------------------------------------------===//
192191 //--- IntervalMapImpl::NodeBase ---//
445444 LeafSize = DesiredLeafSize > MinLeafSize ? DesiredLeafSize : MinLeafSize
446445 };
447446
448 using LeafBase = NodeBase, ValT, LeafSize>;
447 typedef NodeBase, ValT, LeafSize> LeafBase;
449448
450449 enum {
451450 // Now that we have the leaf branching factor, compute the actual allocation
461460 /// This typedef is very likely to be identical for all IntervalMaps with
462461 /// reasonably sized entries, so the same allocator can be shared among
463462 /// different kinds of maps.
464 using Allocator =
465 RecyclingAllocator;
463 typedef RecyclingAllocator
464 AllocBytes, CacheLineBytes> Allocator;
466465 };
467466
468467 //===----------------------------------------------------------------------===//
930929 unsigned N = IntervalMapImpl::NodeSizer::LeafSize,
931930 typename Traits = IntervalMapInfo>
932931 class IntervalMap {
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;
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;
939938
940939 // The RootLeaf capacity is given as a template parameter. We must compute the
941940 // corresponding RootBranch capacity.
945944 RootBranchCap = DesiredRootBranchCap ? DesiredRootBranchCap : 1
946945 };
947946
948 using RootBranch =
949 IntervalMapImpl::BranchNode;
947 typedef IntervalMapImpl::BranchNode
948 RootBranch;
950949
951950 // When branched, we store a global start key as well as the branch node.
952951 struct RootBranchData {
955954 };
956955
957956 public:
958 using Allocator = typename Sizer::Allocator;
959 using KeyType = KeyT;
960 using ValueType = ValT;
961 using KeyTraits = Traits;
957 typedef typename Sizer::Allocator Allocator;
958 typedef KeyT KeyType;
959 typedef ValT ValueType;
960 typedef Traits KeyTraits;
962961
963962 private:
964963 // The root data is either a RootLeaf or a RootBranchData instance.
12901289 friend class IntervalMap;
12911290
12921291 // The map referred to.
1293 IntervalMap *map = nullptr;
1292 IntervalMap *map;
12941293
12951294 // We store a full path from the root to the current position.
12961295 // The path may be partially filled, but never between iterator calls.
13381337
13391338 public:
13401339 /// const_iterator - Create an iterator that isn't pointing anywhere.
1341 const_iterator() = default;
1340 const_iterator() : map(nullptr) {}
13421341
13431342 /// setMap - Change the map iterated over. This call must be followed by a
13441343 /// call to goToBegin(), goToEnd(), or find()
15091508 template
15101509 class IntervalMap::iterator : public const_iterator {
15111510 friend class IntervalMap;
1512
1513 using IdxPair = IntervalMapImpl::IdxPair;
1511 typedef IntervalMapImpl::IdxPair IdxPair;
15141512
15151513 explicit iterator(IntervalMap &map) : const_iterator(map) {}
15161514
20042002 // Elements have been rearranged, now update node sizes and stops.
20052003 bool SplitRoot = false;
20062004 unsigned Pos = 0;
2007 while (true) {
2005 for (;;) {
20082006 KeyT Stop = Node[Pos]->stop(NewSize[Pos]-1);
20092007 if (NewNode && Pos == NewNode) {
20102008 SplitRoot = insertNode(Level, NodeRef(Node[Pos], NewSize[Pos]), Stop);
20462044 ///
20472045 template
20482046 class IntervalMapOverlaps {
2049 using KeyType = typename MapA::KeyType;
2050 using Traits = typename MapA::KeyTraits;
2051
2047 typedef typename MapA::KeyType KeyType;
2048 typedef typename MapA::KeyTraits Traits;
20522049 typename MapA::const_iterator posA;
20532050 typename MapB::const_iterator posB;
20542051
20732070 // Already overlapping.
20742071 return;
20752072
2076 while (true) {
2073 for (;;) {
20772074 // Make a.end > b.start.
20782075 posA.advanceTo(posB.start());
20792076 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 &) {}
75 RefCountedBase(const RefCountedBase &) : RefCount(0) {}
7676
7777 void Retain() const { ++RefCount; }
78
7978 void Release() const {
8079 assert(RefCount > 0 && "Reference count is already zero.");
8180 if (--RefCount == 0)
136135 T *Obj = nullptr;
137136
138137 public:
139 using element_type = T;
138 typedef T element_type;
140139
141140 explicit IntrusiveRefCntPtr() = default;
142141 IntrusiveRefCntPtr(T *obj) : Obj(obj) { retain(); }
153152 retain();
154153 }
155154
156 ~IntrusiveRefCntPtr() { release(); }
157
158155 IntrusiveRefCntPtr &operator=(IntrusiveRefCntPtr S) {
159156 swap(S);
160157 return *this;
161158 }
159
160 ~IntrusiveRefCntPtr() { release(); }
162161
163162 T &operator*() const { return *Obj; }
164163 T *operator->() const { return Obj; }
183182 if (Obj)
184183 IntrusiveRefCntPtrInfo::retain(Obj);
185184 }
186
187185 void release() {
188186 if (Obj)
189187 IntrusiveRefCntPtrInfo::release(Obj);
249247 template struct simplify_type;
250248
251249 template struct simplify_type> {
252 using SimpleType = T *;
253
250 typedef T *SimpleType;
254251 static SimpleType getSimplifiedValue(IntrusiveRefCntPtr &Val) {
255252 return Val.get();
256253 }
257254 };
258255
259256 template struct simplify_type> {
260 using SimpleType = /*const*/ T *;
261
257 typedef /*const*/ T *SimpleType;
262258 static SimpleType getSimplifiedValue(const IntrusiveRefCntPtr &Val) {
263259 return Val.get();
264260 }
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
2721 #include
2822
2923 namespace llvm {
3226 /// in a deterministic order. The values are kept in a std::vector and the
3327 /// mapping is done with DenseMap from Keys to indexes in that vector.
3428 template
35 typename MapType = DenseMap,
36 typename VectorType = std::vector>>
29 typename MapType = llvm::DenseMap,
30 typename VectorType = std::vector > >
3731 class MapVector {
38 using value_type = typename VectorType::value_type;
39 using size_type = typename VectorType::size_type;
32 typedef typename VectorType::value_type value_type;
33 typedef typename VectorType::size_type size_type;
4034
4135 MapType Map;
4236 VectorType Vector;
4337
4438 public:
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;
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;
4943
5044 /// Clear the MapVector and return the underlying vector.
5145 VectorType takeVector() {
225219
226220 } // end namespace llvm
227221
228 #endif // LLVM_ADT_MAPVECTOR_H
222 #endif
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
2321 #include
2422 #include
2523 #include
2927 template
3028 class Optional {
3129 AlignedCharArrayUnion storage;
32 bool hasVal = false;
33
30 bool hasVal;
3431 public:
35 using value_type = T;
36
37 Optional(NoneType) {}
38 explicit Optional() {}
39
32 typedef T value_type;
33
34 Optional(NoneType) : hasVal(false) {}
35 explicit Optional() : hasVal(false) {}
4036 Optional(const T &y) : hasVal(true) {
4137 new (storage.buffer) T(y);
4238 }
43
4439 Optional(const Optional &O) : hasVal(O.hasVal) {
4540 if (hasVal)
4641 new (storage.buffer) T(*O);
4944 Optional(T &&y) : hasVal(true) {
5045 new (storage.buffer) T(std::forward(y));
5146 }
52
5347 Optional(Optional &&O) : hasVal(O) {
5448 if (O) {
5549 new (storage.buffer) T(std::move(*O));
5650 O.reset();
5751 }
5852 }
59
60 ~Optional() {
61 reset();
62 }
63
6453 Optional &operator=(T &&y) {
6554 if (hasVal)
6655 **this = std::move(y);
7059 }
7160 return *this;
7261 }
73
7462 Optional &operator=(Optional &&O) {
7563 if (!O)
7664 reset();
123111 }
124112 }
125113
114 ~Optional() {
115 reset();
116 }
117
126118 const T* getPointer() const { assert(hasVal); return reinterpret_cast(storage.buffer); }
127119 T* getPointer() { assert(hasVal); return reinterpret_cast(storage.buffer); }
128120 const T& getValue() const LLVM_LVALUE_FUNCTION { assert(hasVal); return *getPointer(); }
151143 #endif
152144 };
153145
154 template struct isPodLike> {
146 template struct isPodLike;
147 template struct isPodLike > {
155148 // An Optional is pod-like if T is.
156149 static const bool value = isPodLike::value;
157150 };
290283 return !(X < Y);
291284 }
292285
293 } // end namespace llvm
294
295 #endif // LLVM_ADT_OPTIONAL_H
286 } // end llvm namespace
287
288 #endif
7575 class PackedVector : public PackedVectorBase
7676 std::numeric_limits::is_signed> {
7777 BitVectorTy Bits;
78 using base = PackedVectorBase
79 std::numeric_limits::is_signed>;
78 typedef PackedVectorBase
79 std::numeric_limits::is_signed> base;
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
1615 #include
17 #include
18 #include
1916
2017 namespace llvm {
2118
3128 /// Also, the default constructed value zero initializes the integer.
3229 template
3330 class PointerEmbeddedInt {
34 uintptr_t Value = 0;
31 uintptr_t Value;
3532
3633 // Note: This '<' is correct; using '<=' would result in some shifts
3734 // overflowing their storage types.
5653 explicit PointerEmbeddedInt(uintptr_t Value, RawValueTag) : Value(Value) {}
5754
5855 public:
59 PointerEmbeddedInt() = default;
56 PointerEmbeddedInt() : Value(0) {}
6057
61 PointerEmbeddedInt(IntT I) { *this = I; }
58 PointerEmbeddedInt(IntT I) {
59 *this = I;
60 }
6261
6362 PointerEmbeddedInt &operator=(IntT I) {
64 assert((std::is_signed::value ? isInt(I) : isUInt(I)) &&
63 assert((std::is_signed::value ? llvm::isInt(I)
64 : llvm::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 using T = PointerEmbeddedInt;
83 typedef PointerEmbeddedInt T;
8484
8585 public:
8686 static inline void *getAsVoidPointer(const T &P) {
8787 return reinterpret_cast(P.Value);
8888 }
89
9089 static inline T getFromVoidPointer(void *P) {
9190 return T(reinterpret_cast(P), typename T::RawValueTag());
9291 }
93
9492 static inline T getFromVoidPointer(const void *P) {
9593 return T(reinterpret_cast(P), typename T::RawValueTag());
9694 }
102100 // itself can be a key.
103101 template
104102 struct DenseMapInfo> {
105 using T = PointerEmbeddedInt;
106 using IntInfo = DenseMapInfo;
103 typedef PointerEmbeddedInt T;
104
105 typedef DenseMapInfo IntInfo;
107106
108107 static inline T getEmptyKey() { return IntInfo::getEmptyKey(); }
109108 static inline T getTombstoneKey() { return IntInfo::getTombstoneKey(); }
110
111109 static unsigned getHashValue(const T &Arg) {
112110 return IntInfo::getHashValue(Arg);
113111 }
114
115112 static bool isEqual(const T &LHS, const T &RHS) { return LHS == RHS; }
116113 };
114 }
117115
118 } // end namespace llvm
119
120 #endif // LLVM_ADT_POINTEREMBEDDEDINT_H
116 #endif
1313 #ifndef LLVM_ADT_POINTERINTPAIR_H
1414 #define LLVM_ADT_POINTERINTPAIR_H
1515
16 #include "llvm/Support/Compiler.h"
1617 #include "llvm/Support/PointerLikeTypeTraits.h"
1718 #include
18 #include
1919 #include
2020
2121 namespace llvm {
4343 typename PtrTraits = PointerLikeTypeTraits,
4444 typename Info = PointerIntPairInfo>
4545 class PointerIntPair {
46 intptr_t Value = 0;
46 intptr_t Value;
4747
4848 public:
49 PointerIntPair() = default;
50
49 PointerIntPair() : Value(0) {}
5150 PointerIntPair(PointerTy PtrVal, IntType IntVal) {
5251 setPointerAndInt(PtrVal, IntVal);
5352 }
54
5553 explicit PointerIntPair(PointerTy PtrVal) { initWithPointer(PtrVal); }
5654
5755 PointerTy getPointer() const { return Info::getPointer(Value); }
5856
59 IntType getInt() const { return (IntType)Info::getInt(Value); }
57 IntType getInt() const {
58 return (IntType)Info::getInt(Value);
59 }
6060
6161 void setPointer(PointerTy PtrVal) {
6262 Value = Info::updatePointer(Value, PtrVal);
8787 }
8888
8989 void *getOpaqueValue() const { return reinterpret_cast(Value); }
90
9190 void setFromOpaqueValue(void *Val) {
9291 Value = reinterpret_cast(Val);
9392 }
108107 bool operator==(const PointerIntPair &RHS) const {
109108 return Value == RHS.Value;
110109 }
111
112110 bool operator!=(const PointerIntPair &RHS) const {
113111 return Value != RHS.Value;
114112 }
115
116113 bool operator<(const PointerIntPair &RHS) const { return Value < RHS.Value; }
117114 bool operator>(const PointerIntPair &RHS) const { return Value > RHS.Value; }
118
119115 bool operator<=(const PointerIntPair &RHS) const {
120116 return Value <= RHS.Value;
121117 }
122
123118 bool operator>=(const PointerIntPair &RHS) const {
124119 return Value >= RHS.Value;
125120 }
184179 // Provide specialization of DenseMapInfo for PointerIntPair.
185180 template
186181 struct DenseMapInfo> {
187 using Ty = PointerIntPair;
188
182 typedef PointerIntPair Ty;
189183 static Ty getEmptyKey() {
190184 uintptr_t Val = static_cast(-1);
191185 Val <<= PointerLikeTypeTraits::NumLowBitsAvailable;
192186 return Ty::getFromOpaqueValue(reinterpret_cast(Val));
193187 }
194
195188 static Ty getTombstoneKey() {
196189 uintptr_t Val = static_cast(-2);
197190 Val <<= PointerLikeTypeTraits::NumLowBitsAvailable;
198191 return Ty::getFromOpaqueValue(reinterpret_cast(Val));
199192 }
200
201193 static unsigned getHashValue(Ty V) {
202194 uintptr_t IV = reinterpret_cast(V.getOpaqueValue());
203195 return unsigned(IV) ^ unsigned(IV >> 9);
204196 }
205
206197 static bool isEqual(const Ty &LHS, const Ty &RHS) { return LHS == RHS; }
207198 };
208199
216207 getAsVoidPointer(const PointerIntPair &P) {
217208 return P.getOpaqueValue();
218209 }
219
220210 static inline PointerIntPair
221211 getFromVoidPointer(void *P) {
222212 return PointerIntPair::getFromOpaqueValue(P);
223213 }
224
225214 static inline PointerIntPair
226215 getFromVoidPointer(const void *P) {
227216 return PointerIntPair::getFromOpaqueValue(P);
228217 }
229
230218 enum { NumLowBitsAvailable = PtrTraits::NumLowBitsAvailable - IntBits };
231219 };
232220
233221 } // end namespace llvm
234
235 #endif // LLVM_ADT_POINTERINTPAIR_H
222 #endif
1010 #define LLVM_ADT_POINTERSUMTYPE_H
1111
1212 #include "llvm/ADT/DenseMapInfo.h"
13 #include "llvm/Support/Compiler.h"
1314 #include "llvm/Support/PointerLikeTypeTraits.h"
14 #include
15 #include
16 #include
1715
1816 namespace llvm {
1917
2523 typename TraitsArgT = PointerLikeTypeTraits>
2624 struct PointerSumTypeMember {
2725 enum { Tag = N };
28 using PointerT = PointerArgT;
29 using TraitsT = TraitsArgT;
26 typedef PointerArgT PointerT;
27 typedef TraitsArgT TraitsT;
3028 };
3129
3230 namespace detail {
3331
34 template struct PointerSumTypeHelper;
35
36 } // end namespace detail
32 template
33 struct PointerSumTypeHelper;
34
35 }
3736
3837 /// A sum type over pointer-like types.
3938 ///
6059 /// There is no support for constructing or accessing with a dynamic tag as
6160 /// that would fundamentally violate the type safety provided by the sum type.
6261 template class PointerSumType {
63 uintptr_t Value = 0;
64
65 using HelperT = detail::PointerSumTypeHelper;
62 uintptr_t Value;
63
64 typedef detail::PointerSumTypeHelper HelperT;
6665
6766 public:
68 PointerSumType() = default;
67 PointerSumType() : Value(0) {}
6968
7069 /// A typed constructor for a specific tagged member of the sum type.
7170 template
128127 template static void LookupOverload(...);
129128 template struct Lookup {
130129 // Compute a particular member type by resolving the lookup helper ovorload.
131 using MemberT = decltype(
132 LookupOverload(static_cast(nullptr)));
130 typedef decltype(LookupOverload(
131 static_cast(nullptr))) MemberT;
133132
134133 /// The Nth member's pointer type.
135 using PointerT = typename MemberT::PointerT;
134 typedef typename MemberT::PointerT PointerT;
136135
137136 /// The Nth member's traits type.
138 using TraitsT = typename MemberT::TraitsT;
137 typedef typename MemberT::TraitsT TraitsT;
139138 };
140139
141140 // Next we need to compute the number of bits available for the discriminant
171170 "Each member must pass the checker.");
172171 };
173172
174 } // end namespace detail
173 }
175174
176175 // Teach DenseMap how to use PointerSumTypes as keys.
177176 template
178177 struct DenseMapInfo> {
179 using SumType = PointerSumType;
180
181 using HelperT = detail::PointerSumTypeHelper;
178 typedef PointerSumType SumType;
179
180 typedef detail::PointerSumTypeHelper HelperT;
182181 enum { SomeTag = HelperT::MinTag };
183 using SomePointerT =
184 typename HelperT::template Lookup::PointerT;
185 using SomePointerInfo = DenseMapInfo;
182 typedef typename HelperT::template Lookup::PointerT
183 SomePointerT;
184 typedef DenseMapInfo SomePointerInfo;
186185
187186 static inline SumType getEmptyKey() {
188187 return SumType::create(SomePointerInfo::getEmptyKey());
189188 }
190
191189 static inline SumType getTombstoneKey() {
192 return SumType::create(SomePointerInfo::getTombstoneKey());
193 }
194
190 return SumType::create(
191 SomePointerInfo::getTombstoneKey());
192 }
195193 static unsigned getHashValue(const SumType &Arg) {
196194 uintptr_t OpaqueValue = Arg.getOpaqueValue();
197195 return DenseMapInfo::getHashValue(OpaqueValue);
198196 }
199
200197 static bool isEqual(const SumType &LHS, const SumType &RHS) {
201198 return LHS == RHS;
202199 }
203200 };
204201
205 } // end namespace llvm
206
207 #endif // LLVM_ADT_POINTERSUMTYPE_H
202 }
203
204 #endif
1818 #include "llvm/ADT/PointerIntPair.h"
1919 #include "llvm/Support/PointerLikeTypeTraits.h"
2020 #include
21 #include
2122 #include
22 #include
2323
2424 namespace llvm {
2525
2626 template struct PointerUnionTypeSelectorReturn {
27 using Return = T;
27 typedef T Return;
2828 };
2929
3030 /// Get a type based on whether two types are the same or not.
3838 /// Ret will be EQ type if T1 is same as T2 or NE type otherwise.
3939 template
4040 struct PointerUnionTypeSelector {
41 using Return = typename PointerUnionTypeSelectorReturn::Return;
41 typedef typename PointerUnionTypeSelectorReturn::Return Return;
4242 };
4343
4444 template
4545 struct PointerUnionTypeSelector {
46 using Return = typename PointerUnionTypeSelectorReturn::Return;
46 typedef typename PointerUnionTypeSelectorReturn::Return Return;
4747 };
4848
4949 template
5050 struct PointerUnionTypeSelectorReturn<
5151 PointerUnionTypeSelector> {
52 using Return =
53 typename PointerUnionTypeSelector::Return;
52 typedef
53 typename PointerUnionTypeSelector::Return Return;
5454 };
5555
5656 /// Provide PointerLikeTypeTraits for void* that is used by PointerUnion
8585 /// X = P.get(); // runtime assertion failure.
8686 template class PointerUnion {
8787 public:
88 using ValTy =
89 PointerIntPair>;
88 typedef PointerIntPair>
89 ValTy;
9090
9191 private:
9292 ValTy Val;
120120
121121 /// Test if the Union currently holds the type matching T.
122122 template int is() const {
123 using Ty = typename ::llvm::PointerUnionTypeSelector<
124 PT1, T, IsPT1,
125 ::llvm::PointerUnionTypeSelector
126 UNION_DOESNT_CONTAIN_TYPE>>::Return;
123 typedef typename ::llvm::PointerUnionTypeSelector<
124 PT1, T, IsPT1, ::llvm::PointerUnionTypeSelector<
125 PT2, T, IsPT2, UNION_DOESNT_CONTAIN_TYPE>>::Return
126 Ty;
127127 int TyNo = Ty::Num;
128128 return static_cast(Val.getInt()) == TyNo;
129129 }
227227 /// for usage.
228228 template class PointerUnion3 {
229229 public:
230 using InnerUnion = PointerUnion;
231 using ValTy = PointerUnion;
230 typedef PointerUnion InnerUnion;
231 typedef PointerUnion ValTy;
232232
233233 private:
234234 ValTy Val;
235235
236236 struct IsInnerUnion {
237237 ValTy Val;
238
239238 IsInnerUnion(ValTy val) : Val(val) {}
240
241239 template int is() const {
242240 return Val.template is() &&
243241 Val.template get().template is();
244242 }
245
246243 template T get() const {
247244 return Val.template get().template get();
248245 }
250247
251248 struct IsPT3 {
252249 ValTy Val;
253
254250 IsPT3(ValTy val) : Val(val) {}
255
256251 template int is() const { return Val.template is(); }
257252 template T get() const { return Val.template get(); }
258253 };
259254
260255 public:
261256 PointerUnion3() = default;
257
262258 PointerUnion3(PT1 V) { Val = InnerUnion(V); }
263259 PointerUnion3(PT2 V) { Val = InnerUnion(V); }
264260 PointerUnion3(PT3 V) { Val = V; }
271267 /// Test if the Union currently holds the type matching T.
272268 template int is() const {
273269 // If T is PT1/PT2 choose IsInnerUnion otherwise choose IsPT3.
274 using Ty = typename ::llvm::PointerUnionTypeSelector<
270 typedef typename ::llvm::PointerUnionTypeSelector<
275271 PT1, T, IsInnerUnion,
276 ::llvm::PointerUnionTypeSelector>::Return;
272 ::llvm::PointerUnionTypeSelector>::Return
273 Ty;
277274 return Ty(Val).template is();
278275 }
279276
283280 template T get() const {
284281 assert(is() && "Invalid accessor called");
285282 // If T is PT1/PT2 choose IsInnerUnion otherwise choose IsPT3.
286 using Ty = typename ::llvm::PointerUnionTypeSelector<
283 typedef typename ::llvm::PointerUnionTypeSelector<
287284 PT1, T, IsInnerUnion,
288 ::llvm::PointerUnionTypeSelector>::Return;
285 ::llvm::PointerUnionTypeSelector>::Return
286 Ty;
289287 return Ty(Val).template get();
290288 }
291289
351349 template
352350 class PointerUnion4 {
353351 public:
354 using InnerUnion1 = PointerUnion;
355 using InnerUnion2 = PointerUnion;
356 using ValTy = PointerUnion;
352 typedef PointerUnion InnerUnion1;
353 typedef PointerUnion InnerUnion2;
354 typedef PointerUnion ValTy;
357355
358356 private:
359357 ValTy Val;
360358
361359 public:
362360 PointerUnion4() = default;
361
363362 PointerUnion4(PT1 V) { Val = InnerUnion1(V); }
364363 PointerUnion4(PT2 V) { Val = InnerUnion1(V); }
365364 PointerUnion4(PT3 V) { Val = InnerUnion2(V); }
373372 /// Test if the Union currently holds the type matching T.
374373 template int is() const {
375374 // If T is PT1/PT2 choose InnerUnion1 otherwise choose InnerUnion2.
376 using Ty = typename ::llvm::PointerUnionTypeSelector<
377 PT1, T, InnerUnion1,
378 ::llvm::PointerUnionTypeSelector
379 InnerUnion2>>::Return;
375 typedef typename ::llvm::PointerUnionTypeSelector<
376 PT1, T, InnerUnion1, ::llvm::PointerUnionTypeSelector<
377 PT2, T, InnerUnion1, InnerUnion2>>::Return Ty;
380378 return Val.template is() && Val.template get().template is();
381379 }
382380
386384 template T get() const {
387385 assert(is() && "Invalid accessor called");
388386 // If T is PT1/PT2 choose InnerUnion1 otherwise choose InnerUnion2.
389 using Ty = typename ::llvm::PointerUnionTypeSelector<
390 PT1, T, InnerUnion1,
391 ::llvm::PointerUnionTypeSelector
392 InnerUnion2>>::Return;
387 typedef typename ::llvm::PointerUnionTypeSelector<
388 PT1, T, InnerUnion1, ::llvm::PointerUnionTypeSelector<
389 PT2, T, InnerUnion1, InnerUnion2>>::Return Ty;
393390 return Val.template get().template get();
394391 }
395392
457454
458455 // Teach DenseMap how to use PointerUnions as keys.
459456 template struct DenseMapInfo> {
460 using Pair = PointerUnion;
461 using FirstInfo = DenseMapInfo;
462 using SecondInfo = DenseMapInfo;
457 typedef PointerUnion Pair;
458 typedef DenseMapInfo FirstInfo;
459 typedef DenseMapInfo SecondInfo;
463460
464461 static inline Pair getEmptyKey() { return Pair(FirstInfo::getEmptyKey()); }
465
466462 static inline Pair getTombstoneKey() {
467463 return Pair(FirstInfo::getTombstoneKey());
468464 }
469
470465 static unsigned getHashValue(const Pair &PairVal) {
471466 intptr_t key = (intptr_t)PairVal.getOpaqueValue();
472467 return DenseMapInfo::getHashValue(key);
473468 }
474
475469 static bool isEqual(const Pair &LHS, const Pair &RHS) {
476470 return LHS.template is() == RHS.template is() &&
477471 (LHS.template is() ? FirstInfo::isEqual(LHS.template get(),
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"
1715 #include
1816 #include
1917 #include
20 #include
21 #include
22 #include
2318
2419 namespace llvm {
2520
8176 typename ilist_detail::compute_node_options::type> {
8277 static_assert(ilist_detail::check_options::value,
8378 "Unrecognized node option!");
84 using OptionsT =
85 typename ilist_detail::compute_node_options::type;
86 using list_base_type = typename OptionsT::list_base_type;
79 typedef
80 typename ilist_detail::compute_node_options::type OptionsT;
81 typedef typename OptionsT::list_base_type list_base_type;
8782 ilist_sentinel Sentinel;
8883
8984 public:
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;
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;
10196
10297 simple_ilist() = default;
10398 ~simple_ilist() = default;