summaryrefslogtreecommitdiffstats
path: root/llvm/tools
diff options
context:
space:
mode:
authorYing Yi <maggieyi666@gmail.com>2016-09-06 21:41:38 +0000
committerYing Yi <maggieyi666@gmail.com>2016-09-06 21:41:38 +0000
commit24e91bd05fec332b73a991fa1f59160ea1c1e18e (patch)
tree8e65166010889596601e08e24a5592560daaa0d3 /llvm/tools
parent8a0e3f828a6712cf5098bb53ca082b5f87c7ea75 (diff)
downloadbcm5719-llvm-24e91bd05fec332b73a991fa1f59160ea1c1e18e.tar.gz
bcm5719-llvm-24e91bd05fec332b73a991fa1f59160ea1c1e18e.zip
[llvm-cov] Add the project summary to the text coverage report for each source file.
This patch is a spin-off from https://reviews.llvm.org/D23922. It extends the text view to preserve the same feature as the html view. Differential Revision: https://reviews.llvm.org/D24241 llvm-svn: 280756
Diffstat (limited to 'llvm/tools')
-rw-r--r--llvm/tools/llvm-cov/CodeCoverage.cpp2
-rw-r--r--llvm/tools/llvm-cov/SourceCoverageView.cpp9
-rw-r--r--llvm/tools/llvm-cov/SourceCoverageView.h3
-rw-r--r--llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp7
-rw-r--r--llvm/tools/llvm-cov/SourceCoverageViewText.cpp4
5 files changed, 16 insertions, 9 deletions
diff --git a/llvm/tools/llvm-cov/CodeCoverage.cpp b/llvm/tools/llvm-cov/CodeCoverage.cpp
index 00c547063bc..02309c9de75 100644
--- a/llvm/tools/llvm-cov/CodeCoverage.cpp
+++ b/llvm/tools/llvm-cov/CodeCoverage.cpp
@@ -669,7 +669,7 @@ int CodeCoverageTool::show(int argc, const char **argv,
// Show files
bool ShowFilenames =
- (SourceFiles.size() != 1) ||
+ (SourceFiles.size() != 1) || ViewOpts.hasOutputDirectory() ||
(ViewOpts.Format == CoverageViewOptions::OutputFormat::HTML);
if (SourceFiles.empty())
diff --git a/llvm/tools/llvm-cov/SourceCoverageView.cpp b/llvm/tools/llvm-cov/SourceCoverageView.cpp
index 323352a5174..47980ab0952 100644
--- a/llvm/tools/llvm-cov/SourceCoverageView.cpp
+++ b/llvm/tools/llvm-cov/SourceCoverageView.cpp
@@ -142,6 +142,15 @@ SourceCoverageView::create(StringRef SourceName, const MemoryBuffer &File,
llvm_unreachable("Unknown coverage output format!");
}
+std::string SourceCoverageView::getNativeSourceName() const {
+ std::string SourceFile = isFunctionView() ? "Function: " : "Source: ";
+ SourceFile += getSourceName().str();
+ SmallString<128> SourceText(SourceFile);
+ sys::path::remove_dots(SourceText, /*remove_dot_dots=*/true);
+ sys::path::native(SourceText);
+ return SourceText.c_str();
+}
+
void SourceCoverageView::addExpansion(
const coverage::CounterMappingRegion &Region,
std::unique_ptr<SourceCoverageView> View) {
diff --git a/llvm/tools/llvm-cov/SourceCoverageView.h b/llvm/tools/llvm-cov/SourceCoverageView.h
index 410c8fd1c26..63c5b65a207 100644
--- a/llvm/tools/llvm-cov/SourceCoverageView.h
+++ b/llvm/tools/llvm-cov/SourceCoverageView.h
@@ -278,6 +278,9 @@ public:
StringRef getSourceName() const { return SourceName; }
+ /// \brief Return the source name formatted for the host OS.
+ std::string getNativeSourceName() const;
+
bool isFunctionView() const { return FunctionView; }
const CoverageViewOptions &getOptions() const { return Options; }
diff --git a/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp b/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp
index 7e069de849c..52e594f5ff1 100644
--- a/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp
+++ b/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp
@@ -342,12 +342,7 @@ void SourceCoverageViewHTML::renderSourceName(raw_ostream &OS, bool WholeFile,
unsigned FirstUncoveredLineNo) {
OS << BeginSourceNameDiv;
// Render the source name for the view.
- std::string SourceFile = isFunctionView() ? "Function: " : "Source: ";
- SourceFile += getSourceName().str();
- SmallString<128> SourceText(SourceFile);
- sys::path::remove_dots(SourceText, /*remove_dot_dots=*/true);
- sys::path::native(SourceText);
- OS << tag("pre", escape(SourceText, getOptions()));
+ OS << tag("pre", escape(getNativeSourceName(), getOptions()));
if (WholeFile) {
// Render the object file name for the view.
OS << tag("pre",
diff --git a/llvm/tools/llvm-cov/SourceCoverageViewText.cpp b/llvm/tools/llvm-cov/SourceCoverageViewText.cpp
index 52e405e298d..6dec4c7aed5 100644
--- a/llvm/tools/llvm-cov/SourceCoverageViewText.cpp
+++ b/llvm/tools/llvm-cov/SourceCoverageViewText.cpp
@@ -65,11 +65,11 @@ void SourceCoverageViewText::renderViewFooter(raw_ostream &) {}
void SourceCoverageViewText::renderSourceName(raw_ostream &OS, bool WholeFile,
unsigned FirstUncoveredLineNo) {
- getOptions().colored_ostream(OS, raw_ostream::CYAN) << getSourceName()
+ getOptions().colored_ostream(OS, raw_ostream::CYAN) << getNativeSourceName()
<< ":\n";
if (WholeFile) {
getOptions().colored_ostream(OS, raw_ostream::CYAN)
- << getOptions().ObjectFilename << ":\n";
+ << "Binary: " << getOptions().ObjectFilename << ":\n";
}
}
OpenPOWER on IntegriCloud