llvm.org GIT mirror llvm / 6f42331
[ADT] Fix some Clang-tidy modernize-use-using warnings; other minor fixes (NFC). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303221 91177308-0d34-0410-b5e6-96231b3b80d8 Eugene Zelenko 3 years ago
17 changed file(s) with 388 addition(s) and 356 deletion(s). Raw diff Collapse all Expand all
9595 class po_iterator
9696 : public std::iterator,
9797 public po_iterator_storage {
98 typedef std::iterator super;
99 typedef typename GT::NodeRef NodeRef;
100 typedef typename GT::ChildIteratorType ChildItTy;
98 using super = std::iterator;
99 using NodeRef = typename GT::NodeRef;
100 using ChildItTy = typename GT::ChildIteratorType;
101101
102102 // VisitStack - Used to maintain the ordering. Top = current block
103103 // First element is basic block pointer, second is the 'next child' to visit
104104 std::vector> VisitStack;
105
106 po_iterator(NodeRef BB) {
107 this->insertEdge(Optional(), BB);
108 VisitStack.push_back(std::make_pair(BB, GT::child_begin(BB)));
109 traverseChild();
110 }
111
112 po_iterator() = default; // End is when stack is empty.
113
114 po_iterator(NodeRef BB, SetType &S)
115 : po_iterator_storage(S) {
116 if (this->insertEdge(Optional(), BB)) {
117 VisitStack.push_back(std::make_pair(BB, GT::child_begin(BB)));
118 traverseChild();
119 }
120 }
121
122 po_iterator(SetType &S)
123 : po_iterator_storage(S) {
124 } // End is when stack is empty.
105125
106126 void traverseChild() {
107127 while (VisitStack.back().second != GT::child_end(VisitStack.back().first)) {
113133 }
114134 }
115135
116 po_iterator(NodeRef BB) {
117 this->insertEdge(Optional(), BB);
118 VisitStack.push_back(std::make_pair(BB, GT::child_begin(BB)));
119 traverseChild();
120 }
121
122 po_iterator() = default; // End is when stack is empty.
123
124 po_iterator(NodeRef BB, SetType &S)
125 : po_iterator_storage(S) {
126 if (this->insertEdge(Optional(), BB)) {
127 VisitStack.push_back(std::make_pair(BB, GT::child_begin(BB)));
128 traverseChild();
129 }
130 }
131
132 po_iterator(SetType &S)
133 : po_iterator_storage(S) {
134 } // End is when stack is empty.
135
136136 public:
137 typedef typename super::pointer pointer;
137 using pointer = typename super::pointer;
138138
139139 // Provide static "constructors"...
140140 static po_iterator begin(GraphT G) {
285285
286286 template>
287287 class ReversePostOrderTraversal {
288 typedef typename GT::NodeRef NodeRef;
288 using NodeRef = typename GT::NodeRef;
289
289290 std::vector Blocks; // Block list in normal PO order
290291
291292 void Initialize(NodeRef BB) {
293294 }
294295
295296 public:
296 typedef typename std::vector::reverse_iterator rpo_iterator;
297 using rpo_iterator = typename std::vector::reverse_iterator;
297298
298299 ReversePostOrderTraversal(GraphT G) { Initialize(GT::getEntryNode(G)); }
299300
1616 #define LLVM_ADT_PRIORITYWORKLIST_H
1717
1818 #include "llvm/ADT/DenseMap.h"
19 #include "llvm/ADT/SmallVector.h"
1920 #include "llvm/ADT/STLExtras.h"
20 #include "llvm/ADT/Sequence.h"
21 #include "llvm/ADT/SmallVector.h"
2221 #include "llvm/Support/Compiler.h"
2322 #include
2423 #include
2524 #include
25 #include
26 #include
2627 #include
2728
2829 namespace llvm {
5455 typename MapT = DenseMap>
5556 class PriorityWorklist {
5657 public:
57 typedef T value_type;
58 typedef T key_type;
59 typedef T& reference;
60 typedef const T& const_reference;
61 typedef typename MapT::size_type size_type;
58 using value_type = T;
59 using key_type = T;
60 using reference = T&;
61 using const_reference = const T&;
62 using size_type = typename MapT::size_type;
6263
6364 /// Construct an empty PriorityWorklist
6465 PriorityWorklist() = default;
None //===---- ADT/SCCIterator.h - Strongly Connected Comp. Iter. ----*- C++ -*-===//
0 //===- ADT/SCCIterator.h - Strongly Connected Comp. Iter. -------*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
4242 class scc_iterator : public iterator_facade_base<
4343 scc_iterator, std::forward_iterator_tag,
4444 const std::vector, ptrdiff_t> {
45 typedef typename GT::NodeRef NodeRef;
46 typedef typename GT::ChildIteratorType ChildItTy;
47 typedef std::vector SccTy;
48 typedef typename scc_iterator::reference reference;
45 using NodeRef = typename GT::NodeRef;
46 using ChildItTy = typename GT::ChildIteratorType;
47 using SccTy = std::vector;
48 using reference = typename scc_iterator::reference;
4949
5050 /// Element of VisitStack during DFS.
5151 struct StackElement {
1212 ///
1313 //===----------------------------------------------------------------------===//
1414
15 #ifndef LLVM_ADT_SEQ_H
16 #define LLVM_ADT_SEQ_H
15 #ifndef LLVM_ADT_SEQUENCE_H
16 #define LLVM_ADT_SEQUENCE_H
1717
1818 #include "llvm/ADT/iterator.h"
1919 #include "llvm/ADT/iterator_range.h"
20 #include
21 #include
22 #include
2023
2124 namespace llvm {
2225
2326 namespace detail {
27
2428 template
2529 class value_sequence_iterator
2630 : public iterator_facade_base,
2731 std::random_access_iterator_tag,
2832 const ValueT> {
29 typedef typename value_sequence_iterator::iterator_facade_base BaseT;
33 using BaseT = typename value_sequence_iterator::iterator_facade_base;
3034
3135 ValueT Value;
3236
3337 public:
34 typedef typename BaseT::difference_type difference_type;
35 typedef typename BaseT::reference reference;
38 using difference_type = typename BaseT::difference_type;
39 using reference = typename BaseT::reference;
3640
3741 value_sequence_iterator() = default;
3842 value_sequence_iterator(const value_sequence_iterator &) = default;
6468
6569 reference operator*() const { return Value; }
6670 };
67 } // End detail namespace.
71
72 } // end namespace detail
6873
6974 template
7075 iterator_range> seq(ValueT Begin,
7378 detail::value_sequence_iterator(End));
7479 }
7580
76 }
81 } // end namespace llvm
7782
78 #endif
83 #endif // LLVM_ADT_SEQUENCE_H
3939 typename Set = DenseSet>
4040 class SetVector {
4141 public:
42 typedef T value_type;
43 typedef T key_type;
44 typedef T& reference;
45 typedef const T& const_reference;
46 typedef Set set_type;
47 typedef Vector vector_type;
48 typedef typename vector_type::const_iterator iterator;
49 typedef typename vector_type::const_iterator const_iterator;
50 typedef typename vector_type::const_reverse_iterator reverse_iterator;
51 typedef typename vector_type::const_reverse_iterator const_reverse_iterator;
52 typedef typename vector_type::size_type size_type;
42 using value_type = T;
43 using key_type = T;
44 using reference = T&;
45 using const_reference = const T&;
46 using set_type = Set;
47 using vector_type = Vector;
48 using iterator = typename vector_type::const_iterator;
49 using const_iterator = typename vector_type::const_iterator;
50 using reverse_iterator = typename vector_type::const_reverse_iterator;
51 using const_reverse_iterator = typename vector_type::const_reverse_iterator;
52 using size_type = typename vector_type::size_type;
5353
5454 /// \brief Construct an empty SetVector
5555 SetVector() = default;
2626 #include
2727 #include
2828
29 #if LLVM_ENABLE_ABI_BREAKING_CHECKS
3029 namespace llvm {
30
31 #if LLVM_ENABLE_ABI_BREAKING_CHECKS
3132 template struct ReverseIterate { static bool value; };
3233 template bool ReverseIterate::value = false;
33 }
34 #endif
35
36 namespace llvm {
34 #endif
3735
3836 /// SmallPtrSetImplBase - This is the common code shared among all the
3937 /// SmallPtrSet<>'s, which is almost everything. SmallPtrSet has two modes, one
9189 }
9290
9391 public:
94 typedef unsigned size_type;
92 using size_type = unsigned;
9593
9694 SmallPtrSetImplBase &operator=(const SmallPtrSetImplBase &) = delete;
9795
272270 /// SmallPtrSetIterator - This implements a const_iterator for SmallPtrSet.
273271 template
274272 class SmallPtrSetIterator : public SmallPtrSetIteratorImpl {
275 typedef PointerLikeTypeTraits PtrTraits;
273 using PtrTraits = PointerLikeTypeTraits;
276274
277275 public:
278 typedef PtrTy value_type;
279 typedef PtrTy reference;
280 typedef PtrTy pointer;
281 typedef std::ptrdiff_t difference_type;
282 typedef std::forward_iterator_tag iterator_category;
276 using value_type = PtrTy;
277 using reference = PtrTy;
278 using pointer = PtrTy;
279 using difference_type = std::ptrdiff_t;
280 using iterator_category = std::forward_iterator_tag;
283281
284282 explicit SmallPtrSetIterator(const void *const *BP, const void *const *E)
285283 : SmallPtrSetIteratorImpl(BP, E) {}
350348 template
351349 class SmallPtrSetImpl : public SmallPtrSetImplBase {
352350 using ConstPtrType = typename add_const_past_pointer::type;
353 typedef PointerLikeTypeTraits PtrTraits;
354 typedef PointerLikeTypeTraits ConstPtrTraits;
351 using PtrTraits = PointerLikeTypeTraits;
352 using ConstPtrTraits = PointerLikeTypeTraits;
355353
356354 protected:
357355 // Constructors that forward to the base.
364362 : SmallPtrSetImplBase(SmallStorage, SmallSize) {}
365363
366364 public:
367 typedef SmallPtrSetIterator iterator;
368 typedef SmallPtrSetIterator const_iterator;
365 using iterator = SmallPtrSetIterator;
366 using const_iterator = SmallPtrSetIterator;
369367
370368 SmallPtrSetImpl(const SmallPtrSetImpl &) = delete;
371369
430428 // DenseSet<> instead if you expect many elements in the set.
431429 static_assert(SmallSize <= 32, "SmallSize should be small");
432430
433 typedef SmallPtrSetImpl BaseT;
431 using BaseT = SmallPtrSetImpl;
434432
435433 // Make sure that SmallSize is a power of two, round up if not.
436434 enum { SmallSizePowTwo = RoundUpToPowerOfTwo::Val };
7070 // Allocate raw space for N elements of type T. If T has a ctor or dtor, we
7171 // don't want it to be automatically run, so we need to represent the space as
7272 // something else. Use an array of char of sufficient alignment.
73 typedef AlignedCharArrayUnion U;
73 using U = AlignedCharArrayUnion;
7474 U FirstEl;
7575 // Space after 'FirstEl' is clobbered, do not add any instance vars after it.
7676
9595 void setEnd(T *P) { this->EndX = P; }
9696
9797 public:
98 typedef size_t size_type;
99 typedef ptrdiff_t difference_type;
100 typedef T value_type;
101 typedef T *iterator;
102 typedef const T *const_iterator;
103
104 typedef std::reverse_iterator const_reverse_iterator;
105 typedef std::reverse_iterator reverse_iterator;
106
107 typedef T &reference;
108 typedef const T &const_reference;
109 typedef T *pointer;
110 typedef const T *const_pointer;
98 using size_type = size_t;
99 using difference_type = ptrdiff_t;
100 using value_type = T;
101 using iterator = T *;
102 using const_iterator = const T *;
103
104 using const_reverse_iterator = std::reverse_iterator;
105 using reverse_iterator = std::reverse_iterator;
106
107 using reference = T &;
108 using const_reference = const T &;
109 using pointer = T *;
110 using const_pointer = const T *;
111111
112112 // forward iterator creation methods.
113113 LLVM_ATTRIBUTE_ALWAYS_INLINE
318318 /// reduce code duplication based on the SmallVector 'N' template parameter.
319319 template
320320 class SmallVectorImpl : public SmallVectorTemplateBase::value> {
321 typedef SmallVectorTemplateBase::value > SuperClass;
321 using SuperClass = SmallVectorTemplateBase::value>;
322322
323323 public:
324 typedef typename SuperClass::iterator iterator;
325 typedef typename SuperClass::const_iterator const_iterator;
326 typedef typename SuperClass::size_type size_type;
324 using iterator = typename SuperClass::iterator;
325 using const_iterator = typename SuperClass::const_iterator;
326 using size_type = typename SuperClass::size_type;
327327
328328 protected:
329329 // Default ctor - Initialize to empty.
844844 SmallVectorStorage Storage;
845845
846846 public:
847 SmallVector() : SmallVectorImpl(N) {
848 }
847 SmallVector() : SmallVectorImpl(N) {}
849848
850849 explicit SmallVector(size_t Size, const T &Value = T())
851850 : SmallVectorImpl(N) {
882881 SmallVectorImpl::operator=(::std::move(RHS));
883882 }
884883
884 SmallVector(SmallVectorImpl &&RHS) : SmallVectorImpl(N) {
885 if (!RHS.empty())
886 SmallVectorImpl::operator=(::std::move(RHS));
887 }
888
885889 const SmallVector &operator=(SmallVector &&RHS) {
886890 SmallVectorImpl::operator=(::std::move(RHS));
887891 return *this;
888 }
889
890 SmallVector(SmallVectorImpl &&RHS) : SmallVectorImpl(N) {
891 if (!RHS.empty())
892 SmallVectorImpl::operator=(::std::move(RHS));
893892 }
894893
895894 const SmallVector &operator=(SmallVectorImpl &&RHS) {
None //===- llvm/ADT/SparseBitVector.h - Efficient Sparse BitVector -*- C++ -*- ===//
0 //===- llvm/ADT/SparseBitVector.h - Efficient Sparse BitVector --*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
4040
4141 template struct SparseBitVectorElement {
4242 public:
43 typedef unsigned long BitWord;
44 typedef unsigned size_type;
43 using BitWord = unsigned long;
44 using size_type = unsigned;
4545 enum {
4646 BITWORD_SIZE = sizeof(BitWord) * CHAR_BIT,
4747 BITWORDS_PER_ELEMENT = (ElementSize + BITWORD_SIZE - 1) / BITWORD_SIZE,
9999 Bits[Idx / BITWORD_SIZE] |= 1L << (Idx % BITWORD_SIZE);
100100 }
101101
102 bool test_and_set (unsigned Idx) {
102 bool test_and_set(unsigned Idx) {
103103 bool old = test(Idx);
104104 if (!old) {
105105 set(Idx);
253253
254254 template
255255 class SparseBitVector {
256 typedef std::list> ElementList;
257 typedef typename ElementList::iterator ElementListIter;
258 typedef typename ElementList::const_iterator ElementListConstIter;
256 using ElementList = std::list>;
257 using ElementListIter = typename ElementList::iterator;
258 using ElementListConstIter = typename ElementList::const_iterator;
259259 enum {
260260 BITWORD_SIZE = SparseBitVectorElement::BITWORD_SIZE
261261 };
420420 };
421421
422422 public:
423 typedef SparseBitVectorIterator iterator;
423 using iterator = SparseBitVectorIterator;
424424
425425 SparseBitVector() {
426426 CurrElementIter = Elements.begin();
427427 }
428
429 ~SparseBitVector() = default;
430428
431429 // SparseBitVector copy ctor.
432430 SparseBitVector(const SparseBitVector &RHS) {
438436
439437 CurrElementIter = Elements.begin ();
440438 }
439
440 ~SparseBitVector() = default;
441441
442442 // Clear.
443443 void clear() {
None //===--- llvm/ADT/SparseMultiSet.h - Sparse multiset ------------*- C++ -*-===//
0 //===- llvm/ADT/SparseMultiSet.h - Sparse multiset --------------*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
100100 unsigned Prev;
101101 unsigned Next;
102102
103 SMSNode(ValueT D, unsigned P, unsigned N) : Data(D), Prev(P), Next(N) { }
103 SMSNode(ValueT D, unsigned P, unsigned N) : Data(D), Prev(P), Next(N) {}
104104
105105 /// List tails have invalid Nexts.
106106 bool isTail() const {
117117 bool isValid() const { return Prev != INVALID; }
118118 };
119119
120 typedef typename KeyFunctorT::argument_type KeyT;
121 typedef SmallVector DenseT;
120 using KeyT = typename KeyFunctorT::argument_type;
121 using DenseT = SmallVector;
122122 DenseT Dense;
123123 SparseT *Sparse = nullptr;
124124 unsigned Universe = 0;
182182 }
183183
184184 public:
185 typedef ValueT value_type;
186 typedef ValueT &reference;
187 typedef const ValueT &const_reference;
188 typedef ValueT *pointer;
189 typedef const ValueT *const_pointer;
190 typedef unsigned size_type;
185 using value_type = ValueT;
186 using reference = ValueT &;
187 using const_reference = const ValueT &;
188 using pointer = ValueT *;
189 using const_pointer = const ValueT *;
190 using size_type = unsigned;
191191
192192 SparseMultiSet() = default;
193193 SparseMultiSet(const SparseMultiSet &) = delete;
226226 unsigned SparseIdx;
227227
228228 iterator_base(SMSPtrTy P, unsigned I, unsigned SI)
229 : SMS(P), Idx(I), SparseIdx(SI) { }
229 : SMS(P), Idx(I), SparseIdx(SI) {}
230230
231231 /// Whether our iterator has fallen outside our dense vector.
232232 bool isEnd() const {
247247 void setNext(unsigned N) { SMS->Dense[Idx].Next = N; }
248248
249249 public:
250 typedef std::iterator super;
251 typedef typename super::value_type value_type;
252 typedef typename super::difference_type difference_type;
253 typedef typename super::pointer pointer;
254 typedef typename super::reference reference;
250 using super = std::iterator;
251 using value_type = typename super::value_type;
252 using difference_type = typename super::difference_type;
253 using pointer = typename super::pointer;
254 using reference = typename super::reference;
255255
256256 reference operator*() const {
257257 assert(isKeyed() && SMS->sparseIndex(SMS->Dense[Idx].Data) == SparseIdx &&
307307 return I;
308308 }
309309 };
310 typedef iterator_base iterator;
311 typedef iterator_base const_iterator;
310
311 using iterator = iterator_base;
312 using const_iterator = iterator_base;
312313
313314 // Convenience types
314 typedef std::pair RangePair;
315 using RangePair = std::pair;
315316
316317 /// Returns an iterator past this container. Note that such an iterator cannot
317318 /// be decremented, but will compare equal to other end iterators.
None //===--- llvm/ADT/SparseSet.h - Sparse set ----------------------*- C++ -*-===//
0 //===- llvm/ADT/SparseSet.h - Sparse set ------------------------*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
124124 !std::numeric_limits::is_signed,
125125 "SparseT must be an unsigned integer type");
126126
127 typedef typename KeyFunctorT::argument_type KeyT;
128 typedef SmallVector DenseT;
129 typedef unsigned size_type;
127 using KeyT = typename KeyFunctorT::argument_type;
128 using DenseT = SmallVector;
129 using size_type = unsigned;
130130 DenseT Dense;
131131 SparseT *Sparse = nullptr;
132132 unsigned Universe = 0;
134134 SparseSetValFunctor ValIndexOf;
135135
136136 public:
137 typedef ValueT value_type;
138 typedef ValueT &reference;
139 typedef const ValueT &const_reference;
140 typedef ValueT *pointer;
141 typedef const ValueT *const_pointer;
137 using value_type = ValueT;
138 using reference = ValueT &;
139 using const_reference = const ValueT &;
140 using pointer = ValueT *;
141 using const_pointer = const ValueT *;
142142
143143 SparseSet() = default;
144144 SparseSet(const SparseSet &) = delete;
167167 }
168168
169169 // Import trivial vector stuff from DenseT.
170 typedef typename DenseT::iterator iterator;
171 typedef typename DenseT::const_iterator const_iterator;
170 using iterator = typename DenseT::iterator;
171 using const_iterator = typename DenseT::const_iterator;
172172
173173 const_iterator begin() const { return Dense.begin(); }
174174 const_iterator end() const { return Dense.end(); }
None //===-- llvm/ADT/StringExtras.h - Useful string functions -------*- C++ -*-===//
0 //===- llvm/ADT/StringExtras.h - Useful string functions --------*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
1414 #define LLVM_ADT_STRINGEXTRAS_H
1515
1616 #include "llvm/ADT/StringRef.h"
17 #include "llvm/Support/DataTypes.h"
1817 #include
18 #include
19 #include
20 #include
21 #include
22 #include
23 #include
1924
2025 namespace llvm {
26
27 template class SmallVectorImpl;
2128 class raw_ostream;
22 template class SmallVectorImpl;
2329
2430 /// hexdigit - Return the hexadecimal character for the
2531 /// given number \p X (which should be less than 16).
126132 if (isNeg) *--BufPtr = '-'; // Add negative sign...
127133 return std::string(BufPtr, std::end(Buffer));
128134 }
129
130135
131136 static inline std::string itostr(int64_t X) {
132137 if (X < 0)
260265 inline size_t join_items_size(const A1 &A, Args &&... Items) {
261266 return join_one_item_size(A) + join_items_size(std::forward(Items)...);
262267 }
263 }
268
269 } // end namespace detail
264270
265271 /// Joins the strings in the range [Begin, End), adding Separator between
266272 /// the elements.
267273 template
268274 inline std::string join(IteratorT Begin, IteratorT End, StringRef Separator) {
269 typedef typename std::iterator_traits::iterator_category tag;
275 using tag = typename std::iterator_traits::iterator_category;
270276 return detail::join_impl(Begin, End, Separator, tag());
271277 }
272278
294300 return Result;
295301 }
296302
297 } // End llvm namespace
298
299 #endif
303 } // end namespace llvm
304
305 #endif // LLVM_ADT_STRINGEXTRAS_H
None //===--- StringMap.h - String Hash table map interface ----------*- C++ -*-===//
0 //===- StringMap.h - String Hash table map interface ------------*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
1515
1616 #include "llvm/ADT/StringRef.h"
1717 #include "llvm/ADT/iterator.h"
18 #include "llvm/ADT/iterator_range.h"
1819 #include "llvm/Support/Allocator.h"
1920 #include "llvm/Support/PointerLikeTypeTraits.h"
21 #include
2022 #include
2123 #include
2224 #include
2325 #include
2426 #include
25 #include <new>
27 #include <iterator>
2628 #include
2729
2830 namespace llvm {
2931
30 template
31 class StringMapConstIterator;
32 template
33 class StringMapIterator;
34 template class StringMapKeyIterator;
35 template
36 class StringMapEntry;
32 template class StringMapConstIterator;
33 template class StringMapIterator;
34 template class StringMapKeyIterator;
3735
3836 /// StringMapEntryBase - Shared base class of StringMapEntry instances.
3937 class StringMapEntryBase {
5250 // Array of NumBuckets pointers to entries, null pointers are holes.
5351 // TheTable[NumBuckets] contains a sentinel value for easy iteration. Followed
5452 // by an array of the actual hash values as unsigned integers.
55 StringMapEntryBase **TheTable;
56 unsigned NumBuckets;
57 unsigned NumItems;
58 unsigned NumTombstones;
53 StringMapEntryBase **TheTable = nullptr;
54 unsigned NumBuckets = 0;
55 unsigned NumItems = 0;
56 unsigned NumTombstones = 0;
5957 unsigned ItemSize;
6058
6159 protected:
6260 explicit StringMapImpl(unsigned itemSize)
63 : TheTable(nullptr),
64 // Initialize the map with zero buckets to allocation.
65 NumBuckets(0), NumItems(0), NumTombstones(0), ItemSize(itemSize) {}
61 : ItemSize(itemSize) {}
6662 StringMapImpl(StringMapImpl &&RHS)
6763 : TheTable(RHS.TheTable), NumBuckets(RHS.NumBuckets),
6864 NumItems(RHS.NumItems), NumTombstones(RHS.NumTombstones),
224220 AllocatorTy Allocator;
225221
226222 public:
227 typedef StringMapEntry MapEntryTy;
223 using MapEntryTy = StringMapEntry;
228224
229225 StringMap() : StringMapImpl(static_cast(sizeof(MapEntryTy))) {}
226
230227 explicit StringMap(unsigned InitialSize)
231228 : StringMapImpl(InitialSize, static_cast(sizeof(MapEntryTy))) {}
232229
246243
247244 StringMap(StringMap &&RHS)
248245 : StringMapImpl(std::move(RHS)), Allocator(std::move(RHS.Allocator)) {}
249
250 StringMap &operator=(StringMap RHS) {
251 StringMapImpl::swap(RHS);
252 std::swap(Allocator, RHS.Allocator);
253 return *this;
254 }
255246
256247 StringMap(const StringMap &RHS) :
257248 StringMapImpl(static_cast(sizeof(MapEntryTy))),
288279 // not worthwhile.
289280 }
290281
291 AllocatorTy &getAllocator() { return Allocator; }
292 const AllocatorTy &getAllocator() const { return Allocator; }
293
294 typedef const char* key_type;
295 typedef ValueTy mapped_type;
296 typedef StringMapEntry value_type;
297 typedef size_t size_type;
298
299 typedef StringMapConstIterator const_iterator;
300 typedef StringMapIterator iterator;
301
302 iterator begin() {
303 return iterator(TheTable, NumBuckets == 0);
304 }
305 iterator end() {
306 return iterator(TheTable+NumBuckets, true);
307 }
308 const_iterator begin() const {
309 return const_iterator(TheTable, NumBuckets == 0);
310 }
311 const_iterator end() const {
312 return const_iterator(TheTable+NumBuckets, true);
313 }
314
315 llvm::iterator_range> keys() const {
316 return make_range(StringMapKeyIterator(begin()),
317 StringMapKeyIterator(end()));
318 }
319
320 iterator find(StringRef Key) {
321 int Bucket = FindKey(Key);
322 if (Bucket == -1) return end();
323 return iterator(TheTable+Bucket, true);
324 }
325
326 const_iterator find(StringRef Key) const {
327 int Bucket = FindKey(Key);
328 if (Bucket == -1) return end();
329 return const_iterator(TheTable+Bucket, true);
330 }
331
332 /// lookup - Return the entry for the specified key, or a default
333 /// constructed value if no such entry exists.
334 ValueTy lookup(StringRef Key) const {
335 const_iterator it = find(Key);
336 if (it != end())
337 return it->second;
338 return ValueTy();
339 }
340
341 /// Lookup the ValueTy for the \p Key, or create a default constructed value
342 /// if the key is not in the map.
343 ValueTy &operator[](StringRef Key) { return try_emplace(Key).first->second; }
344
345 /// count - Return 1 if the element is in the map, 0 otherwise.
346 size_type count(StringRef Key) const {
347 return find(Key) == end() ? 0 : 1;
348 }
349
350 /// insert - Insert the specified key/value pair into the map. If the key
351 /// already exists in the map, return false and ignore the request, otherwise
352 /// insert it and return true.
353 bool insert(MapEntryTy *KeyValue) {
354 unsigned BucketNo = LookupBucketFor(KeyValue->getKey());
355 StringMapEntryBase *&Bucket = TheTable[BucketNo];
356 if (Bucket && Bucket != getTombstoneVal())
357 return false; // Already exists in map.
358
359 if (Bucket == getTombstoneVal())
360 --NumTombstones;
361 Bucket = KeyValue;
362 ++NumItems;
363 assert(NumItems + NumTombstones <= NumBuckets);
364
365 RehashTable();
366 return true;
367 }
368
369 /// insert - Inserts the specified key/value pair into the map if the key
370 /// isn't already in the map. The bool component of the returned pair is true
371 /// if and only if the insertion takes place, and the iterator component of
372 /// the pair points to the element with key equivalent to the key of the pair.
373 std::pair insert(std::pair KV) {
374 return try_emplace(KV.first, std::move(KV.second));
375 }
376
377 /// Emplace a new element for the specified key into the map if the key isn't
378 /// already in the map. The bool component of the returned pair is true
379 /// if and only if the insertion takes place, and the iterator component of
380 /// the pair points to the element with key equivalent to the key of the pair.
381 template
382 std::pair try_emplace(StringRef Key, ArgsTy &&... Args) {
383 unsigned BucketNo = LookupBucketFor(Key);
384 StringMapEntryBase *&Bucket = TheTable[BucketNo];
385 if (Bucket && Bucket != getTombstoneVal())
386 return std::make_pair(iterator(TheTable + BucketNo, false),
387 false); // Already exists in map.
388
389 if (Bucket == getTombstoneVal())
390 --NumTombstones;
391 Bucket = MapEntryTy::Create(Key, Allocator, std::forward(Args)...);
392 ++NumItems;
393 assert(NumItems + NumTombstones <= NumBuckets);
394
395 BucketNo = RehashTable(BucketNo);
396 return std::make_pair(iterator(TheTable + BucketNo, false), true);
397 }
398
399 // clear - Empties out the StringMap
400 void clear() {
401 if (empty()) return;
402
403 // Zap all values, resetting the keys back to non-present (not tombstone),
404 // which is safe because we're removing all elements.
405 for (unsigned I = 0, E = NumBuckets; I != E; ++I) {
406 StringMapEntryBase *&Bucket = TheTable[I];
407 if (Bucket && Bucket != getTombstoneVal()) {
408 static_cast(Bucket)->Destroy(Allocator);
409 }
410 Bucket = nullptr;
411 }
412
413 NumItems = 0;
414 NumTombstones = 0;
415 }
416
417 /// remove - Remove the specified key/value pair from the map, but do not
418 /// erase it. This aborts if the key is not in the map.
419 void remove(MapEntryTy *KeyValue) {
420 RemoveKey(KeyValue);
421 }
422
423 void erase(iterator I) {
424 MapEntryTy &V = *I;
425 remove(&V);
426 V.Destroy(Allocator);
427 }
428
429 bool erase(StringRef Key) {
430 iterator I = find(Key);
431 if (I == end()) return false;
432 erase(I);
433 return true;
282 StringMap &operator=(StringMap RHS) {
283 StringMapImpl::swap(RHS);
284 std::swap(Allocator, RHS.Allocator);
285 return *this;
434286 }
435287
436288 ~StringMap() {
447299 }
448300 free(TheTable);
449301 }
302
303 AllocatorTy &getAllocator() { return Allocator; }
304 const AllocatorTy &getAllocator() const { return Allocator; }
305
306 using key_type = const char*;
307 using mapped_type = ValueTy;
308 using value_type = StringMapEntry;
309 using size_type = size_t;
310
311 using const_iterator = StringMapConstIterator;
312 using iterator = StringMapIterator;
313
314 iterator begin() {
315 return iterator(TheTable, NumBuckets == 0);
316 }
317 iterator end() {
318 return iterator(TheTable+NumBuckets, true);
319 }
320 const_iterator begin() const {
321 return const_iterator(TheTable, NumBuckets == 0);
322 }
323 const_iterator end() const {
324 return const_iterator(TheTable+NumBuckets, true);
325 }
326
327 iterator_range> keys() const {
328 return make_range(StringMapKeyIterator(begin()),
329 StringMapKeyIterator(end()));
330 }
331
332 iterator find(StringRef Key) {
333 int Bucket = FindKey(Key);
334 if (Bucket == -1) return end();
335 return iterator(TheTable+Bucket, true);
336 }
337
338 const_iterator find(StringRef Key) const {
339 int Bucket = FindKey(Key);
340 if (Bucket == -1) return end();
341 return const_iterator(TheTable+Bucket, true);
342 }
343
344 /// lookup - Return the entry for the specified key, or a default
345 /// constructed value if no such entry exists.
346 ValueTy lookup(StringRef Key) const {
347 const_iterator it = find(Key);
348 if (it != end())
349 return it->second;
350 return ValueTy();
351 }
352
353 /// Lookup the ValueTy for the \p Key, or create a default constructed value
354 /// if the key is not in the map.
355 ValueTy &operator[](StringRef Key) { return try_emplace(Key).first->second; }
356
357 /// count - Return 1 if the element is in the map, 0 otherwise.
358 size_type count(StringRef Key) const {
359 return find(Key) == end() ? 0 : 1;
360 }
361
362 /// insert - Insert the specified key/value pair into the map. If the key
363 /// already exists in the map, return false and ignore the request, otherwise
364 /// insert it and return true.
365 bool insert(MapEntryTy *KeyValue) {
366 unsigned BucketNo = LookupBucketFor(KeyValue->getKey());
367 StringMapEntryBase *&Bucket = TheTable[BucketNo];
368 if (Bucket && Bucket != getTombstoneVal())
369 return false; // Already exists in map.
370
371 if (Bucket == getTombstoneVal())
372 --NumTombstones;
373 Bucket = KeyValue;
374 ++NumItems;
375 assert(NumItems + NumTombstones <= NumBuckets);
376
377 RehashTable();
378 return true;
379 }
380
381 /// insert - Inserts the specified key/value pair into the map if the key
382 /// isn't already in the map. The bool component of the returned pair is true
383 /// if and only if the insertion takes place, and the iterator component of
384 /// the pair points to the element with key equivalent to the key of the pair.
385 std::pair insert(std::pair KV) {
386 return try_emplace(KV.first, std::move(KV.second));
387 }
388
389 /// Emplace a new element for the specified key into the map if the key isn't
390 /// already in the map. The bool component of the returned pair is true
391 /// if and only if the insertion takes place, and the iterator component of
392 /// the pair points to the element with key equivalent to the key of the pair.
393 template
394 std::pair try_emplace(StringRef Key, ArgsTy &&... Args) {
395 unsigned BucketNo = LookupBucketFor(Key);
396 StringMapEntryBase *&Bucket = TheTable[BucketNo];
397 if (Bucket && Bucket != getTombstoneVal())
398 return std::make_pair(iterator(TheTable + BucketNo, false),
399 false); // Already exists in map.
400
401 if (Bucket == getTombstoneVal())
402 --NumTombstones;
403 Bucket = MapEntryTy::Create(Key, Allocator, std::forward(Args)...);
404 ++NumItems;
405 assert(NumItems + NumTombstones <= NumBuckets);
406
407 BucketNo = RehashTable(BucketNo);
408 return std::make_pair(iterator(TheTable + BucketNo, false), true);
409 }
410
411 // clear - Empties out the StringMap
412 void clear() {
413 if (empty()) return;
414
415 // Zap all values, resetting the keys back to non-present (not tombstone),
416 // which is safe because we're removing all elements.
417 for (unsigned I = 0, E = NumBuckets; I != E; ++I) {
418 StringMapEntryBase *&Bucket = TheTable[I];
419 if (Bucket && Bucket != getTombstoneVal()) {
420 static_cast(Bucket)->Destroy(Allocator);
421 }
422 Bucket = nullptr;
423 }
424
425 NumItems = 0;
426 NumTombstones = 0;
427 }
428
429 /// remove - Remove the specified key/value pair from the map, but do not
430 /// erase it. This aborts if the key is not in the map.
431 void remove(MapEntryTy *KeyValue) {
432 RemoveKey(KeyValue);
433 }
434
435 void erase(iterator I) {
436 MapEntryTy &V = *I;
437 remove(&V);
438 V.Destroy(Allocator);
439 }
440
441 bool erase(StringRef Key) {
442 iterator I = find(Key);
443 if (I == end()) return false;
444 erase(I);
445 return true;
446 }
450447 };
451448
452449 template
541538
542539 public:
543540 StringMapKeyIterator() = default;
544
545541 explicit StringMapKeyIterator(StringMapConstIterator Iter)
546542 : base(std::move(Iter)) {}
547543
None //===--- StringRef.h - Constant String Reference Wrapper --------*- C++ -*-===//
0 //===- StringRef.h - Constant String Reference Wrapper ----------*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
1414 #include "llvm/Support/Compiler.h"
1515 #include
1616 #include
17 #include
1718 #include
1819 #include
20 #include
1921 #include
2022 #include
2123
2224 namespace llvm {
23 template
24 class SmallVectorImpl;
25
2526 class APInt;
2627 class hash_code;
28 template class SmallVectorImpl;
2729 class StringRef;
2830
2931 /// Helper functions for StringRef::getAsInteger.
4547 /// general safe to store a StringRef.
4648 class StringRef {
4749 public:
48 typedef const char *iterator;
49 typedef const char *const_iterator;
5050 static const size_t npos = ~size_t(0);
51 typedef size_t size_type;
51
52 using iterator = const char *;
53 using const_iterator = const char *;
54 using size_type = size_t;
5255
5356 private:
5457 /// The start of the string, in an external buffer.
905908 // StringRefs can be treated like a POD type.
906909 template struct isPodLike;
907910 template <> struct isPodLike { static const bool value = true; };
908 }
909
910 #endif
911
912 } // end namespace llvm
913
914 #endif // LLVM_ADT_STRINGREF_H
None //===--- StringSet.h - The LLVM Compiler Driver -----------------*- C++ -*-===//
0 //===- StringSet.h - The LLVM Compiler Driver -------------------*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
1414 #define LLVM_ADT_STRINGSET_H
1515
1616 #include "llvm/ADT/StringMap.h"
17 #include "llvm/ADT/StringRef.h"
18 #include "llvm/Support/Allocator.h"
19 #include
20 #include
21 #include
1722
1823 namespace llvm {
1924
2025 /// StringSet - A wrapper for StringMap that provides set-like functionality.
21 template
22 class StringSet : public llvm::StringMap {
23 typedef llvm::StringMap base;
26 template
27 class StringSet : public StringMap {
28 using base = StringMap;
29
2430 public:
2531 StringSet() = default;
2632 StringSet(std::initializer_list S) {
3945 base::insert(std::make_pair(*It, '\0'));
4046 }
4147 };
42 }
48
49 } // end namespace llvm
4350
4451 #endif // LLVM_ADT_STRINGSET_H
2929 template
3030 class TinyPtrVector {
3131 public:
32 typedef SmallVector VecTy;
33 typedef typename VecTy::value_type value_type;
34 typedef PointerUnion PtrUnion;
32 using VecTy = SmallVector;
33 using value_type = typename VecTy::value_type;
34 using PtrUnion = PointerUnion;
3535
3636 private:
3737 PtrUnion Val;
166166 return Val.template get()->size();
167167 }
168168
169 typedef EltTy *iterator;
170 typedef const EltTy *const_iterator;
171 typedef std::reverse_iterator reverse_iterator;
172 typedef std::reverse_iterator const_reverse_iterator;
169 using iterator = EltTy *;
170 using const_iterator = const EltTy *;
171 using reverse_iterator = std::reverse_iterator;
172 using const_reverse_iterator = std::reverse_iterator;
173173
174174 iterator begin() {
175175 if (Val.template is())
None //===-- llvm/ADT/UniqueVector.h ---------------------------------*- C++ -*-===//
0 //===- llvm/ADT/UniqueVector.h ----------------------------------*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
2323 /// Entries can be fetched using operator[] with the entry ID.
2424 template class UniqueVector {
2525 public:
26 typedef typename std::vector VectorType;
27 typedef typename VectorType::iterator iterator;
28 typedef typename VectorType::const_iterator const_iterator;
26 using VectorType = typename std::vector;
27 using iterator = typename VectorType::iterator;
28 using const_iterator = typename VectorType::const_iterator;
2929
3030 private:
3131 // Map - Used to handle the correspondence of entry to ID.
3232 std::map Map;
3333
3434 // Vector - ID ordered vector of entries. Entries can be indexed by ID - 1.
35 //
3635 VectorType Vector;
3736
3837 public:
6766 }
6867
6968 /// operator[] - Returns a reference to the entry with the specified ID.
70 ///
7169 const T &operator[](unsigned ID) const {
7270 assert(ID-1 < size() && "ID is 0 or out of range!");
7371 return Vector[ID - 1];
8684 const_iterator end() const { return Vector.end(); }
8785
8886 /// size - Returns the number of entries in the vector.
89 ///
9087 size_t size() const { return Vector.size(); }
9188
9289 /// empty - Returns true if the vector is empty.
93 ///
9490 bool empty() const { return Vector.empty(); }
9591
9692 /// reset - Clears all the entries.
97 ///
9893 void reset() {
9994 Map.clear();
10095 Vector.resize(0, 0);
10196 }
10297 };
10398
104 } // End of namespace llvm
99 } // end namespace llvm
105100
106101 #endif // LLVM_ADT_UNIQUEVECTOR_H
None //===-- SimpleLoopUnswitch.cpp - Hoist loop-invariant control flow --------===//
0 //===- SimpleLoopUnswitch.cpp - Hoist loop-invariant control flow ---------===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
66 //
77 //===----------------------------------------------------------------------===//
88
9 #include "llvm/Transforms/Scalar/SimpleLoopUnswitch.h"
9 #include "llvm/ADT/DenseMap.h"
10 #include "llvm/ADT/Sequence.h"
11 #include "llvm/ADT/SetVector.h"
12 #include "llvm/ADT/SmallPtrSet.h"
13 #include "llvm/ADT/SmallVector.h"
14 #include "llvm/ADT/Statistic.h"
1015 #include "llvm/ADT/STLExtras.h"
11 #include "llvm/ADT/SmallPtrSet.h"
12 #include "llvm/ADT/Statistic.h"
16 #include "llvm/ADT/Twine.h"
1317 #include "llvm/Analysis/AssumptionCache.h"
18 #include "llvm/Analysis/LoopAnalysisManager.h"
1419 #include "llvm/Analysis/LoopInfo.h"
1520 #include "llvm/Analysis/LoopPass.h"
21 #include "llvm/IR/BasicBlock.h"
22 #include "llvm/IR/Constant.h"
1623 #include "llvm/IR/Constants.h"
1724 #include "llvm/IR/Dominators.h"
1825 #include "llvm/IR/Function.h"
26 #include "llvm/IR/InstrTypes.h"
27 #include "llvm/IR/Instruction.h"
1928 #include "llvm/IR/Instructions.h"
20 #include "llvm/Support/CommandLine.h"
29 #include "llvm/IR/Use.h"
30 #include "llvm/IR/Value.h"
31 #include "llvm/Pass.h"
32 #include "llvm/Support/Casting.h"
2133 #include "llvm/Support/Debug.h"
34 #include "llvm/Support/ErrorHandling.h"
35 #include "llvm/Support/GenericDomTree.h"
2236 #include "llvm/Support/raw_ostream.h"
2337 #include "llvm/Transforms/Utils/BasicBlockUtils.h"
24 #include "llvm/Transforms/Utils/Cloning.h"
25 #include "llvm/Transforms/Utils/Local.h"
26 #include "llvm/Transforms/Scalar/LoopPassManager.h"
2738 #include "llvm/Transforms/Utils/LoopUtils.h"
39 #include "llvm/Transforms/Scalar/SimpleLoopUnswitch.h"
40 #include
41 #include
42 #include
43 #include
2844
2945 #define DEBUG_TYPE "simple-loop-unswitch"
3046
173189 // When the loop exit is directly unswitched we just need to update the
174190 // incoming basic block. We loop to handle weird cases with repeated
175191 // incoming blocks, but expect to typically only have one operand here.
176 for (auto i : llvm::seq(0, PN->getNumOperands())) {
192 for (auto i : seq(0, PN->getNumOperands())) {
177193 assert(PN->getIncomingBlock(i) == &OldExitingBB &&
178194 "Found incoming block different from unique predecessor!");
179195 PN->setIncomingBlock(i, &OldPH);
687703 }
688704
689705 namespace {
706
690707 class SimpleLoopUnswitchLegacyPass : public LoopPass {
691708 public:
692709 static char ID; // Pass ID, replacement for typeid
710
693711 explicit SimpleLoopUnswitchLegacyPass() : LoopPass(ID) {
694712 initializeSimpleLoopUnswitchLegacyPassPass(
695713 *PassRegistry::getPassRegistry());
702720 getLoopAnalysisUsage(AU);
703721 }
704722 };
705 } // namespace
723
724 } // end anonymous namespace
706725
707726 bool SimpleLoopUnswitchLegacyPass::runOnLoop(Loop *L, LPPassManager &LPM) {
708727 if (skipLoop(L))