Coverage Report

Created: 2019-02-23 12:57

/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
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
//
9
//  This file provides BumpVector, a vector-like ADT whose contents are
10
//  allocated from a BumpPtrAllocator.
11
//
12
//===----------------------------------------------------------------------===//
13
14
// FIXME: Most of this is copy-and-paste from SmallVector.h.  We can
15
// refactor this core logic into something common that is shared between
16
// the two.  The main thing that is different is the allocation strategy.
17
18
#ifndef LLVM_CLANG_ANALYSIS_SUPPORT_BUMPVECTOR_H
19
#define LLVM_CLANG_ANALYSIS_SUPPORT_BUMPVECTOR_H
20
21
#include "llvm/ADT/PointerIntPair.h"
22
#include "llvm/Support/Allocator.h"
23
#include <cassert>
24
#include <cstddef>
25
#include <cstring>
26
#include <iterator>
27
#include <memory>
28
#include <type_traits>
29
30
namespace clang {
31
32
class BumpVectorContext {
33
  llvm::PointerIntPair<llvm::BumpPtrAllocator*, 1> Alloc;
34
35
public:
36
  /// Construct a new BumpVectorContext that creates a new BumpPtrAllocator
37
  /// and destroys it when the BumpVectorContext object is destroyed.
38
433k
  BumpVectorContext() : Alloc(new llvm::BumpPtrAllocator(), 1) {}
39
40
13.8k
  BumpVectorContext(BumpVectorContext &&Other) : Alloc(Other.Alloc) {
41
13.8k
    Other.Alloc.setInt(false);
42
13.8k
    Other.Alloc.setPointer(nullptr);
43
13.8k
  }
44
45
  /// Construct a new BumpVectorContext that reuses an existing
46
  /// BumpPtrAllocator.  This BumpPtrAllocator is not destroyed when the
47
  /// BumpVectorContext object is destroyed.
48
14.4k
  BumpVectorContext(llvm::BumpPtrAllocator &A) : Alloc(&A, 0) {}
49
50
448k
  ~BumpVectorContext() {
51
448k
    if (Alloc.getInt())
52
433k
      delete Alloc.getPointer();
53
448k
  }
54
55
15.1M
  llvm::BumpPtrAllocator &getAllocator() { return *Alloc.getPointer(); }
56
};
57
58
template<typename T>
59
class BumpVector {
60
  T *Begin = nullptr;
61
  T *End = nullptr;
62
  T *Capacity = nullptr;
63
64
public:
65
  // Default ctor - Initialize to empty.
66
6.53M
  explicit BumpVector(BumpVectorContext &C, unsigned N) {
67
6.53M
    reserve(C, N);
68
6.53M
  }
clang::BumpVector<clang::ento::ExplodedNode*>::BumpVector(clang::BumpVectorContext&, unsigned int)
Line
Count
Source
66
37.2k
  explicit BumpVector(BumpVectorContext &C, unsigned N) {
67
37.2k
    reserve(C, N);
68
37.2k
  }
clang::BumpVector<clang::ento::MemRegion const*>::BumpVector(clang::BumpVectorContext&, unsigned int)
Line
Count
Source
66
462
  explicit BumpVector(BumpVectorContext &C, unsigned N) {
67
462
    reserve(C, N);
68
462
  }
clang::BumpVector<clang::VarDecl const*>::BumpVector(clang::BumpVectorContext&, unsigned int)
Line
Count
Source
66
388
  explicit BumpVector(BumpVectorContext &C, unsigned N) {
67
388
    reserve(C, N);
68
388
  }
clang::BumpVector<clang::CFGElement>::BumpVector(clang::BumpVectorContext&, unsigned int)
Line
Count
Source
66
2.02M
  explicit BumpVector(BumpVectorContext &C, unsigned N) {
67
2.02M
    reserve(C, N);
68
2.02M
  }
clang::BumpVector<clang::CFGBlock::AdjacentBlock>::BumpVector(clang::BumpVectorContext&, unsigned int)
Line
Count
Source
66
4.05M
  explicit BumpVector(BumpVectorContext &C, unsigned N) {
67
4.05M
    reserve(C, N);
68
4.05M
  }
clang::BumpVector<clang::CFGBlock*>::BumpVector(clang::BumpVectorContext&, unsigned int)
Line
Count
Source
66
403k
  explicit BumpVector(BumpVectorContext &C, unsigned N) {
67
403k
    reserve(C, N);
68
403k
  }
clang::BumpVector<clang::VarDecl*>::BumpVector(clang::BumpVectorContext&, unsigned int)
Line
Count
Source
66
13.8k
  explicit BumpVector(BumpVectorContext &C, unsigned N) {
67
13.8k
    reserve(C, N);
68
13.8k
  }
69
70
403k
  ~BumpVector() {
71
403k
    if (std::is_class<T>::value) {
72
0
      // Destroy the constructed elements in the vector.
73
0
      destroy_range(Begin, End);
74
0
    }
75
403k
  }
76
77
  using size_type = size_t;
78
  using difference_type = ptrdiff_t;
79
  using value_type = T;
80
  using iterator = T *;
81
  using const_iterator = const T *;
82
83
  using const_reverse_iterator = std::reverse_iterator<const_iterator>;
84
  using reverse_iterator = std::reverse_iterator<iterator>;
85
86
  using reference = T &;
87
  using const_reference = const T &;
88
  using pointer = T *;
89
  using const_pointer = const T *;
90
91
  // forward iterator creation methods.
92
4.53M
  iterator begin() { return Begin; }
clang::BumpVector<clang::CFGElement>::begin()
Line
Count
Source
92
1.60M
  iterator begin() { return Begin; }
clang::BumpVector<clang::CFGBlock*>::begin()
Line
Count
Source
92
2.09M
  iterator begin() { return Begin; }
clang::BumpVector<clang::CFGBlock::AdjacentBlock>::begin()
Line
Count
Source
92
824k
  iterator begin() { return Begin; }
clang::BumpVector<clang::ento::ExplodedNode*>::begin()
Line
Count
Source
92
8.03k
  iterator begin() { return Begin; }
clang::BumpVector<clang::ento::MemRegion const*>::begin()
Line
Count
Source
92
4.52k
  iterator begin() { return Begin; }
93
5.53M
  const_iterator begin() const { return Begin; }
clang::BumpVector<clang::CFGElement>::begin() const
Line
Count
Source
93
1.18M
  const_iterator begin() const { return Begin; }
clang::BumpVector<clang::CFGBlock*>::begin() const
Line
Count
Source
93
89.0k
  const_iterator begin() const { return Begin; }
clang::BumpVector<clang::CFGBlock::AdjacentBlock>::begin() const
Line
Count
Source
93
4.25M
  const_iterator begin() const { return Begin; }
clang::BumpVector<clang::VarDecl const*>::begin() const
Line
Count
Source
93
768
  const_iterator begin() const { return Begin; }
94
6.96M
  iterator end() { return End; }
clang::BumpVector<clang::CFGBlock*>::end()
Line
Count
Source
94
4.52M
  iterator end() { return End; }
clang::BumpVector<clang::CFGElement>::end()
Line
Count
Source
94
1.60M
  iterator end() { return End; }
clang::BumpVector<clang::CFGBlock::AdjacentBlock>::end()
Line
Count
Source
94
824k
  iterator end() { return End; }
clang::BumpVector<clang::ento::ExplodedNode*>::end()
Line
Count
Source
94
7.39k
  iterator end() { return End; }
clang::BumpVector<clang::ento::MemRegion const*>::end()
Line
Count
Source
94
4.50k
  iterator end() { return End; }
95
6.40M
  const_iterator end() const { return End; }
clang::BumpVector<clang::CFGBlock*>::end() const
Line
Count
Source
95
89.0k
  const_iterator end() const { return End; }
clang::BumpVector<clang::CFGElement>::end() const
Line
Count
Source
95
1.22M
  const_iterator end() const { return End; }
clang::BumpVector<clang::CFGBlock::AdjacentBlock>::end() const
Line
Count
Source
95
5.08M
  const_iterator end() const { return End; }
clang::BumpVector<clang::VarDecl const*>::end() const
Line
Count
Source
95
768
  const_iterator end() const { return End; }
96
97
  // reverse iterator creation methods.
98
1.60M
  reverse_iterator rbegin() { return reverse_iterator(end()); }
clang::BumpVector<clang::CFGElement>::rbegin()
Line
Count
Source
98
1.60M
  reverse_iterator rbegin() { return reverse_iterator(end()); }
Unexecuted instantiation: clang::BumpVector<clang::CFGBlock::AdjacentBlock>::rbegin()
clang::BumpVector<clang::CFGBlock*>::rbegin()
Line
Count
Source
98
67
  reverse_iterator rbegin() { return reverse_iterator(end()); }
99
777k
  const_reverse_iterator rbegin() const{ return const_reverse_iterator(end()); }
clang::BumpVector<clang::CFGElement>::rbegin() const
Line
Count
Source
99
776k
  const_reverse_iterator rbegin() const{ return const_reverse_iterator(end()); }
clang::BumpVector<clang::CFGBlock::AdjacentBlock>::rbegin() const
Line
Count
Source
99
348
  const_reverse_iterator rbegin() const{ return const_reverse_iterator(end()); }
Unexecuted instantiation: clang::BumpVector<clang::CFGBlock*>::rbegin() const
100
1.60M
  reverse_iterator rend() { return reverse_iterator(begin()); }
clang::BumpVector<clang::CFGElement>::rend()
Line
Count
Source
100
1.60M
  reverse_iterator rend() { return reverse_iterator(begin()); }
Unexecuted instantiation: clang::BumpVector<clang::CFGBlock::AdjacentBlock>::rend()
clang::BumpVector<clang::CFGBlock*>::rend()
Line
Count
Source
100
67
  reverse_iterator rend() { return reverse_iterator(begin()); }
101
776k
  const_reverse_iterator rend() const {
102
776k
    return const_reverse_iterator(begin());
103
776k
  }
clang::BumpVector<clang::CFGElement>::rend() const
Line
Count
Source
101
776k
  const_reverse_iterator rend() const {
102
776k
    return const_reverse_iterator(begin());
103
776k
  }
clang::BumpVector<clang::CFGBlock::AdjacentBlock>::rend() const
Line
Count
Source
101
216
  const_reverse_iterator rend() const {
102
216
    return const_reverse_iterator(begin());
103
216
  }
Unexecuted instantiation: clang::BumpVector<clang::CFGBlock*>::rend() const
104
105
480k
  bool empty() const { return Begin == End; }
clang::BumpVector<clang::CFGElement>::empty() const
Line
Count
Source
105
168k
  bool empty() const { return Begin == End; }
clang::BumpVector<clang::CFGBlock::AdjacentBlock>::empty() const
Line
Count
Source
105
311k
  bool empty() const { return Begin == End; }
106
11.9M
  size_type size() const { return End-Begin; }
clang::BumpVector<clang::CFGElement>::size() const
Line
Count
Source
106
6.48M
  size_type size() const { return End-Begin; }
clang::BumpVector<clang::CFGBlock::AdjacentBlock>::size() const
Line
Count
Source
106
4.90M
  size_type size() const { return End-Begin; }
clang::BumpVector<clang::ento::ExplodedNode*>::size() const
Line
Count
Source
106
124k
  size_type size() const { return End-Begin; }
clang::BumpVector<clang::ento::MemRegion const*>::size() const
Line
Count
Source
106
462
  size_type size() const { return End-Begin; }
clang::BumpVector<clang::VarDecl const*>::size() const
Line
Count
Source
106
388
  size_type size() const { return End-Begin; }
clang::BumpVector<clang::CFGBlock*>::size() const
Line
Count
Source
106
449k
  size_type size() const { return End-Begin; }
clang::BumpVector<clang::VarDecl*>::size() const
Line
Count
Source
106
29.8k
  size_type size() const { return End-Begin; }
107
108
  reference operator[](unsigned idx) {
109
    assert(Begin + idx < End);
110
    return Begin[idx];
111
  }
112
2.56M
  const_reference operator[](unsigned idx) const {
113
2.56M
    assert(Begin + idx < End);
114
2.56M
    return Begin[idx];
115
2.56M
  }
clang::BumpVector<clang::CFGElement>::operator[](unsigned int) const
Line
Count
Source
112
2.46M
  const_reference operator[](unsigned idx) const {
113
2.46M
    assert(Begin + idx < End);
114
2.46M
    return Begin[idx];
115
2.46M
  }
clang::BumpVector<clang::VarDecl*>::operator[](unsigned int) const
Line
Count
Source
112
101k
  const_reference operator[](unsigned idx) const {
113
101k
    assert(Begin + idx < End);
114
101k
    return Begin[idx];
115
101k
  }
116
117
  reference front() {
118
    return begin()[0];
119
  }
120
54.3k
  const_reference front() const {
121
54.3k
    return begin()[0];
122
54.3k
  }
123
124
2.42M
  reference back() {
125
2.42M
    return end()[-1];
126
2.42M
  }
127
96.4k
  const_reference back() const {
128
96.4k
    return end()[-1];
129
96.4k
  }
130
131
  void pop_back() {
132
    --End;
133
    End->~T();
134
  }
135
136
  T pop_back_val() {
137
    T Result = back();
138
    pop_back();
139
    return Result;
140
  }
141
142
  void clear() {
143
    if (std::is_class<T>::value) {
144
      destroy_range(Begin, End);
145
    }
146
    End = Begin;
147
  }
148
149
  /// data - Return a pointer to the vector's buffer, even if empty().
150
  pointer data() {
151
    return pointer(Begin);
152
  }
153
154
  /// data - Return a pointer to the vector's buffer, even if empty().
155
  const_pointer data() const {
156
    return const_pointer(Begin);
157
  }
158
159
15.3M
  void push_back(const_reference Elt, BumpVectorContext &C) {
160
15.3M
    if (End < Capacity) {
161
15.3M
    Retry:
162
15.3M
      new (End) T(Elt);
163
15.3M
      ++End;
164
15.3M
      return;
165
2.02M
    }
166
2.02M
    grow(C);
167
2.02M
    goto Retry;
168
2.02M
  }
clang::BumpVector<clang::ento::ExplodedNode*>::push_back(clang::ento::ExplodedNode* const&, clang::BumpVectorContext&)
Line
Count
Source
159
78.0k
  void push_back(const_reference Elt, BumpVectorContext &C) {
160
78.0k
    if (End < Capacity) {
161
78.0k
    Retry:
162
78.0k
      new (End) T(Elt);
163
78.0k
      ++End;
164
78.0k
      return;
165
218
    }
166
218
    grow(C);
167
218
    goto Retry;
168
218
  }
clang::BumpVector<clang::ento::MemRegion const*>::push_back(clang::ento::MemRegion const* const&, clang::BumpVectorContext&)
Line
Count
Source
159
584
  void push_back(const_reference Elt, BumpVectorContext &C) {
160
584
    if (End < Capacity) {
161
584
    Retry:
162
584
      new (End) T(Elt);
163
584
      ++End;
164
584
      return;
165
0
    }
166
0
    grow(C);
167
0
    goto Retry;
168
0
  }
clang::BumpVector<clang::VarDecl const*>::push_back(clang::VarDecl const* const&, clang::BumpVectorContext&)
Line
Count
Source
159
321
  void push_back(const_reference Elt, BumpVectorContext &C) {
160
321
    if (End < Capacity) {
161
321
    Retry:
162
321
      new (End) T(Elt);
163
321
      ++End;
164
321
      return;
165
0
    }
166
0
    grow(C);
167
0
    goto Retry;
168
0
  }
clang::BumpVector<clang::CFGElement>::push_back(clang::CFGElement const&, clang::BumpVectorContext&)
Line
Count
Source
159
9.08M
  void push_back(const_reference Elt, BumpVectorContext &C) {
160
9.08M
    if (End < Capacity) {
161
9.08M
    Retry:
162
9.08M
      new (End) T(Elt);
163
9.08M
      ++End;
164
9.08M
      return;
165
1.13M
    }
166
1.13M
    grow(C);
167
1.13M
    goto Retry;
168
1.13M
  }
clang::BumpVector<clang::VarDecl*>::push_back(clang::VarDecl* const&, clang::BumpVectorContext&)
Line
Count
Source
159
15.9k
  void push_back(const_reference Elt, BumpVectorContext &C) {
160
15.9k
    if (End < Capacity) {
161
15.9k
    Retry:
162
15.9k
      new (End) T(Elt);
163
15.9k
      ++End;
164
15.9k
      return;
165
57
    }
166
57
    grow(C);
167
57
    goto Retry;
168
57
  }
clang::BumpVector<clang::CFGBlock*>::push_back(clang::CFGBlock* const&, clang::BumpVectorContext&)
Line
Count
Source
159
2.02M
  void push_back(const_reference Elt, BumpVectorContext &C) {
160
2.02M
    if (End < Capacity) {
161
2.02M
    Retry:
162
2.02M
      new (End) T(Elt);
163
2.02M
      ++End;
164
2.02M
      return;
165
45.8k
    }
166
45.8k
    grow(C);
167
45.8k
    goto Retry;
168
45.8k
  }
clang::BumpVector<clang::CFGBlock::AdjacentBlock>::push_back(clang::CFGBlock::AdjacentBlock const&, clang::BumpVectorContext&)
Line
Count
Source
159
4.17M
  void push_back(const_reference Elt, BumpVectorContext &C) {
160
4.17M
    if (End < Capacity) {
161
4.17M
    Retry:
162
4.17M
      new (End) T(Elt);
163
4.17M
      ++End;
164
4.17M
      return;
165
836k
    }
166
836k
    grow(C);
167
836k
    goto Retry;
168
836k
  }
169
170
  /// insert - Insert some number of copies of element into a position. Return
171
  /// iterator to position after last inserted copy.
172
  iterator insert(iterator I, size_t Cnt, const_reference E,
173
116
      BumpVectorContext &C) {
174
116
    assert(I >= Begin && I <= End && "Iterator out of bounds.");
175
116
    if (End + Cnt <= Capacity) {
176
116
    Retry:
177
116
      move_range_right(I, End, Cnt);
178
116
      construct_range(I, I + Cnt, E);
179
116
      End += Cnt;
180
116
      return I + Cnt;
181
0
    }
182
0
    ptrdiff_t D = I - Begin;
183
0
    grow(C, size() + Cnt);
184
0
    I = Begin + D;
185
0
    goto Retry;
186
0
  }
187
188
6.53M
  void reserve(BumpVectorContext &C, unsigned N) {
189
6.53M
    if (unsigned(Capacity-Begin) < N)
190
6.53M
      grow(C, N);
191
6.53M
  }
clang::BumpVector<clang::ento::ExplodedNode*>::reserve(clang::BumpVectorContext&, unsigned int)
Line
Count
Source
188
37.2k
  void reserve(BumpVectorContext &C, unsigned N) {
189
37.2k
    if (unsigned(Capacity-Begin) < N)
190
37.2k
      grow(C, N);
191
37.2k
  }
clang::BumpVector<clang::ento::MemRegion const*>::reserve(clang::BumpVectorContext&, unsigned int)
Line
Count
Source
188
462
  void reserve(BumpVectorContext &C, unsigned N) {
189
462
    if (unsigned(Capacity-Begin) < N)
190
462
      grow(C, N);
191
462
  }
clang::BumpVector<clang::VarDecl const*>::reserve(clang::BumpVectorContext&, unsigned int)
Line
Count
Source
188
388
  void reserve(BumpVectorContext &C, unsigned N) {
189
388
    if (unsigned(Capacity-Begin) < N)
190
388
      grow(C, N);
191
388
  }
clang::BumpVector<clang::CFGElement>::reserve(clang::BumpVectorContext&, unsigned int)
Line
Count
Source
188
2.02M
  void reserve(BumpVectorContext &C, unsigned N) {
189
2.02M
    if (unsigned(Capacity-Begin) < N)
190
2.02M
      grow(C, N);
191
2.02M
  }
clang::BumpVector<clang::CFGBlock::AdjacentBlock>::reserve(clang::BumpVectorContext&, unsigned int)
Line
Count
Source
188
4.05M
  void reserve(BumpVectorContext &C, unsigned N) {
189
4.05M
    if (unsigned(Capacity-Begin) < N)
190
4.05M
      grow(C, N);
191
4.05M
  }
clang::BumpVector<clang::CFGBlock*>::reserve(clang::BumpVectorContext&, unsigned int)
Line
Count
Source
188
403k
  void reserve(BumpVectorContext &C, unsigned N) {
189
403k
    if (unsigned(Capacity-Begin) < N)
190
403k
      grow(C, N);
191
403k
  }
clang::BumpVector<clang::VarDecl*>::reserve(clang::BumpVectorContext&, unsigned int)
Line
Count
Source
188
13.8k
  void reserve(BumpVectorContext &C, unsigned N) {
189
13.8k
    if (unsigned(Capacity-Begin) < N)
190
13.8k
      grow(C, N);
191
13.8k
  }
192
193
  /// capacity - Return the total number of elements in the currently allocated
194
  /// buffer.
195
  size_t capacity() const { return Capacity - Begin; }
196
197
private:
198
  /// grow - double the size of the allocated memory, guaranteeing space for at
199
  /// least one more element or MinSize if specified.
200
  void grow(BumpVectorContext &C, size_type MinSize = 1);
201
202
116
  void construct_range(T *S, T *E, const T &Elt) {
203
143
    for (; S != E; 
++S27
)
204
27
      new (S) T(Elt);
205
116
  }
206
207
1.97M
  void destroy_range(T *S, T *E) {
208
11.6M
    while (S != E) {
209
9.67M
      --E;
210
9.67M
      E->~T();
211
9.67M
    }
212
1.97M
  }
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
207
1.13M
  void destroy_range(T *S, T *E) {
208
9.73M
    while (S != E) {
209
8.59M
      --E;
210
8.59M
      E->~T();
211
8.59M
    }
212
1.13M
  }
clang::BumpVector<clang::CFGBlock::AdjacentBlock>::destroy_range(clang::CFGBlock::AdjacentBlock*, clang::CFGBlock::AdjacentBlock*)
Line
Count
Source
207
836k
  void destroy_range(T *S, T *E) {
208
1.91M
    while (S != E) {
209
1.07M
      --E;
210
1.07M
      E->~T();
211
1.07M
    }
212
836k
  }
Unexecuted instantiation: clang::BumpVector<clang::VarDecl*>::destroy_range(clang::VarDecl**, clang::VarDecl**)
213
214
116
  void move_range_right(T *S, T *E, size_t D) {
215
369
    for (T *I = E + D - 1, *IL = S + D - 1; I != IL; 
--I253
) {
216
253
      --E;
217
253
      new (I) T(*E);
218
253
      E->~T();
219
253
    }
220
116
  }
221
};
222
223
// Define this out-of-line to dissuade the C++ compiler from inlining it.
224
template <typename T>
225
8.55M
void BumpVector<T>::grow(BumpVectorContext &C, size_t MinSize) {
226
8.55M
  size_t CurCapacity = Capacity-Begin;
227
8.55M
  size_t CurSize = size();
228
8.55M
  size_t NewCapacity = 2*CurCapacity;
229
8.55M
  if (NewCapacity < MinSize)
230
6.53M
    NewCapacity = MinSize;
231
8.55M
232
8.55M
  // Allocate the memory from the BumpPtrAllocator.
233
8.55M
  T *NewElts = C.getAllocator().template Allocate<T>(NewCapacity);
234
8.55M
235
8.55M
  // Copy the elements over.
236
8.55M
  if (Begin != End) {
237
2.02M
    if (std::is_class<T>::value) {
238
1.97M
      std::uninitialized_copy(Begin, End, NewElts);
239
1.97M
      // Destroy the original elements.
240
1.97M
      destroy_range(Begin, End);
241
1.97M
    } else {
242
46.1k
      // Use memcpy for PODs (std::uninitialized_copy optimizes to memmove).
243
46.1k
      memcpy(NewElts, Begin, CurSize * sizeof(T));
244
46.1k
    }
245
2.02M
  }
246
8.55M
247
8.55M
  // For now, leak 'Begin'.  We can add it back to a freelist in
248
8.55M
  // BumpVectorContext.
249
8.55M
  Begin = NewElts;
250
8.55M
  End = NewElts+CurSize;
251
8.55M
  Capacity = Begin+NewCapacity;
252
8.55M
}
clang::BumpVector<clang::ento::ExplodedNode*>::grow(clang::BumpVectorContext&, unsigned long)
Line
Count
Source
225
37.5k
void BumpVector<T>::grow(BumpVectorContext &C, size_t MinSize) {
226
37.5k
  size_t CurCapacity = Capacity-Begin;
227
37.5k
  size_t CurSize = size();
228
37.5k
  size_t NewCapacity = 2*CurCapacity;
229
37.5k
  if (NewCapacity < MinSize)
230
37.2k
    NewCapacity = MinSize;
231
37.5k
232
37.5k
  // Allocate the memory from the BumpPtrAllocator.
233
37.5k
  T *NewElts = C.getAllocator().template Allocate<T>(NewCapacity);
234
37.5k
235
37.5k
  // Copy the elements over.
236
37.5k
  if (Begin != End) {
237
218
    if (std::is_class<T>::value) {
238
0
      std::uninitialized_copy(Begin, End, NewElts);
239
0
      // Destroy the original elements.
240
0
      destroy_range(Begin, End);
241
218
    } else {
242
218
      // Use memcpy for PODs (std::uninitialized_copy optimizes to memmove).
243
218
      memcpy(NewElts, Begin, CurSize * sizeof(T));
244
218
    }
245
218
  }
246
37.5k
247
37.5k
  // For now, leak 'Begin'.  We can add it back to a freelist in
248
37.5k
  // BumpVectorContext.
249
37.5k
  Begin = NewElts;
250
37.5k
  End = NewElts+CurSize;
251
37.5k
  Capacity = Begin+NewCapacity;
252
37.5k
}
clang::BumpVector<clang::ento::MemRegion const*>::grow(clang::BumpVectorContext&, unsigned long)
Line
Count
Source
225
462
void BumpVector<T>::grow(BumpVectorContext &C, size_t MinSize) {
226
462
  size_t CurCapacity = Capacity-Begin;
227
462
  size_t CurSize = size();
228
462
  size_t NewCapacity = 2*CurCapacity;
229
462
  if (NewCapacity < MinSize)
230
462
    NewCapacity = MinSize;
231
462
232
462
  // Allocate the memory from the BumpPtrAllocator.
233
462
  T *NewElts = C.getAllocator().template Allocate<T>(NewCapacity);
234
462
235
462
  // Copy the elements over.
236
462
  if (Begin != End) {
237
0
    if (std::is_class<T>::value) {
238
0
      std::uninitialized_copy(Begin, End, NewElts);
239
0
      // Destroy the original elements.
240
0
      destroy_range(Begin, End);
241
0
    } else {
242
0
      // Use memcpy for PODs (std::uninitialized_copy optimizes to memmove).
243
0
      memcpy(NewElts, Begin, CurSize * sizeof(T));
244
0
    }
245
0
  }
246
462
247
462
  // For now, leak 'Begin'.  We can add it back to a freelist in
248
462
  // BumpVectorContext.
249
462
  Begin = NewElts;
250
462
  End = NewElts+CurSize;
251
462
  Capacity = Begin+NewCapacity;
252
462
}
clang::BumpVector<clang::VarDecl const*>::grow(clang::BumpVectorContext&, unsigned long)
Line
Count
Source
225
388
void BumpVector<T>::grow(BumpVectorContext &C, size_t MinSize) {
226
388
  size_t CurCapacity = Capacity-Begin;
227
388
  size_t CurSize = size();
228
388
  size_t NewCapacity = 2*CurCapacity;
229
388
  if (NewCapacity < MinSize)
230
388
    NewCapacity = MinSize;
231
388
232
388
  // Allocate the memory from the BumpPtrAllocator.
233
388
  T *NewElts = C.getAllocator().template Allocate<T>(NewCapacity);
234
388
235
388
  // Copy the elements over.
236
388
  if (Begin != End) {
237
0
    if (std::is_class<T>::value) {
238
0
      std::uninitialized_copy(Begin, End, NewElts);
239
0
      // Destroy the original elements.
240
0
      destroy_range(Begin, End);
241
0
    } else {
242
0
      // Use memcpy for PODs (std::uninitialized_copy optimizes to memmove).
243
0
      memcpy(NewElts, Begin, CurSize * sizeof(T));
244
0
    }
245
0
  }
246
388
247
388
  // For now, leak 'Begin'.  We can add it back to a freelist in
248
388
  // BumpVectorContext.
249
388
  Begin = NewElts;
250
388
  End = NewElts+CurSize;
251
388
  Capacity = Begin+NewCapacity;
252
388
}
clang::BumpVector<clang::CFGElement>::grow(clang::BumpVectorContext&, unsigned long)
Line
Count
Source
225
3.16M
void BumpVector<T>::grow(BumpVectorContext &C, size_t MinSize) {
226
3.16M
  size_t CurCapacity = Capacity-Begin;
227
3.16M
  size_t CurSize = size();
228
3.16M
  size_t NewCapacity = 2*CurCapacity;
229
3.16M
  if (NewCapacity < MinSize)
230
2.02M
    NewCapacity = MinSize;
231
3.16M
232
3.16M
  // Allocate the memory from the BumpPtrAllocator.
233
3.16M
  T *NewElts = C.getAllocator().template Allocate<T>(NewCapacity);
234
3.16M
235
3.16M
  // Copy the elements over.
236
3.16M
  if (Begin != End) {
237
1.13M
    if (std::is_class<T>::value) {
238
1.13M
      std::uninitialized_copy(Begin, End, NewElts);
239
1.13M
      // Destroy the original elements.
240
1.13M
      destroy_range(Begin, End);
241
1.13M
    } else {
242
0
      // Use memcpy for PODs (std::uninitialized_copy optimizes to memmove).
243
0
      memcpy(NewElts, Begin, CurSize * sizeof(T));
244
0
    }
245
1.13M
  }
246
3.16M
247
3.16M
  // For now, leak 'Begin'.  We can add it back to a freelist in
248
3.16M
  // BumpVectorContext.
249
3.16M
  Begin = NewElts;
250
3.16M
  End = NewElts+CurSize;
251
3.16M
  Capacity = Begin+NewCapacity;
252
3.16M
}
clang::BumpVector<clang::CFGBlock::AdjacentBlock>::grow(clang::BumpVectorContext&, unsigned long)
Line
Count
Source
225
4.88M
void BumpVector<T>::grow(BumpVectorContext &C, size_t MinSize) {
226
4.88M
  size_t CurCapacity = Capacity-Begin;
227
4.88M
  size_t CurSize = size();
228
4.88M
  size_t NewCapacity = 2*CurCapacity;
229
4.88M
  if (NewCapacity < MinSize)
230
4.05M
    NewCapacity = MinSize;
231
4.88M
232
4.88M
  // Allocate the memory from the BumpPtrAllocator.
233
4.88M
  T *NewElts = C.getAllocator().template Allocate<T>(NewCapacity);
234
4.88M
235
4.88M
  // Copy the elements over.
236
4.88M
  if (Begin != End) {
237
836k
    if (std::is_class<T>::value) {
238
836k
      std::uninitialized_copy(Begin, End, NewElts);
239
836k
      // Destroy the original elements.
240
836k
      destroy_range(Begin, End);
241
836k
    } else {
242
0
      // Use memcpy for PODs (std::uninitialized_copy optimizes to memmove).
243
0
      memcpy(NewElts, Begin, CurSize * sizeof(T));
244
0
    }
245
836k
  }
246
4.88M
247
4.88M
  // For now, leak 'Begin'.  We can add it back to a freelist in
248
4.88M
  // BumpVectorContext.
249
4.88M
  Begin = NewElts;
250
4.88M
  End = NewElts+CurSize;
251
4.88M
  Capacity = Begin+NewCapacity;
252
4.88M
}
clang::BumpVector<clang::CFGBlock*>::grow(clang::BumpVectorContext&, unsigned long)
Line
Count
Source
225
449k
void BumpVector<T>::grow(BumpVectorContext &C, size_t MinSize) {
226
449k
  size_t CurCapacity = Capacity-Begin;
227
449k
  size_t CurSize = size();
228
449k
  size_t NewCapacity = 2*CurCapacity;
229
449k
  if (NewCapacity < MinSize)
230
403k
    NewCapacity = MinSize;
231
449k
232
449k
  // Allocate the memory from the BumpPtrAllocator.
233
449k
  T *NewElts = C.getAllocator().template Allocate<T>(NewCapacity);
234
449k
235
449k
  // Copy the elements over.
236
449k
  if (Begin != End) {
237
45.8k
    if (std::is_class<T>::value) {
238
0
      std::uninitialized_copy(Begin, End, NewElts);
239
0
      // Destroy the original elements.
240
0
      destroy_range(Begin, End);
241
45.8k
    } else {
242
45.8k
      // Use memcpy for PODs (std::uninitialized_copy optimizes to memmove).
243
45.8k
      memcpy(NewElts, Begin, CurSize * sizeof(T));
244
45.8k
    }
245
45.8k
  }
246
449k
247
449k
  // For now, leak 'Begin'.  We can add it back to a freelist in
248
449k
  // BumpVectorContext.
249
449k
  Begin = NewElts;
250
449k
  End = NewElts+CurSize;
251
449k
  Capacity = Begin+NewCapacity;
252
449k
}
clang::BumpVector<clang::VarDecl*>::grow(clang::BumpVectorContext&, unsigned long)
Line
Count
Source
225
13.9k
void BumpVector<T>::grow(BumpVectorContext &C, size_t MinSize) {
226
13.9k
  size_t CurCapacity = Capacity-Begin;
227
13.9k
  size_t CurSize = size();
228
13.9k
  size_t NewCapacity = 2*CurCapacity;
229
13.9k
  if (NewCapacity < MinSize)
230
13.8k
    NewCapacity = MinSize;
231
13.9k
232
13.9k
  // Allocate the memory from the BumpPtrAllocator.
233
13.9k
  T *NewElts = C.getAllocator().template Allocate<T>(NewCapacity);
234
13.9k
235
13.9k
  // Copy the elements over.
236
13.9k
  if (Begin != End) {
237
57
    if (std::is_class<T>::value) {
238
0
      std::uninitialized_copy(Begin, End, NewElts);
239
0
      // Destroy the original elements.
240
0
      destroy_range(Begin, End);
241
57
    } else {
242
57
      // Use memcpy for PODs (std::uninitialized_copy optimizes to memmove).
243
57
      memcpy(NewElts, Begin, CurSize * sizeof(T));
244
57
    }
245
57
  }
246
13.9k
247
13.9k
  // For now, leak 'Begin'.  We can add it back to a freelist in
248
13.9k
  // BumpVectorContext.
249
13.9k
  Begin = NewElts;
250
13.9k
  End = NewElts+CurSize;
251
13.9k
  Capacity = Begin+NewCapacity;
252
13.9k
}
253
254
} // namespace clang
255
256
#endif // LLVM_CLANG_ANALYSIS_SUPPORT_BUMPVECTOR_H