diff options
Diffstat (limited to 'llvm/tools/llvm-cov')
-rw-r--r-- | llvm/tools/llvm-cov/SourceCoverageView.cpp | 9 | ||||
-rw-r--r-- | llvm/tools/llvm-cov/SourceCoverageView.h | 8 | ||||
-rw-r--r-- | llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp | 29 | ||||
-rw-r--r-- | llvm/tools/llvm-cov/SourceCoverageViewHTML.h | 6 | ||||
-rw-r--r-- | llvm/tools/llvm-cov/SourceCoverageViewText.cpp | 6 | ||||
-rw-r--r-- | llvm/tools/llvm-cov/SourceCoverageViewText.h | 6 |
6 files changed, 31 insertions, 33 deletions
diff --git a/llvm/tools/llvm-cov/SourceCoverageView.cpp b/llvm/tools/llvm-cov/SourceCoverageView.cpp index 23c86e32dcc..362f48be258 100644 --- a/llvm/tools/llvm-cov/SourceCoverageView.cpp +++ b/llvm/tools/llvm-cov/SourceCoverageView.cpp @@ -173,14 +173,11 @@ void SourceCoverageView::print(raw_ostream &OS, bool WholeFile, renderViewHeader(OS); - unsigned FirstUncoveredLineNo = 0; - if (WholeFile) - FirstUncoveredLineNo = getFirstUncoveredLineNo(); - if (ShowSourceName) - renderSourceName(OS, WholeFile, FirstUncoveredLineNo); + renderSourceName(OS, WholeFile); + + renderTableHeader(OS, getFirstUncoveredLineNo(), ViewDepth); - renderTableHeader(OS, ViewDepth); // We need the expansions and instantiations sorted so we can go through them // while we iterate lines. std::sort(ExpansionSubViews.begin(), ExpansionSubViews.end()); diff --git a/llvm/tools/llvm-cov/SourceCoverageView.h b/llvm/tools/llvm-cov/SourceCoverageView.h index b1bbff8e804..68e8251e9b8 100644 --- a/llvm/tools/llvm-cov/SourceCoverageView.h +++ b/llvm/tools/llvm-cov/SourceCoverageView.h @@ -196,8 +196,7 @@ protected: virtual void renderViewFooter(raw_ostream &OS) = 0; /// \brief Render the source name for the view. - virtual void renderSourceName(raw_ostream &OS, bool WholeFile, - unsigned FirstUncoveredLineNo) = 0; + virtual void renderSourceName(raw_ostream &OS, bool WholeFile) = 0; /// \brief Render the line prefix at the given \p ViewDepth. virtual void renderLinePrefix(raw_ostream &OS, unsigned ViewDepth) = 0; @@ -245,8 +244,9 @@ protected: /// created time for the view. virtual void renderCellInTitle(raw_ostream &OS, StringRef CellText) = 0; - /// \brief Render the table header for a given source file - virtual void renderTableHeader(raw_ostream &OS, unsigned IndentLevel = 0) = 0; + /// \brief Render the table header for a given source file. + virtual void renderTableHeader(raw_ostream &OS, unsigned FirstUncoveredLineNo, + unsigned IndentLevel) = 0; /// @} diff --git a/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp b/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp index 8bb51590fde..cfa3078a8b3 100644 --- a/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp +++ b/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp @@ -395,21 +395,11 @@ void SourceCoverageViewHTML::renderViewFooter(raw_ostream &OS) { OS << EndTable << EndCenteredDiv; } -void SourceCoverageViewHTML::renderSourceName(raw_ostream &OS, bool WholeFile, - unsigned FirstUncoveredLineNo) { +void SourceCoverageViewHTML::renderSourceName(raw_ostream &OS, bool WholeFile) { OS << BeginSourceNameDiv; std::string ViewInfo = escape( WholeFile ? getVerboseSourceName() : getSourceName(), getOptions()); OS << tag("pre", ViewInfo); - if (WholeFile) { - // Render the "Go to first unexecuted line" link for the view. - if (FirstUncoveredLineNo != 0) { // The file is not fully covered - std::string LinkText = - escape("Go to first unexecuted line", getOptions()); - std::string LinkTarget = "#L" + utostr(uint64_t(FirstUncoveredLineNo)); - OS << tag("pre", a(LinkTarget, LinkText)); - } - } OS << EndSourceNameDiv; } @@ -608,10 +598,21 @@ void SourceCoverageViewHTML::renderCellInTitle(raw_ostream &OS, } void SourceCoverageViewHTML::renderTableHeader(raw_ostream &OS, + unsigned FirstUncoveredLineNo, unsigned ViewDepth) { + std::string SourceLabel; + if (FirstUncoveredLineNo == 0) { + SourceLabel = tag("td", tag("pre", "Source")); + } else { + std::string LinkTarget = "#L" + utostr(uint64_t(FirstUncoveredLineNo)); + SourceLabel = + tag("td", tag("pre", "Source (" + + a(LinkTarget, "jump to first uncovered line") + + ")")); + } + renderLinePrefix(OS, ViewDepth); - OS << tag("td", tag("span", tag("pre", escape("Line No.", getOptions())))) - << tag("td", tag("span", tag("pre", escape("Count", getOptions())))) - << tag("td", tag("span", tag("pre", escape("Source", getOptions())))); + OS << tag("td", tag("pre", "Line No.")) << tag("td", tag("pre", "Count")) + << SourceLabel; renderLineSuffix(OS, ViewDepth); } diff --git a/llvm/tools/llvm-cov/SourceCoverageViewHTML.h b/llvm/tools/llvm-cov/SourceCoverageViewHTML.h index bcf2793666e..b97c1802af8 100644 --- a/llvm/tools/llvm-cov/SourceCoverageViewHTML.h +++ b/llvm/tools/llvm-cov/SourceCoverageViewHTML.h @@ -46,8 +46,7 @@ class SourceCoverageViewHTML : public SourceCoverageView { void renderViewFooter(raw_ostream &OS) override; - void renderSourceName(raw_ostream &OS, bool WholeFile, - unsigned FirstUncoveredLineNo) override; + void renderSourceName(raw_ostream &OS, bool WholeFile) override; void renderLinePrefix(raw_ostream &OS, unsigned ViewDepth) override; @@ -81,7 +80,8 @@ class SourceCoverageViewHTML : public SourceCoverageView { void renderCellInTitle(raw_ostream &OS, StringRef CellText) override; - void renderTableHeader(raw_ostream &OS, unsigned IndentLevel) override; + void renderTableHeader(raw_ostream &OS, unsigned FirstUncoveredLineNo, + unsigned IndentLevel) override; public: SourceCoverageViewHTML(StringRef SourceName, const MemoryBuffer &File, diff --git a/llvm/tools/llvm-cov/SourceCoverageViewText.cpp b/llvm/tools/llvm-cov/SourceCoverageViewText.cpp index b0676cad7b9..3d3045ed0b6 100644 --- a/llvm/tools/llvm-cov/SourceCoverageViewText.cpp +++ b/llvm/tools/llvm-cov/SourceCoverageViewText.cpp @@ -66,8 +66,7 @@ void SourceCoverageViewText::renderViewHeader(raw_ostream &) {} void SourceCoverageViewText::renderViewFooter(raw_ostream &) {} -void SourceCoverageViewText::renderSourceName(raw_ostream &OS, bool WholeFile, - unsigned FirstUncoveredLineNo) { +void SourceCoverageViewText::renderSourceName(raw_ostream &OS, bool WholeFile) { std::string ViewInfo = WholeFile ? getVerboseSourceName() : getSourceName(); getOptions().colored_ostream(OS, raw_ostream::CYAN) << ViewInfo << ":\n"; } @@ -229,4 +228,5 @@ void SourceCoverageViewText::renderCellInTitle(raw_ostream &OS, << getOptions().CreatedTimeStr << "\n"; } -void SourceCoverageViewText::renderTableHeader(raw_ostream &, unsigned) {} +void SourceCoverageViewText::renderTableHeader(raw_ostream &, unsigned, + unsigned) {} diff --git a/llvm/tools/llvm-cov/SourceCoverageViewText.h b/llvm/tools/llvm-cov/SourceCoverageViewText.h index 6fd35f5f286..7fdeef50ea2 100644 --- a/llvm/tools/llvm-cov/SourceCoverageViewText.h +++ b/llvm/tools/llvm-cov/SourceCoverageViewText.h @@ -39,8 +39,7 @@ class SourceCoverageViewText : public SourceCoverageView { void renderViewFooter(raw_ostream &OS) override; - void renderSourceName(raw_ostream &OS, bool WholeFile, - unsigned FirstUncoveredLineNo) override; + void renderSourceName(raw_ostream &OS, bool WholeFile) override; void renderLinePrefix(raw_ostream &OS, unsigned ViewDepth) override; @@ -74,7 +73,8 @@ class SourceCoverageViewText : public SourceCoverageView { void renderCellInTitle(raw_ostream &OS, StringRef CellText) override; - void renderTableHeader(raw_ostream &OS, unsigned IndentLevel) override; + void renderTableHeader(raw_ostream &OS, unsigned FirstUncoveredLineNo, + unsigned IndentLevel) override; public: SourceCoverageViewText(StringRef SourceName, const MemoryBuffer &File, |