[llvm] r273789 - [llvm-cov] Simplify the way expansion views are rendered (NFC)
Vedant Kumar via llvm-commits
llvm-commits at lists.llvm.org
Sat Jun 25 19:45:15 PDT 2016
Author: vedantk
Date: Sat Jun 25 21:45:13 2016
New Revision: 273789
URL: http://llvm.org/viewvc/llvm-project?rev=273789&view=rev
Log:
[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.
Modified:
llvm/trunk/tools/llvm-cov/SourceCoverageView.cpp
llvm/trunk/tools/llvm-cov/SourceCoverageView.h
llvm/trunk/tools/llvm-cov/SourceCoverageViewText.cpp
llvm/trunk/tools/llvm-cov/SourceCoverageViewText.h
Modified: llvm/trunk/tools/llvm-cov/SourceCoverageView.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/SourceCoverageView.cpp?rev=273789&r1=273788&r2=273789&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/SourceCoverageView.cpp (original)
+++ llvm/trunk/tools/llvm-cov/SourceCoverageView.cpp Sat Jun 25 21:45:13 2016
@@ -129,14 +129,22 @@ void SourceCoverageView::print(raw_ostre
for (; NextESV != EndESV && NextESV->getLine() == LI.line_number();
++NextESV) {
renderViewDivider(OS, ViewDepth + 1);
- ExpansionColumn = renderExpansionView(
- OS, *NextESV,
- RenderedSubView ? Optional<LineRef>({*LI, LI.line_number()})
- : Optional<LineRef>(),
- WrappedSegment, LineSegments, ExpansionColumn, ViewDepth);
+
+ // Re-render the current line and highlight the expansion range for
+ // this subview.
+ if (RenderedSubView) {
+ 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;
}
for (; NextISV != EndISV && NextISV->Line == LI.line_number(); ++NextISV) {
+ renderViewDivider(OS, ViewDepth + 1);
renderInstantiationView(OS, *NextISV, ViewDepth + 1);
RenderedSubView = true;
}
Modified: llvm/trunk/tools/llvm-cov/SourceCoverageView.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/SourceCoverageView.h?rev=273789&r1=273788&r2=273789&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/SourceCoverageView.h (original)
+++ llvm/trunk/tools/llvm-cov/SourceCoverageView.h Sat Jun 25 21:45:13 2016
@@ -16,7 +16,6 @@
#include "CoverageViewOptions.h"
#include "llvm/ProfileData/Coverage/CoverageMapping.h"
-#include "llvm/ADT/Optional.h"
#include "llvm/Support/MemoryBuffer.h"
#include <vector>
@@ -163,16 +162,18 @@ protected:
CoverageSegmentArray Segments,
unsigned ViewDepth) = 0;
- /// \brief Render an expansion view. If the expansion site must be re-rendered
- /// for clarity, it is passed in via \p FirstLine.
- virtual unsigned
- renderExpansionView(raw_ostream &OS, ExpansionView &ESV,
- Optional<LineRef> FirstLine,
+ /// \brief Render the site of an expansion.
+ virtual void
+ renderExpansionSite(raw_ostream &OS, ExpansionView &ESV, LineRef L,
const coverage::CoverageSegment *WrappedSegment,
CoverageSegmentArray Segments, unsigned ExpansionCol,
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,
unsigned ViewDepth) = 0;
Modified: llvm/trunk/tools/llvm-cov/SourceCoverageViewText.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/SourceCoverageViewText.cpp?rev=273789&r1=273788&r2=273789&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/SourceCoverageViewText.cpp (original)
+++ llvm/trunk/tools/llvm-cov/SourceCoverageViewText.cpp Sat Jun 25 21:45:13 2016
@@ -12,6 +12,7 @@
//===----------------------------------------------------------------------===//
#include "SourceCoverageViewText.h"
+#include "llvm/ADT/Optional.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringExtras.h"
@@ -156,37 +157,29 @@ void SourceCoverageViewText::renderRegio
<< formatCount(S->Count) << (S->IsRegionEntry ? "\n" : " (pop)\n");
}
-unsigned SourceCoverageViewText::renderExpansionView(
- raw_ostream &OS, ExpansionView &ESV, Optional<LineRef> FirstLine,
+void SourceCoverageViewText::renderExpansionSite(
+ raw_ostream &OS, ExpansionView &ESV, LineRef L,
const coverage::CoverageSegment *WrappedSegment,
CoverageSegmentArray Segments, unsigned ExpansionCol, unsigned ViewDepth) {
- unsigned NextExpansionCol = ExpansionCol;
-
- if (FirstLine.hasValue()) {
- // 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);
- }
+ renderLinePrefix(OS, ViewDepth);
+ OS.indent(getCombinedColumnWidth(getOptions()) + (ViewDepth == 0 ? 0 : 1));
+ renderLine(OS, L, WrappedSegment, Segments, ExpansionCol, ViewDepth);
+}
+void SourceCoverageViewText::renderExpansionView(raw_ostream &OS,
+ ExpansionView &ESV,
+ unsigned ViewDepth) {
// Render the child subview.
if (getOptions().Debug)
errs() << "Expansion at line " << ESV.getLine() << ", " << ESV.getStartCol()
<< " -> " << ESV.getEndCol() << '\n';
ESV.View->print(OS, /*WholeFile=*/false, /*ShowSourceName=*/false,
ViewDepth + 1);
-
- return NextExpansionCol;
}
void SourceCoverageViewText::renderInstantiationView(raw_ostream &OS,
InstantiationView &ISV,
unsigned ViewDepth) {
- renderViewDivider(OS, ViewDepth);
renderLinePrefix(OS, ViewDepth);
OS << ' ';
ISV.View->print(OS, /*WholeFile=*/false, /*ShowSourceName=*/true, ViewDepth);
Modified: llvm/trunk/tools/llvm-cov/SourceCoverageViewText.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/SourceCoverageViewText.h?rev=273789&r1=273788&r2=273789&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/SourceCoverageViewText.h (original)
+++ llvm/trunk/tools/llvm-cov/SourceCoverageViewText.h Sat Jun 25 21:45:13 2016
@@ -31,12 +31,13 @@ class SourceCoverageViewText : public So
CoverageSegmentArray Segments, unsigned ExpansionCol,
unsigned ViewDepth) override;
- unsigned renderExpansionView(raw_ostream &OS, ExpansionView &ESV,
- Optional<LineRef> FirstLine,
- const coverage::CoverageSegment *WrappedSegment,
- CoverageSegmentArray Segments,
- unsigned ExpansionCol,
- unsigned ViewDepth) override;
+ void renderExpansionSite(raw_ostream &OS, ExpansionView &ESV, LineRef L,
+ const coverage::CoverageSegment *WrappedSegment,
+ CoverageSegmentArray Segments, unsigned ExpansionCol,
+ unsigned ViewDepth) override;
+
+ void renderExpansionView(raw_ostream &OS, ExpansionView &ESV,
+ unsigned ViewDepth) override;
void renderInstantiationView(raw_ostream &OS, InstantiationView &ISV,
unsigned ViewDepth) override;
More information about the llvm-commits
mailing list