mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 10:42:39 +01:00
[llvm-cov] Pass LineCoverageStats in SourceCoverageView. NFC.
Instead of copying around the wrapped segment and the list of line segments, just pass a reference to a LineCoverageStats object. This simplifies the interface. It also makes an upcoming change to suppress distracting highlights possible. llvm-svn: 316108
This commit is contained in:
parent
ff20a555f6
commit
6c2710f166
@ -218,12 +218,11 @@ void SourceCoverageView::print(raw_ostream &OS, bool WholeFile,
|
||||
ExpansionColumn = NextESV->getStartCol();
|
||||
|
||||
// Display the source code for the current line.
|
||||
renderLine(OS, {*LI, LI.line_number()}, LCI->getWrappedSegment(),
|
||||
LCI->getLineSegments(), ExpansionColumn, ViewDepth);
|
||||
renderLine(OS, {*LI, LI.line_number()}, *LCI, ExpansionColumn, ViewDepth);
|
||||
|
||||
// Show the region markers.
|
||||
if (shouldRenderRegionMarkers(LCI->getLineSegments()))
|
||||
renderRegionMarkers(OS, LCI->getLineSegments(), ViewDepth);
|
||||
renderRegionMarkers(OS, *LCI, ViewDepth);
|
||||
|
||||
// Show the expansions and instantiations for this line.
|
||||
bool RenderedSubView = false;
|
||||
@ -235,9 +234,8 @@ void SourceCoverageView::print(raw_ostream &OS, bool WholeFile,
|
||||
// this subview.
|
||||
if (RenderedSubView) {
|
||||
ExpansionColumn = NextESV->getStartCol();
|
||||
renderExpansionSite(OS, {*LI, LI.line_number()},
|
||||
LCI->getWrappedSegment(), LCI->getLineSegments(),
|
||||
ExpansionColumn, ViewDepth);
|
||||
renderExpansionSite(OS, {*LI, LI.line_number()}, *LCI, ExpansionColumn,
|
||||
ViewDepth);
|
||||
renderViewDivider(OS, ViewDepth + 1);
|
||||
}
|
||||
|
||||
|
@ -179,8 +179,7 @@ protected:
|
||||
|
||||
/// \brief Render a source line with highlighting.
|
||||
virtual void renderLine(raw_ostream &OS, LineRef L,
|
||||
const coverage::CoverageSegment *WrappedSegment,
|
||||
CoverageSegmentArray Segments, unsigned ExpansionCol,
|
||||
const LineCoverageStats &LCS, unsigned ExpansionCol,
|
||||
unsigned ViewDepth) = 0;
|
||||
|
||||
/// \brief Render the line's execution count column.
|
||||
@ -192,15 +191,14 @@ protected:
|
||||
|
||||
/// \brief Render all the region's execution counts on a line.
|
||||
virtual void renderRegionMarkers(raw_ostream &OS,
|
||||
CoverageSegmentArray Segments,
|
||||
const LineCoverageStats &Line,
|
||||
unsigned ViewDepth) = 0;
|
||||
|
||||
/// \brief Render the site of an expansion.
|
||||
virtual void
|
||||
renderExpansionSite(raw_ostream &OS, LineRef L,
|
||||
const coverage::CoverageSegment *WrappedSegment,
|
||||
CoverageSegmentArray Segments, unsigned ExpansionCol,
|
||||
unsigned ViewDepth) = 0;
|
||||
virtual void renderExpansionSite(raw_ostream &OS, LineRef L,
|
||||
const LineCoverageStats &LCS,
|
||||
unsigned ExpansionCol,
|
||||
unsigned ViewDepth) = 0;
|
||||
|
||||
/// \brief Render an expansion view and any nested views.
|
||||
virtual void renderExpansionView(raw_ostream &OS, ExpansionView &ESV,
|
||||
|
@ -468,9 +468,9 @@ void SourceCoverageViewHTML::renderViewDivider(raw_ostream &, unsigned) {
|
||||
// The table-based output makes view dividers unnecessary.
|
||||
}
|
||||
|
||||
void SourceCoverageViewHTML::renderLine(
|
||||
raw_ostream &OS, LineRef L, const coverage::CoverageSegment *WrappedSegment,
|
||||
CoverageSegmentArray Segments, unsigned ExpansionCol, unsigned) {
|
||||
void SourceCoverageViewHTML::renderLine(raw_ostream &OS, LineRef L,
|
||||
const LineCoverageStats &LCS,
|
||||
unsigned ExpansionCol, unsigned) {
|
||||
StringRef Line = L.Line;
|
||||
unsigned LineNo = L.LineNo;
|
||||
|
||||
@ -482,6 +482,7 @@ void SourceCoverageViewHTML::renderLine(
|
||||
// at the end of the line. Both are required but may be empty.
|
||||
|
||||
SmallVector<std::string, 8> Snippets;
|
||||
CoverageSegmentArray Segments = LCS.getLineSegments();
|
||||
|
||||
unsigned LCol = 1;
|
||||
auto Snip = [&](unsigned Start, unsigned Len) {
|
||||
@ -518,7 +519,7 @@ void SourceCoverageViewHTML::renderLine(
|
||||
return S && S->HasCount && S->Count == 0;
|
||||
};
|
||||
|
||||
if (CheckIfUncovered(WrappedSegment)) {
|
||||
if (CheckIfUncovered(LCS.getWrappedSegment())) {
|
||||
Color = "red";
|
||||
if (!Snippets[0].empty())
|
||||
Snippets[0] = Highlight(Snippets[0], 1, 1 + Snippets[0].size());
|
||||
@ -605,16 +606,17 @@ void SourceCoverageViewHTML::renderLineNumberColumn(raw_ostream &OS,
|
||||
}
|
||||
|
||||
void SourceCoverageViewHTML::renderRegionMarkers(raw_ostream &,
|
||||
CoverageSegmentArray,
|
||||
const LineCoverageStats &Line,
|
||||
unsigned) {
|
||||
// Region markers are rendered in-line using tooltips.
|
||||
}
|
||||
|
||||
void SourceCoverageViewHTML::renderExpansionSite(
|
||||
raw_ostream &OS, LineRef L, const coverage::CoverageSegment *WrappedSegment,
|
||||
CoverageSegmentArray Segments, unsigned ExpansionCol, unsigned ViewDepth) {
|
||||
void SourceCoverageViewHTML::renderExpansionSite(raw_ostream &OS, LineRef L,
|
||||
const LineCoverageStats &LCS,
|
||||
unsigned ExpansionCol,
|
||||
unsigned ViewDepth) {
|
||||
// Render the line containing the expansion site. No extra formatting needed.
|
||||
renderLine(OS, L, WrappedSegment, Segments, ExpansionCol, ViewDepth);
|
||||
renderLine(OS, L, LCS, ExpansionCol, ViewDepth);
|
||||
}
|
||||
|
||||
void SourceCoverageViewHTML::renderExpansionView(raw_ostream &OS,
|
||||
|
@ -57,14 +57,11 @@ class SourceCoverageViewHTML : public SourceCoverageView {
|
||||
|
||||
void renderViewDivider(raw_ostream &OS, unsigned ViewDepth) override;
|
||||
|
||||
void renderLine(raw_ostream &OS, LineRef L,
|
||||
const coverage::CoverageSegment *WrappedSegment,
|
||||
CoverageSegmentArray Segments, unsigned ExpansionCol,
|
||||
unsigned ViewDepth) override;
|
||||
void renderLine(raw_ostream &OS, LineRef L, const LineCoverageStats &LCS,
|
||||
unsigned ExpansionCol, unsigned ViewDepth) override;
|
||||
|
||||
void renderExpansionSite(raw_ostream &OS, LineRef L,
|
||||
const coverage::CoverageSegment *WrappedSegment,
|
||||
CoverageSegmentArray Segments, unsigned ExpansionCol,
|
||||
const LineCoverageStats &LCS, unsigned ExpansionCol,
|
||||
unsigned ViewDepth) override;
|
||||
|
||||
void renderExpansionView(raw_ostream &OS, ExpansionView &ESV,
|
||||
@ -78,7 +75,7 @@ class SourceCoverageViewHTML : public SourceCoverageView {
|
||||
|
||||
void renderLineNumberColumn(raw_ostream &OS, unsigned LineNo) override;
|
||||
|
||||
void renderRegionMarkers(raw_ostream &OS, CoverageSegmentArray Segments,
|
||||
void renderRegionMarkers(raw_ostream &OS, const LineCoverageStats &Line,
|
||||
unsigned ViewDepth) override;
|
||||
|
||||
void renderTitle(raw_ostream &OS, StringRef Title) override;
|
||||
|
@ -94,12 +94,14 @@ void SourceCoverageViewText::renderViewDivider(raw_ostream &OS,
|
||||
OS << '\n';
|
||||
}
|
||||
|
||||
void SourceCoverageViewText::renderLine(
|
||||
raw_ostream &OS, LineRef L,
|
||||
const coverage::CoverageSegment *WrappedSegment,
|
||||
CoverageSegmentArray Segments, unsigned ExpansionCol, unsigned ViewDepth) {
|
||||
void SourceCoverageViewText::renderLine(raw_ostream &OS, LineRef L,
|
||||
const LineCoverageStats &LCS,
|
||||
unsigned ExpansionCol,
|
||||
unsigned ViewDepth) {
|
||||
StringRef Line = L.Line;
|
||||
unsigned LineNumber = L.LineNo;
|
||||
auto *WrappedSegment = LCS.getWrappedSegment();
|
||||
CoverageSegmentArray Segments = LCS.getLineSegments();
|
||||
|
||||
Optional<raw_ostream::Colors> Highlight;
|
||||
SmallVector<std::pair<unsigned, unsigned>, 2> HighlightedRanges;
|
||||
@ -168,11 +170,14 @@ void SourceCoverageViewText::renderLineNumberColumn(raw_ostream &OS,
|
||||
OS.indent(LineNumberColumnWidth - Str.size()) << Str << '|';
|
||||
}
|
||||
|
||||
void SourceCoverageViewText::renderRegionMarkers(
|
||||
raw_ostream &OS, CoverageSegmentArray Segments, unsigned ViewDepth) {
|
||||
void SourceCoverageViewText::renderRegionMarkers(raw_ostream &OS,
|
||||
const LineCoverageStats &Line,
|
||||
unsigned ViewDepth) {
|
||||
renderLinePrefix(OS, ViewDepth);
|
||||
OS.indent(getCombinedColumnWidth(getOptions()));
|
||||
|
||||
CoverageSegmentArray Segments = Line.getLineSegments();
|
||||
|
||||
// Just consider the segments which start *and* end on this line.
|
||||
if (Segments.size() > 1)
|
||||
Segments = Segments.drop_back();
|
||||
@ -196,12 +201,13 @@ void SourceCoverageViewText::renderRegionMarkers(
|
||||
OS << '\n';
|
||||
}
|
||||
|
||||
void SourceCoverageViewText::renderExpansionSite(
|
||||
raw_ostream &OS, LineRef L, const coverage::CoverageSegment *WrappedSegment,
|
||||
CoverageSegmentArray Segments, unsigned ExpansionCol, unsigned ViewDepth) {
|
||||
void SourceCoverageViewText::renderExpansionSite(raw_ostream &OS, LineRef L,
|
||||
const LineCoverageStats &LCS,
|
||||
unsigned ExpansionCol,
|
||||
unsigned ViewDepth) {
|
||||
renderLinePrefix(OS, ViewDepth);
|
||||
OS.indent(getCombinedColumnWidth(getOptions()) + (ViewDepth == 0 ? 0 : 1));
|
||||
renderLine(OS, L, WrappedSegment, Segments, ExpansionCol, ViewDepth);
|
||||
renderLine(OS, L, LCS, ExpansionCol, ViewDepth);
|
||||
}
|
||||
|
||||
void SourceCoverageViewText::renderExpansionView(raw_ostream &OS,
|
||||
|
@ -48,14 +48,11 @@ class SourceCoverageViewText : public SourceCoverageView {
|
||||
|
||||
void renderViewDivider(raw_ostream &OS, unsigned ViewDepth) override;
|
||||
|
||||
void renderLine(raw_ostream &OS, LineRef L,
|
||||
const coverage::CoverageSegment *WrappedSegment,
|
||||
CoverageSegmentArray Segments, unsigned ExpansionCol,
|
||||
unsigned ViewDepth) override;
|
||||
void renderLine(raw_ostream &OS, LineRef L, const LineCoverageStats &LCS,
|
||||
unsigned ExpansionCol, unsigned ViewDepth) override;
|
||||
|
||||
void renderExpansionSite(raw_ostream &OS, LineRef L,
|
||||
const coverage::CoverageSegment *WrappedSegment,
|
||||
CoverageSegmentArray Segments, unsigned ExpansionCol,
|
||||
const LineCoverageStats &LCS, unsigned ExpansionCol,
|
||||
unsigned ViewDepth) override;
|
||||
|
||||
void renderExpansionView(raw_ostream &OS, ExpansionView &ESV,
|
||||
@ -69,7 +66,7 @@ class SourceCoverageViewText : public SourceCoverageView {
|
||||
|
||||
void renderLineNumberColumn(raw_ostream &OS, unsigned LineNo) override;
|
||||
|
||||
void renderRegionMarkers(raw_ostream &OS, CoverageSegmentArray Segments,
|
||||
void renderRegionMarkers(raw_ostream &OS, const LineCoverageStats &Line,
|
||||
unsigned ViewDepth) override;
|
||||
|
||||
void renderTitle(raw_ostream &OS, StringRef Title) override;
|
||||
|
Loading…
Reference in New Issue
Block a user