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