19 using namespace coverage;
23 for (
const auto &Filename : Filenames) {
32 class CounterExpressionsMinimizer {
35 std::vector<unsigned> AdjustedExpressionIDs;
42 AdjustedExpressionIDs[
ID] = 1;
43 mark(Expressions[ID].LHS);
44 mark(Expressions[ID].RHS);
52 UsedExpressions.push_back(E);
59 : Expressions(Expressions) {
60 AdjustedExpressionIDs.resize(Expressions.
size(), 0);
61 for (
const auto &
I : MappingRegions)
63 for (
const auto &
I : MappingRegions)
112 std::stable_sort(MappingRegions.begin(), MappingRegions.end());
116 for (
const auto &FileID : VirtualFileMapping)
120 CounterExpressionsMinimizer Minimizer(Expressions, MappingRegions);
121 auto MinExpressions = Minimizer.getExpressions();
123 for (
const auto &E : MinExpressions) {
124 writeCounter(MinExpressions, Minimizer.adjust(E.LHS), OS);
125 writeCounter(MinExpressions, Minimizer.adjust(E.RHS), OS);
131 unsigned PrevLineStart = 0;
132 unsigned CurrentFileID = ~0U;
133 for (
auto I = MappingRegions.begin(), E = MappingRegions.end();
I != E; ++
I) {
134 if (
I->FileID != CurrentFileID) {
136 assert(
I->FileID == (CurrentFileID + 1));
138 unsigned RegionCount = 1;
139 for (
auto J =
I + 1; J != E &&
I->FileID == J->FileID; ++J)
144 CurrentFileID =
I->FileID;
147 Counter Count = Minimizer.adjust(
I->Count);
154 assert(
I->ExpandedFileID <=
155 (std::numeric_limits<unsigned>::max() >>
159 unsigned EncodedTagExpandedFileID =
173 assert(
I->LineStart >= PrevLineStart);
176 assert(
I->LineEnd >=
I->LineStart);
179 PrevLineStart =
I->LineStart;
182 assert(CurrentFileID == (VirtualFileMapping.size() - 1));
void write(raw_ostream &OS)
Write encoded coverage mapping data to the given output stream.
void write(raw_ostream &OS)
Write encoded filenames to the given output stream.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
size_t size() const
size - Get the array size.
static unsigned encodeCounter(ArrayRef< CounterExpression > Expressions, Counter C)
Encode the counter.
unsigned getExpressionID() const
CounterKind getKind() const
A CodeRegion associates some code with a counter.
unsigned getCounterID() const
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
An ExpansionRegion represents a file expansion region that associates a source range with the expansi...
A SkippedRegion represents a source range with code that was skipped by a preprocessor or similar mea...
static void writeCounter(ArrayRef< CounterExpression > Expressions, Counter C, raw_ostream &OS)
static const unsigned EncodingCounterTagAndExpansionRegionTagBits
bool isExpression() const
static const unsigned EncodingTagBits
This class implements an extremely fast bulk output stream that can only output to a stream...
void encodeULEB128(uint64_t Value, raw_ostream &OS, unsigned Padding=0)
Utility function to encode a ULEB128 value to an output stream.
static Counter getExpression(unsigned ExpressionId)
Return the counter that corresponds to a specific addition counter expression.
A Counter is an abstract value that describes how to compute the execution count for a region of code...