[PATCH] D73160: [llvm-cov] Add support for -skip-functions to lcov

Keith Smiley via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 21 21:27:11 PST 2020


keith created this revision.
keith added reviewers: kastiglione, Dor1s, vsk, allevato.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This flag was added for the json format to exclude functions from the
output. This mirrors that behavior in lcov (where it was previously
accepted but ignored). This makes the output file smaller which can be
beneficial depending on how you consume it, especially if you don't use
this data anyways.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73160

Files:
  llvm/test/tools/llvm-cov/export_functions-lcov.test
  llvm/tools/llvm-cov/CoverageExporterLcov.cpp


Index: llvm/tools/llvm-cov/CoverageExporterLcov.cpp
===================================================================
--- llvm/tools/llvm-cov/CoverageExporterLcov.cpp
+++ llvm/tools/llvm-cov/CoverageExporterLcov.cpp
@@ -78,10 +78,11 @@
 
 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);
@@ -99,9 +100,10 @@
 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
@@ -119,6 +121,6 @@
   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);
 }
Index: llvm/test/tools/llvm-cov/export_functions-lcov.test
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-cov/export_functions-lcov.test
@@ -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:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73160.239489.patch
Type: text/x-patch
Size: 2517 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200122/294c3219/attachment.bin>


More information about the llvm-commits mailing list