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"
33 llvm::PointerIntPair<llvm::BumpPtrAllocator*, 1> Alloc;
41 Other.Alloc.setInt(
false);
42 Other.Alloc.setPointer(
nullptr);
61 delete Alloc.getPointer();
64 llvm::BumpPtrAllocator &
getAllocator() {
return *Alloc.getPointer(); }
71 T *Capacity =
nullptr;
80 if (std::is_class<T>::value) {
82 destroy_range(
Begin, End);
118 assert(
Begin + idx < End);
122 assert(
Begin + idx < End);
152 if (std::is_class<T>::value) {
153 destroy_range(
Begin, End);
169 if (End < Capacity) {
183 assert(I >=
Begin && I <= End &&
"Iterator out of bounds.");
184 if (End + Cnt <= Capacity) {
186 move_range_right(I, End, Cnt);
187 construct_range(I, I + Cnt,
E);
192 grow(
C,
size() + Cnt);
198 if (
unsigned(Capacity-
Begin) < N)
211 void construct_range(
T *S,
T *
E,
const T &Elt) {
216 void destroy_range(
T *S,
T *
E) {
223 void move_range_right(
T *S,
T *
E,
size_t D) {
224 for (
T *I =
E +
D - 1, *IL = S +
D - 1; I != IL; --I) {
234void BumpVector<T>::grow(BumpVectorContext &
C,
size_t MinSize) {
235 size_t CurCapacity = Capacity-
Begin;
236 size_t CurSize = size();
237 size_t NewCapacity = 2*CurCapacity;
238 if (NewCapacity < MinSize)
239 NewCapacity = MinSize;
242 T *NewElts =
C.getAllocator().template Allocate<T>(NewCapacity);
246 if (std::is_class<T>::value) {
247 std::uninitialized_copy(
Begin, End, NewElts);
249 destroy_range(
Begin, End);
259 End = NewElts+CurSize;
260 Capacity =
Begin+NewCapacity;
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
__PTRDIFF_TYPE__ ptrdiff_t
BumpVectorContext(const BumpVectorContext &)=delete
BumpVectorContext(llvm::BumpPtrAllocator &A)
Construct a new BumpVectorContext that reuses an existing BumpPtrAllocator.
BumpVectorContext & operator=(const BumpVectorContext &)=delete
BumpVectorContext(BumpVectorContext &&Other)
BumpVectorContext & operator=(BumpVectorContext &&)=delete
llvm::BumpPtrAllocator & getAllocator()
BumpVectorContext()
Construct a new BumpVectorContext that creates a new BumpPtrAllocator and destroys it when the BumpVe...
std::reverse_iterator< const_iterator > const_reverse_iterator
reference operator[](unsigned idx)
ptrdiff_t difference_type
const_reference operator[](unsigned idx) const
const_reference front() const
const_iterator begin() const
const_iterator end() const
iterator insert(iterator I, size_t Cnt, const_reference E, BumpVectorContext &C)
insert - Insert some number of copies of element into a position.
pointer data()
data - Return a pointer to the vector's buffer, even if empty().
BumpVector(BumpVectorContext &C, unsigned N)
void reserve(BumpVectorContext &C, unsigned N)
const T & const_reference
const_reverse_iterator rbegin() const
reverse_iterator rbegin()
std::reverse_iterator< iterator > reverse_iterator
const_pointer data() const
data - Return a pointer to the vector's buffer, even if empty().
const_reference back() const
const_reverse_iterator rend() const
void push_back(const_reference Elt, BumpVectorContext &C)
size_t capacity() const
capacity - Return the total number of elements in the currently allocated buffer.
The JSON file list parser is used to communicate input to InstallAPI.
@ Result
The result type of a method or function.
const FunctionProtoType * T
@ Other
Other implicit parameter.
Diagnostic wrappers for TextAPI types for error reporting.