@@ -26,11 +26,6 @@ using namespace llvm;
26
26
// ===----------------------------------------------------------------------===//
27
27
// GCOVFile implementation.
28
28
29
- // / ~GCOVFile - Delete GCOVFile and its content.
30
- GCOVFile::~GCOVFile () {
31
- DeleteContainerPointers (Functions);
32
- }
33
-
34
29
// / readGCNO - Read GCNO buffer.
35
30
bool GCOVFile::readGCNO (GCOVBuffer &Buffer) {
36
31
if (!Buffer.readGCNOFormat ()) return false ;
@@ -39,10 +34,10 @@ bool GCOVFile::readGCNO(GCOVBuffer &Buffer) {
39
34
if (!Buffer.readInt (Checksum)) return false ;
40
35
while (true ) {
41
36
if (!Buffer.readFunctionTag ()) break ;
42
- GCOVFunction * GFun = new GCOVFunction (*this );
37
+ auto GFun = make_unique< GCOVFunction> (*this );
43
38
if (!GFun->readGCNO (Buffer, Version))
44
39
return false ;
45
- Functions.push_back (GFun);
40
+ Functions.push_back (std::move ( GFun) );
46
41
}
47
42
48
43
GCNOInitialized = true ;
@@ -97,30 +92,22 @@ bool GCOVFile::readGCDA(GCOVBuffer &Buffer) {
97
92
98
93
// / dump - Dump GCOVFile content to dbgs() for debugging purposes.
99
94
void GCOVFile::dump () const {
100
- for (SmallVectorImpl<GCOVFunction *>::const_iterator I = Functions.begin (),
101
- E = Functions.end (); I != E; ++I)
102
- (*I)->dump ();
95
+ for (const auto &FPtr : Functions)
96
+ FPtr->dump ();
103
97
}
104
98
105
99
// / collectLineCounts - Collect line counts. This must be used after
106
100
// / reading .gcno and .gcda files.
107
101
void GCOVFile::collectLineCounts (FileInfo &FI) {
108
- for (SmallVectorImpl<GCOVFunction *>::iterator I = Functions.begin (),
109
- E = Functions.end (); I != E; ++I)
110
- (*I)->collectLineCounts (FI);
102
+ for (const auto &FPtr : Functions)
103
+ FPtr->collectLineCounts (FI);
111
104
FI.setRunCount (RunCount);
112
105
FI.setProgramCount (ProgramCount);
113
106
}
114
107
115
108
// ===----------------------------------------------------------------------===//
116
109
// GCOVFunction implementation.
117
110
118
- // / ~GCOVFunction - Delete GCOVFunction and its content.
119
- GCOVFunction::~GCOVFunction () {
120
- DeleteContainerPointers (Blocks);
121
- DeleteContainerPointers (Edges);
122
- }
123
-
124
111
// / readGCNO - Read a function from the GCNO buffer. Return false if an error
125
112
// / occurs.
126
113
bool GCOVFunction::readGCNO (GCOVBuffer &Buff, GCOV::GCOVVersion Version) {
@@ -150,7 +137,7 @@ bool GCOVFunction::readGCNO(GCOVBuffer &Buff, GCOV::GCOVVersion Version) {
150
137
if (!Buff.readInt (BlockCount)) return false ;
151
138
for (uint32_t i = 0 , e = BlockCount; i != e; ++i) {
152
139
if (!Buff.readInt (Dummy)) return false ; // Block flags;
153
- Blocks.push_back (new GCOVBlock (*this , i));
140
+ Blocks.push_back (make_unique< GCOVBlock> (*this , i));
154
141
}
155
142
156
143
// read edges.
@@ -168,8 +155,8 @@ bool GCOVFunction::readGCNO(GCOVBuffer &Buff, GCOV::GCOVVersion Version) {
168
155
for (uint32_t i = 0 , e = EdgeCount; i != e; ++i) {
169
156
uint32_t Dst;
170
157
if (!Buff.readInt (Dst)) return false ;
171
- GCOVEdge *Edge = new GCOVEdge ( Blocks[BlockNo], Blocks[Dst]);
172
- Edges.push_back (Edge );
158
+ Edges. push_back (make_unique< GCOVEdge>(* Blocks[BlockNo], * Blocks[Dst]) );
159
+ GCOVEdge *Edge = Edges.back (). get ( );
173
160
Blocks[BlockNo]->addDstEdge (Edge);
174
161
Blocks[Dst]->addSrcEdge (Edge);
175
162
if (!Buff.readInt (Dummy)) return false ; // Edge flag
@@ -188,7 +175,7 @@ bool GCOVFunction::readGCNO(GCOVBuffer &Buff, GCOV::GCOVVersion Version) {
188
175
<< " ).\n " ;
189
176
return false ;
190
177
}
191
- GCOVBlock * Block = Blocks[BlockNo];
178
+ GCOVBlock & Block = * Blocks[BlockNo];
192
179
if (!Buff.readInt (Dummy)) return false ; // flag
193
180
while (Buff.getCursor () != (EndPos - 4 )) {
194
181
StringRef F;
@@ -203,7 +190,7 @@ bool GCOVFunction::readGCNO(GCOVBuffer &Buff, GCOV::GCOVVersion Version) {
203
190
uint32_t Line;
204
191
if (!Buff.readInt (Line)) return false ;
205
192
if (!Line) break ;
206
- Block-> addLine (Line);
193
+ Block. addLine (Line);
207
194
}
208
195
}
209
196
if (!Buff.readInt (Dummy)) return false ; // flag
@@ -300,9 +287,8 @@ uint64_t GCOVFunction::getExitCount() const {
300
287
// / dump - Dump GCOVFunction content to dbgs() for debugging purposes.
301
288
void GCOVFunction::dump () const {
302
289
dbgs () << " ===== " << Name << " @ " << Filename << " :" << LineNumber << " \n " ;
303
- for (SmallVectorImpl<GCOVBlock *>::const_iterator I = Blocks.begin (),
304
- E = Blocks.end (); I != E; ++I)
305
- (*I)->dump ();
290
+ for (const auto &Block : Blocks)
291
+ Block->dump ();
306
292
}
307
293
308
294
// / collectLineCounts - Collect line counts. This must be used after
@@ -313,9 +299,8 @@ void GCOVFunction::collectLineCounts(FileInfo &FI) {
313
299
if (LineNumber == 0 )
314
300
return ;
315
301
316
- for (SmallVectorImpl<GCOVBlock *>::iterator I = Blocks.begin (),
317
- E = Blocks.end (); I != E; ++I)
318
- (*I)->collectLineCounts (FI);
302
+ for (const auto &Block : Blocks)
303
+ Block->collectLineCounts (FI);
319
304
FI.addFunctionLine (Filename, LineNumber, this );
320
305
}
321
306
@@ -335,8 +320,8 @@ void GCOVBlock::addCount(size_t DstEdgeNo, uint64_t N) {
335
320
assert (DstEdgeNo < DstEdges.size ()); // up to caller to ensure EdgeNo is valid
336
321
DstEdges[DstEdgeNo]->Count = N;
337
322
Counter += N;
338
- if (!DstEdges[DstEdgeNo]->Dst -> getNumDstEdges ())
339
- DstEdges[DstEdgeNo]->Dst -> Counter += N;
323
+ if (!DstEdges[DstEdgeNo]->Dst . getNumDstEdges ())
324
+ DstEdges[DstEdgeNo]->Dst . Counter += N;
340
325
}
341
326
342
327
// / sortDstEdges - Sort destination edges by block number, nop if already
@@ -363,15 +348,15 @@ void GCOVBlock::dump() const {
363
348
dbgs () << " \t Source Edges : " ;
364
349
for (EdgeIterator I = SrcEdges.begin (), E = SrcEdges.end (); I != E; ++I) {
365
350
const GCOVEdge *Edge = *I;
366
- dbgs () << Edge->Src -> Number << " (" << Edge->Count << " ), " ;
351
+ dbgs () << Edge->Src . Number << " (" << Edge->Count << " ), " ;
367
352
}
368
353
dbgs () << " \n " ;
369
354
}
370
355
if (!DstEdges.empty ()) {
371
356
dbgs () << " \t Destination Edges : " ;
372
357
for (EdgeIterator I = DstEdges.begin (), E = DstEdges.end (); I != E; ++I) {
373
358
const GCOVEdge *Edge = *I;
374
- dbgs () << Edge->Dst -> Number << " (" << Edge->Count << " ), " ;
359
+ dbgs () << Edge->Dst . Number << " (" << Edge->Count << " ), " ;
375
360
}
376
361
dbgs () << " \n " ;
377
362
}
@@ -617,8 +602,8 @@ void FileInfo::printFunctionSummary(raw_fd_ostream &OS,
617
602
uint32_t BlocksExec = 0 ;
618
603
for (GCOVFunction::BlockIterator I = Func->block_begin (),
619
604
E = Func->block_end (); I != E; ++I) {
620
- const GCOVBlock * Block = *I;
621
- if (Block-> getNumDstEdges () && Block-> getCount ())
605
+ const GCOVBlock & Block = * *I;
606
+ if (Block. getNumDstEdges () && Block. getCount ())
622
607
++BlocksExec;
623
608
}
624
609
0 commit comments