Coverage Report

Created: 2018-11-16 02:38

/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
448k
  BumpVectorContext() : Alloc(new llvm::BumpPtrAllocator(), 1) {}
40
41
14.0k
  BumpVectorContext(BumpVectorContext &&Other) : Alloc(Other.Alloc) {
42
14.0k
    Other.Alloc.setInt(false);
43
14.0k
    Other.Alloc.setPointer(nullptr);
44
14.0k
  }
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.6k
  BumpVectorContext(llvm::BumpPtrAllocator &A) : Alloc(&A, 0) {}
50
51
463k
  ~BumpVectorContext() {
52
463k
    if (Alloc.getInt())
53
448k
      delete Alloc.getPointer();
54
463k
  }
55
56
15.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.84M
  explicit BumpVector(BumpVectorContext &C, unsigned N) {
68
6.84M
    reserve(C, N);
69
6.84M
  }
clang::BumpVector<clang::ento::ExplodedNode*>::BumpVector(clang::BumpVectorContext&, unsigned int)
Line
Count
Source
67
36.1k
  explicit BumpVector(BumpVectorContext &C, unsigned N) {
68
36.1k
    reserve(C, N);
69
36.1k
  }
clang::BumpVector<clang::ento::MemRegion const*>::BumpVector(clang::BumpVectorContext&, unsigned int)
Line
Count
Source
67
450
  explicit BumpVector(BumpVectorContext &C, unsigned N) {
68
450
    reserve(C, N);
69
450
  }
clang::BumpVector<clang::VarDecl const*>::BumpVector(clang::BumpVectorContext&, unsigned int)
Line
Count
Source
67
373
  explicit BumpVector(BumpVectorContext &C, unsigned N) {
68
373
    reserve(C, N);
69
373
  }
clang::BumpVector<clang::CFGElement>::BumpVector(clang::BumpVectorContext&, unsigned int)
Line
Count
Source
67
2.12M
  explicit BumpVector(BumpVectorContext &C, unsigned N) {
68
2.12M
    reserve(C, N);
69
2.12M
  }
clang::BumpVector<clang::CFGBlock::AdjacentBlock>::BumpVector(clang::BumpVectorContext&, unsigned int)
Line
Count
Source
67
4.25M
  explicit BumpVector(BumpVectorContext &C, unsigned N) {
68
4.25M
    reserve(C, N);
69
4.25M
  }
clang::BumpVector<clang::CFGBlock*>::BumpVector(clang::BumpVectorContext&, unsigned int)
Line
Count
Source
67
420k
  explicit BumpVector(BumpVectorContext &C, unsigned N) {
68
420k
    reserve(C, N);
69
420k
  }
clang::BumpVector<clang::VarDecl*>::BumpVector(clang::BumpVectorContext&, unsigned int)
Line
Count
Source
67
14.0k
  explicit BumpVector(BumpVectorContext &C, unsigned N) {
68
14.0k
    reserve(C, N);
69
14.0k
  }
70
71
420k
  ~BumpVector() {
72
420k
    if (std::is_class<T>::value) {
73
0
      // Destroy the constructed elements in the vector.
74
0
      destroy_range(Begin, End);
75
0
    }
76
420k
  }
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.80M
  iterator begin() { return Begin; }
clang::BumpVector<clang::CFGElement>::begin()
Line
Count
Source
93
1.71M
  iterator begin() { return Begin; }
clang::BumpVector<clang::CFGBlock*>::begin()
Line
Count
Source
93
2.19M
  iterator begin() { return Begin; }
clang::BumpVector<clang::CFGBlock::AdjacentBlock>::begin()
Line
Count
Source
93
882k
  iterator begin() { return Begin; }
clang::BumpVector<clang::ento::ExplodedNode*>::begin()
Line
Count
Source
93
7.18k
  iterator begin() { return Begin; }
clang::BumpVector<clang::ento::MemRegion const*>::begin()
Line
Count
Source
93
4.44k
  iterator begin() { return Begin; }
