summaryrefslogtreecommitdiffstats
path: root/llvm/tools
diff options
context:
space:
mode:
authorVedant Kumar <vsk@apple.com>2017-09-08 18:44:46 +0000
committerVedant Kumar <vsk@apple.com>2017-09-08 18:44:46 +0000
commit933b37f99f4f6f2ca3ab0d268caafc33c50bee84 (patch)
treee55936ba795b66684453481b0ef3f3f6c386ebf9 /llvm/tools
parentee6a352a8ddfd3bf7b7dea95bc2d7d7df0b9aa5f (diff)
downloadbcm5719-llvm-933b37f99f4f6f2ca3ab0d268caafc33c50bee84.tar.gz
bcm5719-llvm-933b37f99f4f6f2ca3ab0d268caafc33c50bee84.zip
[llvm-cov] Unify region marker placement between text/html modes
Make sure that the text and html emitters always emit the same set of region markers, and avoid emitting redundant markers for line segments which don't end on the line they start on. This is related to D35925, and depends on D36014 Differential Revision: https://reviews.llvm.org/D36020 llvm-svn: 312813
Diffstat (limited to 'llvm/tools')
-rw-r--r--llvm/tools/llvm-cov/CodeCoverage.cpp1
-rw-r--r--llvm/tools/llvm-cov/CoverageViewOptions.h1
-rw-r--r--llvm/tools/llvm-cov/SourceCoverageView.cpp16
-rw-r--r--llvm/tools/llvm-cov/SourceCoverageView.h2
-rw-r--r--llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp20
-rw-r--r--llvm/tools/llvm-cov/SourceCoverageViewText.cpp13
6 files changed, 29 insertions, 24 deletions
diff --git a/llvm/tools/llvm-cov/CodeCoverage.cpp b/llvm/tools/llvm-cov/CodeCoverage.cpp
index f75fcb8884c..b99a4189b01 100644
--- a/llvm/tools/llvm-cov/CodeCoverage.cpp
+++ b/llvm/tools/llvm-cov/CodeCoverage.cpp
@@ -789,7 +789,6 @@ int CodeCoverageTool::show(int argc, const char **argv,
ViewOpts.ShowLineStats = ShowLineExecutionCounts.getNumOccurrences() != 0 ||
!ShowRegions || ShowBestLineRegionsCounts;
ViewOpts.ShowRegionMarkers = ShowRegions || ShowBestLineRegionsCounts;
- ViewOpts.ShowLineStatsOrRegionMarkers = ShowBestLineRegionsCounts;
ViewOpts.ShowExpandedRegions = ShowExpansions;
ViewOpts.ShowFunctionInstantiations = ShowInstantiations;
ViewOpts.ShowOutputDirectory = ShowOutputDirectory;
diff --git a/llvm/tools/llvm-cov/CoverageViewOptions.h b/llvm/tools/llvm-cov/CoverageViewOptions.h
index 266b380b7d3..144b373dc63 100644
--- a/llvm/tools/llvm-cov/CoverageViewOptions.h
+++ b/llvm/tools/llvm-cov/CoverageViewOptions.h
@@ -27,7 +27,6 @@ struct CoverageViewOptions {
bool ShowLineNumbers;
bool ShowLineStats;
bool ShowRegionMarkers;
- bool ShowLineStatsOrRegionMarkers;
bool ShowExpandedRegions;
bool ShowFunctionInstantiations;
bool ShowFullFilenames;
diff --git a/llvm/tools/llvm-cov/SourceCoverageView.cpp b/llvm/tools/llvm-cov/SourceCoverageView.cpp
index 6630f3333bd..3806ee9c795 100644
--- a/llvm/tools/llvm-cov/SourceCoverageView.cpp
+++ b/llvm/tools/llvm-cov/SourceCoverageView.cpp
@@ -153,9 +153,17 @@ std::string SourceCoverageView::formatCount(uint64_t N) {
}
bool SourceCoverageView::shouldRenderRegionMarkers(
- bool LineHasMultipleRegions) const {
- return getOptions().ShowRegionMarkers &&
- (!getOptions().ShowLineStatsOrRegionMarkers || LineHasMultipleRegions);
+ CoverageSegmentArray Segments) const {
+ if (!getOptions().ShowRegionMarkers)
+ return false;
+
+ // Render the region markers if there's more than one count to show.
+ unsigned RegionCount = 0;
+ for (const auto *S : Segments)
+ if (S->IsRegionEntry)
+ if (++RegionCount > 1)
+ return true;
+ return false;
}
bool SourceCoverageView::hasSubViews() const {
@@ -261,7 +269,7 @@ void SourceCoverageView::print(raw_ostream &OS, bool WholeFile,
ExpansionColumn, ViewDepth);
// Show the region markers.
- if (shouldRenderRegionMarkers(LineCount.hasMultipleRegions()))
+ if (shouldRenderRegionMarkers(LineSegments))
renderRegionMarkers(OS, LineSegments, ViewDepth);
// Show the expansions and instantiations for this line.
diff --git a/llvm/tools/llvm-cov/SourceCoverageView.h b/llvm/tools/llvm-cov/SourceCoverageView.h
index c9f0c57b5cb..9b1562555a8 100644
--- a/llvm/tools/llvm-cov/SourceCoverageView.h
+++ b/llvm/tools/llvm-cov/SourceCoverageView.h
@@ -236,7 +236,7 @@ protected:
static std::string formatCount(uint64_t N);
/// \brief Check if region marker output is expected for a line.
- bool shouldRenderRegionMarkers(bool LineHasMultipleRegions) const;
+ bool shouldRenderRegionMarkers(CoverageSegmentArray Segments) const;
/// \brief Check if there are any sub-views attached to this view.
bool hasSubViews() const;
diff --git a/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp b/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp
index 7548a969b99..eecc352f225 100644
--- a/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp
+++ b/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp
@@ -547,25 +547,21 @@ void SourceCoverageViewHTML::renderLine(
// 4. Snippets[1:N+1] correspond to \p Segments[0:N]: use these to generate
// sub-line region count tooltips if needed.
- bool HasMultipleRegions = [&] {
- unsigned RegionCount = 0;
- for (const auto *S : Segments)
- if (S->HasCount && S->IsRegionEntry)
- if (++RegionCount > 1)
- return true;
- return false;
- }();
-
- if (shouldRenderRegionMarkers(HasMultipleRegions)) {
- for (unsigned I = 0, E = Segments.size(); I < E; ++I) {
+ if (shouldRenderRegionMarkers(Segments)) {
+ // Just consider the segments which start *and* end on this line.
+ for (unsigned I = 0, E = Segments.size() - 1; I < E; ++I) {
const auto *CurSeg = Segments[I];
- if (!CurSeg->IsRegionEntry || !CurSeg->HasCount)
+ if (!CurSeg->IsRegionEntry)
continue;
Snippets[I + 1] =
tag("div", Snippets[I + 1] + tag("span", formatCount(CurSeg->Count),
"tooltip-content"),
"tooltip");
+
+ if (getOptions().Debug)
+ errs() << "Marker at " << CurSeg->Line << ":" << CurSeg->Col << " = "
+ << formatCount(CurSeg->Count) << "\n";
}
}
diff --git a/llvm/tools/llvm-cov/SourceCoverageViewText.cpp b/llvm/tools/llvm-cov/SourceCoverageViewText.cpp
index 4ad120f642e..a88558fceca 100644
--- a/llvm/tools/llvm-cov/SourceCoverageViewText.cpp
+++ b/llvm/tools/llvm-cov/SourceCoverageViewText.cpp
@@ -171,6 +171,10 @@ void SourceCoverageViewText::renderRegionMarkers(
renderLinePrefix(OS, ViewDepth);
OS.indent(getCombinedColumnWidth(getOptions()));
+ // Just consider the segments which start *and* end on this line.
+ if (Segments.size() > 1)
+ Segments = Segments.drop_back();
+
unsigned PrevColumn = 1;
for (const auto *S : Segments) {
if (!S->IsRegionEntry)
@@ -182,13 +186,12 @@ void SourceCoverageViewText::renderRegionMarkers(
std::string C = formatCount(S->Count);
PrevColumn += C.size();
OS << '^' << C;
- }
- OS << '\n';
- if (getOptions().Debug)
- for (const auto *S : Segments)
+ if (getOptions().Debug)
errs() << "Marker at " << S->Line << ":" << S->Col << " = "
- << formatCount(S->Count) << (S->IsRegionEntry ? "\n" : " (pop)\n");
+ << formatCount(S->Count) << "\n";
+ }
+ OS << '\n';
}
void SourceCoverageViewText::renderExpansionSite(
OpenPOWER on IntegriCloud