-
-void SourceCoverageView::setUpVisibleRange(SourceCoverageDataManager &Data) {
- auto CountedRegions = Data.getSourceRegions();
- if (!CountedRegions.size())
- return;
-
- unsigned Start = CountedRegions.front().LineStart, End = 0;
- for (const auto &CR : CountedRegions) {
- Start = std::min(Start, CR.LineStart);
- End = std::max(End, CR.LineEnd);
- }
- LineOffset = Start;
- LineStats.resize(End - Start + 1);
-}
-
-void
-SourceCoverageView::createLineCoverageInfo(SourceCoverageDataManager &Data) {
- auto CountedRegions = Data.getSourceRegions();
- for (const auto &CR : CountedRegions) {
- if (CR.Kind == coverage::CounterMappingRegion::SkippedRegion) {
- // Reset the line stats for skipped regions.
- for (unsigned Line = CR.LineStart; Line <= CR.LineEnd;
- ++Line)
- LineStats[Line - LineOffset] = LineCoverageInfo();
- continue;
- }
- LineStats[CR.LineStart - LineOffset].addRegionStartCount(CR.ExecutionCount);
- for (unsigned Line = CR.LineStart + 1; Line <= CR.LineEnd; ++Line)
- LineStats[Line - LineOffset].addRegionCount(CR.ExecutionCount);
- }
-}
-
-void
-SourceCoverageView::createHighlightRanges(SourceCoverageDataManager &Data) {
- auto CountedRegions = Data.getSourceRegions();
- std::vector<bool> AlreadyHighlighted;
- AlreadyHighlighted.resize(CountedRegions.size(), false);
-
- for (size_t I = 0, S = CountedRegions.size(); I < S; ++I) {
- const auto &CR = CountedRegions[I];
- if (CR.Kind == coverage::CounterMappingRegion::SkippedRegion ||
- CR.ExecutionCount != 0)
- continue;
- if (AlreadyHighlighted[I])
- continue;
- for (size_t J = 0; J < S; ++J) {
- if (CR.contains(CountedRegions[J])) {
- AlreadyHighlighted[J] = true;
- }
- }
- if (CR.LineStart == CR.LineEnd) {
- HighlightRanges.push_back(HighlightRange(
- CR.LineStart, CR.ColumnStart, CR.ColumnEnd));
- continue;
- }
- HighlightRanges.push_back(
- HighlightRange(CR.LineStart, CR.ColumnStart,
- std::numeric_limits<unsigned>::max()));
- HighlightRanges.push_back(
- HighlightRange(CR.LineEnd, 1, CR.ColumnEnd));
- for (unsigned Line = CR.LineStart + 1; Line < CR.LineEnd;
- ++Line) {
- HighlightRanges.push_back(
- HighlightRange(Line, 1, std::numeric_limits<unsigned>::max()));
- }
- }
-
- std::sort(HighlightRanges.begin(), HighlightRanges.end());
-}
-
-void SourceCoverageView::createRegionMarkers(SourceCoverageDataManager &Data) {
- for (const auto &CR : Data.getSourceRegions())
- if (CR.Kind != coverage::CounterMappingRegion::SkippedRegion)
- Markers.push_back(
- RegionMarker(CR.LineStart, CR.ColumnStart, CR.ExecutionCount));
-}
-
-void SourceCoverageView::load(SourceCoverageDataManager &Data) {
- setUpVisibleRange(Data);
- if (Options.ShowLineStats)
- createLineCoverageInfo(Data);
- if (Options.Colors)
- createHighlightRanges(Data);
- if (Options.ShowRegionMarkers)
- createRegionMarkers(Data);
-}