[llvm-cov] Use getOptions() instead of Options in SourceCoverageView, NFC

A lot of this code is going to move into the text-based coverage
renderer, and won't be able to use Options directly. Use the getter.

llvm-svn: 273635
This commit is contained in:
Vedant Kumar 2016-06-24 00:41:26 +00:00
parent 9d70d0b5ff
commit 1c4f588df7
1 changed files with 16 additions and 14 deletions

View File

@ -36,9 +36,10 @@ void SourceCoverageView::renderLine(
for (const auto *S : Segments) {
unsigned End = std::min(S->Col, static_cast<unsigned>(Line.size()) + 1);
colored_ostream(OS, Highlight ? *Highlight : raw_ostream::SAVEDCOLOR,
Options.Colors && Highlight, /*Bold=*/false, /*BG=*/true)
getOptions().Colors && Highlight, /*Bold=*/false,
/*BG=*/true)
<< Line.substr(Col - 1, End - Col);
if (Options.Debug && Highlight)
if (getOptions().Debug && Highlight)
HighlightedRanges.push_back(std::make_pair(Col, End));
Col = End;
if (Col == ExpansionCol)
@ -51,11 +52,11 @@ void SourceCoverageView::renderLine(
// Show the rest of the line
colored_ostream(OS, Highlight ? *Highlight : raw_ostream::SAVEDCOLOR,
Options.Colors && Highlight, /*Bold=*/false, /*BG=*/true)
getOptions().Colors && Highlight, /*Bold=*/false, /*BG=*/true)
<< Line.substr(Col - 1, Line.size() - Col + 1);
OS << "\n";
if (Options.Debug) {
if (getOptions().Debug) {
for (const auto &Range : HighlightedRanges)
errs() << "Highlighted line " << LineNumber << ", " << Range.first
<< " -> " << Range.second << "\n";
@ -104,7 +105,7 @@ SourceCoverageView::renderLineCoverageColumn(raw_ostream &OS,
std::string C = formatCount(Line.ExecutionCount);
OS.indent(LineCoverageColumnWidth - C.size());
colored_ostream(OS, raw_ostream::MAGENTA,
Line.hasMultipleRegions() && Options.Colors)
Line.hasMultipleRegions() && getOptions().Colors)
<< C;
OS << '|';
}
@ -136,7 +137,7 @@ void SourceCoverageView::renderRegionMarkers(
}
OS << "\n";
if (Options.Debug)
if (getOptions().Debug)
for (const auto *S : Segments)
errs() << "Marker at " << S->Line << ":" << S->Col << " = "
<< formatCount(S->Count) << (S->IsRegionEntry ? "\n" : " (pop)\n");
@ -146,8 +147,8 @@ void SourceCoverageView::render(raw_ostream &OS, bool WholeFile,
unsigned IndentLevel) {
// The width of the leading columns
unsigned CombinedColumnWidth =
(Options.ShowLineStats ? LineCoverageColumnWidth + 1 : 0) +
(Options.ShowLineNumbers ? LineNumberColumnWidth + 1 : 0);
(getOptions().ShowLineStats ? LineCoverageColumnWidth + 1 : 0) +
(getOptions().ShowLineNumbers ? LineNumberColumnWidth + 1 : 0);
// The width of the line that is used to divide between the view and the
// subviews.
unsigned DividerWidth = CombinedColumnWidth + 4;
@ -195,15 +196,15 @@ void SourceCoverageView::render(raw_ostream &OS, bool WholeFile,
// Render the line prefix.
renderIndent(OS, IndentLevel);
if (Options.ShowLineStats)
if (getOptions().ShowLineStats)
renderLineCoverageColumn(OS, LineCount);
if (Options.ShowLineNumbers)
if (getOptions().ShowLineNumbers)
renderLineNumberColumn(OS, LI.line_number());
// If there are expansion subviews, we want to highlight the first one.
unsigned ExpansionColumn = 0;
if (NextESV != EndESV && NextESV->getLine() == LI.line_number() &&
Options.Colors)
getOptions().Colors)
ExpansionColumn = NextESV->getStartCol();
// Display the source code for the current line.
@ -211,8 +212,9 @@ void SourceCoverageView::render(raw_ostream &OS, bool WholeFile,
ExpansionColumn);
// Show the region markers.
if (Options.ShowRegionMarkers && (!Options.ShowLineStatsOrRegionMarkers ||
LineCount.hasMultipleRegions()) &&
if (getOptions().ShowRegionMarkers &&
(!getOptions().ShowLineStatsOrRegionMarkers ||
LineCount.hasMultipleRegions()) &&
!LineSegments.empty()) {
renderIndent(OS, IndentLevel);
OS.indent(CombinedColumnWidth);
@ -238,7 +240,7 @@ void SourceCoverageView::render(raw_ostream &OS, bool WholeFile,
OS << "\n";
}
// Render the child subview
if (Options.Debug)
if (getOptions().Debug)
errs() << "Expansion at line " << NextESV->getLine() << ", "
<< NextESV->getStartCol() << " -> " << NextESV->getEndCol()
<< "\n";