mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
[llvm-cov] Simplify the way expansion views are rendered (NFC)
If a sub-view has already been rendered, it's helpful to re-render the expansion site before rendering the next expansion view. Make this fact explicit in the rendering interface, instead of hiding it behind an awkward Optional<LineRef> parameter. llvm-svn: 273789
This commit is contained in:
parent
ba6158b462
commit
0bf7c0b1b7
@ -129,14 +129,22 @@ void SourceCoverageView::print(raw_ostream &OS, bool WholeFile,
|
|||||||
for (; NextESV != EndESV && NextESV->getLine() == LI.line_number();
|
for (; NextESV != EndESV && NextESV->getLine() == LI.line_number();
|
||||||
++NextESV) {
|
++NextESV) {
|
||||||
renderViewDivider(OS, ViewDepth + 1);
|
renderViewDivider(OS, ViewDepth + 1);
|
||||||
ExpansionColumn = renderExpansionView(
|
|
||||||
OS, *NextESV,
|
// Re-render the current line and highlight the expansion range for
|
||||||
RenderedSubView ? Optional<LineRef>({*LI, LI.line_number()})
|
// this subview.
|
||||||
: Optional<LineRef>(),
|
if (RenderedSubView) {
|
||||||
WrappedSegment, LineSegments, ExpansionColumn, ViewDepth);
|
ExpansionColumn = NextESV->getStartCol();
|
||||||
|
renderExpansionSite(
|
||||||
|
OS, *NextESV, {*LI, LI.line_number()}, WrappedSegment, LineSegments,
|
||||||
|
ExpansionColumn, ViewDepth);
|
||||||
|
renderViewDivider(OS, ViewDepth + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
renderExpansionView(OS, *NextESV, ViewDepth + 1);
|
||||||
RenderedSubView = true;
|
RenderedSubView = true;
|
||||||
}
|
}
|
||||||
for (; NextISV != EndISV && NextISV->Line == LI.line_number(); ++NextISV) {
|
for (; NextISV != EndISV && NextISV->Line == LI.line_number(); ++NextISV) {
|
||||||
|
renderViewDivider(OS, ViewDepth + 1);
|
||||||
renderInstantiationView(OS, *NextISV, ViewDepth + 1);
|
renderInstantiationView(OS, *NextISV, ViewDepth + 1);
|
||||||
RenderedSubView = true;
|
RenderedSubView = true;
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
#include "CoverageViewOptions.h"
|
#include "CoverageViewOptions.h"
|
||||||
#include "llvm/ProfileData/Coverage/CoverageMapping.h"
|
#include "llvm/ProfileData/Coverage/CoverageMapping.h"
|
||||||
#include "llvm/ADT/Optional.h"
|
|
||||||
#include "llvm/Support/MemoryBuffer.h"
|
#include "llvm/Support/MemoryBuffer.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@ -163,16 +162,18 @@ protected:
|
|||||||
CoverageSegmentArray Segments,
|
CoverageSegmentArray Segments,
|
||||||
unsigned ViewDepth) = 0;
|
unsigned ViewDepth) = 0;
|
||||||
|
|
||||||
/// \brief Render an expansion view. If the expansion site must be re-rendered
|
/// \brief Render the site of an expansion.
|
||||||
/// for clarity, it is passed in via \p FirstLine.
|
virtual void
|
||||||
virtual unsigned
|
renderExpansionSite(raw_ostream &OS, ExpansionView &ESV, LineRef L,
|
||||||
renderExpansionView(raw_ostream &OS, ExpansionView &ESV,
|
|
||||||
Optional<LineRef> FirstLine,
|
|
||||||
const coverage::CoverageSegment *WrappedSegment,
|
const coverage::CoverageSegment *WrappedSegment,
|
||||||
CoverageSegmentArray Segments, unsigned ExpansionCol,
|
CoverageSegmentArray Segments, unsigned ExpansionCol,
|
||||||
unsigned ViewDepth) = 0;
|
unsigned ViewDepth) = 0;
|
||||||
|
|
||||||
/// \brief Render an instantiation view.
|
/// \brief Render an expansion view and any nested views.
|
||||||
|
virtual void renderExpansionView(raw_ostream &OS, ExpansionView &ESV,
|
||||||
|
unsigned ViewDepth) = 0;
|
||||||
|
|
||||||
|
/// \brief Render an instantiation view and any nested views.
|
||||||
virtual void renderInstantiationView(raw_ostream &OS, InstantiationView &ISV,
|
virtual void renderInstantiationView(raw_ostream &OS, InstantiationView &ISV,
|
||||||
unsigned ViewDepth) = 0;
|
unsigned ViewDepth) = 0;
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "SourceCoverageViewText.h"
|
#include "SourceCoverageViewText.h"
|
||||||
|
#include "llvm/ADT/Optional.h"
|
||||||
#include "llvm/ADT/SmallString.h"
|
#include "llvm/ADT/SmallString.h"
|
||||||
#include "llvm/ADT/StringExtras.h"
|
#include "llvm/ADT/StringExtras.h"
|
||||||
|
|
||||||
@ -156,37 +157,29 @@ void SourceCoverageViewText::renderRegionMarkers(
|
|||||||
<< formatCount(S->Count) << (S->IsRegionEntry ? "\n" : " (pop)\n");
|
<< formatCount(S->Count) << (S->IsRegionEntry ? "\n" : " (pop)\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned SourceCoverageViewText::renderExpansionView(
|
void SourceCoverageViewText::renderExpansionSite(
|
||||||
raw_ostream &OS, ExpansionView &ESV, Optional<LineRef> FirstLine,
|
raw_ostream &OS, ExpansionView &ESV, LineRef L,
|
||||||
const coverage::CoverageSegment *WrappedSegment,
|
const coverage::CoverageSegment *WrappedSegment,
|
||||||
CoverageSegmentArray Segments, unsigned ExpansionCol, unsigned ViewDepth) {
|
CoverageSegmentArray Segments, unsigned ExpansionCol, unsigned ViewDepth) {
|
||||||
unsigned NextExpansionCol = ExpansionCol;
|
renderLinePrefix(OS, ViewDepth);
|
||||||
|
OS.indent(getCombinedColumnWidth(getOptions()) + (ViewDepth == 0 ? 0 : 1));
|
||||||
if (FirstLine.hasValue()) {
|
renderLine(OS, L, WrappedSegment, Segments, ExpansionCol, ViewDepth);
|
||||||
// Re-render the current line and highlight the expansion range for
|
}
|
||||||
// this subview.
|
|
||||||
NextExpansionCol = ESV.getStartCol();
|
|
||||||
renderLinePrefix(OS, ViewDepth);
|
|
||||||
OS.indent(getCombinedColumnWidth(getOptions()) + (ViewDepth == 0 ? 0 : 1));
|
|
||||||
renderLine(OS, *FirstLine, WrappedSegment, Segments, ExpansionCol,
|
|
||||||
ViewDepth);
|
|
||||||
renderViewDivider(OS, ViewDepth + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
void SourceCoverageViewText::renderExpansionView(raw_ostream &OS,
|
||||||
|
ExpansionView &ESV,
|
||||||
|
unsigned ViewDepth) {
|
||||||
// Render the child subview.
|
// Render the child subview.
|
||||||
if (getOptions().Debug)
|
if (getOptions().Debug)
|
||||||
errs() << "Expansion at line " << ESV.getLine() << ", " << ESV.getStartCol()
|
errs() << "Expansion at line " << ESV.getLine() << ", " << ESV.getStartCol()
|
||||||
<< " -> " << ESV.getEndCol() << '\n';
|
<< " -> " << ESV.getEndCol() << '\n';
|
||||||
ESV.View->print(OS, /*WholeFile=*/false, /*ShowSourceName=*/false,
|
ESV.View->print(OS, /*WholeFile=*/false, /*ShowSourceName=*/false,
|
||||||
ViewDepth + 1);
|
ViewDepth + 1);
|
||||||
|
|
||||||
return NextExpansionCol;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SourceCoverageViewText::renderInstantiationView(raw_ostream &OS,
|
void SourceCoverageViewText::renderInstantiationView(raw_ostream &OS,
|
||||||
InstantiationView &ISV,
|
InstantiationView &ISV,
|
||||||
unsigned ViewDepth) {
|
unsigned ViewDepth) {
|
||||||
renderViewDivider(OS, ViewDepth);
|
|
||||||
renderLinePrefix(OS, ViewDepth);
|
renderLinePrefix(OS, ViewDepth);
|
||||||
OS << ' ';
|
OS << ' ';
|
||||||
ISV.View->print(OS, /*WholeFile=*/false, /*ShowSourceName=*/true, ViewDepth);
|
ISV.View->print(OS, /*WholeFile=*/false, /*ShowSourceName=*/true, ViewDepth);
|
||||||
|
@ -31,12 +31,13 @@ class SourceCoverageViewText : public SourceCoverageView {
|
|||||||
CoverageSegmentArray Segments, unsigned ExpansionCol,
|
CoverageSegmentArray Segments, unsigned ExpansionCol,
|
||||||
unsigned ViewDepth) override;
|
unsigned ViewDepth) override;
|
||||||
|
|
||||||
unsigned renderExpansionView(raw_ostream &OS, ExpansionView &ESV,
|
void renderExpansionSite(raw_ostream &OS, ExpansionView &ESV, LineRef L,
|
||||||
Optional<LineRef> FirstLine,
|
const coverage::CoverageSegment *WrappedSegment,
|
||||||
const coverage::CoverageSegment *WrappedSegment,
|
CoverageSegmentArray Segments, unsigned ExpansionCol,
|
||||||
CoverageSegmentArray Segments,
|
unsigned ViewDepth) override;
|
||||||
unsigned ExpansionCol,
|
|
||||||
unsigned ViewDepth) override;
|
void renderExpansionView(raw_ostream &OS, ExpansionView &ESV,
|
||||||
|
unsigned ViewDepth) override;
|
||||||
|
|
||||||
void renderInstantiationView(raw_ostream &OS, InstantiationView &ISV,
|
void renderInstantiationView(raw_ostream &OS, InstantiationView &ISV,
|
||||||
unsigned ViewDepth) override;
|
unsigned ViewDepth) override;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user