Browse Source

[llvm-cov] Don't show function summaries when filtering by filename (fixes PR31395)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@294137 91177308-0d34-0410-b5e6-96231b3b80d8
Vedant Kumar 8 years ago
parent
commit
2006b414f1

+ 4 - 0
docs/CommandGuide/llvm-cov.rst

@@ -322,6 +322,10 @@ OPTIONS
  universal binary or to use an architecture that does not match a
  universal binary or to use an architecture that does not match a
  non-universal binary.
  non-universal binary.
 
 
+.. option:: -show-functions
+
+ Show coverage summaries for each function.
+
 .. program:: llvm-cov export
 .. program:: llvm-cov export
 
 
 .. _llvm-cov-export:
 .. _llvm-cov-export:

+ 1 - 1
test/tools/llvm-cov/demangle.test

@@ -5,7 +5,7 @@ RUN: llvm-profdata merge %S/Inputs/hideUnexecutedSubviews.proftext -o %t.profdat
 RUN: llvm-cov show %S/Inputs/templateInstantiations.covmapping -instr-profile %t.profdata -Xdemangler sed -Xdemangler 's/_/X/g' -filename-equivalence %S/showTemplateInstantiations.cpp | FileCheck %s
 RUN: llvm-cov show %S/Inputs/templateInstantiations.covmapping -instr-profile %t.profdata -Xdemangler sed -Xdemangler 's/_/X/g' -filename-equivalence %S/showTemplateInstantiations.cpp | FileCheck %s
 
 
 // Check that we demangle names when printing out function summaries.
 // Check that we demangle names when printing out function summaries.
-RUN: llvm-cov report %S/Inputs/templateInstantiations.covmapping -instr-profile %S/Inputs/templateInstantiations.profdata -Xdemangler sed -Xdemangler 's/_/X/g' -filename-equivalence %S/showTemplateInstantiations.cpp | FileCheck %s
+RUN: llvm-cov report -show-functions %S/Inputs/templateInstantiations.covmapping -instr-profile %S/Inputs/templateInstantiations.profdata -Xdemangler sed -Xdemangler 's/_/X/g' -filename-equivalence %S/showTemplateInstantiations.cpp | FileCheck %s
 
 
 CHECK-DAG: XZ4funcIbEiTX
 CHECK-DAG: XZ4funcIbEiTX
 CHECK-DAG: XZ4funcIiEiTX
 CHECK-DAG: XZ4funcIiEiTX

+ 2 - 2
test/tools/llvm-cov/report.cpp

@@ -1,6 +1,6 @@
 // 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 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 %s
-// RUN: llvm-cov report %S/Inputs/report.covmapping -instr-profile %S/Inputs/report.profdata -filename-equivalence report.cpp does-not-exist.cpp 2>&1 | FileCheck -check-prefix=FILT %s
+// RUN: llvm-cov report -show-functions %S/Inputs/report.covmapping -instr-profile %S/Inputs/report.profdata -filename-equivalence report.cpp 2>&1 | FileCheck -check-prefix=FILT %s
+// RUN: llvm-cov report -show-functions %S/Inputs/report.covmapping -instr-profile %S/Inputs/report.profdata -filename-equivalence report.cpp does-not-exist.cpp 2>&1 | FileCheck -check-prefix=FILT %s
 
 
 // CHECK: Regions    Missed Regions     Cover   Functions  Missed Functions  Executed  Instantiations   Missed Insts.  Executed       Lines      Missed Lines     Cover
 // CHECK: Regions    Missed Regions     Cover   Functions  Missed Functions  Executed  Instantiations   Missed Insts.  Executed       Lines      Missed Lines     Cover
 // CHECK-NEXT: ---
 // CHECK-NEXT: ---

+ 5 - 1
tools/llvm-cov/CodeCoverage.cpp

@@ -808,6 +808,10 @@ int CodeCoverageTool::show(int argc, const char **argv,
 
 
 int CodeCoverageTool::report(int argc, const char **argv,
 int CodeCoverageTool::report(int argc, const char **argv,
                              CommandLineParserType commandLineParser) {
                              CommandLineParserType commandLineParser) {
+  cl::opt<bool> ShowFunctionSummaries(
+      "show-functions", cl::Optional, cl::init(false),
+      cl::desc("Show coverage summaries for each function"));
+
   auto Err = commandLineParser(argc, argv);
   auto Err = commandLineParser(argc, argv);
   if (Err)
   if (Err)
     return Err;
     return Err;
@@ -820,7 +824,7 @@ int CodeCoverageTool::report(int argc, const char **argv,
     return 1;
     return 1;
 
 
   CoverageReport Report(ViewOpts, *Coverage.get());
   CoverageReport Report(ViewOpts, *Coverage.get());
-  if (SourceFiles.empty())
+  if (!ShowFunctionSummaries)
     Report.renderFileReports(llvm::outs());
     Report.renderFileReports(llvm::outs());
   else
   else
     Report.renderFunctionReports(SourceFiles, DC, llvm::outs());
     Report.renderFunctionReports(SourceFiles, DC, llvm::outs());