94
5.77M
  const_iterator begin() const { return Begin; }
clang::BumpVector<clang::CFGElement>::begin() const
Line
Count
Source
94
1.23M
  const_iterator begin() const { return Begin; }
clang::BumpVector<clang::CFGBlock*>::begin() const
Line
Count
Source
94
95.3k
  const_iterator begin() const { return Begin; }
clang::BumpVector<clang::CFGBlock::AdjacentBlock>::begin() const
Line
Count
Source
94
4.44M
  const_iterator begin() const { return Begin; }
clang::BumpVector<clang::VarDecl const*>::begin() const
Line
Count
Source
94
738
  const_iterator begin() const { return Begin; }
95
7.34M
  iterator end() { return End; }
clang::BumpVector<clang::CFGBlock*>::end()
Line
Count
Source
95
4.73M
  iterator end() { return End; }
clang::BumpVector<clang::CFGElement>::end()
Line
Count
Source
95
1.71M
  iterator end() { return End; }
clang::BumpVector<clang::CFGBlock::AdjacentBlock>::end()
Line
Count
Source
95
882k
  iterator end() { return End; }
clang::BumpVector<clang::ento::ExplodedNode*>::end()
Line
Count
Source
95
6.64k
  iterator end() { return End; }
clang::BumpVector<clang::ento::MemRegion const*>::end()
Line
Count
Source
95
4.41k
  iterator end() { return End; }
96
6.72M
  const_iterator end() const { return End; }
clang::BumpVector<clang::CFGBlock*>::end() const
Line
Count
Source
96
95.3k
  const_iterator end() const { return End; }
clang::BumpVector<clang::CFGElement>::end() const
Line
Count
Source
96
1.27M
  const_iterator end() const { return End; }
clang::BumpVector<clang::CFGBlock::AdjacentBlock>::end() const
Line
Count
Source
96
5.35M
  const_iterator end() const { return End; }
clang::BumpVector<clang::VarDecl const*>::end() const
Line
Count
Source
96
738
  const_iterator end() const { return End; }
97
98
  // reverse iterator creation methods.
99
1.71M
  reverse_iterator rbegin() { return reverse_iterator(end()); }
clang::BumpVector<clang::CFGElement>::rbegin()
Line
Count
Source
99
1.71M
  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
826k
  const_reverse_iterator rbegin() const{ return const_reverse_iterator(end()); }
clang::BumpVector<clang::CFGElement>::rbegin() const
Line
Count
Source
100
826k
  const_reverse_iterator rbegin() const{ return const_reverse_iterator(end()); }
clang::BumpVector<clang::CFGBlock::AdjacentBlock>::rbegin() const
Line
Count
Source
100
234
  const_reverse_iterator rbegin() const{ return const_reverse_iterator(end()); }
Unexecuted instantiation: clang::BumpVector<clang::CFGBlock*>::rbegin() const
101
1.71M
  reverse_iterator rend() { return reverse_iterator(begin()); }
clang::BumpVector<clang::CFGElement>::rend()
Line
Count
Source
101
1.71M
  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
826k
  const_reverse_iterator rend() const {
103
826k
    return const_reverse_iterator(begin());
104
826k
  }
clang::BumpVector<clang::CFGElement>::rend() const
Line
Count
Source
102
826k
  const_reverse_iterator rend() const {
103
826k
    return const_reverse_iterator(begin());
104
826k
  }
clang::BumpVector<clang::CFGBlock::AdjacentBlock>::rend() const
Line
Count
Source
102
144
  const_reverse_iterator rend() const {
103
144
    return const_reverse_iterator(begin());
104
144
  }
Unexecuted instantiation: clang::BumpVector<clang::CFGBlock*>::rend() const
105
106
171k
  bool empty() const { return Begin == End; }
clang::BumpVector<clang::CFGElement>::empty() const
Line
Count
Source
106
150k
  bool empty() const { return Begin == End; }
