[PATCH] D22569: [LLVM-COV] Add the coverage of lines in the summary report.
Ying Yi via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 20 07:09:57 PDT 2016
MaggieYi created this revision.
MaggieYi added reviewers: vsk, davidxl, harlanhaskins, bogner.
MaggieYi added a subscriber: llvm-commits.
The llvm-cov ‘report' command displays a summary of the coverage of a binary file.
The summary report currently only includes covered regions and covered functions as shown below:
Filename Regions Miss Cover Functions Executed
----------------------------------------------------------------------
I:\test\test.cpp 12 2 83.33% 3 100.00%
----------------------------------------------------------------------
TOTAL 12 2 83.33% 3 100.00%
This patch adds the coverage of lines in the summary report, for example:
Filename Regions Miss Cover Functions Miss Executed Lines Miss Cover
----------------------------------------------------------------------------------------------------
I:\test\test.cpp 12 2 83.33% 3 0 100.00% 26 2 92.31%
-----------------------------------------------------------------------------------------------------
TOTAL 12 2 83.33% 3 0 100.00% 26 2 92.31%
https://reviews.llvm.org/D22569
Files:
test/tools/llvm-cov/report.cpp
tools/llvm-cov/CoverageReport.cpp
Index: tools/llvm-cov/CoverageReport.cpp
===================================================================
--- tools/llvm-cov/CoverageReport.cpp
+++ tools/llvm-cov/CoverageReport.cpp
@@ -88,7 +88,8 @@
return Column(Str, Width).set(Value);
}
-static size_t FileReportColumns[] = {25, 10, 8, 8, 10, 10};
+// Add the column widths for line coverage.
+static size_t FileReportColumns[] = {25, 10, 8, 8, 10, 8, 10, 10, 8, 8};
static size_t FunctionReportColumns[] = {25, 10, 8, 8, 10, 8, 8};
/// \brief Adjust column widths to fit long file paths and function names.
@@ -136,10 +137,24 @@
File.RegionCoverage.getPercentCovered()) << '%';
OS << format("%*u", FileReportColumns[4],
(unsigned)File.FunctionCoverage.NumFunctions);
+ OS << format("%*u", FileReportColumns[5],
+ (unsigned)(File.FunctionCoverage.NumFunctions -
+ File.FunctionCoverage.Executed));
Options.colored_ostream(
OS, determineCoveragePercentageColor(File.FunctionCoverage))
- << format("%*.2f", FileReportColumns[5] - 1,
+ << format("%*.2f", FileReportColumns[6] - 1,
File.FunctionCoverage.getPercentCovered()) << '%';
+ OS << format("%*u", FileReportColumns[7],
+ (unsigned)File.LineCoverage.NumLines);
+ Options.colored_ostream(OS, File.LineCoverage.isFullyCovered()
+ ? raw_ostream::GREEN
+ : raw_ostream::RED)
+ << format("%*u", FileReportColumns[8],
+ (unsigned)File.LineCoverage.NotCovered);
+ Options.colored_ostream(OS,
+ determineCoveragePercentageColor(File.LineCoverage))
+ << format("%*.2f", FileReportColumns[9] - 1,
+ File.LineCoverage.getPercentCovered()) << '%';
OS << "\n";
}
@@ -214,7 +229,12 @@
<< column("Miss", FileReportColumns[2], Column::RightAlignment)
<< column("Cover", FileReportColumns[3], Column::RightAlignment)
<< column("Functions", FileReportColumns[4], Column::RightAlignment)
- << column("Executed", FileReportColumns[5], Column::RightAlignment)
+ << column("Miss", FileReportColumns[5],
+ Column::RightAlignment)
+ << column("Executed", FileReportColumns[6], Column::RightAlignment)
+ << column("Lines", FileReportColumns[7], Column::RightAlignment)
+ << column("Miss", FileReportColumns[8], Column::RightAlignment)
+ << column("Cover", FileReportColumns[9], Column::RightAlignment)
<< "\n";
renderDivider(FileReportColumns, OS);
OS << "\n";
Index: test/tools/llvm-cov/report.cpp
===================================================================
--- test/tools/llvm-cov/report.cpp
+++ test/tools/llvm-cov/report.cpp
@@ -1,11 +1,11 @@
// RUN: llvm-cov report %S/Inputs/report.covmapping -instr-profile %S/Inputs/report.profdata -filename-equivalence 2>&1 | FileCheck %s
// RUN: llvm-cov report %S/Inputs/report.covmapping -instr-profile %S/Inputs/report.profdata -filename-equivalence report.cpp 2>&1 | FileCheck -check-prefix=FILT-NEXT %s
-// CHECK: Filename Regions Miss Cover Functions Executed
+// CHECK: Filename Regions Miss Cover Functions Miss Executed Lines Miss Cover
// CHECK-NEXT: ---
-// CHECK-NEXT: report.cpp 5 2 60.00% 4 75.00%
+// CHECK-NEXT: report.cpp 5 2 60.00% 4 1 75.00% 13 4 69.23%
// CHECK-NEXT: ---
-// CHECK-NEXT: TOTAL 5 2 60.00% 4 75.00%
+// CHECK-NEXT: TOTAL 5 2 60.00% 4 1 75.00% 13 4 69.23%
// FILT: File 'report.cpp':
// FILT-NEXT: Name Regions Miss Cover Lines Miss Cover
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22569.64682.patch
Type: text/x-patch
Size: 3750 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160720/275cb62d/attachment-0001.bin>
More information about the llvm-commits
mailing list