Skip to content

Commit 38d781d

Browse files
authored
Merge pull request #732 from keith/ks/llvm-cov-cherry
[llvm-cov] Add support for -skip-functions to lcov
2 parents da8fcf2 + 852b4f2 commit 38d781d

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Test that llvm-cov export produces function data by default and that it can be
2+
# turned off with a flag.
3+
4+
RUN: llvm-cov export -format lcov %S/Inputs/report.covmapping -instr-profile %S/Inputs/report.profdata 2>&1 | FileCheck %s
5+
RUN: llvm-cov export -format lcov %S/Inputs/report.covmapping -instr-profile %S/Inputs/report.profdata -skip-functions 2>&1 | FileCheck -check-prefix=SKIP-FUNCTIONS %s
6+
7+
CHECK: FN:
8+
SKIP-FUNCTIONS-NOT: FN:

llvm/tools/llvm-cov/CoverageExporterLcov.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,11 @@ void renderLineSummary(raw_ostream &OS, const FileCoverageSummary &Summary) {
7878

7979
void renderFile(raw_ostream &OS, const coverage::CoverageMapping &Coverage,
8080
const std::string &Filename,
81-
const FileCoverageSummary &FileReport, bool ExportSummaryOnly) {
81+
const FileCoverageSummary &FileReport, bool ExportSummaryOnly,
82+
bool SkipFunctions) {
8283
OS << "SF:" << Filename << '\n';
8384

84-
if (!ExportSummaryOnly) {
85+
if (!ExportSummaryOnly && !SkipFunctions) {
8586
renderFunctions(OS, Coverage.getCoveredFunctions(Filename));
8687
}
8788
renderFunctionSummary(OS, FileReport);
@@ -99,9 +100,10 @@ void renderFile(raw_ostream &OS, const coverage::CoverageMapping &Coverage,
99100
void renderFiles(raw_ostream &OS, const coverage::CoverageMapping &Coverage,
100101
ArrayRef<std::string> SourceFiles,
101102
ArrayRef<FileCoverageSummary> FileReports,
102-
bool ExportSummaryOnly) {
103+
bool ExportSummaryOnly, bool SkipFunctions) {
103104
for (unsigned I = 0, E = SourceFiles.size(); I < E; ++I)
104-
renderFile(OS, Coverage, SourceFiles[I], FileReports[I], ExportSummaryOnly);
105+
renderFile(OS, Coverage, SourceFiles[I], FileReports[I], ExportSummaryOnly,
106+
SkipFunctions);
105107
}
106108

107109
} // end anonymous namespace
@@ -119,6 +121,6 @@ void CoverageExporterLcov::renderRoot(ArrayRef<std::string> SourceFiles) {
119121
FileCoverageSummary Totals = FileCoverageSummary("Totals");
120122
auto FileReports = CoverageReport::prepareFileReports(Coverage, Totals,
121123
SourceFiles, Options);
122-
renderFiles(OS, Coverage, SourceFiles, FileReports,
123-
Options.ExportSummaryOnly);
124+
renderFiles(OS, Coverage, SourceFiles, FileReports, Options.ExportSummaryOnly,
125+
Options.SkipFunctions);
124126
}

0 commit comments

Comments
 (0)