[llvm] r280756 - [llvm-cov] Add the project summary to the text coverage report for each source file.
Ying Yi via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 6 14:41:39 PDT 2016
Author: yingyi
Date: Tue Sep 6 16:41:38 2016
New Revision: 280756
URL: http://llvm.org/viewvc/llvm-project?rev=280756&view=rev
Log:
[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
Modified:
llvm/trunk/test/tools/llvm-cov/native_separators.c
llvm/trunk/test/tools/llvm-cov/showTemplateInstantiations.cpp
llvm/trunk/tools/llvm-cov/CodeCoverage.cpp
llvm/trunk/tools/llvm-cov/SourceCoverageView.cpp
llvm/trunk/tools/llvm-cov/SourceCoverageView.h
llvm/trunk/tools/llvm-cov/SourceCoverageViewHTML.cpp
llvm/trunk/tools/llvm-cov/SourceCoverageViewText.cpp
Modified: llvm/trunk/test/tools/llvm-cov/native_separators.c
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-cov/native_separators.c?rev=280756&r1=280755&r2=280756&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-cov/native_separators.c (original)
+++ llvm/trunk/test/tools/llvm-cov/native_separators.c Tue Sep 6 16:41:38 2016
@@ -20,6 +20,11 @@
int main() {}
+// RUN: llvm-cov show %S/Inputs/native_separators.covmapping -instr-profile=%t.profdata -filename-equivalence %s -o %t.dir
+// RUN: FileCheck -check-prefixes=TEXT -input-file=%t.dir/coverage/tmp/native_separators.c.txt %s
+// TEXT: {{^}}Source: \tmp\native_separators.c:{{$}}
+// TEXT: {{^}}Binary: {{.*}}tools\llvm-cov\Inputs\native_separators.covmapping:{{$}}
+
// Re-purpose this file to test that "Go to first unexecuted line" feature.
// RUN: llvm-cov show %S/Inputs/native_separators.covmapping -instr-profile %t.profdata -filename-equivalence -format html -o %t.dir %s
Modified: llvm/trunk/test/tools/llvm-cov/showTemplateInstantiations.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-cov/showTemplateInstantiations.cpp?rev=280756&r1=280755&r2=280756&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-cov/showTemplateInstantiations.cpp (original)
+++ llvm/trunk/test/tools/llvm-cov/showTemplateInstantiations.cpp Tue Sep 6 16:41:38 2016
@@ -12,7 +12,7 @@ int func(T x) { // ALL-NEXT: [[@
int j = 1; // ALL-NEXT: [[@LINE]]| 0| int j = 1;
} // ALL-NEXT: [[@LINE]]| 2|}
- // SHARED: {{^ *(\| )?}}_Z4funcIbEiT_:
+ // SHARED: {{^ *(\| )?}}Function: _Z4funcIbEiT_:
// SHARED: [[@LINE-9]]| 1|int func(T x) {
// SHARED-NEXT: [[@LINE-9]]| 1| if(x)
// SHARED-NEXT: [[@LINE-9]]| 1| return 0;
@@ -21,8 +21,8 @@ int func(T x) { // ALL-NEXT: [[@
// SHARED-NEXT: [[@LINE-9]]| 0| int j = 1;
// SHARED-NEXT: [[@LINE-9]]| 1|}
- // ALL: {{^ *}}| _Z4funcIiEiT_:
- // FILTER-NOT: {{^ *(\| )?}} _Z4funcIiEiT_:
+ // ALL: {{^ *}}| Function: _Z4funcIiEiT_:
+ // FILTER-NOT: {{^ *(\| )?}}Function: _Z4funcIiEiT_:
// ALL: [[@LINE-19]]| 1|int func(T x) {
// ALL-NEXT: [[@LINE-19]]| 1| if(x)
// ALL-NEXT: [[@LINE-19]]| 0| return 0;
Modified: llvm/trunk/tools/llvm-cov/CodeCoverage.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/CodeCoverage.cpp?rev=280756&r1=280755&r2=280756&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/CodeCoverage.cpp (original)
+++ llvm/trunk/tools/llvm-cov/CodeCoverage.cpp Tue Sep 6 16:41:38 2016
@@ -669,7 +669,7 @@ int CodeCoverageTool::show(int argc, con
// Show files
bool ShowFilenames =
- (SourceFiles.size() != 1) ||
+ (SourceFiles.size() != 1) || ViewOpts.hasOutputDirectory() ||
(ViewOpts.Format == CoverageViewOptions::OutputFormat::HTML);
if (SourceFiles.empty())
Modified: llvm/trunk/tools/llvm-cov/SourceCoverageView.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/SourceCoverageView.cpp?rev=280756&r1=280755&r2=280756&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/SourceCoverageView.cpp (original)
+++ llvm/trunk/tools/llvm-cov/SourceCoverageView.cpp Tue Sep 6 16:41:38 2016
@@ -142,6 +142,15 @@ SourceCoverageView::create(StringRef Sou
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) {
Modified: llvm/trunk/tools/llvm-cov/SourceCoverageView.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/SourceCoverageView.h?rev=280756&r1=280755&r2=280756&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/SourceCoverageView.h (original)
+++ llvm/trunk/tools/llvm-cov/SourceCoverageView.h Tue Sep 6 16:41:38 2016
@@ -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; }
Modified: llvm/trunk/tools/llvm-cov/SourceCoverageViewHTML.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/SourceCoverageViewHTML.cpp?rev=280756&r1=280755&r2=280756&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/SourceCoverageViewHTML.cpp (original)
+++ llvm/trunk/tools/llvm-cov/SourceCoverageViewHTML.cpp Tue Sep 6 16:41:38 2016
@@ -342,12 +342,7 @@ void SourceCoverageViewHTML::renderSourc
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",
Modified: llvm/trunk/tools/llvm-cov/SourceCoverageViewText.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/SourceCoverageViewText.cpp?rev=280756&r1=280755&r2=280756&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/SourceCoverageViewText.cpp (original)
+++ llvm/trunk/tools/llvm-cov/SourceCoverageViewText.cpp Tue Sep 6 16:41:38 2016
@@ -65,11 +65,11 @@ void SourceCoverageViewText::renderViewF
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";
}
}
More information about the llvm-commits
mailing list