clang::BumpVector<clang::CFGBlock::AdjacentBlock>::empty() const
Line
Count
Source
106
20.5k
  bool empty() const { return Begin == End; }
107
12.1M
  size_type size() const { return End-Begin; }
clang::BumpVector<clang::CFGElement>::size() const
Line
Count
Source
107
6.36M
  size_type size() const { return End-Begin; }
clang::BumpVector<clang::CFGBlock::AdjacentBlock>::size() const
Line
Count
Source
107
5.15M
  size_type size() const { return End-Begin; }
clang::BumpVector<clang::ento::ExplodedNode*>::size() const
Line
Count
Source
107
122k
  size_type size() const { return End-Begin; }
clang::BumpVector<clang::ento::MemRegion const*>::size() const
Line
Count
Source
107
450
  size_type size() const { return End-Begin; }
clang::BumpVector<clang::VarDecl const*>::size() const
Line
Count
Source
107
373
  size_type size() const { return End-Begin; }
clang::BumpVector<clang::CFGBlock*>::size() const
Line
Count
Source
107
469k
  size_type size() const { return End-Begin; }
clang::BumpVector<clang::VarDecl*>::size() const
Line
Count
Source
107
30.0k
  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.36M
  const_reference operator[](unsigned idx) const {
114
2.36M
    assert(Begin + idx < End);
115
2.36M
    return Begin[idx];
116
2.36M
  }
clang::BumpVector<clang::CFGElement>::operator[](unsigned int) const
Line
Count
Source
113
2.26M
  const_reference operator[](unsigned idx) const {
114
2.26M
    assert(Begin + idx < End);
115
2.26M
    return Begin[idx];
116
2.26M
  }
clang::BumpVector<clang::VarDecl*>::operator[](unsigned int) const
Line
Count
Source
113
100k
  const_reference operator[](unsigned idx) const {
114
100k
    assert(Begin + idx < End);
115
100k
    return Begin[idx];
116
100k
  }
117
118
  reference front() {
119
    return begin()[0];
120
  }
121
46.9k
  const_reference front() const {
122
46.9k
    return begin()[0];
123
46.9k
  }
124
125
2.54M
  reference back() {
126
2.54M
    return end()[-1];
127
2.54M
  }
128
86.8k
  const_reference back() const {
129
86.8k
    return end()[-1];
130
86.8k
  }
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.0M
  void push_back(const_reference Elt, BumpVectorContext &C) {
161
16.0M
    if (End < Capacity) {
162
16.0M
    Retry:
163
16.0M
      new (End) T(Elt);
164
16.0M
      ++End;
165
16.0M
      return;
166
2.12M
    }
167
2.12M
    grow(C);
168
2.12M
    goto Retry;
169
2.12M
  }
clang::BumpVector<clang::ento::ExplodedNode*>::push_back(clang::ento::ExplodedNode* const&, clang::BumpVectorContext&)
Line
Count
Source
160
75.7k
  void push_back(const_reference Elt, BumpVectorContext &C) {
161
75.7k
    if (End < Capacity) {
162
75.7k
    Retry:
163
75.7k
      new (End) T(Elt);
164
75.7k
      ++End;
165
75.7k
      return;
166
196
    }
167
196
    grow(C);
168
196
    goto Retry;
169
196
  }
