1
- // =-- CoverageMapping.h - Code coverage mapping support --------- *- C++ -*-=//
1
+ // ===- CoverageMapping.h - Code coverage mapping support --------*- C++ -*-== =//
2
2
//
3
3
// The LLVM Compiler Infrastructure
4
4
//
12
12
//
13
13
// ===----------------------------------------------------------------------===//
14
14
15
- #ifndef LLVM_PROFILEDATA_COVERAGEMAPPING_H_
16
- #define LLVM_PROFILEDATA_COVERAGEMAPPING_H_
15
+ #ifndef LLVM_PROFILEDATA_COVERAGE_COVERAGEMAPPING_H
16
+ #define LLVM_PROFILEDATA_COVERAGE_COVERAGEMAPPING_H
17
17
18
18
#include " llvm/ADT/ArrayRef.h"
19
19
#include " llvm/ADT/DenseMap.h"
20
20
#include " llvm/ADT/Hashing.h"
21
- #include " llvm/ADT/StringSet.h"
22
- #include " llvm/ADT/Triple.h"
23
21
#include " llvm/ADT/iterator.h"
22
+ #include " llvm/ADT/iterator_range.h"
23
+ #include " llvm/ADT/None.h"
24
+ #include " llvm/ADT/StringSet.h"
25
+ #include " llvm/ADT/StringRef.h"
24
26
#include " llvm/ProfileData/InstrProf.h"
27
+ #include " llvm/Support/Compiler.h"
25
28
#include " llvm/Support/Debug.h"
26
29
#include " llvm/Support/Endian.h"
30
+ #include " llvm/Support/Error.h"
27
31
#include " llvm/Support/raw_ostream.h"
32
+ #include < cassert>
33
+ #include < cstdint>
34
+ #include < iterator>
35
+ #include < memory>
36
+ #include < string>
28
37
#include < system_error>
29
38
#include < tuple>
39
+ #include < utility>
40
+ #include < vector>
30
41
31
42
namespace llvm {
43
+
44
+ class IndexedInstrProfReader ;
45
+
32
46
namespace coverage {
33
47
48
+ class CoverageMappingReader ;
49
+ struct CoverageMappingRecord ;
50
+
34
51
enum class coveragemap_error {
35
52
success = 0 ,
36
53
eof,
@@ -68,19 +85,6 @@ class CoverageMapError : public ErrorInfo<CoverageMapError> {
68
85
coveragemap_error Err;
69
86
};
70
87
71
- } // end of coverage namespace.
72
- } // end of llvm namespace
73
-
74
- namespace llvm {
75
- class IndexedInstrProfReader ;
76
- namespace coverage {
77
-
78
- class CoverageMappingReader ;
79
- struct CoverageMappingRecord ;
80
-
81
- class CoverageMapping ;
82
- struct CounterExpressions ;
83
-
84
88
// / \brief A Counter is an abstract value that describes how to compute the
85
89
// / execution count for a region of code using the collected profile count data.
86
90
struct Counter {
@@ -91,13 +95,13 @@ struct Counter {
91
95
EncodingTagBits + 1 ;
92
96
93
97
private:
94
- CounterKind Kind;
95
- unsigned ID;
98
+ CounterKind Kind = Zero ;
99
+ unsigned ID = 0 ;
96
100
97
101
Counter (CounterKind Kind, unsigned ID) : Kind(Kind), ID(ID) {}
98
102
99
103
public:
100
- Counter () : Kind(Zero), ID( 0 ) {}
104
+ Counter () = default ;
101
105
102
106
CounterKind getKind () const { return Kind; }
103
107
@@ -153,8 +157,9 @@ struct CounterExpression {
153
157
class CounterExpressionBuilder {
154
158
// / \brief A list of all the counter expressions
155
159
std::vector<CounterExpression> Expressions;
160
+
156
161
// / \brief A lookup table for the index of a given expression.
157
- llvm:: DenseMap<CounterExpression, unsigned > ExpressionIndices;
162
+ DenseMap<CounterExpression, unsigned > ExpressionIndices;
158
163
159
164
// / \brief Return the counter which corresponds to the given expression.
160
165
// /
@@ -238,7 +243,6 @@ struct CounterMappingRegion {
238
243
LineEnd, ColumnEnd, SkippedRegion);
239
244
}
240
245
241
-
242
246
inline std::pair<unsigned , unsigned > startLoc () const {
243
247
return std::pair<unsigned , unsigned >(LineStart, ColumnStart);
244
248
}
@@ -269,7 +273,7 @@ class CounterMappingContext {
269
273
270
274
void setCounts (ArrayRef<uint64_t > Counts) { CounterValues = Counts; }
271
275
272
- void dump (const Counter &C, llvm:: raw_ostream &OS) const ;
276
+ void dump (const Counter &C, raw_ostream &OS) const ;
273
277
void dump (const Counter &C) const { dump (C, dbgs ()); }
274
278
275
279
// / \brief Return the number of times that a region of code associated with
@@ -390,13 +394,14 @@ struct CoverageSegment {
390
394
// / provides a sequence of CoverageSegments to iterate through, as well as the
391
395
// / list of expansions that can be further processed.
392
396
class CoverageData {
397
+ friend class CoverageMapping ;
398
+
393
399
std::string Filename;
394
400
std::vector<CoverageSegment> Segments;
395
401
std::vector<ExpansionRecord> Expansions;
396
- friend class CoverageMapping ;
397
402
398
403
public:
399
- CoverageData () {}
404
+ CoverageData () = default ;
400
405
401
406
CoverageData (StringRef Filename) : Filename(Filename) {}
402
407
@@ -422,18 +427,17 @@ class CoverageData {
422
427
class CoverageMapping {
423
428
StringSet<> FunctionNames;
424
429
std::vector<FunctionRecord> Functions;
425
- unsigned MismatchedFunctionCount;
426
-
427
- CoverageMapping () : MismatchedFunctionCount(0 ) {}
428
-
429
- CoverageMapping (const CoverageMapping &) = delete ;
430
- const CoverageMapping &operator =(const CoverageMapping &) = delete ;
430
+ unsigned MismatchedFunctionCount = 0 ;
431
431
432
+ CoverageMapping () = default ;
432
433
// / \brief Add a function record corresponding to \p Record.
433
434
Error loadFunctionRecord (const CoverageMappingRecord &Record,
434
435
IndexedInstrProfReader &ProfileReader);
435
436
436
437
public:
438
+ CoverageMapping (const CoverageMapping &) = delete ;
439
+ CoverageMapping &operator =(const CoverageMapping &) = delete ;
440
+
437
441
// / \brief Load the coverage mapping using the given readers.
438
442
static Expected<std::unique_ptr<CoverageMapping>>
439
443
load (CoverageMappingReader &CoverageReader,
@@ -517,14 +521,17 @@ template <class IntPtrT> struct CovMapFunctionRecordV1 {
517
521
template <support::endianness Endian> uint64_t getFuncHash () const {
518
522
return support::endian::byte_swap<uint64_t , Endian>(FuncHash);
519
523
}
524
+
520
525
// Return the coverage map data size for the funciton.
521
526
template <support::endianness Endian> uint32_t getDataSize () const {
522
527
return support::endian::byte_swap<uint32_t , Endian>(DataSize);
523
528
}
529
+
524
530
// Return function lookup key. The value is consider opaque.
525
531
template <support::endianness Endian> IntPtrT getFuncNameRef () const {
526
532
return support::endian::byte_swap<IntPtrT, Endian>(NamePtr);
527
533
}
534
+
528
535
// Return the PGO name of the function */
529
536
template <support::endianness Endian>
530
537
Error getFuncName (InstrProfSymtab &ProfileNames, StringRef &FuncName) const {
@@ -545,14 +552,17 @@ struct CovMapFunctionRecord {
545
552
template <support::endianness Endian> uint64_t getFuncHash () const {
546
553
return support::endian::byte_swap<uint64_t , Endian>(FuncHash);
547
554
}
555
+
548
556
// Return the coverage map data size for the funciton.
549
557
template <support::endianness Endian> uint32_t getDataSize () const {
550
558
return support::endian::byte_swap<uint32_t , Endian>(DataSize);
551
559
}
560
+
552
561
// Return function lookup key. The value is consider opaque.
553
562
template <support::endianness Endian> uint64_t getFuncNameRef () const {
554
563
return support::endian::byte_swap<uint64_t , Endian>(NameRef);
555
564
}
565
+
556
566
// Return the PGO name of the function */
557
567
template <support::endianness Endian>
558
568
Error getFuncName (InstrProfSymtab &ProfileNames, StringRef &FuncName) const {
@@ -570,12 +580,15 @@ struct CovMapHeader {
570
580
template <support::endianness Endian> uint32_t getNRecords () const {
571
581
return support::endian::byte_swap<uint32_t , Endian>(NRecords);
572
582
}
583
+
573
584
template <support::endianness Endian> uint32_t getFilenamesSize () const {
574
585
return support::endian::byte_swap<uint32_t , Endian>(FilenamesSize);
575
586
}
587
+
576
588
template <support::endianness Endian> uint32_t getCoverageSize () const {
577
589
return support::endian::byte_swap<uint32_t , Endian>(CoverageSize);
578
590
}
591
+
579
592
template <support::endianness Endian> uint32_t getVersion () const {
580
593
return support::endian::byte_swap<uint32_t , Endian>(Version);
581
594
}
@@ -635,4 +648,4 @@ template<> struct DenseMapInfo<coverage::CounterExpression> {
635
648
636
649
} // end namespace llvm
637
650
638
- #endif // LLVM_PROFILEDATA_COVERAGEMAPPING_H_
651
+ #endif // LLVM_PROFILEDATA_COVERAGE_COVERAGEMAPPING_H
0 commit comments