19 #ifndef LLVM_CLANG_ANALYSIS_SUPPORT_BUMPVECTOR_H 20 #define LLVM_CLANG_ANALYSIS_SUPPORT_BUMPVECTOR_H 22 #include "llvm/ADT/PointerIntPair.h" 23 #include "llvm/Support/Allocator.h" 29 #include <type_traits> 34 llvm::PointerIntPair<llvm::BumpPtrAllocator*, 1> Alloc;
42 Other.Alloc.setInt(
false);
43 Other.Alloc.setPointer(
nullptr);
53 delete Alloc.getPointer();
56 llvm::BumpPtrAllocator &
getAllocator() {
return *Alloc.getPointer(); }
63 T *Capacity =
nullptr;
72 if (std::is_class<T>::value) {
74 destroy_range(Begin, End);
110 assert(Begin + idx < End);
114 assert(Begin + idx < End);
144 if (std::is_class<T>::value) {
145 destroy_range(Begin, End);
161 if (End < Capacity) {
175 assert(I >= Begin && I <= End &&
"Iterator out of bounds.");
176 if (End + Cnt <= Capacity) {
178 move_range_right(I, End, Cnt);
179 construct_range(I, I + Cnt, E);
184 grow(C, size() + Cnt);
190 if (
unsigned(Capacity-Begin) < N)
203 void construct_range(
T *S,
T *E,
const T &Elt) {
208 void destroy_range(
T *S,
T *E) {
215 void move_range_right(
T *S,
T *E,
size_t D) {
216 for (
T *I = E + D - 1, *IL = S + D - 1; I != IL; --I) {
225 template <
typename T>
227 size_t CurCapacity = Capacity-
Begin;
228 size_t CurSize = size();
229 size_t NewCapacity = 2*CurCapacity;
230 if (NewCapacity < MinSize)
231 NewCapacity = MinSize;
234 T *NewElts = C.
getAllocator().template Allocate<T>(NewCapacity);
238 if (std::is_class<T>::value) {
239 std::uninitialized_copy(Begin,
End, NewElts);
241 destroy_range(Begin,
End);
244 memcpy(NewElts, Begin, CurSize *
sizeof(
T));
251 End = NewElts+CurSize;
252 Capacity = Begin+NewCapacity;
257 #endif // LLVM_CLANG_ANALYSIS_SUPPORT_BUMPVECTOR_H reference operator[](unsigned idx)
__SIZE_TYPE__ size_t
The unsigned integer type of the result of the sizeof operator.
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterat...
llvm::BumpPtrAllocator & getAllocator()
reverse_iterator rbegin()
BumpVector(BumpVectorContext &C, unsigned N)
const_iterator begin() const
std::reverse_iterator< iterator > reverse_iterator
BumpVectorContext(BumpVectorContext &&Other)
pointer data()
data - Return a pointer to the vector's buffer, even if empty().
const_reference back() const
const_iterator end() const
ptrdiff_t difference_type
void reserve(BumpVectorContext &C, unsigned N)
const FunctionProtoType * T
const_pointer data() const
data - Return a pointer to the vector's buffer, even if empty().
std::reverse_iterator< const_iterator > const_reverse_iterator
The result type of a method or function.
const_reference front() const
__PTRDIFF_TYPE__ ptrdiff_t
A signed integer type that is the result of subtracting two pointers.
const_reference operator[](unsigned idx) const
void push_back(const_reference Elt, BumpVectorContext &C)
Dataflow Directional Tag Classes.
BumpVectorContext(llvm::BumpPtrAllocator &A)
Construct a new BumpVectorContext that reuses an existing BumpPtrAllocator.
const_reverse_iterator rbegin() const
iterator insert(iterator I, size_t Cnt, const_reference E, BumpVectorContext &C)
insert - Insert some number of copies of element into a position.
CFGElement - Represents a top-level expression in a basic block.
size_t capacity() const
capacity - Return the total number of elements in the currently allocated buffer. ...
const_reverse_iterator rend() const
BumpVectorContext()
Construct a new BumpVectorContext that creates a new BumpPtrAllocator and destroys it when the BumpVe...