Go to the documentation of this file.
18 #ifndef LLVM_CLANG_ANALYSIS_SUPPORT_BUMPVECTOR_H
19 #define LLVM_CLANG_ANALYSIS_SUPPORT_BUMPVECTOR_H
21 #include "llvm/ADT/PointerIntPair.h"
22 #include "llvm/Support/Allocator.h"
28 #include <type_traits>
33 llvm::PointerIntPair<llvm::BumpPtrAllocator*, 1> Alloc;
41 Other.Alloc.setInt(
false);
42 Other.Alloc.setPointer(
nullptr);
52 delete Alloc.getPointer();
55 llvm::BumpPtrAllocator &
getAllocator() {
return *Alloc.getPointer(); }
62 T *Capacity =
nullptr;
71 if (std::is_class<T>::value) {
73 destroy_range(
Begin, End);
109 assert(
Begin + idx < End);
113 assert(
Begin + idx < End);
143 if (std::is_class<T>::value) {
144 destroy_range(
Begin, End);
160 if (End < Capacity) {
174 assert(I >=
Begin && I <= End &&
"Iterator out of bounds.");
175 if (End + Cnt <= Capacity) {
177 move_range_right(I, End, Cnt);
178 construct_range(I, I + Cnt, E);
183 grow(C,
size() + Cnt);
189 if (
unsigned(Capacity-
Begin) < N)
202 void construct_range(T *S, T *E,
const T &Elt) {
207 void destroy_range(T *S, T *E) {
214 void move_range_right(T *S, T *E,
size_t D) {
215 for (T *I = E + D - 1, *IL = S + D - 1; I != IL; --I) {
224 template <
typename T>
225 void BumpVector<T>::grow(BumpVectorContext &C,
size_t MinSize) {
226 size_t CurCapacity = Capacity-
Begin;
227 size_t CurSize = size();
228 size_t NewCapacity = 2*CurCapacity;
229 if (NewCapacity < MinSize)
230 NewCapacity = MinSize;
233 T *NewElts =
C.getAllocator().template Allocate<T>(NewCapacity);
237 if (std::is_class<T>::value) {
238 std::uninitialized_copy(
Begin,
End, NewElts);
250 End = NewElts+CurSize;
251 Capacity =
Begin+NewCapacity;
256 #endif // LLVM_CLANG_ANALYSIS_SUPPORT_BUMPVECTOR_H
YAML serialization mapping.
ptrdiff_t difference_type
BumpVectorContext(llvm::BumpPtrAllocator &A)
Construct a new BumpVectorContext that reuses an existing BumpPtrAllocator.
const_reverse_iterator rbegin() const
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
void reserve(BumpVectorContext &C, unsigned N)
reference operator[](unsigned idx)
std::reverse_iterator< iterator > reverse_iterator
const_pointer data() const
data - Return a pointer to the vector's buffer, even if empty().
const_reverse_iterator rend() const
__SIZE_TYPE__ size_t
The unsigned integer type of the result of the sizeof operator.
size_t capacity() const
capacity - Return the total number of elements in the currently allocated buffer.
reverse_iterator rbegin()
const_reference back() const
BumpVectorContext(BumpVectorContext &&Other)
iterator insert(iterator I, size_t Cnt, const_reference E, BumpVectorContext &C)
insert - Insert some number of copies of element into a position.
std::reverse_iterator< const_iterator > const_reverse_iterator
pointer data()
data - Return a pointer to the vector's buffer, even if empty().
BumpVectorContext()
Construct a new BumpVectorContext that creates a new BumpPtrAllocator and destroys it when the BumpVe...
llvm::BumpPtrAllocator & getAllocator()
Represents a top-level expression in a basic block.
const_iterator end() const
__PTRDIFF_TYPE__ ptrdiff_t
A signed integer type that is the result of subtracting two pointers.
BumpVector(BumpVectorContext &C, unsigned N)
const_reference operator[](unsigned idx) const
void push_back(const_reference Elt, BumpVectorContext &C)
const_iterator begin() const
const_reference front() const