LLVM 22.0.0git
ArrayRef.h
Go to the documentation of this file.
1//===- ArrayRef.h - Array Reference Wrapper ---------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_ADT_ARRAYREF_H
10#define LLVM_ADT_ARRAYREF_H
11
12#include "llvm/ADT/Hashing.h"
14#include "llvm/ADT/STLExtras.h"
16#include <algorithm>
17#include <array>
18#include <cassert>
19#include <cstddef>
20#include <initializer_list>
21#include <iterator>
22#include <memory>
23#include <type_traits>
24#include <vector>
25
26namespace llvm {
27 template<typename T> class [[nodiscard]] MutableArrayRef;
28
29 /// ArrayRef - Represent a constant reference to an array (0 or more elements
30 /// consecutively in memory), i.e. a start pointer and a length. It allows
31 /// various APIs to take consecutive elements easily and conveniently.
32 ///
33 /// This class does not own the underlying data, it is expected to be used in
34 /// situations where the data resides in some other buffer, whose lifetime
35 /// extends past that of the ArrayRef. For this reason, it is not in general
36 /// safe to store an ArrayRef.
37 ///
38 /// This is intended to be trivially copyable, so it should be passed by
39 /// value.
40 template<typename T>
41 class LLVM_GSL_POINTER [[nodiscard]] ArrayRef {
42 public:
43 using value_type = T;
45 using const_pointer = const value_type *;
47 using const_reference = const value_type &;
50 using reverse_iterator = std::reverse_iterator<iterator>;
51 using const_reverse_iterator = std::reverse_iterator<const_iterator>;
52 using size_type = size_t;
54
55 private:
56 /// The start of the array, in an external buffer.
57 const T *Data = nullptr;
58
59 /// The number of elements.
60 size_type Length = 0;
61
62 public:
63 /// @name Constructors
64 /// @{
65
66 /// Construct an empty ArrayRef.
67 /*implicit*/ ArrayRef() = default;
68
69 /// Construct an empty ArrayRef from std::nullopt.
70 /*implicit*/ LLVM_DEPRECATED("Use {} or ArrayRef<T>() instead", "{}")
71 ArrayRef(std::nullopt_t) {}
72
73 /// Construct an ArrayRef from a single element.
74 /*implicit*/ ArrayRef(const T &OneElt LLVM_LIFETIME_BOUND)
75 : Data(&OneElt), Length(1) {}
76
77 /// Construct an ArrayRef from a pointer and length.
78 constexpr /*implicit*/ ArrayRef(const T *data LLVM_LIFETIME_BOUND,
79 size_t length)
80 : Data(data), Length(length) {}
81
82 /// Construct an ArrayRef from a range.
83 constexpr ArrayRef(const T *begin LLVM_LIFETIME_BOUND, const T *end)
84 : Data(begin), Length(end - begin) {
85 assert(begin <= end);
86 }
87
88 /// Construct an ArrayRef from a type that has a data() method that returns
89 /// a pointer convertible to const T *.
90 template <
91 typename C,
92 typename = std::enable_if_t<
93 std::conjunction_v<
94 std::is_convertible<
95 decltype(std::declval<const C &>().data()) *,
96 const T *const *>,
97 std::is_integral<decltype(std::declval<const C &>().size())>>,
98 void>>
99 /*implicit*/ constexpr ArrayRef(const C &V)
100 : Data(V.data()), Length(V.size()) {}
101
102 /// Construct an ArrayRef from a C array.
103 template <size_t N>
104 /*implicit*/ constexpr ArrayRef(const T (&Arr LLVM_LIFETIME_BOUND)[N])
105 : Data(Arr), Length(N) {}
106
107 /// Construct an ArrayRef from a std::initializer_list.
108#if LLVM_GNUC_PREREQ(9, 0, 0)
109// Disable gcc's warning in this constructor as it generates an enormous amount
110// of messages. Anyone using ArrayRef should already be aware of the fact that
111// it does not do lifetime extension.
112#pragma GCC diagnostic push
113#pragma GCC diagnostic ignored "-Winit-list-lifetime"
114#endif
115 constexpr /*implicit*/ ArrayRef(
116 std::initializer_list<T> Vec LLVM_LIFETIME_BOUND)
117 : Data(Vec.begin() == Vec.end() ? (T *)nullptr : Vec.begin()),
118 Length(Vec.size()) {}
119#if LLVM_GNUC_PREREQ(9, 0, 0)
120#pragma GCC diagnostic pop
121#endif
122
123 /// Construct an ArrayRef<T> from iterator_range<U*>. This uses SFINAE
124 /// to ensure that this is only used for iterator ranges over plain pointer
125 /// iterators.
126 template <typename U, typename = std::enable_if_t<
127 std::is_convertible_v<U *const *, T *const *>>>
129 : Data(Range.begin()), Length(llvm::size(Range)) {}
130
131 /// @}
132 /// @name Simple Operations
133 /// @{
134
135 iterator begin() const { return Data; }
136 iterator end() const { return Data + Length; }
137
138 reverse_iterator rbegin() const { return reverse_iterator(end()); }
139 reverse_iterator rend() const { return reverse_iterator(begin()); }
140
141 /// empty - Check if the array is empty.
142 bool empty() const { return Length == 0; }
143
144 const T *data() const { return Data; }
145
146 /// size - Get the array size.
147 size_t size() const { return Length; }
148
149 /// front - Get the first element.
150 const T &front() const {
151 assert(!empty());
152 return Data[0];
153 }
154
155 /// back - Get the last element.
156 const T &back() const {
157 assert(!empty());
158 return Data[Length-1];
159 }
160
161 /// consume_front() - Returns the first element and drops it from ArrayRef.
162 const T &consume_front() {
163 const T &Ret = front();
164 *this = drop_front();
165 return Ret;
166 }
167
168 /// consume_back() - Returns the last element and drops it from ArrayRef.
169 const T &consume_back() {
170 const T &Ret = back();
171 *this = drop_back();
172 return Ret;
173 }
174
175 // copy - Allocate copy in Allocator and return ArrayRef<T> to it.
176 template <typename Allocator> MutableArrayRef<T> copy(Allocator &A) {
177 T *Buff = A.template Allocate<T>(Length);
178 llvm::uninitialized_copy(*this, Buff);
179 return MutableArrayRef<T>(Buff, Length);
180 }
181
182 /// equals - Check for element-wise equality.
183 bool equals(ArrayRef RHS) const {
184 if (Length != RHS.Length)
185 return false;
186 return std::equal(begin(), end(), RHS.begin());
187 }
188
189 /// slice(n, m) - Chop off the first N elements of the array, and keep M
190 /// elements in the array.
191 ArrayRef<T> slice(size_t N, size_t M) const {
192 assert(N+M <= size() && "Invalid specifier");
193 return ArrayRef<T>(data()+N, M);
194 }
195
196 /// slice(n) - Chop off the first N elements of the array.
197 ArrayRef<T> slice(size_t N) const { return drop_front(N); }
198
199 /// Drop the first \p N elements of the array.
200 ArrayRef<T> drop_front(size_t N = 1) const {
201 assert(size() >= N && "Dropping more elements than exist");
202 return slice(N, size() - N);
203 }
204
205 /// Drop the last \p N elements of the array.
206 ArrayRef<T> drop_back(size_t N = 1) const {
207 assert(size() >= N && "Dropping more elements than exist");
208 return slice(0, size() - N);
209 }
210
211 /// Return a copy of *this with the first N elements satisfying the
212 /// given predicate removed.
213 template <class PredicateT> ArrayRef<T> drop_while(PredicateT Pred) const {
214 return ArrayRef<T>(find_if_not(*this, Pred), end());
215 }
216
217 /// Return a copy of *this with the first N elements not satisfying
218 /// the given predicate removed.
219 template <class PredicateT> ArrayRef<T> drop_until(PredicateT Pred) const {
220 return ArrayRef<T>(find_if(*this, Pred), end());
221 }
222
223 /// Return a copy of *this with only the first \p N elements.
224 ArrayRef<T> take_front(size_t N = 1) const {
225 if (N >= size())
226 return *this;
227 return drop_back(size() - N);
228 }
229
230 /// Return a copy of *this with only the last \p N elements.
231 ArrayRef<T> take_back(size_t N = 1) const {
232 if (N >= size())
233 return *this;
234 return drop_front(size() - N);
235 }
236
237 /// Return the first N elements of this Array that satisfy the given
238 /// predicate.
239 template <class PredicateT> ArrayRef<T> take_while(PredicateT Pred) const {
240 return ArrayRef<T>(begin(), find_if_not(*this, Pred));
241 }
242
243 /// Return the first N elements of this Array that don't satisfy the
244 /// given predicate.
245 template <class PredicateT> ArrayRef<T> take_until(PredicateT Pred) const {
246 return ArrayRef<T>(begin(), find_if(*this, Pred));
247 }
248
249 /// @}
250 /// @name Operator Overloads
251 /// @{
252 const T &operator[](size_t Index) const {
253 assert(Index < Length && "Invalid index!");
254 return Data[Index];
255 }
256
257 /// Disallow accidental assignment from a temporary.
258 ///
259 /// The declaration here is extra complicated so that "arrayRef = {}"
260 /// continues to select the move assignment operator.
261 template <typename U>
262 std::enable_if_t<std::is_same<U, T>::value, ArrayRef<T>> &
263 operator=(U &&Temporary) = delete;
264
265 /// Disallow accidental assignment from a temporary.
266 ///
267 /// The declaration here is extra complicated so that "arrayRef = {}"
268 /// continues to select the move assignment operator.
269 template <typename U>
270 std::enable_if_t<std::is_same<U, T>::value, ArrayRef<T>> &
271 operator=(std::initializer_list<U>) = delete;
272
273 /// @}
274 /// @name Expensive Operations
275 /// @{
276 std::vector<T> vec() const {
277 return std::vector<T>(Data, Data+Length);
278 }
279
280 /// @}
281 /// @name Conversion operators
282 /// @{
283 operator std::vector<T>() const {
284 return std::vector<T>(Data, Data+Length);
285 }
286
287 /// @}
288 };
289
290 /// MutableArrayRef - Represent a mutable reference to an array (0 or more
291 /// elements consecutively in memory), i.e. a start pointer and a length. It
292 /// allows various APIs to take and modify consecutive elements easily and
293 /// conveniently.
294 ///
295 /// This class does not own the underlying data, it is expected to be used in
296 /// situations where the data resides in some other buffer, whose lifetime
297 /// extends past that of the MutableArrayRef. For this reason, it is not in
298 /// general safe to store a MutableArrayRef.
299 ///
300 /// This is intended to be trivially copyable, so it should be passed by
301 /// value.
302 template<typename T>
303 class [[nodiscard]] MutableArrayRef : public ArrayRef<T> {
304 public:
305 using value_type = T;
307 using const_pointer = const value_type *;
312 using reverse_iterator = std::reverse_iterator<iterator>;
313 using const_reverse_iterator = std::reverse_iterator<const_iterator>;
314 using size_type = size_t;
316
317 /// Construct an empty MutableArrayRef.
318 /*implicit*/ MutableArrayRef() = default;
319
320 /// Construct a MutableArrayRef from a single element.
321 /*implicit*/ MutableArrayRef(T &OneElt) : ArrayRef<T>(OneElt) {}
322
323 /// Construct a MutableArrayRef from a pointer and length.
324 /*implicit*/ MutableArrayRef(T *data, size_t length)
325 : ArrayRef<T>(data, length) {}
326
327 /// Construct a MutableArrayRef from a range.
328 MutableArrayRef(T *begin, T *end) : ArrayRef<T>(begin, end) {}
329
330 /// Construct a MutableArrayRef from a type that has a data() method that
331 /// returns a pointer convertible to T *.
332 template <typename C,
333 typename = std::enable_if_t<
334 std::conjunction_v<
335 std::is_convertible<
336 decltype(std::declval<C &>().data()) *, T *const *>,
337 std::is_integral<decltype(std::declval<C &>().size())>>,
338 void>>
339 /*implicit*/ constexpr MutableArrayRef(const C &V) : ArrayRef<T>(V) {}
340
341 /// Construct a MutableArrayRef from a C array.
342 template <size_t N>
343 /*implicit*/ constexpr MutableArrayRef(T (&Arr)[N]) : ArrayRef<T>(Arr) {}
344
345 T *data() const { return const_cast<T*>(ArrayRef<T>::data()); }
346
347 iterator begin() const { return data(); }
348 iterator end() const { return data() + this->size(); }
349
350 reverse_iterator rbegin() const { return reverse_iterator(end()); }
351 reverse_iterator rend() const { return reverse_iterator(begin()); }
352
353 /// front - Get the first element.
354 T &front() const {
355 assert(!this->empty());
356 return data()[0];
357 }
358
359 /// back - Get the last element.
360 T &back() const {
361 assert(!this->empty());
362 return data()[this->size()-1];
363 }
364
365 /// consume_front() - Returns the first element and drops it from ArrayRef.
367 T &Ret = front();
368 *this = drop_front();
369 return Ret;
370 }
371
372 /// consume_back() - Returns the last element and drops it from ArrayRef.
374 T &Ret = back();
375 *this = drop_back();
376 return Ret;
377 }
378
379 /// slice(n, m) - Chop off the first N elements of the array, and keep M
380 /// elements in the array.
381 MutableArrayRef<T> slice(size_t N, size_t M) const {
382 assert(N + M <= this->size() && "Invalid specifier");
383 return MutableArrayRef<T>(this->data() + N, M);
384 }
385
386 /// slice(n) - Chop off the first N elements of the array.
387 MutableArrayRef<T> slice(size_t N) const {
388 return slice(N, this->size() - N);
389 }
390
391 /// Drop the first \p N elements of the array.
392 MutableArrayRef<T> drop_front(size_t N = 1) const {
393 assert(this->size() >= N && "Dropping more elements than exist");
394 return slice(N, this->size() - N);
395 }
396
397 MutableArrayRef<T> drop_back(size_t N = 1) const {
398 assert(this->size() >= N && "Dropping more elements than exist");
399 return slice(0, this->size() - N);
400 }
401
402 /// Return a copy of *this with the first N elements satisfying the
403 /// given predicate removed.
404 template <class PredicateT>
406 return MutableArrayRef<T>(find_if_not(*this, Pred), end());
407 }
408
409 /// Return a copy of *this with the first N elements not satisfying
410 /// the given predicate removed.
411 template <class PredicateT>
413 return MutableArrayRef<T>(find_if(*this, Pred), end());
414 }
415
416 /// Return a copy of *this with only the first \p N elements.
417 MutableArrayRef<T> take_front(size_t N = 1) const {
418 if (N >= this->size())
419 return *this;
420 return drop_back(this->size() - N);
421 }
422
423 /// Return a copy of *this with only the last \p N elements.
424 MutableArrayRef<T> take_back(size_t N = 1) const {
425 if (N >= this->size())
426 return *this;
427 return drop_front(this->size() - N);
428 }
429
430 /// Return the first N elements of this Array that satisfy the given
431 /// predicate.
432 template <class PredicateT>
434 return MutableArrayRef<T>(begin(), find_if_not(*this, Pred));
435 }
436
437 /// Return the first N elements of this Array that don't satisfy the
438 /// given predicate.
439 template <class PredicateT>
441 return MutableArrayRef<T>(begin(), find_if(*this, Pred));
442 }
443
444 /// @}
445 /// @name Operator Overloads
446 /// @{
447 T &operator[](size_t Index) const {
448 assert(Index < this->size() && "Invalid index!");
449 return data()[Index];
450 }
451 };
452
453 /// This is a MutableArrayRef that owns its array.
454 template <typename T> class OwningArrayRef : public MutableArrayRef<T> {
455 public:
456 OwningArrayRef() = default;
458
460 : MutableArrayRef<T>(new T[Data.size()], Data.size()) {
461 std::copy(Data.begin(), Data.end(), this->begin());
462 }
463
464 OwningArrayRef(OwningArrayRef &&Other) { *this = std::move(Other); }
465
467 delete[] this->data();
469 Other.MutableArrayRef<T>::operator=(MutableArrayRef<T>());
470 return *this;
471 }
472
473 ~OwningArrayRef() { delete[] this->data(); }
474 };
475
476 /// @name ArrayRef Deduction guides
477 /// @{
478 /// Deduction guide to construct an ArrayRef from a single element.
479 template <typename T> ArrayRef(const T &OneElt) -> ArrayRef<T>;
480
481 /// Deduction guide to construct an ArrayRef from a pointer and length
482 template <typename T> ArrayRef(const T *data, size_t length) -> ArrayRef<T>;
483
484 /// Deduction guide to construct an ArrayRef from a range
485 template <typename T> ArrayRef(const T *data, const T *end) -> ArrayRef<T>;
486
487 /// Deduction guide to construct an ArrayRef from a SmallVector
488 template <typename T> ArrayRef(const SmallVectorImpl<T> &Vec) -> ArrayRef<T>;
489
490 /// Deduction guide to construct an ArrayRef from a SmallVector
491 template <typename T, unsigned N>
493
494 /// Deduction guide to construct an ArrayRef from a std::vector
495 template <typename T> ArrayRef(const std::vector<T> &Vec) -> ArrayRef<T>;
496
497 /// Deduction guide to construct an ArrayRef from a std::array
498 template <typename T, std::size_t N>
499 ArrayRef(const std::array<T, N> &Vec) -> ArrayRef<T>;
500
501 /// Deduction guide to construct an ArrayRef from an ArrayRef (const)
502 template <typename T> ArrayRef(const ArrayRef<T> &Vec) -> ArrayRef<T>;
503
504 /// Deduction guide to construct an ArrayRef from an ArrayRef
505 template <typename T> ArrayRef(ArrayRef<T> &Vec) -> ArrayRef<T>;
506
507 /// Deduction guide to construct an ArrayRef from a C array.
508 template <typename T, size_t N> ArrayRef(const T (&Arr)[N]) -> ArrayRef<T>;
509
510 /// @}
511
512 /// @name MutableArrayRef Deduction guides
513 /// @{
514 /// Deduction guide to construct a `MutableArrayRef` from a single element
515 template <class T> MutableArrayRef(T &OneElt) -> MutableArrayRef<T>;
516
517 /// Deduction guide to construct a `MutableArrayRef` from a pointer and
518 /// length.
519 template <class T>
521
522 /// Deduction guide to construct a `MutableArrayRef` from a `SmallVector`.
523 template <class T>
525
526 template <class T, unsigned N>
528
529 /// Deduction guide to construct a `MutableArrayRef` from a `std::vector`.
530 template <class T> MutableArrayRef(std::vector<T> &Vec) -> MutableArrayRef<T>;
531
532 /// Deduction guide to construct a `MutableArrayRef` from a `std::array`.
533 template <class T, std::size_t N>
534 MutableArrayRef(std::array<T, N> &Vec) -> MutableArrayRef<T>;
535
536 /// Deduction guide to construct a `MutableArrayRef` from a C array.
537 template <typename T, size_t N>
539
540 /// @}
541 /// @name ArrayRef Comparison Operators
542 /// @{
543
544 template<typename T>
546 return LHS.equals(RHS);
547 }
548
549 template <typename T>
551 return ArrayRef<T>(LHS).equals(RHS);
552 }
553
554 template <typename T>
556 return !(LHS == RHS);
557 }
558
559 template <typename T>
561 return !(LHS == RHS);
562 }
563
564 template <typename T>
566 return std::lexicographical_compare(LHS.begin(), LHS.end(), RHS.begin(),
567 RHS.end());
568 }
569
570 template <typename T>
572 return RHS < LHS;
573 }
574
575 template <typename T>
577 return !(LHS > RHS);
578 }
579
580 template <typename T>
582 return !(LHS < RHS);
583 }
584
585 /// @}
586
587 template <typename T> hash_code hash_value(ArrayRef<T> S) {
588 return hash_combine_range(S);
589 }
590
591 // Provide DenseMapInfo for ArrayRefs.
592 template <typename T> struct DenseMapInfo<ArrayRef<T>, void> {
593 static inline ArrayRef<T> getEmptyKey() {
594 return ArrayRef<T>(
595 reinterpret_cast<const T *>(~static_cast<uintptr_t>(0)), size_t(0));
596 }
597
598 static inline ArrayRef<T> getTombstoneKey() {
599 return ArrayRef<T>(
600 reinterpret_cast<const T *>(~static_cast<uintptr_t>(1)), size_t(0));
601 }
602
603 static unsigned getHashValue(ArrayRef<T> Val) {
604 assert(Val.data() != getEmptyKey().data() &&
605 "Cannot hash the empty key!");
606 assert(Val.data() != getTombstoneKey().data() &&
607 "Cannot hash the tombstone key!");
608 return (unsigned)(hash_value(Val));
609 }
610
612 if (RHS.data() == getEmptyKey().data())
613 return LHS.data() == getEmptyKey().data();
614 if (RHS.data() == getTombstoneKey().data())
615 return LHS.data() == getTombstoneKey().data();
616 return LHS == RHS;
617 }
618 };
619
620} // end namespace llvm
621
622#endif // LLVM_ADT_ARRAYREF_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
#define LLVM_LIFETIME_BOUND
Definition: Compiler.h:435
#define LLVM_GSL_POINTER
LLVM_GSL_POINTER - Apply this to non-owning classes like StringRef to enable lifetime warnings.
Definition: Compiler.h:429
uint32_t Index
uint64_t Size
#define T
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
Basic Register Allocator
This file contains some templates that are useful if you are working with the STL at all.
This file defines the SmallVector class.
static Split data
Value * RHS
Value * LHS
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
std::enable_if_t< std::is_same< U, T >::value, ArrayRef< T > > & operator=(std::initializer_list< U >)=delete
Disallow accidental assignment from a temporary.
size_t size_type
Definition: ArrayRef.h:52
std::vector< T > vec() const
Definition: ArrayRef.h:276
bool equals(ArrayRef RHS) const
equals - Check for element-wise equality.
Definition: ArrayRef.h:183
ArrayRef< T > drop_while(PredicateT Pred) const
Return a copy of *this with the first N elements satisfying the given predicate removed.
Definition: ArrayRef.h:213
const T & back() const
back - Get the last element.
Definition: ArrayRef.h:156
ArrayRef< T > take_front(size_t N=1) const
Return a copy of *this with only the first N elements.
Definition: ArrayRef.h:224
constexpr ArrayRef(std::initializer_list< T > Vec LLVM_LIFETIME_BOUND)
Construct an ArrayRef from a std::initializer_list.
Definition: ArrayRef.h:115
MutableArrayRef< T > copy(Allocator &A)
Definition: ArrayRef.h:176
ArrayRef< T > drop_front(size_t N=1) const
Drop the first N elements of the array.
Definition: ArrayRef.h:200
ArrayRef< T > slice(size_t N) const
slice(n) - Chop off the first N elements of the array.
Definition: ArrayRef.h:197
reverse_iterator rend() const
Definition: ArrayRef.h:139
const T & front() const
front - Get the first element.
Definition: ArrayRef.h:150
ArrayRef< T > take_while(PredicateT Pred) const
Return the first N elements of this Array that satisfy the given predicate.
Definition: ArrayRef.h:239
ArrayRef(const T &OneElt LLVM_LIFETIME_BOUND)
Construct an ArrayRef from a single element.
Definition: ArrayRef.h:74
constexpr ArrayRef(const T *begin LLVM_LIFETIME_BOUND, const T *end)
Construct an ArrayRef from a range.
Definition: ArrayRef.h:83
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition: ArrayRef.h:51
iterator end() const
Definition: ArrayRef.h:136
ArrayRef< T > take_until(PredicateT Pred) const
Return the first N elements of this Array that don't satisfy the given predicate.
Definition: ArrayRef.h:245
ArrayRef< T > drop_until(PredicateT Pred) const
Return a copy of *this with the first N elements not satisfying the given predicate removed.
Definition: ArrayRef.h:219
size_t size() const
size - Get the array size.
Definition: ArrayRef.h:147
ArrayRef()=default
Construct an empty ArrayRef.
const T & consume_back()
consume_back() - Returns the last element and drops it from ArrayRef.
Definition: ArrayRef.h:169
std::reverse_iterator< iterator > reverse_iterator
Definition: ArrayRef.h:50
ArrayRef< T > drop_back(size_t N=1) const
Drop the last N elements of the array.
Definition: ArrayRef.h:206
iterator begin() const
Definition: ArrayRef.h:135
ArrayRef< T > take_back(size_t N=1) const
Return a copy of *this with only the last N elements.
Definition: ArrayRef.h:231
bool empty() const
empty - Check if the array is empty.
Definition: ArrayRef.h:142
constexpr ArrayRef(const T(&Arr LLVM_LIFETIME_BOUND)[N])
Construct an ArrayRef from a C array.
Definition: ArrayRef.h:104
ArrayRef(const iterator_range< U * > &Range)
Construct an ArrayRef<T> from iterator_range<U*>.
Definition: ArrayRef.h:128
constexpr ArrayRef(const T *data LLVM_LIFETIME_BOUND, size_t length)
Construct an ArrayRef from a pointer and length.
Definition: ArrayRef.h:78
const T & operator[](size_t Index) const
Definition: ArrayRef.h:252
const T * data() const
Definition: ArrayRef.h:144
LLVM_DEPRECATED("Use {} or ArrayRef<T>() instead", "{}") ArrayRef(std
Construct an empty ArrayRef from std::nullopt.
Definition: ArrayRef.h:70
constexpr ArrayRef(const C &V)
Construct an ArrayRef from a type that has a data() method that returns a pointer convertible to cons...
Definition: ArrayRef.h:99
std::enable_if_t< std::is_same< U, T >::value, ArrayRef< T > > & operator=(U &&Temporary)=delete
Disallow accidental assignment from a temporary.
reverse_iterator rbegin() const
Definition: ArrayRef.h:138
ArrayRef< T > slice(size_t N, size_t M) const
slice(n, m) - Chop off the first N elements of the array, and keep M elements in the array.
Definition: ArrayRef.h:191
const T & consume_front()
consume_front() - Returns the first element and drops it from ArrayRef.
Definition: ArrayRef.h:162
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
Definition: ArrayRef.h:303
T * data() const
Definition: ArrayRef.h:345
MutableArrayRef< T > take_until(PredicateT Pred) const
Return the first N elements of this Array that don't satisfy the given predicate.
Definition: ArrayRef.h:440
MutableArrayRef(T &OneElt)
Construct a MutableArrayRef from a single element.
Definition: ArrayRef.h:321
MutableArrayRef< T > drop_front(size_t N=1) const
Drop the first N elements of the array.
Definition: ArrayRef.h:392
T & consume_front()
consume_front() - Returns the first element and drops it from ArrayRef.
Definition: ArrayRef.h:366
T & consume_back()
consume_back() - Returns the last element and drops it from ArrayRef.
Definition: ArrayRef.h:373
MutableArrayRef< T > take_back(size_t N=1) const
Return a copy of *this with only the last N elements.
Definition: ArrayRef.h:424
reverse_iterator rbegin() const
Definition: ArrayRef.h:350
MutableArrayRef(T *begin, T *end)
Construct a MutableArrayRef from a range.
Definition: ArrayRef.h:328
MutableArrayRef< T > slice(size_t N) const
slice(n) - Chop off the first N elements of the array.
Definition: ArrayRef.h:387
MutableArrayRef(T *data, size_t length)
Construct a MutableArrayRef from a pointer and length.
Definition: ArrayRef.h:324
MutableArrayRef()=default
Construct an empty MutableArrayRef.
T & front() const
front - Get the first element.
Definition: ArrayRef.h:354
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition: ArrayRef.h:313
iterator end() const
Definition: ArrayRef.h:348
iterator begin() const
Definition: ArrayRef.h:347
T & operator[](size_t Index) const
Definition: ArrayRef.h:447
T & back() const
back - Get the last element.
Definition: ArrayRef.h:360
constexpr MutableArrayRef(const C &V)
Construct a MutableArrayRef from a type that has a data() method that returns a pointer convertible t...
Definition: ArrayRef.h:339
constexpr MutableArrayRef(T(&Arr)[N])
Construct a MutableArrayRef from a C array.
Definition: ArrayRef.h:343
MutableArrayRef< T > drop_back(size_t N=1) const
Definition: ArrayRef.h:397
MutableArrayRef< T > take_while(PredicateT Pred) const
Return the first N elements of this Array that satisfy the given predicate.
Definition: ArrayRef.h:433
MutableArrayRef< T > slice(size_t N, size_t M) const
slice(n, m) - Chop off the first N elements of the array, and keep M elements in the array.
Definition: ArrayRef.h:381
MutableArrayRef< T > drop_while(PredicateT Pred) const
Return a copy of *this with the first N elements satisfying the given predicate removed.
Definition: ArrayRef.h:405
reverse_iterator rend() const
Definition: ArrayRef.h:351
MutableArrayRef< T > drop_until(PredicateT Pred) const
Return a copy of *this with the first N elements not satisfying the given predicate removed.
Definition: ArrayRef.h:412
MutableArrayRef< T > take_front(size_t N=1) const
Return a copy of *this with only the first N elements.
Definition: ArrayRef.h:417
std::reverse_iterator< iterator > reverse_iterator
Definition: ArrayRef.h:312
This is a MutableArrayRef that owns its array.
Definition: ArrayRef.h:454
OwningArrayRef & operator=(OwningArrayRef &&Other)
Definition: ArrayRef.h:466
OwningArrayRef(OwningArrayRef &&Other)
Definition: ArrayRef.h:464
OwningArrayRef()=default
OwningArrayRef(ArrayRef< T > Data)
Definition: ArrayRef.h:459
OwningArrayRef(size_t Size)
Definition: ArrayRef.h:457
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: SmallVector.h:574
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1197
An opaque object representing a hash code.
Definition: Hashing.h:76
A range adaptor for a pair of iterators.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ Length
Definition: DWP.cpp:477
bool operator<(int64_t V1, const APSInt &V2)
Definition: APSInt.h:362
hash_code hash_value(const FixedPointSemantics &Val)
Definition: APFixedPoint.h:137
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
Definition: STLExtras.h:1702
bool operator!=(uint64_t V1, const APInt &V2)
Definition: APInt.h:2113
bool operator>=(int64_t V1, const APSInt &V2)
Definition: APSInt.h:361
auto uninitialized_copy(R &&Src, IterTy Dst)
Definition: STLExtras.h:2072
bool operator==(const AddressRangeValuePair &LHS, const AddressRangeValuePair &RHS)
bool operator>(int64_t V1, const APSInt &V2)
Definition: APSInt.h:363
auto find_if_not(R &&Range, UnaryPredicate P)
Definition: STLExtras.h:1782
MutableArrayRef(T &OneElt) -> MutableArrayRef< T >
@ Other
Any other memory.
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1777
hash_code hash_combine_range(InputIteratorT first, InputIteratorT last)
Compute a hash_code for a sequence of values.
Definition: Hashing.h:469
bool operator<=(int64_t V1, const APSInt &V2)
Definition: APSInt.h:360
Implement std::hash so that hash_code can be used in STL containers.
Definition: BitVector.h:856
#define N
static bool isEqual(ArrayRef< T > LHS, ArrayRef< T > RHS)
Definition: ArrayRef.h:611
static ArrayRef< T > getTombstoneKey()
Definition: ArrayRef.h:598
static unsigned getHashValue(ArrayRef< T > Val)
Definition: ArrayRef.h:603
static ArrayRef< T > getEmptyKey()
Definition: ArrayRef.h:593
An information struct used to provide DenseMap with the various necessary components for a given valu...
Definition: DenseMapInfo.h:54