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