Skip to content

[llvm-cov] Add support for -skip-functions to lcov #732

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions llvm/test/tools/llvm-cov/export_functions-lcov.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Test that llvm-cov export produces function data by default and that it can be
# turned off with a flag.

RUN: llvm-cov export -format lcov %S/Inputs/report.covmapping -instr-profile %S/Inputs/report.profdata 2>&1 | FileCheck %s
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

CHECK: FN:
SKIP-FUNCTIONS-NOT: FN:
14 changes: 8 additions & 6 deletions llvm/tools/llvm-cov/CoverageExporterLcov.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,11 @@ void renderLineSummary(raw_ostream &OS, const FileCoverageSummary &Summary) {

void renderFile(raw_ostream &OS, const coverage::CoverageMapping &Coverage,
const std::string &Filename,
const FileCoverageSummary &FileReport, bool ExportSummaryOnly) {
const FileCoverageSummary &FileReport, bool ExportSummaryOnly,
bool SkipFunctions) {
OS << "SF:" << Filename << '\n';

if (!ExportSummaryOnly) {
if (!ExportSummaryOnly && !SkipFunctions) {
renderFunctions(OS, Coverage.getCoveredFunctions(Filename));
}
renderFunctionSummary(OS, FileReport);
Expand All @@ -99,9 +100,10 @@ void renderFile(raw_ostream &OS, const coverage::CoverageMapping &Coverage,
void renderFiles(raw_ostream &OS, const coverage::CoverageMapping &Coverage,
ArrayRef<std::string> SourceFiles,
ArrayRef<FileCoverageSummary> FileReports,
bool ExportSummaryOnly) {
bool ExportSummaryOnly, bool SkipFunctions) {
for (unsigned I = 0, E = SourceFiles.size(); I < E; ++I)
renderFile(OS, Coverage, SourceFiles[I], FileReports[I], ExportSummaryOnly);
renderFile(OS, Coverage, SourceFiles[I], FileReports[I], ExportSummaryOnly,
SkipFunctions);
}

} // end anonymous namespace
Expand All @@ -119,6 +121,6 @@ void CoverageExporterLcov::renderRoot(ArrayRef<std::string> SourceFiles) {
FileCoverageSummary Totals = FileCoverageSummary("Totals");
auto FileReports = CoverageReport::prepareFileReports(Coverage, Totals,
SourceFiles, Options);
renderFiles(OS, Coverage, SourceFiles, FileReports,
Options.ExportSummaryOnly);
renderFiles(OS, Coverage, SourceFiles, FileReports, Options.ExportSummaryOnly,
Options.SkipFunctions);
}