clang::BumpVector<clang::ento::MemRegion const*>::push_back(clang::ento::MemRegion const* const&, clang::BumpVectorContext&)
Line
Count
Source
160
572
  void push_back(const_reference Elt, BumpVectorContext &C) {
161
572
    if (End < Capacity) {
162
572
    Retry:
163
572
      new (End) T(Elt);
164
572
      ++End;
165
572
      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
315
  void push_back(const_reference Elt, BumpVectorContext &C) {
161
315
    if (End < Capacity) {
162
315
    Retry:
163
315
      new (End) T(Elt);
164
315
      ++End;
165
315
      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.45M
  void push_back(const_reference Elt, BumpVectorContext &C) {
161
9.45M
    if (End < Capacity) {
162
9.45M
    Retry:
163
9.45M
      new (End) T(Elt);
164
9.45M
      ++End;
165
9.45M
      return;
166
1.19M
    }
167
1.19M
    grow(C);
168
1.19M
    goto Retry;
169
1.19M
  }
clang::BumpVector<clang::VarDecl*>::push_back(clang::VarDecl* const&, clang::BumpVectorContext&)
Line
Count
Source
160
16.0k
  void push_back(const_reference Elt, BumpVectorContext &C) {
161
16.0k
    if (End < Capacity) {
162
16.0k
    Retry:
163
16.0k
      new (End) T(Elt);
164
16.0k
      ++End;
165
16.0k
      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.12M
  void push_back(const_reference Elt, BumpVectorContext &C) {
161
2.12M
    if (End < Capacity) {
162
2.12M
    Retry:
163
2.12M
      new (End) T(Elt);
164
2.12M
      ++End;
165
2.12M
      return;
166
48.6k
    }
167
48.6k
    grow(C);
168
48.6k
    goto Retry;
169
48.6k
  }
clang::BumpVector<clang::CFGBlock::AdjacentBlock>::push_back(clang::CFGBlock::AdjacentBlock const&, clang::BumpVectorContext&)
Line
Count
Source
160
4.38M
  void push_back(const_reference Elt, BumpVectorContext &C) {
161
4.38M
    if (End < Capacity) {
162
4.38M
    Retry:
163
4.38M
      new (End) T(Elt);
164
4.38M
      ++End;
165
4.38M
      return;
166
888k
    }
167
888k
    grow(C);
168
888k
    goto Retry;
169
888k
  }
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
102
      BumpVectorContext &C) {
175
102
    assert(I >= Begin && I <= End && "Iterator out of bounds.");
176
102
    if (End + Cnt <= Capacity) {
177
102
    Retry:
178
102
      move_range_right(I, End, Cnt);
179
102
      construct_range(I, I + Cnt, E);
180
102
      End += Cnt;
181
102
      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.84M
  void reserve(BumpVectorContext &C, unsigned N) {
190
6.84M
    if (unsigned(Capacity-Begin) < N)
191
6.84M
      grow(C, N);
192
6.84M
  }
clang::BumpVector<clang::ento::ExplodedNode*>::reserve(clang::BumpVectorContext&, unsigned int)
Line
Count
Source
189
36.1k
  void reserve(BumpVectorContext &C, unsigned N) {
190
36.1k
    if (unsigned(Capacity-Begin) < N)
191
36.1k
      grow(C, N);
192
36.1k
  }
clang::BumpVector<clang::ento::MemRegion const*>::reserve(clang::BumpVectorContext&, unsigned int)
Line
Count
Source
189
450
  void reserve(BumpVectorContext &C, unsigned N) {
190
450
    if (unsigned(Capacity-Begin) < N)
191
450
      grow(C, N);
192
450
  }
clang::BumpVector<clang::VarDecl const*>::reserve(clang::BumpVectorContext&, unsigned int)
Line
Count
Source
189
373
  void reserve(BumpVectorContext &C, unsigned N) {
190
373
    if (unsigned(Capacity-Begin) < N)
191
373
      grow(C, N);
192
373
  }
clang::BumpVector<clang::CFGElement>::reserve(clang::BumpVectorContext&, unsigned int)
Line
Count
Source
189
2.12M
  void reserve(BumpVectorContext &C, unsigned N) {
190
2.12M
    if (unsigned(Capacity-Begin) < N)
191
2.12M
      grow(C, N);
192
2.12M
  }
clang::BumpVector<clang::CFGBlock::AdjacentBlock>::reserve(clang::BumpVectorContext&, unsigned int)
Line
Count
Source
189
4.25M
  void reserve(BumpVectorContext &C, unsigned N) {
190
4.25M
    if (unsigned(Capacity-Begin) < N)
191
4.25M
      grow(C, N);
192
4.25M
  }
clang::BumpVector<clang::CFGBlock*>::reserve(clang::BumpVectorContext&, unsigned int)
Line
Count
Source
189
420k
  void reserve(BumpVectorContext &C, unsigned N) {
190
420k
    if (unsigned(Capacity-Begin) < N)
191
420k
      grow(C, N);
192
420k
  }
clang::BumpVector<clang::VarDecl*>::reserve(clang::BumpVectorContext&, unsigned int)
Line
Count
Source
189
14.0k
  void reserve(BumpVectorContext &C, unsigned N) {
190
14.0k
    if (unsigned(Capacity-Begin) < N)
191
14.0k
      grow(C, N);
192
14.0k
  }
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
102
  void construct_range(T *S, T *E, const T &Elt) {
204
129
    for (; S != E; 
++S27
)
205
27
      new (S) T(Elt);
206
102
  }
207
208
2.07M
  void destroy_range(T *S, T *E) {
209
12.1M
    while (S != E) {
210
10.0M
      --E;
211
10.0M
      E->~T();
212
10.0M
    }
213
2.07M
  }
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.19M
  void destroy_range(T *S, T *E) {
209
10.1M
    while (S != E) {
210
8.92M
      --E;
211
8.92M
      E->~T();
212
8.92M
    }
213
1.19M
  }
clang::BumpVector<clang::CFGBlock::AdjacentBlock>::destroy_range(clang::CFGBlock::AdjacentBlock*, clang::CFGBlock::AdjacentBlock*)
Line
Count
Source
208
888k
  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
888k
  }
Unexecuted instantiation: clang::BumpVector<clang::VarDecl*>::destroy_range(clang::VarDecl**, clang::VarDecl**)
214
215
102
  void move_range_right(T *S, T *E, size_t D) {
216
313
    for (T *I = E + D - 1, *IL = S + D - 1; I != IL; 
--I211
) {
217
211
      --E;
218
211
      new (I) T(*E);
219
211
      E->~T();
220
211
    }
221
102
  }
222
};
223
224
// Define this out-of-line to dissuade the C++ compiler from inlining it.
225
template <typename T>
226
8.97M
void BumpVector<T>::grow(BumpVectorContext &C, size_t MinSize) {
227
8.97M
  size_t CurCapacity = Capacity-Begin;
228
8.97M
  size_t CurSize = size();
229
8.97M
  size_t NewCapacity = 2*CurCapacity;
230
8.97M
  if (NewCapacity < MinSize)
231
6.84M
    NewCapacity = MinSize;
232
8.97M
233
8.97M
  // Allocate the memory from the BumpPtrAllocator.
234
8.97M
  T *NewElts = C.getAllocator().template Allocate<T>(NewCapacity);
235
8.97M
236
8.97M
  // Copy the elements over.
237
8.97M
  if (Begin != End) {
238
2.12M
    if (std::is_class<T>::value) {
239
2.07M
      std::uninitialized_copy(Begin, End, NewElts);
240
2.07M
      // Destroy the original elements.
241
2.07M
      destroy_range(Begin, End);
242
2.07M
    } else {
243
48.9k
      // Use memcpy for PODs (std::uninitialized_copy optimizes to memmove).
244
48.9k
      memcpy(NewElts, Begin, CurSize * sizeof(T));
245
48.9k
    }
246
2.12M
  }
247
8.97M
248
8.97M
  // For now, leak 'Begin'.  We can add it back to a freelist in
249
8.97M
  // BumpVectorContext.
250
8.97M
  Begin = NewElts;
251
8.97M
  End = NewElts+CurSize;
252
8.97M
  Capacity = Begin+NewCapacity;
253
8.97M
}
clang::BumpVector<clang::ento::ExplodedNode*>::grow(clang::BumpVectorContext&, unsigned long)
Line
Count
Source
226
36.3k
void BumpVector<T>::grow(BumpVectorContext &C, size_t MinSize) {
227
36.3k
  size_t CurCapacity = Capacity-Begin;
228
36.3k
  size_t CurSize = size();
229
36.3k
  size_t NewCapacity = 2*CurCapacity;
230
36.3k
  if (NewCapacity < MinSize)
231
36.1k
    NewCapacity = MinSize;
232
36.3k
233
36.3k
  // Allocate the memory from the BumpPtrAllocator.
234
36.3k
  T *NewElts = C.getAllocator().template Allocate<T>(NewCapacity);
235
36.3k
236
36.3k
  // Copy the elements over.
237
36.3k
  if (Begin != End) {
238
196
    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
196
    } else {
243
196
      // Use memcpy for PODs (std::uninitialized_copy optimizes to memmove).
244
196
      memcpy(NewElts, Begin, CurSize * sizeof(T));
245
196
    }
246
196
  }
247
36.3k
248
36.3k
  // For now, leak 'Begin'.  We can add it back to a freelist in
249
36.3k
  // BumpVectorContext.
250
36.3k
  Begin = NewElts;
251
36.3k
  End = NewElts+CurSize;
252
36.3k
  Capacity = Begin+NewCapacity;
253
36.3k
}
clang::BumpVector<clang::ento::MemRegion const*>::grow(clang::BumpVectorContext&, unsigned long)
Line
Count
Source
226
450
void BumpVector<T>::grow(BumpVectorContext &C, size_t MinSize) {
227
450
  size_t CurCapacity = Capacity-Begin;
228
450
  size_t CurSize = size();
229
450
  size_t NewCapacity = 2*CurCapacity;
230
450
  if (NewCapacity < MinSize)
231
450
    NewCapacity = MinSize;
232
450
233
450
  // Allocate the memory from the BumpPtrAllocator.
234
450
  T *NewElts = C.getAllocator().template Allocate<T>(NewCapacity);
235
450
236
450
  // Copy the elements over.
237
450
  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
450
248
450
  // For now, leak 'Begin'.  We can add it back to a freelist in
249
450
  // BumpVectorContext.
250
450
  Begin = NewElts;
251
450
  End = NewElts+CurSize;
252
450
  Capacity = Begin+NewCapacity;
253
450
}
clang::BumpVector<clang::VarDecl const*>::grow(clang::BumpVectorContext&, unsigned long)
Line
Count
Source
226
373
void BumpVector<T>::grow(BumpVectorContext &C, size_t MinSize) {
227
373
  size_t CurCapacity = Capacity-Begin;
228
373
  size_t CurSize = size();
229
373
  size_t NewCapacity = 2*CurCapacity;
230
373
  if (NewCapacity < MinSize)
231
373
    NewCapacity = MinSize;
232
373
233
373
  // Allocate the memory from the BumpPtrAllocator.
234
373
  T *NewElts = C.getAllocator().template Allocate<T>(NewCapacity);
235
373
236
373
  // Copy the elements over.
237
373
  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
373
248
373
  // For now, leak 'Begin'.  We can add it back to a freelist in
249
373
  // BumpVectorContext.
250
373
  Begin = NewElts;
251
373
  End = NewElts+CurSize;
252
373
  Capacity = Begin+NewCapacity;
253
373
}
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.12M
    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.19M
    if (std::is_class<T>::value) {
239
1.19M
      std::uninitialized_copy(Begin, End, NewElts);
240
1.19M
      // Destroy the original elements.
241
1.19M
      destroy_range(Begin, End);
242
1.19M
    } 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.19M
  }
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.13M
void BumpVector<T>::grow(BumpVectorContext &C, size_t MinSize) {
227
5.13M
  size_t CurCapacity = Capacity-Begin;
228
5.13M
  size_t CurSize = size();
229
5.13M
  size_t NewCapacity = 2*CurCapacity;
230
5.13M
  if (NewCapacity < MinSize)
231
4.25M
    NewCapacity = MinSize;
232
5.13M
233
5.13M
  // Allocate the memory from the BumpPtrAllocator.
234
5.13M
  T *NewElts = C.getAllocator().template Allocate<T>(NewCapacity);
235
5.13M
236
5.13M
  // Copy the elements over.
237
5.13M
  if (Begin != End) {
238
888k
    if (std::is_class<T>::value) {
239
888k
      std::uninitialized_copy(Begin, End, NewElts);
240
888k
      // Destroy the original elements.
241
888k
      destroy_range(Begin, End);
242
888k
    } else {
243
0
      // Use memcpy for PODs (std::uninitialized_copy optimizes to memmove).
244
0
      memcpy(NewElts, Begin, CurSize * sizeof(T));
245
0
    }
246
888k
  }
247
5.13M
248
5.13M
  // For now, leak 'Begin'.  We can add it back to a freelist in
249
5.13M
  // BumpVectorContext.
250
5.13M
  Begin = NewElts;
251
5.13M
  End = NewElts+CurSize;
252
5.13M
  Capacity = Begin+NewCapacity;
253
5.13M
}
clang::BumpVector<clang::CFGBlock*>::grow(clang::BumpVectorContext&, unsigned long)
Line
Count
Source
226
469k
void BumpVector<T>::grow(BumpVectorContext &C, size_t MinSize) {
227
469k
  size_t CurCapacity = Capacity-Begin;
228
469k
  size_t CurSize = size();
229
469k
  size_t NewCapacity = 2*CurCapacity;
230
469k
  if (NewCapacity < MinSize)
231
420k
    NewCapacity = MinSize;
232
469k
233
469k
  // Allocate the memory from the BumpPtrAllocator.
234
469k
  T *NewElts = C.getAllocator().template Allocate<T>(NewCapacity);
235
469k
236
469k
  // Copy the elements over.
237
469k
  if (Begin != End) {
238
48.6k
    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
48.6k
    } else {
243
48.6k
      // Use memcpy for PODs (std::uninitialized_copy optimizes to memmove).
244
48.6k
      memcpy(NewElts, Begin, CurSize * sizeof(T));
245
48.6k
    }
246
48.6k
  }
247
469k
248
469k
  // For now, leak 'Begin'.  We can add it back to a freelist in
249
469k
  // BumpVectorContext.
250
469k
  Begin = NewElts;
251
469k
  End = NewElts+CurSize;
252
469k
  Capacity = Begin+NewCapacity;
253
469k
}
clang::BumpVector<clang::VarDecl*>::grow(clang::BumpVectorContext&, unsigned long)
Line
Count
Source
226
14.0k
void BumpVector<T>::grow(BumpVectorContext &C, size_t MinSize) {
227
14.0k
  size_t CurCapacity = Capacity-Begin;
228
14.0k
  size_t CurSize = size();
229
14.0k
  size_t NewCapacity = 2*CurCapacity;
230
14.0k
  if (NewCapacity < MinSize)
231
14.0k
    NewCapacity = MinSize;
232
14.0k
233
14.0k
  // Allocate the memory from the BumpPtrAllocator.
234
14.0k
  T *NewElts = C.getAllocator().template Allocate<T>(NewCapacity);
235
14.0k
236
14.0k
  // Copy the elements over.
237
14.0k
  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
14.0k
248
14.0k
  // For now, leak 'Begin'.  We can add it back to a freelist in
249
14.0k
  // BumpVectorContext.
250
14.0k
  Begin = NewElts;
251
14.0k
  End = NewElts+CurSize;
252
14.0k
  Capacity = Begin+NewCapacity;
253
14.0k
}
254
255
} // namespace clang
256
257
#endif // LLVM_CLANG_ANALYSIS_SUPPORT_BUMPVECTOR_H