llvm-cov: Disentangle the coverage data logic from the display (NFC)

This splits the logic for actually looking up coverage information
from the logic that displays it. These were tangled rather thoroughly
so this change is a bit large, but it mostly consists of moving things
around. The coverage lookup logic itself now lives in the library,
rather than being spread between the library and the tool.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218184 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Justin Bogner
2014-09-20 15:31:56 +00:00
parent 73edcffc8f
commit 9eb38163a5
14 changed files with 542 additions and 479 deletions

View File

@ -18,11 +18,11 @@
using namespace llvm;
void SourceCoverageView::renderLine(raw_ostream &OS, StringRef Line,
int64_t LineNumber,
const CoverageSegment *WrappedSegment,
ArrayRef<const CoverageSegment *> Segments,
unsigned ExpansionCol) {
void SourceCoverageView::renderLine(
raw_ostream &OS, StringRef Line, int64_t LineNumber,
const coverage::CoverageSegment *WrappedSegment,
ArrayRef<const coverage::CoverageSegment *> Segments,
unsigned ExpansionCol) {
Optional<raw_ostream::Colors> Highlight;
SmallVector<std::pair<unsigned, unsigned>, 2> HighlightedRanges;
@ -110,7 +110,7 @@ void SourceCoverageView::renderLineNumberColumn(raw_ostream &OS,
}
void SourceCoverageView::renderRegionMarkers(
raw_ostream &OS, ArrayRef<const CoverageSegment *> Segments) {
raw_ostream &OS, ArrayRef<const coverage::CoverageSegment *> Segments) {
SmallString<32> Buffer;
raw_svector_ostream BufferOS(Buffer);
@ -158,14 +158,12 @@ void SourceCoverageView::render(raw_ostream &OS, bool WholeFile,
auto EndISV = InstantiationSubViews.end();
// Get the coverage information for the file.
auto CoverageSegments = RegionManager->getCoverageSegments();
assert(CoverageSegments.size() && "View with no coverage?");
auto NextSegment = CoverageSegments.begin();
auto EndSegment = CoverageSegments.end();
auto NextSegment = CoverageInfo.begin();
auto EndSegment = CoverageInfo.end();
unsigned FirstLine = NextSegment != EndSegment ? NextSegment->Line : 0;
const CoverageSegment *WrappedSegment = nullptr;
SmallVector<const CoverageSegment *, 8> LineSegments;
const coverage::CoverageSegment *WrappedSegment = nullptr;
SmallVector<const coverage::CoverageSegment *, 8> LineSegments;
for (line_iterator LI(File, /*SkipBlanks=*/false); !LI.is_at_eof(); ++LI) {
// If we aren't rendering the whole file, we need to filter out the prologue
// and epilogue.