Movatterモバイル変換


[0]ホーム

URL:


LLVM 20.0.0git
SmallVector.h
Go to the documentation of this file.
1//===- llvm/ADT/SmallVector.h - 'Normally small' vectors --------*- 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/// \file
10/// This file defines the SmallVector class.
11///
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_ADT_SMALLVECTOR_H
15#define LLVM_ADT_SMALLVECTOR_H
16
17#include "llvm/Support/Compiler.h"
18#include <algorithm>
19#include <cassert>
20#include <cstddef>
21#include <cstdint>
22#include <cstdlib>
23#include <cstring>
24#include <functional>
25#include <initializer_list>
26#include <iterator>
27#include <limits>
28#include <memory>
29#include <new>
30#include <type_traits>
31#include <utility>
32
33namespacellvm {
34
35template <typename T>classArrayRef;
36
37template <typename IteratorT>classiterator_range;
38
39template <class Iterator>
40usingEnableIfConvertibleToInputIterator = std::enable_if_t<std::is_convertible<
41typename std::iterator_traits<Iterator>::iterator_category,
42 std::input_iterator_tag>::value>;
43
44/// This is all the stuff common to all SmallVectors.
45///
46/// The template parameter specifies the type which should be used to hold the
47/// Size and Capacity of the SmallVector, so it can be adjusted.
48/// Using 32 bit size is desirable to shrink the size of the SmallVector.
49/// Using 64 bit size is desirable for cases like SmallVector<char>, where a
50/// 32 bit size would limit the vector to ~4GB. SmallVectors are used for
51/// buffering bitcode output - which can exceed 4GB.
52template <class Size_T>classSmallVectorBase {
53protected:
54void *BeginX;
55 Size_TSize = 0,Capacity;
56
57 /// The maximum value of the Size_T used.
58staticconstexprsize_tSizeTypeMax() {
59return std::numeric_limits<Size_T>::max();
60 }
61
62SmallVectorBase() =delete;
63SmallVectorBase(void *FirstEl,size_t TotalCapacity)
64 :BeginX(FirstEl),Capacity(static_cast<Size_T>(TotalCapacity)) {}
65
66 /// This is a helper for \a grow() that's out of line to reduce code
67 /// duplication. This function will report a fatal error if it can't grow at
68 /// least to \p MinSize.
69void *mallocForGrow(void *FirstEl,size_t MinSize,size_t TSize,
70size_t &NewCapacity);
71
72 /// This is an implementation of the grow() method which only works
73 /// on POD-like data types and is out of line to reduce code duplication.
74 /// This function will report a fatal error if it cannot increase capacity.
75voidgrow_pod(void *FirstEl,size_t MinSize,size_t TSize);
76
77public:
78size_tsize() const{returnSize; }
79size_tcapacity() const{returnCapacity; }
80
81 [[nodiscard]]boolempty() const{return !Size; }
82
83protected:
84 /// Set the array size to \p N, which the current array must have enough
85 /// capacity for.
86 ///
87 /// This does not construct or destroy any elements in the vector.
88voidset_size(size_tN) {
89assert(N <=capacity());// implies no overflow in assignment
90Size =static_cast<Size_T>(N);
91 }
92
93 /// Set the array data pointer to \p Begin and capacity to \p N.
94 ///
95 /// This does not construct or destroy any elements in the vector.
96// This does not clean up any existing allocation.
97voidset_allocation_range(void *Begin,size_tN) {
98assert(N <=SizeTypeMax());
99BeginX = Begin;
100Capacity =static_cast<Size_T>(N);
101 }
102};
103
104template <class T>
105usingSmallVectorSizeType =
106 std::conditional_t<sizeof(T) < 4 &&sizeof(void *) >= 8,uint64_t,
107uint32_t>;
108
109/// Figure out the offset of the first element.
110template <class T,typename =void>structSmallVectorAlignmentAndSize {
111alignas(SmallVectorBase<SmallVectorSizeType<T>>)charBase[sizeof(
112SmallVectorBase<SmallVectorSizeType<T>>)];
113alignas(T)charFirstEl[sizeof(T)];
114};
115
116/// This is the part of SmallVectorTemplateBase which does not depend on whether
117/// the type T is a POD. The extra dummy template argument is used by ArrayRef
118/// to avoid unnecessarily requiring T to be complete.
119template <typename T,typename =void>
120classSmallVectorTemplateCommon
121 :publicSmallVectorBase<SmallVectorSizeType<T>> {
122usingBase =SmallVectorBase<SmallVectorSizeType<T>>;
123
124protected:
125 /// Find the address of the first element. For this pointer math to be valid
126 /// with small-size of 0 for T with lots of alignment, it's important that
127 /// SmallVectorStorage is properly-aligned even for small-size of 0.
128void *getFirstEl() const{
129returnconst_cast<void *>(reinterpret_cast<constvoid *>(
130reinterpret_cast<constchar *>(this) +
131offsetof(SmallVectorAlignmentAndSize<T>, FirstEl)));
132 }
133// Space after 'FirstEl' is clobbered, do not add any instance vars after it.
134
135SmallVectorTemplateCommon(size_tSize) :Base(getFirstEl(),Size) {}
136
137voidgrow_pod(size_t MinSize,size_t TSize) {
138Base::grow_pod(getFirstEl(), MinSize, TSize);
139 }
140
141 /// Return true if this is a smallvector which has not had dynamic
142 /// memory allocated for it.
143boolisSmall() const{return this->BeginX ==getFirstEl(); }
144
145 /// Put this vector in a state of being small.
146voidresetToSmall() {
147 this->BeginX =getFirstEl();
148 this->Size = this->Capacity = 0;// FIXME: Setting Capacity to 0 is suspect.
149 }
150
151 /// Return true if V is an internal reference to the given range.
152boolisReferenceToRange(constvoid *V,constvoid *First,constvoid *Last) const{
153// Use std::less to avoid UB.
154 std::less<> LessThan;
155return !LessThan(V,First) && LessThan(V,Last);
156 }
157
158 /// Return true if V is an internal reference to this vector.
159boolisReferenceToStorage(constvoid *V) const{
160returnisReferenceToRange(V, this->begin(), this->end());
161 }
162
163 /// Return true if First and Last form a valid (possibly empty) range in this
164 /// vector's storage.
165boolisRangeInStorage(constvoid *First,constvoid *Last) const{
166// Use std::less to avoid UB.
167 std::less<> LessThan;
168return !LessThan(First, this->begin()) && !LessThan(Last,First) &&
169 !LessThan(this->end(), Last);
170 }
171
172 /// Return true unless Elt will be invalidated by resizing the vector to
173 /// NewSize.
174boolisSafeToReferenceAfterResize(constvoid *Elt,size_t NewSize) {
175// Past the end.
176if (LLVM_LIKELY(!isReferenceToStorage(Elt)))
177returntrue;
178
179// Return false if Elt will be destroyed by shrinking.
180if (NewSize <= this->size())
181return Elt < this->begin() + NewSize;
182
183// Return false if we need to grow.
184return NewSize <= this->capacity();
185 }
186
187 /// Check whether Elt will be invalidated by resizing the vector to NewSize.
188voidassertSafeToReferenceAfterResize(constvoid *Elt,size_t NewSize) {
189assert(isSafeToReferenceAfterResize(Elt, NewSize) &&
190"Attempting to reference an element of the vector in an operation "
191"that invalidates it");
192 }
193
194 /// Check whether Elt will be invalidated by increasing the size of the
195 /// vector by N.
196voidassertSafeToAdd(constvoid *Elt,size_tN = 1) {
197 this->assertSafeToReferenceAfterResize(Elt, this->size() +N);
198 }
199
200 /// Check whether any part of the range will be invalidated by clearing.
201voidassertSafeToReferenceAfterClear(constT *From,constT *To) {
202if (From == To)
203return;
204 this->assertSafeToReferenceAfterResize(From, 0);
205 this->assertSafeToReferenceAfterResize(To - 1, 0);
206 }
207template <
208classItTy,
209 std::enable_if_t<!std::is_same<std::remove_const_t<ItTy>,T *>::value,
210bool> =false>
211voidassertSafeToReferenceAfterClear(ItTy,ItTy) {}
212
213 /// Check whether any part of the range will be invalidated by growing.
214voidassertSafeToAddRange(constT *From,constT *To) {
215if (From == To)
216return;
217 this->assertSafeToAdd(From, To -From);
218 this->assertSafeToAdd(To - 1, To -From);
219 }
220template <
221classItTy,
222 std::enable_if_t<!std::is_same<std::remove_const_t<ItTy>,T *>::value,
223bool> =false>
224voidassertSafeToAddRange(ItTy,ItTy) {}
225
226 /// Reserve enough space to add one element, and return the updated element
227 /// pointer in case it was a reference to the storage.
228template <class U>
229staticconstT *reserveForParamAndGetAddressImpl(U *This,constT &Elt,
230size_tN) {
231size_t NewSize = This->size() +N;
232if (LLVM_LIKELY(NewSize <= This->capacity()))
233return &Elt;
234
235bool ReferencesStorage =false;
236 int64_tIndex = -1;
237if (!U::TakesParamByValue) {
238if (LLVM_UNLIKELY(This->isReferenceToStorage(&Elt))) {
239 ReferencesStorage =true;
240Index = &Elt - This->begin();
241 }
242 }
243 This->grow(NewSize);
244return ReferencesStorage ? This->begin() +Index : &Elt;
245 }
246
247public:
248usingsize_type = size_t;
249usingdifference_type =ptrdiff_t;
250usingvalue_type =T;
251usingiterator =T *;
252usingconst_iterator =constT *;
253
254usingconst_reverse_iterator = std::reverse_iterator<const_iterator>;
255usingreverse_iterator = std::reverse_iterator<iterator>;
256
257usingreference =T &;
258usingconst_reference =constT &;
259usingpointer =T *;
260usingconst_pointer =constT *;
261
262usingBase::capacity;
263usingBase::empty;
264usingBase::size;
265
266// forward iterator creation methods.
267iteratorbegin() {return (iterator)this->BeginX; }
268const_iteratorbegin() const{return (const_iterator)this->BeginX; }
269iteratorend() {returnbegin() +size(); }
270const_iteratorend() const{returnbegin() +size(); }
271
272// reverse iterator creation methods.
273reverse_iteratorrbegin() {returnreverse_iterator(end()); }
274const_reverse_iteratorrbegin() const{returnconst_reverse_iterator(end()); }
275reverse_iteratorrend() {returnreverse_iterator(begin()); }
276const_reverse_iteratorrend() const{returnconst_reverse_iterator(begin());}
277
278size_typesize_in_bytes() const{returnsize() *sizeof(T); }
279size_typemax_size() const{
280return std::min(this->SizeTypeMax(),size_type(-1) /sizeof(T));
281 }
282
283size_tcapacity_in_bytes() const{returncapacity() *sizeof(T); }
284
285 /// Return a pointer to the vector's buffer, even if empty().
286pointerdata() {returnpointer(begin()); }
287 /// Return a pointer to the vector's buffer, even if empty().
288const_pointerdata() const{returnconst_pointer(begin()); }
289
290referenceoperator[](size_type idx) {
291assert(idx <size());
292returnbegin()[idx];
293 }
294const_referenceoperator[](size_type idx) const{
295assert(idx <size());
296returnbegin()[idx];
297 }
298
299referencefront() {
300assert(!empty());
301returnbegin()[0];
302 }
303const_referencefront() const{
304assert(!empty());
305returnbegin()[0];
306 }
307
308referenceback() {
309assert(!empty());
310returnend()[-1];
311 }
312const_referenceback() const{
313assert(!empty());
314returnend()[-1];
315 }
316};
317
318/// SmallVectorTemplateBase<TriviallyCopyable = false> - This is where we put
319/// method implementations that are designed to work with non-trivial T's.
320///
321/// We approximate is_trivially_copyable with trivial move/copy construction and
322/// trivial destruction. While the standard doesn't specify that you're allowed
323/// copy these types with memcpy, there is no way for the type to observe this.
324/// This catches the important case of std::pair<POD, POD>, which is not
325/// trivially assignable.
326template <typename T,bool = (std::is_trivially_copy_constructible<T>::value) &&
327 (std::is_trivially_move_constructible<T>::value) &&
328 std::is_trivially_destructible<T>::value>
329classSmallVectorTemplateBase :publicSmallVectorTemplateCommon<T> {
330friendclassSmallVectorTemplateCommon<T>;
331
332protected:
333staticconstexprboolTakesParamByValue =false;
334usingValueParamT =constT &;
335
336SmallVectorTemplateBase(size_tSize) :SmallVectorTemplateCommon<T>(Size) {}
337
338staticvoiddestroy_range(T *S,T *E) {
339while (S !=E) {
340 --E;
341E->~T();
342 }
343 }
344
345 /// Move the range [I, E) into the uninitialized memory starting with "Dest",
346 /// constructing elements as needed.
347template<typename It1,typename It2>
348staticvoiduninitialized_move(It1I, It1E, It2 Dest) {
349 std::uninitialized_move(I,E, Dest);
350 }
351
352 /// Copy the range [I, E) onto the uninitialized memory starting with "Dest",
353 /// constructing elements as needed.
354template<typename It1,typename It2>
355staticvoiduninitialized_copy(It1I, It1E, It2 Dest) {
356 std::uninitialized_copy(I,E, Dest);
357 }
358
359 /// Grow the allocated memory (without initializing new elements), doubling
360 /// the size of the allocated memory. Guarantees space for at least one more
361 /// element, or MinSize more elements if specified.
362voidgrow(size_t MinSize = 0);
363
364 /// Create a new allocation big enough for \p MinSize and pass back its size
365 /// in \p NewCapacity. This is the first section of \a grow().
366T *mallocForGrow(size_t MinSize,size_t &NewCapacity);
367
368 /// Move existing elements over to the new allocation \p NewElts, the middle
369 /// section of \a grow().
370voidmoveElementsForGrow(T *NewElts);
371
372 /// Transfer ownership of the allocation, finishing up \a grow().
373voidtakeAllocationForGrow(T *NewElts,size_t NewCapacity);
374
375 /// Reserve enough space to add one element, and return the updated element
376 /// pointer in case it was a reference to the storage.
377constT *reserveForParamAndGetAddress(constT &Elt,size_tN = 1) {
378return this->reserveForParamAndGetAddressImpl(this, Elt,N);
379 }
380
381 /// Reserve enough space to add one element, and return the updated element
382 /// pointer in case it was a reference to the storage.
383T *reserveForParamAndGetAddress(T &Elt,size_tN = 1) {
384returnconst_cast<T *>(
385 this->reserveForParamAndGetAddressImpl(this, Elt,N));
386 }
387
388staticT &&forward_value_param(T &&V) {return std::move(V); }
389staticconstT &forward_value_param(constT &V) {return V; }
390
391voidgrowAndAssign(size_t NumElts,constT &Elt) {
392// Grow manually in case Elt is an internal reference.
393size_t NewCapacity;
394T *NewElts =mallocForGrow(NumElts, NewCapacity);
395 std::uninitialized_fill_n(NewElts, NumElts, Elt);
396 this->destroy_range(this->begin(), this->end());
397takeAllocationForGrow(NewElts, NewCapacity);
398 this->set_size(NumElts);
399 }
400
401template <typename... ArgTypes>T &growAndEmplaceBack(ArgTypes &&... Args) {
402// Grow manually in case one of Args is an internal reference.
403size_t NewCapacity;
404T *NewElts =mallocForGrow(0, NewCapacity);
405 ::new ((void *)(NewElts + this->size()))T(std::forward<ArgTypes>(Args)...);
406moveElementsForGrow(NewElts);
407takeAllocationForGrow(NewElts, NewCapacity);
408 this->set_size(this->size() + 1);
409return this->back();
410 }
411
412public:
413voidpush_back(const T &Elt) {
414constT *EltPtr =reserveForParamAndGetAddress(Elt);
415 ::new ((void *)this->end())T(*EltPtr);
416 this->set_size(this->size() + 1);
417 }
418
419voidpush_back(T &&Elt) {
420T *EltPtr =reserveForParamAndGetAddress(Elt);
421 ::new ((void *)this->end())T(::std::move(*EltPtr));
422 this->set_size(this->size() + 1);
423 }
424
425voidpop_back() {
426 this->set_size(this->size() - 1);
427 this->end()->~T();
428 }
429};
430
431// Define this out-of-line to dissuade the C++ compiler from inlining it.
432template <typename T,bool TriviallyCopyable>
433voidSmallVectorTemplateBase<T, TriviallyCopyable>::grow(size_t MinSize) {
434size_t NewCapacity;
435T *NewElts = mallocForGrow(MinSize, NewCapacity);
436 moveElementsForGrow(NewElts);
437 takeAllocationForGrow(NewElts, NewCapacity);
438}
439
440template <typename T,bool TriviallyCopyable>
441T *SmallVectorTemplateBase<T, TriviallyCopyable>::mallocForGrow(
442size_t MinSize,size_t &NewCapacity) {
443returnstatic_cast<T *>(
444SmallVectorBase<SmallVectorSizeType<T>>::mallocForGrow(
445 this->getFirstEl(), MinSize,sizeof(T), NewCapacity));
446}
447
448// Define this out-of-line to dissuade the C++ compiler from inlining it.
449template <typename T,bool TriviallyCopyable>
450voidSmallVectorTemplateBase<T, TriviallyCopyable>::moveElementsForGrow(
451T *NewElts) {
452// Move the elements over.
453 this->uninitialized_move(this->begin(), this->end(), NewElts);
454
455// Destroy the original elements.
456 destroy_range(this->begin(), this->end());
457}
458
459// Define this out-of-line to dissuade the C++ compiler from inlining it.
460template <typename T,bool TriviallyCopyable>
461voidSmallVectorTemplateBase<T, TriviallyCopyable>::takeAllocationForGrow(
462T *NewElts,size_t NewCapacity) {
463// If this wasn't grown from the inline copy, deallocate the old space.
464if (!this->isSmall())
465 free(this->begin());
466
467 this->set_allocation_range(NewElts, NewCapacity);
468}
469
470/// SmallVectorTemplateBase<TriviallyCopyable = true> - This is where we put
471/// method implementations that are designed to work with trivially copyable
472/// T's. This allows using memcpy in place of copy/move construction and
473/// skipping destruction.
474template <typename T>
475classSmallVectorTemplateBase<T,true> :publicSmallVectorTemplateCommon<T> {
476friendclassSmallVectorTemplateCommon<T>;
477
478protected:
479 /// True if it's cheap enough to take parameters by value. Doing so avoids
480 /// overhead related to mitigations for reference invalidation.
481staticconstexprboolTakesParamByValue =sizeof(T) <= 2 *sizeof(void *);
482
483 /// Either const T& or T, depending on whether it's cheap enough to take
484 /// parameters by value.
485usingValueParamT = std::conditional_t<TakesParamByValue, T, const T &>;
486
487SmallVectorTemplateBase(size_tSize) :SmallVectorTemplateCommon<T>(Size) {}
488
489// No need to do a destroy loop for POD's.
490staticvoiddestroy_range(T *,T *) {}
491
492 /// Move the range [I, E) onto the uninitialized memory
493 /// starting with "Dest", constructing elements into it as needed.
494template<typename It1,typename It2>
495staticvoiduninitialized_move(It1I, It1E, It2 Dest) {
496// Just do a copy.
497uninitialized_copy(I,E, Dest);
498 }
499
500 /// Copy the range [I, E) onto the uninitialized memory
501 /// starting with "Dest", constructing elements into it as needed.
502template<typename It1,typename It2>
503staticvoiduninitialized_copy(It1I, It1E, It2 Dest) {
504// Arbitrary iterator types; just use the basic implementation.
505 std::uninitialized_copy(I,E, Dest);
506 }
507
508 /// Copy the range [I, E) onto the uninitialized memory
509 /// starting with "Dest", constructing elements into it as needed.
510template <typename T1,typename T2>
511staticvoiduninitialized_copy(
512T1 *I,T1 *E, T2 *Dest,
513 std::enable_if_t<std::is_same<std::remove_const_t<T1>, T2>::value> * =
514nullptr) {
515// Use memcpy for PODs iterated by pointers (which includes SmallVector
516// iterators): std::uninitialized_copy optimizes to memmove, but we can
517// use memcpy here. Note that I and E are iterators and thus might be
518// invalid for memcpy if they are equal.
519if (I !=E)
520 memcpy(reinterpret_cast<void *>(Dest),I, (E -I) *sizeof(T));
521 }
522
523 /// Double the size of the allocated memory, guaranteeing space for at
524 /// least one more element or MinSize if specified.
525voidgrow(size_t MinSize = 0) { this->grow_pod(MinSize,sizeof(T)); }
526
527 /// Reserve enough space to add one element, and return the updated element
528 /// pointer in case it was a reference to the storage.
529constT *reserveForParamAndGetAddress(constT &Elt,size_tN = 1) {
530return this->reserveForParamAndGetAddressImpl(this, Elt,N);
531 }
532
533 /// Reserve enough space to add one element, and return the updated element
534 /// pointer in case it was a reference to the storage.
535T *reserveForParamAndGetAddress(T &Elt,size_tN = 1) {
536returnconst_cast<T *>(
537 this->reserveForParamAndGetAddressImpl(this, Elt,N));
538 }
539
540 /// Copy \p V or return a reference, depending on \a ValueParamT.
541staticValueParamTforward_value_param(ValueParamT V) {return V; }
542
543voidgrowAndAssign(size_t NumElts,T Elt) {
544// Elt has been copied in case it's an internal reference, side-stepping
545// reference invalidation problems without losing the realloc optimization.
546 this->set_size(0);
547 this->grow(NumElts);
548 std::uninitialized_fill_n(this->begin(), NumElts, Elt);
549 this->set_size(NumElts);
550 }
551
552template <typename... ArgTypes>T &growAndEmplaceBack(ArgTypes &&... Args) {
553// Use push_back with a copy in case Args has an internal reference,
554// side-stepping reference invalidation problems without losing the realloc
555// optimization.
556push_back(T(std::forward<ArgTypes>(Args)...));
557return this->back();
558 }
559
560public:
561voidpush_back(ValueParamT Elt) {
562constT *EltPtr =reserveForParamAndGetAddress(Elt);
563 memcpy(reinterpret_cast<void *>(this->end()), EltPtr,sizeof(T));
564 this->set_size(this->size() + 1);
565 }
566
567voidpop_back() { this->set_size(this->size() - 1); }
568};
569
570/// This class consists of common code factored out of the SmallVector class to
571/// reduce code duplication based on the SmallVector 'N' template parameter.
572template <typename T>
573classSmallVectorImpl :publicSmallVectorTemplateBase<T> {
574usingSuperClass =SmallVectorTemplateBase<T>;
575
576public:
577usingiterator =typenameSuperClass::iterator;
578usingconst_iterator =typenameSuperClass::const_iterator;
579usingreference =typenameSuperClass::reference;
580usingsize_type =typenameSuperClass::size_type;
581
582protected:
583usingSmallVectorTemplateBase<T>::TakesParamByValue;
584usingValueParamT =typenameSuperClass::ValueParamT;
585
586// Default ctor - Initialize to empty.
587explicitSmallVectorImpl(unsignedN)
588 :SmallVectorTemplateBase<T>(N) {}
589
590voidassignRemote(SmallVectorImpl &&RHS) {
591 this->destroy_range(this->begin(), this->end());
592if (!this->isSmall())
593 free(this->begin());
594 this->BeginX =RHS.BeginX;
595 this->Size =RHS.Size;
596 this->Capacity =RHS.Capacity;
597RHS.resetToSmall();
598 }
599
600~SmallVectorImpl() {
601// Subclass has already destructed this vector's elements.
602// If this wasn't grown from the inline copy, deallocate the old space.
603if (!this->isSmall())
604 free(this->begin());
605 }
606
607public:
608SmallVectorImpl(constSmallVectorImpl &) =delete;
609
610voidclear() {
611 this->destroy_range(this->begin(), this->end());
612 this->Size = 0;
613 }
614
615private:
616// Make set_size() private to avoid misuse in subclasses.
617usingSuperClass::set_size;
618
619template <bool ForOverwrite>void resizeImpl(size_typeN) {
620if (N == this->size())
621return;
622
623if (N < this->size()) {
624 this->truncate(N);
625return;
626 }
627
628 this->reserve(N);
629for (autoI = this->end(),E = this->begin() + N;I !=E; ++I)
630if (ForOverwrite)
631new (&*I)T;
632else
633new (&*I)T();
634 this->set_size(N);
635 }
636
637public:
638voidresize(size_typeN) { resizeImpl<false>(N); }
639
640 /// Like resize, but \ref T is POD, the new values won't be initialized.
641voidresize_for_overwrite(size_typeN) { resizeImpl<true>(N); }
642
643 /// Like resize, but requires that \p N is less than \a size().
644voidtruncate(size_typeN) {
645assert(this->size() >=N &&"Cannot increase size with truncate");
646 this->destroy_range(this->begin() + N, this->end());
647 this->set_size(N);
648 }
649
650voidresize(size_typeN,ValueParamT NV) {
651if (N == this->size())
652return;
653
654if (N < this->size()) {
655 this->truncate(N);
656return;
657 }
658
659// N > this->size(). Defer to append.
660 this->append(N - this->size(), NV);
661 }
662
663voidreserve(size_typeN) {
664if (this->capacity() < N)
665 this->grow(N);
666 }
667
668voidpop_back_n(size_type NumItems) {
669assert(this->size() >= NumItems);
670truncate(this->size() - NumItems);
671 }
672
673 [[nodiscard]]Tpop_back_val() {
674T Result = ::std::move(this->back());
675 this->pop_back();
676return Result;
677 }
678
679voidswap(SmallVectorImpl &RHS);
680
681 /// Add the specified range to the end of the SmallVector.
682template <typename ItTy,typename = EnableIfConvertibleToInputIterator<ItTy>>
683voidappend(ItTy in_start,ItTy in_end) {
684 this->assertSafeToAddRange(in_start, in_end);
685size_type NumInputs = std::distance(in_start, in_end);
686 this->reserve(this->size() + NumInputs);
687 this->uninitialized_copy(in_start, in_end, this->end());
688 this->set_size(this->size() + NumInputs);
689 }
690
691 /// Append \p NumInputs copies of \p Elt to the end.
692voidappend(size_type NumInputs,ValueParamT Elt) {
693constT *EltPtr = this->reserveForParamAndGetAddress(Elt, NumInputs);
694 std::uninitialized_fill_n(this->end(), NumInputs, *EltPtr);
695 this->set_size(this->size() + NumInputs);
696 }
697
698voidappend(std::initializer_list<T> IL) {
699append(IL.begin(), IL.end());
700 }
701
702voidappend(constSmallVectorImpl &RHS) {append(RHS.begin(),RHS.end()); }
703
704voidassign(size_type NumElts,ValueParamT Elt) {
705// Note that Elt could be an internal reference.
706if (NumElts > this->capacity()) {
707 this->growAndAssign(NumElts, Elt);
708return;
709 }
710
711// Assign over existing elements.
712 std::fill_n(this->begin(), std::min(NumElts, this->size()), Elt);
713if (NumElts > this->size())
714 std::uninitialized_fill_n(this->end(), NumElts - this->size(), Elt);
715elseif (NumElts < this->size())
716 this->destroy_range(this->begin() + NumElts, this->end());
717 this->set_size(NumElts);
718 }
719
720// FIXME: Consider assigning over existing elements, rather than clearing &
721// re-initializing them - for all assign(...) variants.
722
723template <typename ItTy,typename = EnableIfConvertibleToInputIterator<ItTy>>
724voidassign(ItTy in_start,ItTy in_end) {
725 this->assertSafeToReferenceAfterClear(in_start, in_end);
726clear();
727append(in_start, in_end);
728 }
729
730voidassign(std::initializer_list<T> IL) {
731clear();
732append(IL);
733 }
734
735voidassign(constSmallVectorImpl &RHS) {assign(RHS.begin(),RHS.end()); }
736
737iteratorerase(const_iterator CI) {
738// Just cast away constness because this is a non-const member function.
739iteratorI =const_cast<iterator>(CI);
740
741assert(this->isReferenceToStorage(CI) &&"Iterator to erase is out of bounds.");
742
743iteratorN =I;
744// Shift all elts down one.
745 std::move(I+1, this->end(), I);
746// Drop the last elt.
747 this->pop_back();
748return(N);
749 }
750
751iteratorerase(const_iterator CS,const_iterator CE) {
752// Just cast away constness because this is a non-const member function.
753iterator S =const_cast<iterator>(CS);
754iteratorE =const_cast<iterator>(CE);
755
756assert(this->isRangeInStorage(S,E) &&"Range to erase is out of bounds.");
757
758iteratorN = S;
759// Shift all elts down.
760iteratorI = std::move(E, this->end(), S);
761// Drop the last elts.
762 this->destroy_range(I, this->end());
763 this->set_size(I - this->begin());
764return(N);
765 }
766
767private:
768template <class ArgType>iterator insert_one_impl(iteratorI, ArgType &&Elt) {
769// Callers ensure that ArgType is derived from T.
770static_assert(
771 std::is_same<std::remove_const_t<std::remove_reference_t<ArgType>>,
772T>::value,
773"ArgType must be derived from T!");
774
775if (I == this->end()) {// Important special case for empty vector.
776 this->push_back(::std::forward<ArgType>(Elt));
777return this->end()-1;
778 }
779
780assert(this->isReferenceToStorage(I) &&"Insertion iterator is out of bounds.");
781
782// Grow if necessary.
783size_tIndex =I - this->begin();
784 std::remove_reference_t<ArgType> *EltPtr =
785 this->reserveForParamAndGetAddress(Elt);
786I = this->begin() +Index;
787
788 ::new ((void*) this->end()) T(::std::move(this->back()));
789// Push everything else over.
790std::move_backward(I, this->end()-1, this->end());
791 this->set_size(this->size() + 1);
792
793// If we just moved the element we're inserting, be sure to update
794// the reference (never happens if TakesParamByValue).
795 static_assert(!TakesParamByValue ||std::is_same<ArgType,T>::value,
796 "ArgType must be 'T' when taking byvalue!");
797if (!TakesParamByValue && this->isReferenceToRange(EltPtr,I, this->end()))
798 ++EltPtr;
799
800 *I = ::std::forward<ArgType>(*EltPtr);
801 returnI;
802 }
803
804public:
805iteratorinsert(iteratorI,T &&Elt) {
806return insert_one_impl(I, this->forward_value_param(std::move(Elt)));
807 }
808
809iteratorinsert(iteratorI,constT &Elt) {
810return insert_one_impl(I, this->forward_value_param(Elt));
811 }
812
813iteratorinsert(iteratorI,size_type NumToInsert,ValueParamT Elt) {
814// Convert iterator to elt# to avoid invalidating iterator when we reserve()
815size_t InsertElt =I - this->begin();
816
817if (I == this->end()) {// Important special case for empty vector.
818append(NumToInsert, Elt);
819return this->begin()+InsertElt;
820 }
821
822assert(this->isReferenceToStorage(I) &&"Insertion iterator is out of bounds.");
823
824// Ensure there is enough space, and get the (maybe updated) address of
825// Elt.
826constT *EltPtr = this->reserveForParamAndGetAddress(Elt, NumToInsert);
827
828// Uninvalidate the iterator.
829I = this->begin()+InsertElt;
830
831// If there are more elements between the insertion point and the end of the
832// range than there are being inserted, we can use a simple approach to
833// insertion. Since we already reserved space, we know that this won't
834// reallocate the vector.
835if (size_t(this->end()-I) >= NumToInsert) {
836T *OldEnd = this->end();
837append(std::move_iterator<iterator>(this->end() - NumToInsert),
838 std::move_iterator<iterator>(this->end()));
839
840// Copy the existing elements that get replaced.
841 std::move_backward(I, OldEnd-NumToInsert, OldEnd);
842
843// If we just moved the element we're inserting, be sure to update
844// the reference (never happens if TakesParamByValue).
845if (!TakesParamByValue &&I <= EltPtr && EltPtr < this->end())
846 EltPtr += NumToInsert;
847
848 std::fill_n(I, NumToInsert, *EltPtr);
849returnI;
850 }
851
852// Otherwise, we're inserting more elements than exist already, and we're
853// not inserting at the end.
854
855// Move over the elements that we're about to overwrite.
856T *OldEnd = this->end();
857 this->set_size(this->size() + NumToInsert);
858size_t NumOverwritten = OldEnd-I;
859 this->uninitialized_move(I, OldEnd, this->end()-NumOverwritten);
860
861// If we just moved the element we're inserting, be sure to update
862// the reference (never happens if TakesParamByValue).
863if (!TakesParamByValue &&I <= EltPtr && EltPtr < this->end())
864 EltPtr += NumToInsert;
865
866// Replace the overwritten part.
867 std::fill_n(I, NumOverwritten, *EltPtr);
868
869// Insert the non-overwritten middle part.
870 std::uninitialized_fill_n(OldEnd, NumToInsert - NumOverwritten, *EltPtr);
871returnI;
872 }
873
874template <typename ItTy,typename = EnableIfConvertibleToInputIterator<ItTy>>
875iteratorinsert(iteratorI,ItTyFrom,ItTy To) {
876// Convert iterator to elt# to avoid invalidating iterator when we reserve()
877size_t InsertElt =I - this->begin();
878
879if (I == this->end()) {// Important special case for empty vector.
880append(From, To);
881return this->begin()+InsertElt;
882 }
883
884assert(this->isReferenceToStorage(I) &&"Insertion iterator is out of bounds.");
885
886// Check that the reserve that follows doesn't invalidate the iterators.
887 this->assertSafeToAddRange(From, To);
888
889size_t NumToInsert = std::distance(From, To);
890
891// Ensure there is enough space.
892reserve(this->size() + NumToInsert);
893
894// Uninvalidate the iterator.
895I = this->begin()+InsertElt;
896
897// If there are more elements between the insertion point and the end of the
898// range than there are being inserted, we can use a simple approach to
899// insertion. Since we already reserved space, we know that this won't
900// reallocate the vector.
901if (size_t(this->end()-I) >= NumToInsert) {
902T *OldEnd = this->end();
903append(std::move_iterator<iterator>(this->end() - NumToInsert),
904 std::move_iterator<iterator>(this->end()));
905
906// Copy the existing elements that get replaced.
907 std::move_backward(I, OldEnd-NumToInsert, OldEnd);
908
909 std::copy(From, To,I);
910returnI;
911 }
912
913// Otherwise, we're inserting more elements than exist already, and we're
914// not inserting at the end.
915
916// Move over the elements that we're about to overwrite.
917T *OldEnd = this->end();
918 this->set_size(this->size() + NumToInsert);
919size_t NumOverwritten = OldEnd-I;
920 this->uninitialized_move(I, OldEnd, this->end()-NumOverwritten);
921
922// Replace the overwritten part.
923for (T *J =I; NumOverwritten > 0; --NumOverwritten) {
924 *J = *From;
925 ++J; ++From;
926 }
927
928// Insert the non-overwritten middle part.
929 this->uninitialized_copy(From, To, OldEnd);
930returnI;
931 }
932
933voidinsert(iteratorI, std::initializer_list<T> IL) {
934insert(I, IL.begin(), IL.end());
935 }
936
937template <typename... ArgTypes>referenceemplace_back(ArgTypes &&... Args) {
938if (LLVM_UNLIKELY(this->size() >= this->capacity()))
939return this->growAndEmplaceBack(std::forward<ArgTypes>(Args)...);
940
941 ::new ((void *)this->end())T(std::forward<ArgTypes>(Args)...);
942 this->set_size(this->size() + 1);
943return this->back();
944 }
945
946SmallVectorImpl &operator=(constSmallVectorImpl &RHS);
947
948SmallVectorImpl &operator=(SmallVectorImpl &&RHS);
949
950booloperator==(constSmallVectorImpl &RHS) const{
951if (this->size() !=RHS.size())returnfalse;
952return std::equal(this->begin(), this->end(), RHS.begin());
953 }
954booloperator!=(constSmallVectorImpl &RHS) const{
955return !(*this ==RHS);
956 }
957
958booloperator<(constSmallVectorImpl &RHS) const{
959return std::lexicographical_compare(this->begin(), this->end(),
960 RHS.begin(),RHS.end());
961 }
962booloperator>(constSmallVectorImpl &RHS) const{returnRHS < *this; }
963booloperator<=(constSmallVectorImpl &RHS) const{return !(*this >RHS); }
964booloperator>=(constSmallVectorImpl &RHS) const{return !(*this <RHS); }
965};
966
967template <typename T>
968voidSmallVectorImpl<T>::swap(SmallVectorImpl<T> &RHS) {
969if (this == &RHS)return;
970
971// We can only avoid copying elements if neither vector is small.
972if (!this->isSmall() && !RHS.isSmall()) {
973std::swap(this->BeginX, RHS.BeginX);
974std::swap(this->Size, RHS.Size);
975std::swap(this->Capacity, RHS.Capacity);
976return;
977 }
978 this->reserve(RHS.size());
979RHS.reserve(this->size());
980
981// Swap the shared elements.
982size_t NumShared = this->size();
983if (NumShared >RHS.size()) NumShared =RHS.size();
984for (size_type i = 0; i != NumShared; ++i)
985std::swap((*this)[i],RHS[i]);
986
987// Copy over the extra elts.
988if (this->size() >RHS.size()) {
989size_t EltDiff = this->size() -RHS.size();
990 this->uninitialized_copy(this->begin()+NumShared, this->end(), RHS.end());
991RHS.set_size(RHS.size() + EltDiff);
992 this->destroy_range(this->begin()+NumShared, this->end());
993 this->set_size(NumShared);
994 }elseif (RHS.size() > this->size()) {
995size_t EltDiff =RHS.size() - this->size();
996 this->uninitialized_copy(RHS.begin()+NumShared,RHS.end(), this->end());
997 this->set_size(this->size() + EltDiff);
998 this->destroy_range(RHS.begin()+NumShared,RHS.end());
999RHS.set_size(NumShared);
1000 }
1001}
1002
1003template <typename T>
1004SmallVectorImpl<T> &SmallVectorImpl<T>::
1005 operator=(constSmallVectorImpl<T> &RHS) {
1006// Avoid self-assignment.
1007if (this == &RHS)return *this;
1008
1009// If we already have sufficient space, assign the common elements, then
1010// destroy any excess.
1011size_t RHSSize =RHS.size();
1012size_t CurSize = this->size();
1013if (CurSize >= RHSSize) {
1014// Assign common elements.
1015iterator NewEnd;
1016if (RHSSize)
1017 NewEnd = std::copy(RHS.begin(),RHS.begin()+RHSSize, this->begin());
1018else
1019 NewEnd = this->begin();
1020
1021// Destroy excess elements.
1022 this->destroy_range(NewEnd, this->end());
1023
1024// Trim.
1025 this->set_size(RHSSize);
1026return *this;
1027 }
1028
1029// If we have to grow to have enough elements, destroy the current elements.
1030// This allows us to avoid copying them during the grow.
1031// FIXME: don't do this if they're efficiently moveable.
1032if (this->capacity() < RHSSize) {
1033// Destroy current elements.
1034 this->clear();
1035 CurSize = 0;
1036 this->grow(RHSSize);
1037 }elseif (CurSize) {
1038// Otherwise, use assignment for the already-constructed elements.
1039 std::copy(RHS.begin(),RHS.begin()+CurSize, this->begin());
1040 }
1041
1042// Copy construct the new elements in place.
1043 this->uninitialized_copy(RHS.begin()+CurSize,RHS.end(),
1044 this->begin()+CurSize);
1045
1046// Set end.
1047 this->set_size(RHSSize);
1048return *this;
1049}
1050
1051template <typename T>
1052SmallVectorImpl<T> &SmallVectorImpl<T>::operator=(SmallVectorImpl<T> &&RHS) {
1053// Avoid self-assignment.
1054if (this == &RHS)return *this;
1055
1056// If the RHS isn't small, clear this vector and then steal its buffer.
1057if (!RHS.isSmall()) {
1058 this->assignRemote(std::move(RHS));
1059return *this;
1060 }
1061
1062// If we already have sufficient space, assign the common elements, then
1063// destroy any excess.
1064size_t RHSSize =RHS.size();
1065size_t CurSize = this->size();
1066if (CurSize >= RHSSize) {
1067// Assign common elements.
1068iterator NewEnd = this->begin();
1069if (RHSSize)
1070 NewEnd = std::move(RHS.begin(),RHS.end(), NewEnd);
1071
1072// Destroy excess elements and trim the bounds.
1073 this->destroy_range(NewEnd, this->end());
1074 this->set_size(RHSSize);
1075
1076// Clear the RHS.
1077RHS.clear();
1078
1079return *this;
1080 }
1081
1082// If we have to grow to have enough elements, destroy the current elements.
1083// This allows us to avoid copying them during the grow.
1084// FIXME: this may not actually make any sense if we can efficiently move
1085// elements.
1086if (this->capacity() < RHSSize) {
1087// Destroy current elements.
1088 this->clear();
1089 CurSize = 0;
1090 this->grow(RHSSize);
1091 }elseif (CurSize) {
1092// Otherwise, use assignment for the already-constructed elements.
1093 std::move(RHS.begin(),RHS.begin()+CurSize, this->begin());
1094 }
1095
1096// Move-construct the new elements in place.
1097 this->uninitialized_move(RHS.begin()+CurSize,RHS.end(),
1098 this->begin()+CurSize);
1099
1100// Set end.
1101 this->set_size(RHSSize);
1102
1103RHS.clear();
1104return *this;
1105}
1106
1107/// Storage for the SmallVector elements. This is specialized for the N=0 case
1108/// to avoid allocating unnecessary storage.
1109template <typename T,unsigned N>
1110structSmallVectorStorage {
1111alignas(T)char InlineElts[N *sizeof(T)];
1112};
1113
1114/// We need the storage to be properly aligned even for small-size of 0 so that
1115/// the pointer math in \a SmallVectorTemplateCommon::getFirstEl() is
1116/// well-defined.
1117template <typename T>structalignas(T)SmallVectorStorage<T, 0> {};
1118
1119/// Forward declaration of SmallVector so that
1120/// calculateSmallVectorDefaultInlinedElements can reference
1121/// `sizeof(SmallVector<T, 0>)`.
1122template <typename T,unsigned N>classLLVM_GSL_OWNERSmallVector;
1123
1124/// Helper class for calculating the default number of inline elements for
1125/// `SmallVector<T>`.
1126///
1127/// This should be migrated to a constexpr function when our minimum
1128/// compiler support is enough for multi-statement constexpr functions.
1129template <typename T>structCalculateSmallVectorDefaultInlinedElements {
1130// Parameter controlling the default number of inlined elements
1131// for `SmallVector<T>`.
1132//
1133// The default number of inlined elements ensures that
1134// 1. There is at least one inlined element.
1135// 2. `sizeof(SmallVector<T>) <= kPreferredSmallVectorSizeof` unless
1136// it contradicts 1.
1137staticconstexprsize_t kPreferredSmallVectorSizeof = 64;
1138
1139// static_assert that sizeof(T) is not "too big".
1140//
1141// Because our policy guarantees at least one inlined element, it is possible
1142// for an arbitrarily large inlined element to allocate an arbitrarily large
1143// amount of inline storage. We generally consider it an antipattern for a
1144// SmallVector to allocate an excessive amount of inline storage, so we want
1145// to call attention to these cases and make sure that users are making an
1146// intentional decision if they request a lot of inline storage.
1147//
1148// We want this assertion to trigger in pathological cases, but otherwise
1149// not be too easy to hit. To accomplish that, the cutoff is actually somewhat
1150// larger than kPreferredSmallVectorSizeof (otherwise,
1151// `SmallVector<SmallVector<T>>` would be one easy way to trip it, and that
1152// pattern seems useful in practice).
1153//
1154// One wrinkle is that this assertion is in theory non-portable, since
1155// sizeof(T) is in general platform-dependent. However, we don't expect this
1156// to be much of an issue, because most LLVM development happens on 64-bit
1157// hosts, and therefore sizeof(T) is expected to *decrease* when compiled for
1158// 32-bit hosts, dodging the issue. The reverse situation, where development
1159// happens on a 32-bit host and then fails due to sizeof(T) *increasing* on a
1160// 64-bit host, is expected to be very rare.
1161static_assert(
1162sizeof(T) <= 256,
1163"You are trying to use a default number of inlined elements for "
1164"`SmallVector<T>` but `sizeof(T)` is really big! Please use an "
1165"explicit number of inlined elements with `SmallVector<T, N>` to make "
1166"sure you really want that much inline storage.");
1167
1168// Discount the size of the header itself when calculating the maximum inline
1169// bytes.
1170staticconstexprsize_t PreferredInlineBytes =
1171 kPreferredSmallVectorSizeof -sizeof(SmallVector<T, 0>);
1172staticconstexprsize_t NumElementsThatFit = PreferredInlineBytes /sizeof(T);
1173staticconstexprsize_tvalue =
1174 NumElementsThatFit == 0 ? 1 : NumElementsThatFit;
1175};
1176
1177/// This is a 'vector' (really, a variable-sized array), optimized
1178/// for the case when the array is small. It contains some number of elements
1179/// in-place, which allows it to avoid heap allocation when the actual number of
1180/// elements is below that threshold. This allows normal "small" cases to be
1181/// fast without losing generality for large inputs.
1182///
1183/// \note
1184/// In the absence of a well-motivated choice for the number of inlined
1185/// elements \p N, it is recommended to use \c SmallVector<T> (that is,
1186/// omitting the \p N). This will choose a default number of inlined elements
1187/// reasonable for allocation on the stack (for example, trying to keep \c
1188/// sizeof(SmallVector<T>) around 64 bytes).
1189///
1190/// \warning This does not attempt to be exception safe.
1191///
1192/// \see https://llvm.org/docs/ProgrammersManual.html#llvm-adt-smallvector-h
1193template <typenameT,
1194unsignedN =CalculateSmallVectorDefaultInlinedElements<T>::value>
1195classLLVM_GSL_OWNERSmallVector :publicSmallVectorImpl<T>,
1196SmallVectorStorage<T, N> {
1197public:
1198SmallVector() :SmallVectorImpl<T>(N) {}
1199
1200~SmallVector() {
1201// Destroy the constructed elements in the vector.
1202 this->destroy_range(this->begin(), this->end());
1203 }
1204
1205explicitSmallVector(size_tSize)
1206 :SmallVectorImpl<T>(N) {
1207 this->resize(Size);
1208 }
1209
1210SmallVector(size_tSize,constT &Value)
1211 :SmallVectorImpl<T>(N) {
1212 this->assign(Size,Value);
1213 }
1214
1215template <typename ItTy,typename = EnableIfConvertibleToInputIterator<ItTy>>
1216SmallVector(ItTy S,ItTyE) :SmallVectorImpl<T>(N) {
1217 this->append(S,E);
1218 }
1219
1220template <typename RangeTy>
1221explicitSmallVector(constiterator_range<RangeTy> &R)
1222 :SmallVectorImpl<T>(N) {
1223 this->append(R.begin(), R.end());
1224 }
1225
1226SmallVector(std::initializer_list<T> IL) :SmallVectorImpl<T>(N) {
1227 this->append(IL);
1228 }
1229
1230template <typename U,
1231typename = std::enable_if_t<std::is_convertible<U, T>::value>>
1232explicitSmallVector(ArrayRef<U>A) :SmallVectorImpl<T>(N) {
1233 this->append(A.begin(),A.end());
1234 }
1235
1236SmallVector(constSmallVector &RHS) :SmallVectorImpl<T>(N) {
1237if (!RHS.empty())
1238SmallVectorImpl<T>::operator=(RHS);
1239 }
1240
1241SmallVector &operator=(constSmallVector &RHS) {
1242SmallVectorImpl<T>::operator=(RHS);
1243return *this;
1244 }
1245
1246SmallVector(SmallVector &&RHS) :SmallVectorImpl<T>(N) {
1247if (!RHS.empty())
1248SmallVectorImpl<T>::operator=(::std::move(RHS));
1249 }
1250
1251SmallVector(SmallVectorImpl<T> &&RHS) :SmallVectorImpl<T>(N) {
1252if (!RHS.empty())
1253SmallVectorImpl<T>::operator=(::std::move(RHS));
1254 }
1255
1256SmallVector &operator=(SmallVector &&RHS) {
1257if (N) {
1258SmallVectorImpl<T>::operator=(::std::move(RHS));
1259return *this;
1260 }
1261// SmallVectorImpl<T>::operator= does not leverage N==0. Optimize the
1262// case.
1263if (this == &RHS)
1264return *this;
1265if (RHS.empty()) {
1266 this->destroy_range(this->begin(), this->end());
1267 this->Size = 0;
1268 }else {
1269 this->assignRemote(std::move(RHS));
1270 }
1271return *this;
1272 }
1273
1274SmallVector &operator=(SmallVectorImpl<T> &&RHS) {
1275SmallVectorImpl<T>::operator=(::std::move(RHS));
1276return *this;
1277 }
1278
1279SmallVector &operator=(std::initializer_list<T> IL) {
1280 this->assign(IL);
1281return *this;
1282 }
1283};
1284
1285template <typename T,unsigned N>
1286inlinesize_tcapacity_in_bytes(constSmallVector<T, N> &X) {
1287returnX.capacity_in_bytes();
1288}
1289
1290template <typename RangeType>
1291usingValueTypeFromRangeType =
1292 std::remove_const_t<std::remove_reference_t<decltype(*std::begin(
1293 std::declval<RangeType &>()))>>;
1294
1295/// Given a range of type R, iterate the entire range and return a
1296/// SmallVector with elements of the vector. This is useful, for example,
1297/// when you want to iterate a range and then sort the results.
1298template <unsigned Size,typename R>
1299SmallVector<ValueTypeFromRangeType<R>,Size>to_vector(R &&Range) {
1300return {std::begin(Range), std::end(Range)};
1301}
1302template <typename R>
1303SmallVector<ValueTypeFromRangeType<R>>to_vector(R &&Range) {
1304return {std::begin(Range), std::end(Range)};
1305}
1306
1307template <typename Out,unsigned Size,typename R>
1308SmallVector<Out, Size>to_vector_of(R &&Range) {
1309return {std::begin(Range), std::end(Range)};
1310}
1311
1312template <typename Out,typename R>SmallVector<Out>to_vector_of(R &&Range) {
1313return {std::begin(Range), std::end(Range)};
1314}
1315
1316// Explicit instantiations
1317externtemplateclassllvm::SmallVectorBase<uint32_t>;
1318#if SIZE_MAX > UINT32_MAX
1319externtemplateclassllvm::SmallVectorBase<uint64_t>;
1320#endif
1321
1322}// end namespace llvm
1323
1324namespacestd {
1325
1326 /// Implement std::swap in terms of SmallVector swap.
1327template<typename T>
1328inlinevoid
1329 swap(llvm::SmallVectorImpl<T> &LHS,llvm::SmallVectorImpl<T> &RHS) {
1330LHS.swap(RHS);
1331 }
1332
1333 /// Implement std::swap in terms of SmallVector swap.
1334template<typename T,unsigned N>
1335inlinevoid
1336 swap(llvm::SmallVector<T, N> &LHS,llvm::SmallVector<T, N> &RHS) {
1337LHS.swap(RHS);
1338 }
1339
1340}// end namespace std
1341
1342#endif// LLVM_ADT_SMALLVECTOR_H
offsetof
#define offsetof(TYPE, MEMBER)
Definition:AMDHSAKernelDescriptor.h:30
true
basic Basic Alias true
Definition:BasicAliasAnalysis.cpp:1981
From
BlockVerifier::State From
Definition:BlockVerifier.cpp:57
A
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Compiler.h
LLVM_UNLIKELY
#define LLVM_UNLIKELY(EXPR)
Definition:Compiler.h:320
LLVM_GSL_OWNER
#define LLVM_GSL_OWNER
LLVM_GSL_OWNER - Apply this to owning classes like SmallVector to enable lifetime warnings.
Definition:Compiler.h:405
LLVM_LIKELY
#define LLVM_LIKELY(EXPR)
Definition:Compiler.h:319
value
Given that RA is a live value
Definition:DeadArgumentElimination.cpp:716
Index
uint32_t Index
Definition:ELFObjHandler.cpp:83
Size
uint64_t Size
Definition:ELFObjHandler.cpp:81
X
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
I
#define I(x, y, z)
Definition:MD5.cpp:58
T
#define T
Definition:Mips16ISelLowering.cpp:341
T1
#define T1
Definition:Mips16ISelLowering.cpp:340
Range
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
if
if(PassOpts->AAPipeline)
Definition:PassBuilderBindings.cpp:64
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
RHS
Value * RHS
Definition:X86PartialReduction.cpp:74
LHS
Value * LHS
Definition:X86PartialReduction.cpp:73
ItTy
T
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition:ArrayRef.h:41
llvm::SmallVectorBase
This is all the stuff common to all SmallVectors.
Definition:SmallVector.h:52
llvm::SmallVectorBase::grow_pod
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 ...
Definition:SmallVector.cpp:146
llvm::SmallVectorBase::SmallVectorBase
SmallVectorBase()=delete
llvm::SmallVectorBase::mallocForGrow
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.
Definition:SmallVector.cpp:132
llvm::SmallVectorBase::set_allocation_range
void set_allocation_range(void *Begin, size_t N)
Set the array data pointer to Begin and capacity to N.
Definition:SmallVector.h:97
llvm::SmallVectorBase::Capacity
Size_T Capacity
Definition:SmallVector.h:55
llvm::SmallVectorBase::Size
Size_T Size
Definition:SmallVector.h:55
llvm::SmallVectorBase::SmallVectorBase
SmallVectorBase(void *FirstEl, size_t TotalCapacity)
Definition:SmallVector.h:63
llvm::SmallVectorBase::set_size
void set_size(size_t N)
Set the array size to N, which the current array must have enough capacity for.
Definition:SmallVector.h:88
llvm::SmallVectorBase::empty
bool empty() const
Definition:SmallVector.h:81
llvm::SmallVectorBase::capacity
size_t capacity() const
Definition:SmallVector.h:79
llvm::SmallVectorBase::size
size_t size() const
Definition:SmallVector.h:78
llvm::SmallVectorBase::BeginX
void * BeginX
Definition:SmallVector.h:54
llvm::SmallVectorBase::SizeTypeMax
static constexpr size_t SizeTypeMax()
The maximum value of the Size_T used.
Definition:SmallVector.h:58
llvm::SmallVectorImpl
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition:SmallVector.h:573
llvm::SmallVectorImpl::resize_for_overwrite
void resize_for_overwrite(size_type N)
Like resize, but T is POD, the new values won't be initialized.
Definition:SmallVector.h:641
llvm::SmallVectorImpl::append
void append(const SmallVectorImpl &RHS)
Definition:SmallVector.h:702
llvm::SmallVectorImpl::pop_back_val
T pop_back_val()
Definition:SmallVector.h:673
llvm::SmallVectorImpl::pop_back_n
void pop_back_n(size_type NumItems)
Definition:SmallVector.h:668
llvm::SmallVectorImpl::assign
void assign(const SmallVectorImpl &RHS)
Definition:SmallVector.h:735
llvm::SmallVectorImpl::SmallVectorImpl
SmallVectorImpl(const SmallVectorImpl &)=delete
llvm::SmallVectorImpl::assign
void assign(size_type NumElts, ValueParamT Elt)
Definition:SmallVector.h:704
llvm::SmallVectorImpl::emplace_back
reference emplace_back(ArgTypes &&... Args)
Definition:SmallVector.h:937
llvm::SmallVectorImpl::operator==
bool operator==(const SmallVectorImpl &RHS) const
Definition:SmallVector.h:950
llvm::SmallVectorImpl::reserve
void reserve(size_type N)
Definition:SmallVector.h:663
llvm::SmallVectorImpl::reference
typename SuperClass::reference reference
Definition:SmallVector.h:579
llvm::SmallVectorImpl::insert
iterator insert(iterator I, size_type NumToInsert, ValueParamT Elt)
Definition:SmallVector.h:813
llvm::SmallVectorImpl::erase
iterator erase(const_iterator CI)
Definition:SmallVector.h:737
llvm::SmallVectorImpl::insert
iterator insert(iterator I, ItTy From, ItTy To)
Definition:SmallVector.h:875
llvm::SmallVectorImpl::const_iterator
typename SuperClass::const_iterator const_iterator
Definition:SmallVector.h:578
llvm::SmallVectorImpl::assignRemote
void assignRemote(SmallVectorImpl &&RHS)
Definition:SmallVector.h:590
llvm::SmallVectorImpl::append
void append(ItTy in_start, ItTy in_end)
Add the specified range to the end of the SmallVector.
Definition:SmallVector.h:683
llvm::SmallVectorImpl::resize
void resize(size_type N, ValueParamT NV)
Definition:SmallVector.h:650
llvm::SmallVectorImpl::insert
iterator insert(iterator I, T &&Elt)
Definition:SmallVector.h:805
llvm::SmallVectorImpl::operator>
bool operator>(const SmallVectorImpl &RHS) const
Definition:SmallVector.h:962
llvm::SmallVectorImpl::operator<
bool operator<(const SmallVectorImpl &RHS) const
Definition:SmallVector.h:958
llvm::SmallVectorImpl::erase
iterator erase(const_iterator CS, const_iterator CE)
Definition:SmallVector.h:751
llvm::SmallVectorImpl::clear
void clear()
Definition:SmallVector.h:610
llvm::SmallVectorImpl::operator!=
bool operator!=(const SmallVectorImpl &RHS) const
Definition:SmallVector.h:954
llvm::SmallVectorImpl::truncate
void truncate(size_type N)
Like resize, but requires that N is less than size().
Definition:SmallVector.h:644
llvm::SmallVectorImpl::assign
void assign(ItTy in_start, ItTy in_end)
Definition:SmallVector.h:724
llvm::SmallVectorImpl::assign
void assign(std::initializer_list< T > IL)
Definition:SmallVector.h:730
llvm::SmallVectorImpl::SmallVectorImpl
SmallVectorImpl(unsigned N)
Definition:SmallVector.h:587
llvm::SmallVectorImpl::swap
void swap(SmallVectorImpl &RHS)
Definition:SmallVector.h:968
llvm::SmallVectorImpl::iterator
typename SuperClass::iterator iterator
Definition:SmallVector.h:577
llvm::SmallVectorImpl::operator<=
bool operator<=(const SmallVectorImpl &RHS) const
Definition:SmallVector.h:963
llvm::SmallVectorImpl::size_type
typename SuperClass::size_type size_type
Definition:SmallVector.h:580
llvm::SmallVectorImpl::append
void append(std::initializer_list< T > IL)
Definition:SmallVector.h:698
llvm::SmallVectorImpl::append
void append(size_type NumInputs, ValueParamT Elt)
Append NumInputs copies of Elt to the end.
Definition:SmallVector.h:692
llvm::SmallVectorImpl::resize
void resize(size_type N)
Definition:SmallVector.h:638
llvm::SmallVectorImpl::operator=
SmallVectorImpl & operator=(const SmallVectorImpl &RHS)
Definition:SmallVector.h:1005
llvm::SmallVectorImpl::insert
void insert(iterator I, std::initializer_list< T > IL)
Definition:SmallVector.h:933
llvm::SmallVectorImpl::operator=
SmallVectorImpl & operator=(SmallVectorImpl &&RHS)
Definition:SmallVector.h:1052
llvm::SmallVectorImpl::ValueParamT
typename SuperClass::ValueParamT ValueParamT
Definition:SmallVector.h:584
llvm::SmallVectorImpl::operator>=
bool operator>=(const SmallVectorImpl &RHS) const
Definition:SmallVector.h:964
llvm::SmallVectorImpl::~SmallVectorImpl
~SmallVectorImpl()
Definition:SmallVector.h:600
llvm::SmallVectorImpl::insert
iterator insert(iterator I, const T &Elt)
Definition:SmallVector.h:809
llvm::SmallVectorTemplateBase< T, true >::uninitialized_copy
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:503
llvm::SmallVectorTemplateBase< T, true >::uninitialized_move
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:495
llvm::SmallVectorTemplateBase< T, true >::ValueParamT
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:485
llvm::SmallVectorTemplateBase< T, true >::SmallVectorTemplateBase
SmallVectorTemplateBase(size_t Size)
Definition:SmallVector.h:487
llvm::SmallVectorTemplateBase< T, true >::reserveForParamAndGetAddress
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:529
llvm::SmallVectorTemplateBase< T, true >::push_back
void push_back(ValueParamT Elt)
Definition:SmallVector.h:561
llvm::SmallVectorTemplateBase< T, true >::destroy_range
static void destroy_range(T *, T *)
Definition:SmallVector.h:490
llvm::SmallVectorTemplateBase< T, true >::reserveForParamAndGetAddress
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:535
llvm::SmallVectorTemplateBase< T, true >::forward_value_param
static ValueParamT forward_value_param(ValueParamT V)
Copy V or return a reference, depending on ValueParamT.
Definition:SmallVector.h:541
llvm::SmallVectorTemplateBase< T, true >::growAndEmplaceBack
T & growAndEmplaceBack(ArgTypes &&... Args)
Definition:SmallVector.h:552
llvm::SmallVectorTemplateBase< T, true >::uninitialized_copy
static void uninitialized_copy(T1 *I, T1 *E, T2 *Dest, std::enable_if_t< std::is_same< std::remove_const_t< T1 >, T2 >::value > *=nullptr)
Copy the range [I, E) onto the uninitialized memory starting with "Dest", constructing elements into ...
Definition:SmallVector.h:511
llvm::SmallVectorTemplateBase< T, true >::growAndAssign
void growAndAssign(size_t NumElts, T Elt)
Definition:SmallVector.h:543
llvm::SmallVectorTemplateBase< T, true >::grow
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:525
llvm::SmallVectorTemplateBase< T, true >::pop_back
void pop_back()
Definition:SmallVector.h:567
llvm::SmallVectorTemplateBase
SmallVectorTemplateBase<TriviallyCopyable = false> - This is where we put method implementations that...
Definition:SmallVector.h:329
llvm::SmallVectorTemplateBase::moveElementsForGrow
void moveElementsForGrow(T *NewElts)
Move existing elements over to the new allocation NewElts, the middle section of grow().
Definition:SmallVector.h:450
llvm::SmallVectorTemplateBase::uninitialized_copy
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:355
llvm::SmallVectorTemplateBase::forward_value_param
static T && forward_value_param(T &&V)
Definition:SmallVector.h:388
llvm::SmallVectorTemplateBase::destroy_range
static void destroy_range(T *S, T *E)
Definition:SmallVector.h:338
llvm::SmallVectorTemplateBase::mallocForGrow
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:441
llvm::SmallVectorTemplateBase::TakesParamByValue
static constexpr bool TakesParamByValue
Definition:SmallVector.h:333
llvm::SmallVectorTemplateBase::ValueParamT
const T & ValueParamT
Definition:SmallVector.h:334
llvm::SmallVectorTemplateBase::SmallVectorTemplateBase
SmallVectorTemplateBase(size_t Size)
Definition:SmallVector.h:336
llvm::SmallVectorTemplateBase::reserveForParamAndGetAddress
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:383
llvm::SmallVectorTemplateBase::takeAllocationForGrow
void takeAllocationForGrow(T *NewElts, size_t NewCapacity)
Transfer ownership of the allocation, finishing up grow().
Definition:SmallVector.h:461
llvm::SmallVectorTemplateBase::growAndAssign
void growAndAssign(size_t NumElts, const T &Elt)
Definition:SmallVector.h:391
llvm::SmallVectorTemplateBase::forward_value_param
static const T & forward_value_param(const T &V)
Definition:SmallVector.h:389
llvm::SmallVectorTemplateBase::uninitialized_move
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:348
llvm::SmallVectorTemplateBase::pop_back
void pop_back()
Definition:SmallVector.h:425
llvm::SmallVectorTemplateBase::grow
void grow(size_t MinSize=0)
Grow the allocated memory (without initializing new elements), doubling the size of the allocated mem...
Definition:SmallVector.h:433
llvm::SmallVectorTemplateBase::push_back
void push_back(T &&Elt)
Definition:SmallVector.h:419
llvm::SmallVectorTemplateBase::reserveForParamAndGetAddress
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:377
llvm::SmallVectorTemplateBase::growAndEmplaceBack
T & growAndEmplaceBack(ArgTypes &&... Args)
Definition:SmallVector.h:401
llvm::SmallVectorTemplateBase::push_back
void push_back(const T &Elt)
Definition:SmallVector.h:413
llvm::SmallVectorTemplateCommon
This is the part of SmallVectorTemplateBase which does not depend on whether the type T is a POD.
Definition:SmallVector.h:121
llvm::SmallVectorTemplateCommon::assertSafeToAddRange
void assertSafeToAddRange(ItTy, ItTy)
Definition:SmallVector.h:224
llvm::SmallVectorTemplateCommon::isSmall
bool isSmall() const
Return true if this is a smallvector which has not had dynamic memory allocated for it.
Definition:SmallVector.h:143
llvm::SmallVectorTemplateCommon::end
iterator end()
Definition:SmallVector.h:269
llvm::SmallVectorTemplateCommon::end
const_iterator end() const
Definition:SmallVector.h:270
llvm::SmallVectorTemplateCommon::pointer
T * pointer
Definition:SmallVector.h:259
llvm::SmallVectorTemplateCommon::size_type
size_t size_type
Definition:SmallVector.h:248
llvm::SmallVectorTemplateCommon::rbegin
reverse_iterator rbegin()
Definition:SmallVector.h:273
llvm::SmallVectorTemplateCommon::reserveForParamAndGetAddressImpl
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:229
llvm::SmallVectorTemplateCommon::SmallVectorTemplateCommon
SmallVectorTemplateCommon(size_t Size)
Definition:SmallVector.h:135
llvm::SmallVectorTemplateCommon::front
reference front()
Definition:SmallVector.h:299
llvm::SmallVectorTemplateCommon::assertSafeToAddRange
void assertSafeToAddRange(const T *From, const T *To)
Check whether any part of the range will be invalidated by growing.
Definition:SmallVector.h:214
llvm::SmallVectorTemplateCommon::operator[]
const_reference operator[](size_type idx) const
Definition:SmallVector.h:294
llvm::SmallVectorTemplateCommon::resetToSmall
void resetToSmall()
Put this vector in a state of being small.
Definition:SmallVector.h:146
llvm::SmallVectorTemplateCommon::isSafeToReferenceAfterResize
bool isSafeToReferenceAfterResize(const void *Elt, size_t NewSize)
Return true unless Elt will be invalidated by resizing the vector to NewSize.
Definition:SmallVector.h:174
llvm::SmallVectorTemplateCommon::assertSafeToReferenceAfterClear
void assertSafeToReferenceAfterClear(const T *From, const T *To)
Check whether any part of the range will be invalidated by clearing.
Definition:SmallVector.h:201
llvm::SmallVectorTemplateCommon::const_reverse_iterator
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition:SmallVector.h:254
llvm::SmallVectorTemplateCommon::data
pointer data()
Return a pointer to the vector's buffer, even if empty().
Definition:SmallVector.h:286
llvm::SmallVectorTemplateCommon::isReferenceToRange
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:152
llvm::SmallVectorTemplateCommon::grow_pod
void grow_pod(size_t MinSize, size_t TSize)
Definition:SmallVector.h:137
llvm::SmallVectorTemplateCommon::const_pointer
const T * const_pointer
Definition:SmallVector.h:260
llvm::SmallVectorTemplateCommon::begin
iterator begin()
Definition:SmallVector.h:267
llvm::SmallVectorTemplateCommon::rbegin
const_reverse_iterator rbegin() const
Definition:SmallVector.h:274
llvm::SmallVectorTemplateCommon::iterator
T * iterator
Definition:SmallVector.h:251
llvm::SmallVectorTemplateCommon::const_iterator
const T * const_iterator
Definition:SmallVector.h:252
llvm::SmallVectorTemplateCommon::begin
const_iterator begin() const
Definition:SmallVector.h:268
llvm::SmallVectorTemplateCommon::reference
T & reference
Definition:SmallVector.h:257
llvm::SmallVectorTemplateCommon::operator[]
reference operator[](size_type idx)
Definition:SmallVector.h:290
llvm::SmallVectorTemplateCommon::capacity_in_bytes
size_t capacity_in_bytes() const
Definition:SmallVector.h:283
llvm::SmallVectorTemplateCommon::size_in_bytes
size_type size_in_bytes() const
Definition:SmallVector.h:278
llvm::SmallVectorTemplateCommon::max_size
size_type max_size() const
Definition:SmallVector.h:279
llvm::SmallVectorTemplateCommon::isReferenceToStorage
bool isReferenceToStorage(const void *V) const
Return true if V is an internal reference to this vector.
Definition:SmallVector.h:159
llvm::SmallVectorTemplateCommon::back
reference back()
Definition:SmallVector.h:308
llvm::SmallVectorTemplateCommon::back
const_reference back() const
Definition:SmallVector.h:312
llvm::SmallVectorTemplateCommon::rend
reverse_iterator rend()
Definition:SmallVector.h:275
llvm::SmallVectorTemplateCommon::isRangeInStorage
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:165
llvm::SmallVectorTemplateCommon::front
const_reference front() const
Definition:SmallVector.h:303
llvm::SmallVectorTemplateCommon::assertSafeToAdd
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:196
llvm::SmallVectorTemplateCommon::assertSafeToReferenceAfterResize
void assertSafeToReferenceAfterResize(const void *Elt, size_t NewSize)
Check whether Elt will be invalidated by resizing the vector to NewSize.
Definition:SmallVector.h:188
llvm::SmallVectorTemplateCommon::reverse_iterator
std::reverse_iterator< iterator > reverse_iterator
Definition:SmallVector.h:255
llvm::SmallVectorTemplateCommon::assertSafeToReferenceAfterClear
void assertSafeToReferenceAfterClear(ItTy, ItTy)
Definition:SmallVector.h:211
llvm::SmallVectorTemplateCommon::rend
const_reverse_iterator rend() const
Definition:SmallVector.h:276
llvm::SmallVectorTemplateCommon::data
const_pointer data() const
Return a pointer to the vector's buffer, even if empty().
Definition:SmallVector.h:288
llvm::SmallVectorTemplateCommon::getFirstEl
void * getFirstEl() const
Find the address of the first element.
Definition:SmallVector.h:128
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition:SmallVector.h:1196
llvm::SmallVector::SmallVector
SmallVector(std::initializer_list< T > IL)
Definition:SmallVector.h:1226
llvm::SmallVector::SmallVector
SmallVector(SmallVectorImpl< T > &&RHS)
Definition:SmallVector.h:1251
llvm::SmallVector::SmallVector
SmallVector(size_t Size)
Definition:SmallVector.h:1205
llvm::SmallVector::SmallVector
SmallVector(ArrayRef< U > A)
Definition:SmallVector.h:1232
llvm::SmallVector::SmallVector
SmallVector()
Definition:SmallVector.h:1198
llvm::SmallVector::~SmallVector
~SmallVector()
Definition:SmallVector.h:1200
llvm::SmallVector::SmallVector
SmallVector(size_t Size, const T &Value)
Definition:SmallVector.h:1210
llvm::SmallVector::operator=
SmallVector & operator=(const SmallVector &RHS)
Definition:SmallVector.h:1241
llvm::SmallVector::SmallVector
SmallVector(const iterator_range< RangeTy > &R)
Definition:SmallVector.h:1221
llvm::SmallVector::operator=
SmallVector & operator=(std::initializer_list< T > IL)
Definition:SmallVector.h:1279
llvm::SmallVector::SmallVector
SmallVector(ItTy S, ItTy E)
Definition:SmallVector.h:1216
llvm::SmallVector::SmallVector
SmallVector(SmallVector &&RHS)
Definition:SmallVector.h:1246
llvm::SmallVector::operator=
SmallVector & operator=(SmallVector &&RHS)
Definition:SmallVector.h:1256
llvm::SmallVector::SmallVector
SmallVector(const SmallVector &RHS)
Definition:SmallVector.h:1236
llvm::SmallVector::operator=
SmallVector & operator=(SmallVectorImpl< T > &&RHS)
Definition:SmallVector.h:1274
llvm::Value
LLVM Value Representation.
Definition:Value.h:74
llvm::iterator_range
A range adaptor for a pair of iterators.
Definition:iterator_range.h:42
ptrdiff_t
uint32_t
uint64_t
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition:AddressRanges.h:18
llvm::SmallVectorSizeType
std::conditional_t< sizeof(T)< 4 &&sizeof(void *) >=8, uint64_t, uint32_t > SmallVectorSizeType
Definition:SmallVector.h:107
llvm::capacity_in_bytes
BitVector::size_type capacity_in_bytes(const BitVector &X)
Definition:BitVector.h:835
llvm::EnableIfConvertibleToInputIterator
std::enable_if_t< std::is_convertible< typename std::iterator_traits< Iterator >::iterator_category, std::input_iterator_tag >::value > EnableIfConvertibleToInputIterator
Definition:SmallVector.h:42
llvm::to_vector
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:1299
llvm::ValueTypeFromRangeType
std::remove_const_t< std::remove_reference_t< decltype(*std::begin(std::declval< RangeType & >()))> > ValueTypeFromRangeType
Definition:SmallVector.h:1293
llvm::iterator_range
iterator_range(Container &&) -> iterator_range< llvm::detail::IterOfRange< Container > >
llvm::IRMemLocation::First
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
llvm::ArrayRef
ArrayRef(const T &OneElt) -> ArrayRef< T >
llvm::move
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition:STLExtras.h:1873
llvm::PseudoProbeReservedId::Last
@ Last
llvm::to_vector_of
SmallVector< Out, Size > to_vector_of(R &&Range)
Definition:SmallVector.h:1308
std
Implement std::hash so that hash_code can be used in STL containers.
Definition:BitVector.h:858
std::swap
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Definition:BitVector.h:860
N
#define N
llvm::CalculateSmallVectorDefaultInlinedElements
Helper class for calculating the default number of inline elements for SmallVector<T>.
Definition:SmallVector.h:1129
llvm::SmallVectorAlignmentAndSize
Figure out the offset of the first element.
Definition:SmallVector.h:110
llvm::SmallVectorAlignmentAndSize::Base
char Base[sizeof(SmallVectorBase< SmallVectorSizeType< T > >)]
Definition:SmallVector.h:112
llvm::SmallVectorAlignmentAndSize::FirstEl
char FirstEl[sizeof(T)]
Definition:SmallVector.h:113
llvm::SmallVectorStorage
Storage for the SmallVector elements.
Definition:SmallVector.h:1110

Generated on Thu Jul 17 2025 05:08:15 for LLVM by doxygen 1.9.6
[8]ページ先頭

©2009-2025 Movatter.jp