Coverage Report

Created: 2018-07-22 10:17

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/clang/include/clang/Analysis/Support/BumpVector.h
Line
Count
Source (jump to first uncovered line)
1
//===- BumpVector.h - Vector-like ADT that uses bump allocation -*- C++ -*-===//
2
//
3
//                     The LLVM Compiler Infrastructure
4
//
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
7
//
8
//===----------------------------------------------------------------------===//
9
//
10
//  This file provides BumpVector, a vector-like ADT whose contents are
11
//  allocated from a BumpPtrAllocator.
12
//
13
//===----------------------------------------------------------------------===//
14
15
// FIXME: Most of this is copy-and-paste from SmallVector.h.  We can
16
// refactor this core logic into something common that is shared between
17
// the two.  The main thing that is different is the allocation strategy.
18
19
#ifndef LLVM_CLANG_ANALYSIS_SUPPORT_BUMPVECTOR_H
20
#define LLVM_CLANG_ANALYSIS_SUPPORT_BUMPVECTOR_H
21
22
#include "llvm/ADT/PointerIntPair.h"
23
#include "llvm/Support/Allocator.h"
24
#include <cassert>
25
#include <cstddef>
26
#include <cstring>
27
#include <iterator>
28
#include <memory>
29
#include <type_traits>
30
31
namespace clang {
32
  
33
class BumpVectorContext {
34
  llvm::PointerIntPair<llvm::BumpPtrAllocator*, 1> Alloc;
35
36
public:
37
  /// Construct a new BumpVectorContext that creates a new BumpPtrAllocator
38
  /// and destroys it when the BumpVectorContext object is destroyed.
39
439k
  BumpVectorContext() : Alloc(new llvm::BumpPtrAllocator(), 1) {}
40
41
13.8k
  BumpVectorContext(BumpVectorContext &&Other) : Alloc(Other.Alloc) {
42
13.8k
    Other.Alloc.setInt(false);
43
13.8k
    Other.Alloc.setPointer(nullptr);
44
13.8k
  }
45
46
  /// Construct a new BumpVectorContext that reuses an existing
47
  /// BumpPtrAllocator.  This BumpPtrAllocator is not destroyed when the
48
  /// BumpVectorContext object is destroyed.
49
14.4k
  BumpVectorContext(llvm::BumpPtrAllocator &A) : Alloc(&A, 0) {}
50
  
51
454k
  ~BumpVectorContext() {
52
454k
    if (Alloc.getInt())
53
439k
      delete Alloc.getPointer();
54
454k
  }
55
  
56
16.3M
  llvm::BumpPtrAllocator &getAllocator() { return *Alloc.getPointer(); }
57
};
58
  
59
template<typename T>
60
class BumpVector {
61
  T *Begin = nullptr;
62
  T *End = nullptr;
63
  T *Capacity = nullptr;
64
65
public:
66
  // Default ctor - Initialize to empty.
67
6.79M
  explicit BumpVector(BumpVectorContext &C, unsigned N) {
68
6.79M
    reserve(C, N);
69
6.79M
  }
clang::BumpVector<clang::ento::ExplodedNode*>::BumpVector(clang::BumpVectorContext&, unsigned int)
Line
Count
Source
67
36.0k
  explicit BumpVector(BumpVectorContext &C, unsigned N) {
68
36.0k
    reserve(C, N);
69
36.0k
  }
clang::BumpVector<clang::ento::MemRegion const*>::BumpVector(clang::BumpVectorContext&, unsigned int)
Line
Count
Source
67
454
  explicit BumpVector(BumpVectorContext &C, unsigned N) {
68
454
    reserve(C, N);
69
454
  }
clang::BumpVector<clang::VarDecl const*>::BumpVector(clang::BumpVectorContext&, unsigned int)
Line
Count
Source
67
379
  explicit BumpVector(BumpVectorContext &C, unsigned N) {
68
379
    reserve(C, N);
69
379
  }
clang::BumpVector<clang::CFGElement>::BumpVector(clang::BumpVectorContext&, unsigned int)
Line
Count
Source
67
2.11M
  explicit BumpVector(BumpVectorContext &C, unsigned N) {
68
2.11M
    reserve(C, N);
69
2.11M
  }
clang::BumpVector<clang::CFGBlock::AdjacentBlock>::BumpVector(clang::BumpVectorContext&, unsigned int)
Line
Count
Source
67
4.22M
  explicit BumpVector(BumpVectorContext &C, unsigned N) {
68
4.22M
    reserve(C, N);
69
4.22M
  }
clang::BumpVector<clang::CFGBlock*>::BumpVector(clang::BumpVectorContext&, unsigned int)
Line
Count
Source
67
412k
  explicit BumpVector(BumpVectorContext &C, unsigned N) {
68
412k
    reserve(C, N);
69
412k
  }
clang::BumpVector<clang::VarDecl*>::BumpVector(clang::BumpVectorContext&, unsigned int)
Line
Count
Source
67
13.8k
  explicit BumpVector(BumpVectorContext &C, unsigned N) {
68
13.8k
    reserve(C, N);
69
13.8k
  }
70
  
71
412k
  ~BumpVector() {
72
412k
    if (std::is_class<T>::value) {
73
0
      // Destroy the constructed elements in the vector.
74
0
      destroy_range(Begin, End);
75
0
    }
76
412k
  }
77
  
78
  using size_type = size_t;
79
  using difference_type = ptrdiff_t;
80
  using value_type = T;
81
  using iterator = T *;
82
  using const_iterator = const T *;
83
  
84
  using const_reverse_iterator = std::reverse_iterator<const_iterator>;
85
  using reverse_iterator = std::reverse_iterator<iterator>;
86
  
87
  using reference = T &;
88
  using const_reference = const T &;
89
  using pointer = T *;
90
  using const_pointer = const T *;
91
  
92
  // forward iterator creation methods.
93
4.74M
  iterator begin() { return Begin; }
clang::BumpVector<clang::CFGBlock*>::begin()
Line
Count
Source
93
2.17M
  iterator begin() { return Begin; }
clang::BumpVector<clang::CFGElement>::begin()
Line
Count
Source
93
1.68M
  iterator begin() { return Begin; }
clang::BumpVector<clang::CFGBlock::AdjacentBlock>::begin()
Line
Count
Source
93
871k
  iterator begin() { return Begin; }
clang::BumpVector<clang::ento::ExplodedNode*>::begin()
Line
Count
Source
93
7.17k
  iterator begin() { return Begin; }
clang::BumpVector<clang::ento::MemRegion const*>::begin()
Line
Count
Source
93
4.29k
  iterator begin() { return Begin; }
94
5.67M
  const_iterator begin() const { return Begin; }
clang::BumpVector<clang::CFGBlock*>::begin() const
Line
Count
Source
94
93.8k
  const_iterator begin() const { return Begin; }
clang::BumpVector<clang::CFGBlock::AdjacentBlock>::begin() const
Line
Count
Source
94
4.38M
  const_iterator begin() const { return Begin; }
clang::BumpVector<clang::CFGElement>::begin() const
Line
Count
Source
94
1.19M
  const_iterator begin() const { return Begin; }
clang::BumpVector<clang::VarDecl const*>::begin() const
Line
Count
Source
94
750
  const_iterator begin() const { return Begin; }
95
7.26M
  iterator end() { return End; }
clang::BumpVector<clang::CFGBlock*>::end()
Line
Count
Source
95
4.69M
  iterator end() { return End; }
clang::BumpVector<clang::CFGElement>::end()
Line
Count
Source
95
1.68M
  iterator end() { return End; }
clang::BumpVector<clang::CFGBlock::AdjacentBlock>::end()
Line
Count
Source
95
871k
  iterator end() { return End; }
clang::BumpVector<clang::ento::ExplodedNode*>::end()
Line
Count
Source
95
6.67k
  iterator end() { return End; }
clang::BumpVector<clang::ento::MemRegion const*>::end()
Line
Count
Source
95
4.26k
  iterator end() { return End; }
96
6.60M
  const_iterator end() const { return End; }
clang::BumpVector<clang::CFGBlock*>::end() const
Line
Count
Source
96
93.8k
  const_iterator end() const { return End; }
clang::BumpVector<clang::CFGElement>::end() const
Line
Count
Source
96
1.23M
  const_iterator end() const { return End; }
clang::BumpVector<clang::CFGBlock::AdjacentBlock>::end() const
Line
Count
Source
96
5.27M
  const_iterator end() const { return End; }
clang::BumpVector<clang::VarDecl const*>::end() const
Line
Count
Source
96
750
  const_iterator end() const { return End; }
97
  
98
  // reverse iterator creation methods.
99
1.68M
  reverse_iterator rbegin() { return reverse_iterator(end()); }
clang::BumpVector<clang::CFGElement>::rbegin()
Line
Count
Source
99
1.68M
  reverse_iterator rbegin() { return reverse_iterator(end()); }
Unexecuted instantiation: clang::BumpVector<clang::CFGBlock::AdjacentBlock>::rbegin()
clang::BumpVector<clang::CFGBlock*>::rbegin()
Line
Count
Source
99
64
  reverse_iterator rbegin() { return reverse_iterator(end()); }
100
806k
  const_reverse_iterator rbegin() const{ return const_reverse_iterator(end()); }
clang::BumpVector<clang::CFGElement>::rbegin() const
Line
Count
Source
100
806k
  const_reverse_iterator rbegin() const{ return const_reverse_iterator(end()); }
clang::BumpVector<clang::CFGBlock::AdjacentBlock>::rbegin() const
Line
Count
Source
100
227
  const_reverse_iterator rbegin() const{ return const_reverse_iterator(end()); }
Unexecuted instantiation: clang::BumpVector<clang::CFGBlock*>::rbegin() const
101
1.68M
  reverse_iterator rend() { return reverse_iterator(begin()); }
clang::BumpVector<clang::CFGElement>::rend()
Line
Count
Source
101
1.68M
  reverse_iterator rend() { return reverse_iterator(begin()); }
Unexecuted instantiation: clang::BumpVector<clang::CFGBlock::AdjacentBlock>::rend()
clang::BumpVector<clang::CFGBlock*>::rend()
Line
Count
Source
101
64
  reverse_iterator rend() { return reverse_iterator(begin()); }
102
806k
  const_reverse_iterator rend() const {
103
806k
    return const_reverse_iterator(begin());
104
806k
  }
clang::BumpVector<clang::CFGElement>::rend() const
Line
Count
Source
102
806k
  const_reverse_iterator rend() const {
103
806k
    return const_reverse_iterator(begin());
104
806k
  }
clang::BumpVector<clang::CFGBlock::AdjacentBlock>::rend() const
Line
Count
Source
102
137
  const_reverse_iterator rend() const {
103
137
    return const_reverse_iterator(begin());
104
137
  }
Unexecuted instantiation: clang::BumpVector<clang::CFGBlock*>::rend() const
105
    
106
167k
  bool empty() const { return Begin == End; }
clang::BumpVector<clang::CFGElement>::empty() const
Line
Count
Source
106
147k
  bool empty() const { return Begin == End; }
clang::BumpVector<clang::CFGBlock::AdjacentBlock>::empty() const
Line
Count
Source
106
20.0k
  bool empty() const { return Begin == End; }
107
12.0M
  size_type size() const { return End-Begin; }
clang::BumpVector<clang::CFGElement>::size() const
Line
Count
Source
107
6.27M
  size_type size() const { return End-Begin; }
clang::BumpVector<clang::CFGBlock::AdjacentBlock>::size() const
Line
Count
Source
107
5.12M
  size_type size() const { return End-Begin; }
clang::BumpVector<clang::ento::ExplodedNode*>::size() const
Line
Count
Source
107
123k
  size_type size() const { return End-Begin; }
clang::BumpVector<clang::ento::MemRegion const*>::size() const
Line
Count
Source
107
454
  size_type size() const { return End-Begin; }
clang::BumpVector<clang::VarDecl const*>::size() const
Line
Count
Source
107
379
  size_type size() const { return End-Begin; }
clang::BumpVector<clang::CFGBlock*>::size() const
Line
Count
Source
107
461k
  size_type size() const { return End-Begin; }
clang::BumpVector<clang::VarDecl*>::size() const
Line
Count
Source
107
29.6k
  size_type size() const { return End-Begin; }
108
109
  reference operator[](unsigned idx) {
110
    assert(Begin + idx < End);
111
    return Begin[idx];
112
  }
113
2.29M
  const_reference operator[](unsigned idx) const {
114
2.29M
    assert(Begin + idx < End);
115
2.29M
    return Begin[idx];
116
2.29M
  }
clang::BumpVector<clang::CFGElement>::operator[](unsigned int) const
Line
Count
Source
113
2.19M
  const_reference operator[](unsigned idx) const {
114
2.19M
    assert(Begin + idx < End);
115
2.19M
    return Begin[idx];
116
2.19M
  }
clang::BumpVector<clang::VarDecl*>::operator[](unsigned int) const
Line
Count
Source
113
99.8k
  const_reference operator[](unsigned idx) const {
114
99.8k
    assert(Begin + idx < End);
115
99.8k
    return Begin[idx];
116
99.8k
  }
117
  
118
  reference front() {
119
    return begin()[0];
120
  }
121
45.0k
  const_reference front() const {
122
45.0k
    return begin()[0];
123
45.0k
  }
124
  
125
2.52M
  reference back() {
126
2.52M
    return end()[-1];
127
2.52M
  }
128
85.9k
  const_reference back() const {
129
85.9k
    return end()[-1];
130
85.9k
  }
131
  
132
  void pop_back() {
133
    --End;
134
    End->~T();
135
  }
136
  
137
  T pop_back_val() {
138
    T Result = back();
139
    pop_back();
140
    return Result;
141
  }
142
  
143
  void clear() {
144
    if (std::is_class<T>::value) {
145
      destroy_range(Begin, End);
146
    }
147
    End = Begin;
148
  }
149
  
150
  /// data - Return a pointer to the vector's buffer, even if empty().
151
  pointer data() {
152
    return pointer(Begin);
153
  }
154
  
155
  /// data - Return a pointer to the vector's buffer, even if empty().
156
  const_pointer data() const {
157
    return const_pointer(Begin);
158
  }
159
  
160
16.2M
  void push_back(const_reference Elt, BumpVectorContext &C) {
161
16.2M
    if (End < Capacity) {
162
16.2M
    Retry:
163
16.2M
      new (End) T(Elt);
164
16.2M
      ++End;
165
16.2M
      return;
166
2.14M
    }
167
2.14M
    grow(C);
168
2.14M
    goto Retry;    
169
2.14M
  }
clang::BumpVector<clang::ento::ExplodedNode*>::push_back(clang::ento::ExplodedNode* const&, clang::BumpVectorContext&)
Line
Count
Source
160
75.6k
  void push_back(const_reference Elt, BumpVectorContext &C) {
161
75.6k
    if (End < Capacity) {
162
75.6k
    Retry:
163
75.6k
      new (End) T(Elt);
164
75.6k
      ++End;
165
75.6k
      return;
166
199
    }
167
199
    grow(C);
168
199
    goto Retry;    
169
199
  }
clang::BumpVector<clang::ento::MemRegion const*>::push_back(clang::ento::MemRegion const* const&, clang::BumpVectorContext&)
Line
Count
Source
160
576
  void push_back(const_reference Elt, BumpVectorContext &C) {
161
576
    if (End < Capacity) {
162
576
    Retry:
163
576
      new (End) T(Elt);
164
576
      ++End;
165
576
      return;
166
0
    }
167
0
    grow(C);
168
0
    goto Retry;    
169
0
  }
clang::BumpVector<clang::VarDecl const*>::push_back(clang::VarDecl const* const&, clang::BumpVectorContext&)
Line
Count
Source
160
317
  void push_back(const_reference Elt, BumpVectorContext &C) {
161
317
    if (End < Capacity) {
162
317
    Retry:
163
317
      new (End) T(Elt);
164
317
      ++End;
165
317
      return;
166
0
    }
167
0
    grow(C);
168
0
    goto Retry;    
169
0
  }
clang::BumpVector<clang::CFGElement>::push_back(clang::CFGElement const&, clang::BumpVectorContext&)
Line
Count
Source
160
9.66M
  void push_back(const_reference Elt, BumpVectorContext &C) {
161
9.66M
    if (End < Capacity) {
162
9.66M
    Retry:
163
9.66M
      new (End) T(Elt);
164
9.66M
      ++End;
165
9.66M
      return;
166
1.20M
    }
167
1.20M
    grow(C);
168
1.20M
    goto Retry;    
169
1.20M
  }
clang::BumpVector<clang::VarDecl*>::push_back(clang::VarDecl* const&, clang::BumpVectorContext&)
Line
Count
Source
160
15.8k
  void push_back(const_reference Elt, BumpVectorContext &C) {
161
15.8k
    if (End < Capacity) {
162
15.8k
    Retry:
163
15.8k
      new (End) T(Elt);
164
15.8k
      ++End;
165
15.8k
      return;
166
41
    }
167
41
    grow(C);
168
41
    goto Retry;    
169
41
  }
clang::BumpVector<clang::CFGBlock*>::push_back(clang::CFGBlock* const&, clang::BumpVectorContext&)
Line
Count
Source
160
2.11M
  void push_back(const_reference Elt, BumpVectorContext &C) {
161
2.11M
    if (End < Capacity) {
162
2.11M
    Retry:
163
2.11M
      new (End) T(Elt);
164
2.11M
      ++End;
165
2.11M
      return;
166
49.2k
    }
167
49.2k
    grow(C);
168
49.2k
    goto Retry;    
169
49.2k
  }
clang::BumpVector<clang::CFGBlock::AdjacentBlock>::push_back(clang::CFGBlock::AdjacentBlock const&, clang::BumpVectorContext&)
Line
Count
Source
160
4.37M
  void push_back(const_reference Elt, BumpVectorContext &C) {
161
4.37M
    if (End < Capacity) {
162
4.37M
    Retry:
163
4.37M
      new (End) T(Elt);
164
4.37M
      ++End;
165
4.37M
      return;
166
889k
    }
167
889k
    grow(C);
168
889k
    goto Retry;    
169
889k
  }
170
171
  /// insert - Insert some number of copies of element into a position. Return
172
  /// iterator to position after last inserted copy.
173
  iterator insert(iterator I, size_t Cnt, const_reference E,
174
98
      BumpVectorContext &C) {
175
98
    assert(I >= Begin && I <= End && "Iterator out of bounds.");
176
98
    if (End + Cnt <= Capacity) {
177
98
    Retry:
178
98
      move_range_right(I, End, Cnt);
179
98
      construct_range(I, I + Cnt, E);
180
98
      End += Cnt;
181
98
      return I + Cnt;
182
0
    }
183
0
    ptrdiff_t D = I - Begin;
184
0
    grow(C, size() + Cnt);
185
0
    I = Begin + D;
186
0
    goto Retry;
187
0
  }
188
189
6.79M
  void reserve(BumpVectorContext &C, unsigned N) {
190
6.79M
    if (unsigned(Capacity-Begin) < N)
191
6.79M
      grow(C, N);
192
6.79M
  }
clang::BumpVector<clang::ento::ExplodedNode*>::reserve(clang::BumpVectorContext&, unsigned int)
Line
Count
Source
189
36.0k
  void reserve(BumpVectorContext &C, unsigned N) {
190
36.0k
    if (unsigned(Capacity-Begin) < N)
191
36.0k
      grow(C, N);
192
36.0k
  }
clang::BumpVector<clang::ento::MemRegion const*>::reserve(clang::BumpVectorContext&, unsigned int)
Line
Count
Source
189
454
  void reserve(BumpVectorContext &C, unsigned N) {
190
454
    if (unsigned(Capacity-Begin) < N)
191
454
      grow(C, N);
192
454
  }
clang::BumpVector<clang::VarDecl const*>::reserve(clang::BumpVectorContext&, unsigned int)
Line
Count
Source
189
379
  void reserve(BumpVectorContext &C, unsigned N) {
190
379
    if (unsigned(Capacity-Begin) < N)
191
379
      grow(C, N);
192
379
  }
clang::BumpVector<clang::CFGElement>::reserve(clang::BumpVectorContext&, unsigned int)
Line
Count
Source
189
2.11M
  void reserve(BumpVectorContext &C, unsigned N) {
190
2.11M
    if (unsigned(Capacity-Begin) < N)
191
2.11M
      grow(C, N);
192
2.11M
  }
clang::BumpVector<clang::CFGBlock::AdjacentBlock>::reserve(clang::BumpVectorContext&, unsigned int)
Line
Count
Source
189
4.22M
  void reserve(BumpVectorContext &C, unsigned N) {
190
4.22M
    if (unsigned(Capacity-Begin) < N)
191
4.22M
      grow(C, N);
192
4.22M
  }
clang::BumpVector<clang::CFGBlock*>::reserve(clang::BumpVectorContext&, unsigned int)
Line
Count
Source
189
412k
  void reserve(BumpVectorContext &C, unsigned N) {
190
412k
    if (unsigned(Capacity-Begin) < N)
191
412k
      grow(C, N);
192
412k
  }
clang::BumpVector<clang::VarDecl*>::reserve(clang::BumpVectorContext&, unsigned int)
Line
Count
Source
189
13.8k
  void reserve(BumpVectorContext &C, unsigned N) {
190
13.8k
    if (unsigned(Capacity-Begin) < N)
191
13.8k
      grow(C, N);
192
13.8k
  }
193
194
  /// capacity - Return the total number of elements in the currently allocated
195
  /// buffer.
196
  size_t capacity() const { return Capacity - Begin; }  
197
    
198
private:
199
  /// grow - double the size of the allocated memory, guaranteeing space for at
200
  /// least one more element or MinSize if specified.
201
  void grow(BumpVectorContext &C, size_type MinSize = 1);
202
  
203
98
  void construct_range(T *S, T *E, const T &Elt) {
204
125
    for (; S != E; 
++S27
)
205
27
      new (S) T(Elt);
206
98
  }
207
  
208
2.09M
  void destroy_range(T *S, T *E) {
209
12.5M
    while (S != E) {
210
10.4M
      --E;
211
10.4M
      E->~T();
212
10.4M
    }
213
2.09M
  }
Unexecuted instantiation: clang::BumpVector<clang::ento::ExplodedNode*>::destroy_range(clang::ento::ExplodedNode**, clang::ento::ExplodedNode**)
Unexecuted instantiation: clang::BumpVector<clang::ento::MemRegion const*>::destroy_range(clang::ento::MemRegion const**, clang::ento::MemRegion const**)
Unexecuted instantiation: clang::BumpVector<clang::CFGBlock*>::destroy_range(clang::CFGBlock**, clang::CFGBlock**)
Unexecuted instantiation: clang::BumpVector<clang::VarDecl const*>::destroy_range(clang::VarDecl const**, clang::VarDecl const**)
clang::BumpVector<clang::CFGElement>::destroy_range(clang::CFGElement*, clang::CFGElement*)
Line
Count
Source
208
1.20M
  void destroy_range(T *S, T *E) {
209
10.4M
    while (S != E) {
210
9.29M
      --E;
211
9.29M
      E->~T();
212
9.29M
    }
213
1.20M
  }
clang::BumpVector<clang::CFGBlock::AdjacentBlock>::destroy_range(clang::CFGBlock::AdjacentBlock*, clang::CFGBlock::AdjacentBlock*)
Line
Count
Source
208
889k
  void destroy_range(T *S, T *E) {
209
2.02M
    while (S != E) {
210
1.13M
      --E;
211
1.13M
      E->~T();
212
1.13M
    }
213
889k
  }
Unexecuted instantiation: clang::BumpVector<clang::VarDecl*>::destroy_range(clang::VarDecl**, clang::VarDecl**)
214
215
98
  void move_range_right(T *S, T *E, size_t D) {
216
297
    for (T *I = E + D - 1, *IL = S + D - 1; I != IL; 
--I199
) {
217
199
      --E;
218
199
      new (I) T(*E);
219
199
      E->~T();
220
199
    }
221
98
  }
222
};
223
  
224
// Define this out-of-line to dissuade the C++ compiler from inlining it.
225
template <typename T>
226
8.93M
void BumpVector<T>::grow(BumpVectorContext &C, size_t MinSize) {
227
8.93M
  size_t CurCapacity = Capacity-Begin;
228
8.93M
  size_t CurSize = size();
229
8.93M
  size_t NewCapacity = 2*CurCapacity;
230
8.93M
  if (NewCapacity < MinSize)
231
6.79M
    NewCapacity = MinSize;
232
8.93M
233
8.93M
  // Allocate the memory from the BumpPtrAllocator.
234
8.93M
  T *NewElts = C.getAllocator().template Allocate<T>(NewCapacity);
235
8.93M
  
236
8.93M
  // Copy the elements over.
237
8.93M
  if (Begin != End) {
238
2.14M
    if (std::is_class<T>::value) {
239
2.09M
      std::uninitialized_copy(Begin, End, NewElts);
240
2.09M
      // Destroy the original elements.
241
2.09M
      destroy_range(Begin, End);
242
2.09M
    } else {
243
49.5k
      // Use memcpy for PODs (std::uninitialized_copy optimizes to memmove).
244
49.5k
      memcpy(NewElts, Begin, CurSize * sizeof(T));
245
49.5k
    }
246
2.14M
  }
247
8.93M
248
8.93M
  // For now, leak 'Begin'.  We can add it back to a freelist in
249
8.93M
  // BumpVectorContext.
250
8.93M
  Begin = NewElts;
251
8.93M
  End = NewElts+CurSize;
252
8.93M
  Capacity = Begin+NewCapacity;
253
8.93M
}
clang::BumpVector<clang::ento::ExplodedNode*>::grow(clang::BumpVectorContext&, unsigned long)
Line
Count
Source
226
36.2k
void BumpVector<T>::grow(BumpVectorContext &C, size_t MinSize) {
227
36.2k
  size_t CurCapacity = Capacity-Begin;
228
36.2k
  size_t CurSize = size();
229
36.2k
  size_t NewCapacity = 2*CurCapacity;
230
36.2k
  if (NewCapacity < MinSize)
231
36.0k
    NewCapacity = MinSize;
232
36.2k
233
36.2k
  // Allocate the memory from the BumpPtrAllocator.
234
36.2k
  T *NewElts = C.getAllocator().template Allocate<T>(NewCapacity);
235
36.2k
  
236
36.2k
  // Copy the elements over.
237
36.2k
  if (Begin != End) {
238
199
    if (std::is_class<T>::value) {
239
0
      std::uninitialized_copy(Begin, End, NewElts);
240
0
      // Destroy the original elements.
241
0
      destroy_range(Begin, End);
242
199
    } else {
243
199
      // Use memcpy for PODs (std::uninitialized_copy optimizes to memmove).
244
199
      memcpy(NewElts, Begin, CurSize * sizeof(T));
245
199
    }
246
199
  }
247
36.2k
248
36.2k
  // For now, leak 'Begin'.  We can add it back to a freelist in
249
36.2k
  // BumpVectorContext.
250
36.2k
  Begin = NewElts;
251
36.2k
  End = NewElts+CurSize;
252
36.2k
  Capacity = Begin+NewCapacity;
253
36.2k
}
clang::BumpVector<clang::ento::MemRegion const*>::grow(clang::BumpVectorContext&, unsigned long)
Line
Count
Source
226
454
void BumpVector<T>::grow(BumpVectorContext &C, size_t MinSize) {
227
454
  size_t CurCapacity = Capacity-Begin;
228
454
  size_t CurSize = size();
229
454
  size_t NewCapacity = 2*CurCapacity;
230
454
  if (NewCapacity < MinSize)
231
454
    NewCapacity = MinSize;
232
454
233
454
  // Allocate the memory from the BumpPtrAllocator.
234
454
  T *NewElts = C.getAllocator().template Allocate<T>(NewCapacity);
235
454
  
236
454
  // Copy the elements over.
237
454
  if (Begin != End) {
238
0
    if (std::is_class<T>::value) {
239
0
      std::uninitialized_copy(Begin, End, NewElts);
240
0
      // Destroy the original elements.
241
0
      destroy_range(Begin, End);
242
0
    } else {
243
0
      // Use memcpy for PODs (std::uninitialized_copy optimizes to memmove).
244
0
      memcpy(NewElts, Begin, CurSize * sizeof(T));
245
0
    }
246
0
  }
247
454
248
454
  // For now, leak 'Begin'.  We can add it back to a freelist in
249
454
  // BumpVectorContext.
250
454
  Begin = NewElts;
251
454
  End = NewElts+CurSize;
252
454
  Capacity = Begin+NewCapacity;
253
454
}
clang::BumpVector<clang::VarDecl const*>::grow(clang::BumpVectorContext&, unsigned long)
Line
Count
Source
226
379
void BumpVector<T>::grow(BumpVectorContext &C, size_t MinSize) {
227
379
  size_t CurCapacity = Capacity-Begin;
228
379
  size_t CurSize = size();
229
379
  size_t NewCapacity = 2*CurCapacity;
230
379
  if (NewCapacity < MinSize)
231
379
    NewCapacity = MinSize;
232
379
233
379
  // Allocate the memory from the BumpPtrAllocator.
234
379
  T *NewElts = C.getAllocator().template Allocate<T>(NewCapacity);
235
379
  
236
379
  // Copy the elements over.
237
379
  if (Begin != End) {
238
0
    if (std::is_class<T>::value) {
239
0
      std::uninitialized_copy(Begin, End, NewElts);
240
0
      // Destroy the original elements.
241
0
      destroy_range(Begin, End);
242
0
    } else {
243
0
      // Use memcpy for PODs (std::uninitialized_copy optimizes to memmove).
244
0
      memcpy(NewElts, Begin, CurSize * sizeof(T));
245
0
    }
246
0
  }
247
379
248
379
  // For now, leak 'Begin'.  We can add it back to a freelist in
249
379
  // BumpVectorContext.
250
379
  Begin = NewElts;
251
379
  End = NewElts+CurSize;
252
379
  Capacity = Begin+NewCapacity;
253
379
}
clang::BumpVector<clang::CFGElement>::grow(clang::BumpVectorContext&, unsigned long)
Line
Count
Source
226
3.31M
void BumpVector<T>::grow(BumpVectorContext &C, size_t MinSize) {
227
3.31M
  size_t CurCapacity = Capacity-Begin;
228
3.31M
  size_t CurSize = size();
229
3.31M
  size_t NewCapacity = 2*CurCapacity;
230
3.31M
  if (NewCapacity < MinSize)
231
2.11M
    NewCapacity = MinSize;
232
3.31M
233
3.31M
  // Allocate the memory from the BumpPtrAllocator.
234
3.31M
  T *NewElts = C.getAllocator().template Allocate<T>(NewCapacity);
235
3.31M
  
236
3.31M
  // Copy the elements over.
237
3.31M
  if (Begin != End) {
238
1.20M
    if (std::is_class<T>::value) {
239
1.20M
      std::uninitialized_copy(Begin, End, NewElts);
240
1.20M
      // Destroy the original elements.
241
1.20M
      destroy_range(Begin, End);
242
1.20M
    } else {
243
0
      // Use memcpy for PODs (std::uninitialized_copy optimizes to memmove).
244
0
      memcpy(NewElts, Begin, CurSize * sizeof(T));
245
0
    }
246
1.20M
  }
247
3.31M
248
3.31M
  // For now, leak 'Begin'.  We can add it back to a freelist in
249
3.31M
  // BumpVectorContext.
250
3.31M
  Begin = NewElts;
251
3.31M
  End = NewElts+CurSize;
252
3.31M
  Capacity = Begin+NewCapacity;
253
3.31M
}
clang::BumpVector<clang::CFGBlock::AdjacentBlock>::grow(clang::BumpVectorContext&, unsigned long)
Line
Count
Source
226
5.11M
void BumpVector<T>::grow(BumpVectorContext &C, size_t MinSize) {
227
5.11M
  size_t CurCapacity = Capacity-Begin;
228
5.11M
  size_t CurSize = size();
229
5.11M
  size_t NewCapacity = 2*CurCapacity;
230
5.11M
  if (NewCapacity < MinSize)
231
4.22M
    NewCapacity = MinSize;
232
5.11M
233
5.11M
  // Allocate the memory from the BumpPtrAllocator.
234
5.11M
  T *NewElts = C.getAllocator().template Allocate<T>(NewCapacity);
235
5.11M
  
236
5.11M
  // Copy the elements over.
237
5.11M
  if (Begin != End) {
238
889k
    if (std::is_class<T>::value) {
239
889k
      std::uninitialized_copy(Begin, End, NewElts);
240
889k
      // Destroy the original elements.
241
889k
      destroy_range(Begin, End);
242
889k
    } else {
243
0
      // Use memcpy for PODs (std::uninitialized_copy optimizes to memmove).
244
0
      memcpy(NewElts, Begin, CurSize * sizeof(T));
245
0
    }
246
889k
  }
247
5.11M
248
5.11M
  // For now, leak 'Begin'.  We can add it back to a freelist in
249
5.11M
  // BumpVectorContext.
250
5.11M
  Begin = NewElts;
251
5.11M
  End = NewElts+CurSize;
252
5.11M
  Capacity = Begin+NewCapacity;
253
5.11M
}
clang::BumpVector<clang::CFGBlock*>::grow(clang::BumpVectorContext&, unsigned long)
Line
Count
Source
226
461k
void BumpVector<T>::grow(BumpVectorContext &C, size_t MinSize) {
227
461k
  size_t CurCapacity = Capacity-Begin;
228
461k
  size_t CurSize = size();
229
461k
  size_t NewCapacity = 2*CurCapacity;
230
461k
  if (NewCapacity < MinSize)
231
412k
    NewCapacity = MinSize;
232
461k
233
461k
  // Allocate the memory from the BumpPtrAllocator.
234
461k
  T *NewElts = C.getAllocator().template Allocate<T>(NewCapacity);
235
461k
  
236
461k
  // Copy the elements over.
237
461k
  if (Begin != End) {
238
49.2k
    if (std::is_class<T>::value) {
239
0
      std::uninitialized_copy(Begin, End, NewElts);
240
0
      // Destroy the original elements.
241
0
      destroy_range(Begin, End);
242
49.2k
    } else {
243
49.2k
      // Use memcpy for PODs (std::uninitialized_copy optimizes to memmove).
244
49.2k
      memcpy(NewElts, Begin, CurSize * sizeof(T));
245
49.2k
    }
246
49.2k
  }
247
461k
248
461k
  // For now, leak 'Begin'.  We can add it back to a freelist in
249
461k
  // BumpVectorContext.
250
461k
  Begin = NewElts;
251
461k
  End = NewElts+CurSize;
252
461k
  Capacity = Begin+NewCapacity;
253
461k
}
clang::BumpVector<clang::VarDecl*>::grow(clang::BumpVectorContext&, unsigned long)
Line
Count
Source
226
13.8k
void BumpVector<T>::grow(BumpVectorContext &C, size_t MinSize) {
227
13.8k
  size_t CurCapacity = Capacity-Begin;
228
13.8k
  size_t CurSize = size();
229
13.8k
  size_t NewCapacity = 2*CurCapacity;
230
13.8k
  if (NewCapacity < MinSize)
231
13.8k
    NewCapacity = MinSize;
232
13.8k
233
13.8k
  // Allocate the memory from the BumpPtrAllocator.
234
13.8k
  T *NewElts = C.getAllocator().template Allocate<T>(NewCapacity);
235
13.8k
  
236
13.8k
  // Copy the elements over.
237
13.8k
  if (Begin != End) {
238
41
    if (std::is_class<T>::value) {
239
0
      std::uninitialized_copy(Begin, End, NewElts);
240
0
      // Destroy the original elements.
241
0
      destroy_range(Begin, End);
242
41
    } else {
243
41
      // Use memcpy for PODs (std::uninitialized_copy optimizes to memmove).
244
41
      memcpy(NewElts, Begin, CurSize * sizeof(T));
245
41
    }
246
41
  }
247
13.8k
248
13.8k
  // For now, leak 'Begin'.  We can add it back to a freelist in
249
13.8k
  // BumpVectorContext.
250
13.8k
  Begin = NewElts;
251
13.8k
  End = NewElts+CurSize;
252
13.8k
  Capacity = Begin+NewCapacity;
253
13.8k
}
254
255
} // namespace clang
256
257
#endif // LLVM_CLANG_ANALYSIS_SUPPORT_BUMPVECTOR_H