LLVM: include/llvm/ADT/SmallVector.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14#ifndef LLVM_ADT_SMALLVECTOR_H
15#define LLVM_ADT_SMALLVECTOR_H
16
20#include
21#include
22#include
23#include
24#include
25#include
26#include
27#include <initializer_list>
28#include
29#include
30#include
31#include
32#include <type_traits>
33#include
34
35namespace llvm {
36
37template class ArrayRef;
38
40
41template
43 typename std::iterator_traits::iterator_category,
44 std::input_iterator_tag>::value>;
45
46
47
48
49
50
51
52
53
55protected:
58
59
61 return std::numeric_limits<Size_T>::max();
62 }
63
67
68
69
70
72 size_t &NewCapacity);
73
74
75
76
78
79public:
82
83 [[nodiscard]] bool empty() const { return ; }
84
85protected:
86
87
88
89
94
95
96
97
98
104};
105
106template
108 std::conditional_t<sizeof(T) < 4 && sizeof(void *) >= 8, uint64_t,
110
111
117
118
119
120
121template <typename T, typename = void>
125
126protected:
127
128
129
131 return const_cast<void *>(reinterpret_cast<const void *>(
132 reinterpret_cast<const char *>(this) +
134 }
135
136
138
139 void grow_pod(size_t MinSize, size_t TSize) {
141 }
142
143
144
146
147
152
153
155
156 std::less<> LessThan;
157 return !LessThan(V, First) && LessThan(V, Last);
158 }
159
160
164
165
166
168
169 std::less<> LessThan;
171 !LessThan(this->end(), Last);
172 }
173
174
175
177
179 return true;
180
181
182 if (NewSize <= this->size())
183 return Elt < this->begin() + NewSize;
184
185
186 return NewSize <= this->capacity();
187 }
188
189
192 "Attempting to reference an element of the vector in an operation "
193 "that invalidates it");
194 }
195
196
197
201
202
203 template
205 if constexpr (std::is_pointer_v &&
206 std::is_same_v<
207 std::remove_const_t<std::remove_pointer_t>,
208 std::remove_const_t>) {
209 if (From == To)
210 return;
213 }
214 }
215
216
218 if constexpr (std::is_pointer_v &&
219 std::is_same_v<std::remove_cv_t<std::remove_pointer_t>,
220 T>) {
221 if (From == To)
222 return;
225 }
226 (void)From;
227 (void)To;
228 }
229
230
231
232 template
234 size_t N) {
235 size_t NewSize = This->size() + N;
237 return &Elt;
238
239 bool ReferencesStorage = false;
240 int64_t Index = -1;
241 if (!U::TakesParamByValue) {
242 if (LLVM_UNLIKELY(This->isReferenceToStorage(&Elt))) {
243 ReferencesStorage = true;
244 Index = &Elt - This->begin();
245 }
246 }
247 This->grow(NewSize);
248 return ReferencesStorage ? This->begin() + Index : &Elt;
249 }
250
251public:
257
260
265
269
270
275
276
281
286
288
289
291
293
296 return begin()[idx];
297 }
300 return begin()[idx];
301 }
302
305 return begin()[0];
306 }
309 return begin()[0];
310 }
311
314 return end()[-1];
315 }
318 return end()[-1];
319 }
320};
321
322
323
324
325
326
327
328
329
330template <typename T, bool = (std::is_trivially_copy_constructible::value) &&
331 (std::is_trivially_move_constructible::value) &&
332 std::is_trivially_destructible::value>
335
336protected:
339
341
343 while (S != E) {
344 --E;
345 E->~T();
346 }
347 }
348
349
350
351 template<typename It1, typename It2>
353 std::uninitialized_move(I, E, Dest);
354 }
355
356
357
358 template<typename It1, typename It2>
360 std::uninitialized_copy(I, E, Dest);
361 }
362
363
364
365
366 void grow(size_t MinSize = 0);
367
368
369
371
372
373
375
376
378
379
380
384
385
386
388 return const_cast<T *>(
390 }
391
394
396
397 size_t NewCapacity;
399 std::uninitialized_fill_n(NewElts, NumElts, Elt);
403 }
404
406
407 size_t NewCapacity;
409 ::new ((void *)(NewElts + this->size())) T(std::forward(Args)...);
413 return this->back();
414 }
415
416public:
419 ::new ((void *)this->end()) T(*EltPtr);
421 }
422
425 ::new ((void *)this->end()) T(::std::move(*EltPtr));
427 }
428
431 this->end()->~T();
432 }
433};
434
435
436template <typename T, bool TriviallyCopyable>
438 size_t NewCapacity;
442}
443
444template <typename T, bool TriviallyCopyable>
446 size_t MinSize, size_t &NewCapacity) {
447 return static_cast<T *>(
449 this->getFirstEl(), MinSize, sizeof(T), NewCapacity));
450}
451
452
453template <typename T, bool TriviallyCopyable>
455 T *NewElts) {
456
458
459
461}
462
463
464template <typename T, bool TriviallyCopyable>
466 T *NewElts, size_t NewCapacity) {
467
469 free(this->begin());
470
472}
473
474
475
476
477
478template
481
482protected:
483
484
486
487
488
489 using ValueParamT = std::conditional_t<TakesParamByValue, T, const T &>;
490
492
493
495
496
497
498 template<typename It1, typename It2>
503
504
505
506 template <typename It1, typename It2>
508 if constexpr (std::is_pointer_v && std::is_pointer_v &&
509 std::is_same_v<
510 std::remove_const_t<std::remove_pointer_t>,
511 std::remove_pointer_t>) {
512
513
514
515
517 std::memcpy(reinterpret_cast<void *>(Dest), I, (E - I) * sizeof(T));
518 } else {
519
520 std::uninitialized_copy(I, E, Dest);
521 }
522 }
523
524
525
526 void grow(size_t MinSize = 0) { this->grow_pod(MinSize, sizeof(T)); }
527
528
529
533
534
535
537 return const_cast<T *>(
539 }
540
541
543
545
546
548 this->grow(NumElts);
549 std::uninitialized_fill_n(this->begin(), NumElts, Elt);
551 }
552
554
555
556
557 push_back(T(std::forward(Args)...));
558 return this->back();
559 }
560
561public:
564 std::memcpy(reinterpret_cast<void *>(this->end()), EltPtr, sizeof(T));
566 }
567
569};
570
571
572
573template
576
577public:
582
583protected:
586
587
590
594 free(this->begin());
598 RHS.resetToSmall();
599 }
600
602
603
605 free(this->begin());
606 }
607
608public:
610
613 this->Size = 0;
614 }
615
616private:
617
619
620 template void resizeImpl(size_type N) {
622 return;
623
626 return;
627 }
628
630 for (auto I = this->end(), E = this->begin() + N; I != E; ++I)
631 if (ForOverwrite)
633 else
636 }
637
638public:
640
641
643
644
646 assert(this->size() >= N && "Cannot increase size with truncate");
649 }
650
653 return;
654
657 return;
658 }
659
660
662 }
663
668
673
675 T Result = ::std::move(this->back());
677 return Result;
678 }
679
681
682
683 template <typename ItTy, typename = EnableIfConvertibleToInputIterator>
686 size_type NumInputs = std::distance(in_start, in_end);
690 }
691
692
695 std::uninitialized_fill_n(this->end(), NumInputs, *EltPtr);
697 }
698
699 void append(std::initializer_list IL) {
700 append(IL.begin(), IL.end());
701 }
702
704
706
707 if (NumElts > this->capacity()) {
709 return;
710 }
711
712
713 std::fill_n(this->begin(), std::min(NumElts, this->size()), Elt);
714 if (NumElts > this->size())
715 std::uninitialized_fill_n(this->end(), NumElts - this->size(), Elt);
716 else if (NumElts < this->size())
719 }
720
721
722
723
724 template <typename ItTy, typename = EnableIfConvertibleToInputIterator>
728 append(in_start, in_end);
729 }
730
731 void assign(std::initializer_list IL) {
734 }
735
737
738 template <typename U,
739 typename = std::enable_if_t<std::is_convertible_v<U, T>>>
743
745
747
749
751
752 std::move(I+1, this->end(), I);
753
755 return(N);
756 }
757
759
762
764
766
768
771 return(N);
772 }
773
774private:
775 template iterator insert_one_impl(iterator I, ArgType &&Elt) {
776
777 static_assert(
778 std::is_same<std::remove_const_t<std::remove_reference_t>,
779 T>::value,
780 "ArgType must be derived from T!");
781
783 this->push_back(::std::forward(Elt));
784 return this->end()-1;
785 }
786
788
789
790 size_t Index = I - this->begin();
791 std::remove_reference_t *EltPtr =
793 I = this->begin() + Index;
794
795 ::new ((void*) this->end()) T(::std::move(this->back()));
796
797 std::move_backward(I, this->end()-1, this->end());
799
800
801
803 "ArgType must be 'T' when taking by value!");
805 ++EltPtr;
806
807 *I = ::std::forward(*EltPtr);
808 return I;
809 }
810
811public:
815
819
821
822 size_t InsertElt = I - this->begin();
823
824 if (I == this->end()) {
825 append(NumToInsert, Elt);
826 return this->begin()+InsertElt;
827 }
828
830
831
832
834
835
836 I = this->begin()+InsertElt;
837
838
839
840
841
842 if (size_t(this->end()-I) >= NumToInsert) {
844 append(std::move_iterator(this->end() - NumToInsert),
845 std::move_iterator(this->end()));
846
847
848 std::move_backward(I, OldEnd-NumToInsert, OldEnd);
849
850
851
853 EltPtr += NumToInsert;
854
855 std::fill_n(I, NumToInsert, *EltPtr);
856 return I;
857 }
858
859
860
861
862
865 size_t NumOverwritten = OldEnd-I;
867
868
869
871 EltPtr += NumToInsert;
872
873
874 std::fill_n(I, NumOverwritten, *EltPtr);
875
876
877 std::uninitialized_fill_n(OldEnd, NumToInsert - NumOverwritten, *EltPtr);
878 return I;
879 }
880
881 template <typename ItTy, typename = EnableIfConvertibleToInputIterator>
883
884 size_t InsertElt = I - this->begin();
885
886 if (I == this->end()) {
888 return this->begin()+InsertElt;
889 }
890
892
893
895
896 size_t NumToInsert = std::distance(From, To);
897
898
900
901
902 I = this->begin()+InsertElt;
903
904
905
906
907
908 if (size_t(this->end()-I) >= NumToInsert) {
910 append(std::move_iterator(this->end() - NumToInsert),
911 std::move_iterator(this->end()));
912
913
914 std::move_backward(I, OldEnd-NumToInsert, OldEnd);
915
916 std::copy(From, To, I);
917 return I;
918 }
919
920
921
922
923
926 size_t NumOverwritten = OldEnd-I;
928
929
930 for (T *J = I; NumOverwritten > 0; --NumOverwritten) {
931 *J = *From;
932 ++J; ++From;
933 }
934
935
937 return I;
938 }
939
941 insert(I, IL.begin(), IL.end());
942 }
943
947
948 ::new ((void *)this->end()) T(std::forward(Args)...);
950 return this->back();
951 }
952
954
956
958 if (this->size() != RHS.size()) return false;
959 return std::equal(this->begin(), this->end(), RHS.begin());
960 }
962 return !(*this == RHS);
963 }
964
966 return std::lexicographical_compare(this->begin(), this->end(),
968 }
972};
973
974template
976 if (this == &RHS) return;
977
978
983 return;
984 }
986 RHS.reserve(this->size());
987
988
989 size_t NumShared = this->size();
990 if (NumShared > RHS.size()) NumShared = RHS.size();
991 for (size_type i = 0; i != NumShared; ++i)
993
994
995 if (this->size() > RHS.size()) {
996 size_t EltDiff = this->size() - RHS.size();
998 RHS.set_size(RHS.size() + EltDiff);
1001 } else if (RHS.size() > this->size()) {
1002 size_t EltDiff = RHS.size() - this->size();
1006 RHS.set_size(NumShared);
1007 }
1008}
1009
1010template
1013
1014 if (this == &RHS) return *this;
1015
1016
1017
1018 size_t RHSSize = RHS.size();
1019 size_t CurSize = this->size();
1020 if (CurSize >= RHSSize) {
1021
1023 if (RHSSize)
1024 NewEnd = std::copy(RHS.begin(), RHS.begin()+RHSSize, this->begin());
1025 else
1026 NewEnd = this->begin();
1027
1028
1030
1031
1033 return *this;
1034 }
1035
1036
1037
1038
1039 if (this->capacity() < RHSSize) {
1040
1042 CurSize = 0;
1043 this->grow(RHSSize);
1044 } else if (CurSize) {
1045
1046 std::copy(RHS.begin(), RHS.begin()+CurSize, this->begin());
1047 }
1048
1049
1051 this->begin()+CurSize);
1052
1053
1055 return *this;
1056}
1057
1058template
1060
1061 if (this == &RHS) return *this;
1062
1063
1064 if (.isSmall()) {
1066 return *this;
1067 }
1068
1069
1070
1071 size_t RHSSize = RHS.size();
1072 size_t CurSize = this->size();
1073 if (CurSize >= RHSSize) {
1074
1076 if (RHSSize)
1077 NewEnd = std::move(RHS.begin(), RHS.end(), NewEnd);
1078
1079
1082
1083
1084 RHS.clear();
1085
1086 return *this;
1087 }
1088
1089
1090
1091
1092
1093 if (this->capacity() < RHSSize) {
1094
1096 CurSize = 0;
1097 this->grow(RHSSize);
1098 } else if (CurSize) {
1099
1100 std::move(RHS.begin(), RHS.begin()+CurSize, this->begin());
1101 }
1102
1103
1105 this->begin()+CurSize);
1106
1107
1109
1110 RHS.clear();
1111 return *this;
1112}
1113
1114
1115
1116template <typename T, unsigned N>
1120
1121
1122
1123
1125
1126
1127
1128
1130
1131
1132
1133
1134
1135
1137
1138
1139
1140
1141
1142
1143
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168 static_assert(
1169 sizeof(T) <= 256,
1170 "You are trying to use a default number of inlined elements for "
1171 "`SmallVector` but `sizeof(T)` is really big! Please use an "
1172 "explicit number of inlined elements with `SmallVector<T, N>` to make "
1173 "sure you really want that much inline storage.");
1174
1175
1176
1182};
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200template <typename T,
1204public:
1206
1211
1216
1221
1222 template <typename ItTy, typename = EnableIfConvertibleToInputIterator>
1226
1227 template
1230 this->append(R.begin(), R.end());
1231 }
1232
1236
1237 template <typename U,
1238 typename = std::enable_if_t<std::is_convertible_v<U, T>>>
1240 this->append(A.begin(), A.end());
1241 }
1242
1244 if (.empty())
1246 }
1247
1250 return *this;
1251 }
1252
1254 if (.empty())
1256 }
1257
1259 if (.empty())
1261 }
1262
1264 if (N) {
1266 return *this;
1267 }
1268
1269
1270 if (this == &RHS)
1271 return *this;
1272 if (RHS.empty()) {
1274 this->Size = 0;
1275 } else {
1277 }
1278 return *this;
1279 }
1280
1283 return *this;
1284 }
1285
1288 return *this;
1289 }
1290};
1291
1292template <typename T, unsigned N>
1294 return X.capacity_in_bytes();
1295}
1296
1297template
1299 std::remove_const_t<detail::ValueOfRange>;
1300
1301
1302
1303
1304template <unsigned Size, typename R>
1308template
1312
1313template <typename Out, unsigned Size, typename R>
1317
1321
1322
1324#if SIZE_MAX > UINT32_MAX
1326#endif
1327
1328
1347
1348}
1349
1350namespace std {
1351
1352
1353 template
1354 inline void
1358
1359
1360 template<typename T, unsigned N>
1361 inline void
1365
1366}
1367
1368#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define LLVM_UNLIKELY(EXPR)
#define LLVM_GSL_OWNER
LLVM_GSL_OWNER - Apply this to owning classes like SmallVector to enable lifetime warnings.
#define LLVM_LIKELY(EXPR)
This file defines DenseMapInfo traits for DenseMap.
#define offsetof(TYPE, MEMBER)
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
static TableGen::Emitter::OptClass< SkeletonEmitter > X("gen-skeleton-class", "Generate example skeleton class")
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
This is all the stuff common to all SmallVectors.
Definition SmallVector.h:54
LLVM_ABI void grow_pod(void *FirstEl, size_t MinSize, size_t TSize)
This is an implementation of the grow() method which only works on POD-like data types and is out of ...
LLVM_ABI void * mallocForGrow(void *FirstEl, size_t MinSize, size_t TSize, size_t &NewCapacity)
This is a helper for grow() that's out of line to reduce code duplication.
void set_allocation_range(void *Begin, size_t N)
Set the array data pointer to Begin and capacity to N.
Definition SmallVector.h:99
SmallVectorSizeType< T > Capacity
Definition SmallVector.h:57
SmallVectorSizeType< T > Size
Definition SmallVector.h:57
SmallVectorBase(void *FirstEl, size_t TotalCapacity)
Definition SmallVector.h:65
void set_size(size_t N)
Set the array size to N, which the current array must have enough capacity for.
Definition SmallVector.h:90
bool empty() const
Definition SmallVector.h:83
size_t capacity() const
Definition SmallVector.h:81
size_t size() const
Definition SmallVector.h:80
void * BeginX
Definition SmallVector.h:56
static constexpr size_t SizeTypeMax()
The maximum value of the Size_T used.
Definition SmallVector.h:60
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition SmallVector.h:574
void resize_for_overwrite(size_type N)
Like resize, but T is POD, the new values won't be initialized.
Definition SmallVector.h:642
void append(const SmallVectorImpl &RHS)
Definition SmallVector.h:703
T pop_back_val()
Definition SmallVector.h:674
void pop_back_n(size_type NumItems)
Definition SmallVector.h:669
void assign(const SmallVectorImpl &RHS)
Definition SmallVector.h:736
SmallVectorImpl(const SmallVectorImpl &)=delete
void assign(size_type NumElts, ValueParamT Elt)
Definition SmallVector.h:705
reference emplace_back(ArgTypes &&... Args)
Definition SmallVector.h:944
bool operator==(const SmallVectorImpl &RHS) const
Definition SmallVector.h:957
void reserve(size_type N)
Definition SmallVector.h:664
typename SuperClass::reference reference
Definition SmallVector.h:580
iterator insert(iterator I, size_type NumToInsert, ValueParamT Elt)
Definition SmallVector.h:820
iterator erase(const_iterator CI)
Definition SmallVector.h:744
iterator insert(iterator I, ItTy From, ItTy To)
Definition SmallVector.h:882
typename SuperClass::const_iterator const_iterator
Definition SmallVector.h:579
void assignRemote(SmallVectorImpl &&RHS)
Definition SmallVector.h:591
void append(ItTy in_start, ItTy in_end)
Add the specified range to the end of the SmallVector.
Definition SmallVector.h:684
void resize(size_type N, ValueParamT NV)
Definition SmallVector.h:651
iterator insert(iterator I, MemoryLocation &&Elt)
Definition SmallVector.h:812
bool operator>(const SmallVectorImpl &RHS) const
Definition SmallVector.h:969
bool operator<(const SmallVectorImpl &RHS) const
Definition SmallVector.h:965
iterator erase(const_iterator CS, const_iterator CE)
Definition SmallVector.h:758
void clear()
Definition SmallVector.h:611
bool operator!=(const SmallVectorImpl &RHS) const
Definition SmallVector.h:961
void truncate(size_type N)
Like resize, but requires that N is less than size().
Definition SmallVector.h:645
void assign(ItTy in_start, ItTy in_end)
Definition SmallVector.h:725
void assign(std::initializer_list< T > IL)
Definition SmallVector.h:731
void assign(ArrayRef< U > AR)
Definition SmallVector.h:740
SmallVectorImpl(unsigned N)
Definition SmallVector.h:588
void swap(SmallVectorImpl &RHS)
Definition SmallVector.h:975
typename SuperClass::iterator iterator
Definition SmallVector.h:578
bool operator<=(const SmallVectorImpl &RHS) const
Definition SmallVector.h:970
typename SuperClass::size_type size_type
Definition SmallVector.h:581
void append(std::initializer_list< T > IL)
Definition SmallVector.h:699
void append(size_type NumInputs, ValueParamT Elt)
Append NumInputs copies of Elt to the end.
Definition SmallVector.h:693
void resize(size_type N)
Definition SmallVector.h:639
SmallVectorImpl & operator=(const SmallVectorImpl &RHS)
Definition SmallVector.h:1012
void insert(iterator I, std::initializer_list< T > IL)
Definition SmallVector.h:940
SmallVectorImpl & operator=(SmallVectorImpl &&RHS)
Definition SmallVector.h:1059
typename SuperClass::ValueParamT ValueParamT
Definition SmallVector.h:585
bool operator>=(const SmallVectorImpl &RHS) const
Definition SmallVector.h:971
~SmallVectorImpl()
Definition SmallVector.h:601
iterator insert(iterator I, const T &Elt)
Definition SmallVector.h:816
static void uninitialized_copy(It1 I, It1 E, It2 Dest)
Copy the range [I, E) onto the uninitialized memory starting with "Dest", constructing elements into ...
Definition SmallVector.h:507
static void uninitialized_move(It1 I, It1 E, It2 Dest)
Move the range [I, E) onto the uninitialized memory starting with "Dest", constructing elements into ...
Definition SmallVector.h:499
std::conditional_t< TakesParamByValue, T, const T & > ValueParamT
Either const T& or T, depending on whether it's cheap enough to take parameters by value.
Definition SmallVector.h:489
SmallVectorTemplateBase(size_t Size)
Definition SmallVector.h:491
const T * reserveForParamAndGetAddress(const T &Elt, size_t N=1)
Reserve enough space to add one element, and return the updated element pointer in case it was a refe...
Definition SmallVector.h:530
void push_back(ValueParamT Elt)
Definition SmallVector.h:562
static void destroy_range(T *, T *)
Definition SmallVector.h:494
T * reserveForParamAndGetAddress(T &Elt, size_t N=1)
Reserve enough space to add one element, and return the updated element pointer in case it was a refe...
Definition SmallVector.h:536
static ValueParamT forward_value_param(ValueParamT V)
Copy V or return a reference, depending on ValueParamT.
Definition SmallVector.h:542
T & growAndEmplaceBack(ArgTypes &&... Args)
Definition SmallVector.h:553
static constexpr bool TakesParamByValue
True if it's cheap enough to take parameters by value.
Definition SmallVector.h:485
void growAndAssign(size_t NumElts, T Elt)
Definition SmallVector.h:544
void grow(size_t MinSize=0)
Double the size of the allocated memory, guaranteeing space for at least one more element or MinSize ...
Definition SmallVector.h:526
void pop_back()
Definition SmallVector.h:568
void moveElementsForGrow(T *NewElts)
Move existing elements over to the new allocation NewElts, the middle section of grow().
Definition SmallVector.h:454
static void uninitialized_copy(It1 I, It1 E, It2 Dest)
Copy the range [I, E) onto the uninitialized memory starting with "Dest", constructing elements as ne...
Definition SmallVector.h:359
static T && forward_value_param(T &&V)
Definition SmallVector.h:392
static void destroy_range(T *S, T *E)
Definition SmallVector.h:342
T * mallocForGrow(size_t MinSize, size_t &NewCapacity)
Create a new allocation big enough for MinSize and pass back its size in NewCapacity.
Definition SmallVector.h:445
static constexpr bool TakesParamByValue
Definition SmallVector.h:337
const T & ValueParamT
Definition SmallVector.h:338
SmallVectorTemplateBase(size_t Size)
Definition SmallVector.h:340
T * reserveForParamAndGetAddress(T &Elt, size_t N=1)
Reserve enough space to add one element, and return the updated element pointer in case it was a refe...
Definition SmallVector.h:387
void takeAllocationForGrow(T *NewElts, size_t NewCapacity)
Transfer ownership of the allocation, finishing up grow().
Definition SmallVector.h:465
void growAndAssign(size_t NumElts, const T &Elt)
Definition SmallVector.h:395
static const T & forward_value_param(const T &V)
Definition SmallVector.h:393
static void uninitialized_move(It1 I, It1 E, It2 Dest)
Move the range [I, E) into the uninitialized memory starting with "Dest", constructing elements as ne...
Definition SmallVector.h:352
void pop_back()
Definition SmallVector.h:429
void grow(size_t MinSize=0)
Grow the allocated memory (without initializing new elements), doubling the size of the allocated mem...
Definition SmallVector.h:437
void push_back(T &&Elt)
Definition SmallVector.h:423
const T * reserveForParamAndGetAddress(const T &Elt, size_t N=1)
Reserve enough space to add one element, and return the updated element pointer in case it was a refe...
Definition SmallVector.h:381
T & growAndEmplaceBack(ArgTypes &&... Args)
Definition SmallVector.h:405
void push_back(const T &Elt)
Definition SmallVector.h:417
bool isSmall() const
Return true if this is a smallvector which has not had dynamic memory allocated for it.
Definition SmallVector.h:145
iterator end()
Definition SmallVector.h:273
const_iterator end() const
Definition SmallVector.h:274
T * pointer
Definition SmallVector.h:263
size_t size_type
Definition SmallVector.h:252
size_t size() const
Definition SmallVector.h:80
reverse_iterator rbegin()
Definition SmallVector.h:277
static const T * reserveForParamAndGetAddressImpl(U *This, const T &Elt, size_t N)
Reserve enough space to add one element, and return the updated element pointer in case it was a refe...
Definition SmallVector.h:233
const T & const_reference
Definition SmallVector.h:262
SmallVectorTemplateCommon(size_t Size)
Definition SmallVector.h:137
reference front()
Definition SmallVector.h:303
const_reference operator[](size_type idx) const
Definition SmallVector.h:298
void resetToSmall()
Put this vector in a state of being small.
Definition SmallVector.h:148
bool isSafeToReferenceAfterResize(const void *Elt, size_t NewSize)
Return true unless Elt will be invalidated by resizing the vector to NewSize.
Definition SmallVector.h:176
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition SmallVector.h:258
pointer data()
Return a pointer to the vector's buffer, even if empty().
Definition SmallVector.h:290
T value_type
Definition SmallVector.h:254
bool isReferenceToRange(const void *V, const void *First, const void *Last) const
Return true if V is an internal reference to the given range.
Definition SmallVector.h:154
void grow_pod(size_t MinSize, size_t TSize)
Definition SmallVector.h:139
const T * const_pointer
Definition SmallVector.h:264
iterator begin()
Definition SmallVector.h:271
const_reverse_iterator rbegin() const
Definition SmallVector.h:278
T * iterator
Definition SmallVector.h:255
size_t capacity() const
Definition SmallVector.h:81
const T * const_iterator
Definition SmallVector.h:256
const_iterator begin() const
Definition SmallVector.h:272
T & reference
Definition SmallVector.h:261
reference operator[](size_type idx)
Definition SmallVector.h:294
size_t capacity_in_bytes() const
Definition SmallVector.h:287
size_type size_in_bytes() const
Definition SmallVector.h:282
ptrdiff_t difference_type
Definition SmallVector.h:253
size_type max_size() const
Definition SmallVector.h:283
bool isReferenceToStorage(const void *V) const
Return true if V is an internal reference to this vector.
Definition SmallVector.h:161
reference back()
Definition SmallVector.h:312
const_reference back() const
Definition SmallVector.h:316
reverse_iterator rend()
Definition SmallVector.h:279
bool empty() const
Definition SmallVector.h:83
bool isRangeInStorage(const void *First, const void *Last) const
Return true if First and Last form a valid (possibly empty) range in this vector's storage.
Definition SmallVector.h:167
const_reference front() const
Definition SmallVector.h:307
void assertSafeToAdd(const void *Elt, size_t N=1)
Check whether Elt will be invalidated by increasing the size of the vector by N.
Definition SmallVector.h:198
void assertSafeToReferenceAfterResize(const void *Elt, size_t NewSize)
Check whether Elt will be invalidated by resizing the vector to NewSize.
Definition SmallVector.h:190
void assertSafeToAddRange(ItTy From, ItTy To)
Check whether any part of the range will be invalidated by growing.
Definition SmallVector.h:217
std::reverse_iterator< iterator > reverse_iterator
Definition SmallVector.h:259
void assertSafeToReferenceAfterClear(ItTy From, ItTy To)
Check whether any part of the range will be invalidated by clearing.
Definition SmallVector.h:204
const_reverse_iterator rend() const
Definition SmallVector.h:280
const_pointer data() const
Return a pointer to the vector's buffer, even if empty().
Definition SmallVector.h:292
void * getFirstEl() const
Find the address of the first element.
Definition SmallVector.h:130
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition SmallVector.h:1203
SmallVector(std::initializer_list< T > IL)
Definition SmallVector.h:1233
SmallVector(SmallVectorImpl< T > &&RHS)
Definition SmallVector.h:1258
SmallVector(size_t Size)
Definition SmallVector.h:1212
SmallVector(ArrayRef< U > A)
Definition SmallVector.h:1239
SmallVector()
Definition SmallVector.h:1205
~SmallVector()
Definition SmallVector.h:1207
SmallVector(size_t Size, const T &Value)
Definition SmallVector.h:1217
SmallVector & operator=(const SmallVector &RHS)
Definition SmallVector.h:1248
SmallVector(const iterator_range< RangeTy > &R)
Definition SmallVector.h:1228
SmallVector & operator=(std::initializer_list< T > IL)
Definition SmallVector.h:1286
SmallVector(ItTy S, ItTy E)
Definition SmallVector.h:1223
SmallVector(SmallVector &&RHS)
Definition SmallVector.h:1253
SmallVector & operator=(SmallVector &&RHS)
Definition SmallVector.h:1263
SmallVector(const SmallVector &RHS)
Definition SmallVector.h:1243
SmallVector & operator=(SmallVectorImpl< T > &&RHS)
Definition SmallVector.h:1281
LLVM Value Representation.
A range adaptor for a pair of iterators.
This is an optimization pass for GlobalISel generic memory operations.
std::remove_const_t< detail::ValueOfRange< RangeType > > ValueTypeFromRangeType
Definition SmallVector.h:1298
constexpr auto adl_begin(RangeT &&range) -> decltype(adl_detail::begin_impl(std::forward< RangeT >(range)))
Returns the begin iterator to range using std::begin and function found through Argument-Dependent Lo...
std::enable_if_t< std::is_convertible< typename std::iterator_traits< Iterator >::iterator_category, std::input_iterator_tag >::value > EnableIfConvertibleToInputIterator
Definition SmallVector.h:42
BitVector::size_type capacity_in_bytes(const BitVector &X)
constexpr auto adl_end(RangeT &&range) -> decltype(adl_detail::end_impl(std::forward< RangeT >(range)))
Returns the end iterator to range using std::end and functions found through Argument-Dependent Looku...
SmallVector< ValueTypeFromRangeType< R >, Size > to_vector(R &&Range)
Given a range of type R, iterate the entire range and return a SmallVector with elements of the vecto...
Definition SmallVector.h:1305
std::conditional_t< sizeof(T)< 4 &&sizeof(void *) >=8, uint64_t, uint32_t > SmallVectorSizeType
Definition SmallVector.h:107
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
SmallVector< Out, Size > to_vector_of(R &&Range)
Definition SmallVector.h:1314
hash_code hash_combine_range(InputIteratorT first, InputIteratorT last)
Compute a hash_code for a sequence of values.
Implement std::hash so that hash_code can be used in STL containers.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Helper class for calculating the default number of inline elements for SmallVector.
Definition SmallVector.h:1136
static constexpr size_t kPreferredSmallVectorSizeof
Definition SmallVector.h:1144
static constexpr size_t value
Definition SmallVector.h:1180
static constexpr size_t NumElementsThatFit
Definition SmallVector.h:1179
static constexpr size_t PreferredInlineBytes
Definition SmallVector.h:1177
static bool isEqual(const SmallVector< T, N > &LHS, const SmallVector< T, N > &RHS)
Definition SmallVector.h:1342
static SmallVector< T, N > getTombstoneKey()
Definition SmallVector.h:1334
static SmallVector< T, N > getEmptyKey()
Definition SmallVector.h:1330
static unsigned getHashValue(const SmallVector< T, N > &V)
Definition SmallVector.h:1338
An information struct used to provide DenseMap with the various necessary components for a given valu...
Figure out the offset of the first element.
Definition SmallVector.h:112
char Base[sizeof(SmallVectorBase< SmallVectorSizeType< T > >)]
Definition SmallVector.h:114
char FirstEl[sizeof(T)]
Definition SmallVector.h:115
Storage for the SmallVector elements.
Definition SmallVector.h:1117
char InlineElts[N *sizeof(T)]
Definition SmallVector.h:1118