[llvm] r314175 - [llvm-cov] Warn if -show-functions is used without query files

Vedant Kumar via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 25 16:10:03 PDT 2017


Author: vedantk
Date: Mon Sep 25 16:10:03 2017
New Revision: 314175

URL: http://llvm.org/viewvc/llvm-project?rev=314175&view=rev
Log:
[llvm-cov] Warn if -show-functions is used without query files

llvm-cov's report mode does not print any output when -show-functions is
specified and no source files are specified. This can be surprising, so
the tool should at least print out an error message when this happens.

rdar://problem/34636859

Modified:
    llvm/trunk/test/tools/llvm-cov/report.cpp
    llvm/trunk/tools/llvm-cov/CodeCoverage.cpp

Modified: llvm/trunk/test/tools/llvm-cov/report.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-cov/report.cpp?rev=314175&r1=314174&r2=314175&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-cov/report.cpp (original)
+++ llvm/trunk/test/tools/llvm-cov/report.cpp Mon Sep 25 16:10:03 2017
@@ -1,6 +1,9 @@
 // RUN: llvm-cov report %S/Inputs/report.covmapping -instr-profile %S/Inputs/report.profdata -path-equivalence=,%S 2>&1 -show-region-summary -show-instantiation-summary | FileCheck %s
 // RUN: llvm-cov report -show-functions %S/Inputs/report.covmapping -instr-profile %S/Inputs/report.profdata -path-equivalence=,%S %s 2>&1 | FileCheck -check-prefix=FILT %s
 // RUN: llvm-cov report -show-functions %S/Inputs/report.covmapping -instr-profile %S/Inputs/report.profdata -path-equivalence=,%S %s does-not-exist.cpp 2>&1 | FileCheck -check-prefix=FILT %s
+// RUN: not llvm-cov report -show-functions %S/Inputs/report.covmapping -instr-profile %S/Inputs/report.profdata -path-equivalence=,%S 2>&1 | FileCheck -check-prefix=NO_FILES %s
+
+// NO_FILES: Source files must be specified when -show-functions=true is specified
 
 // CHECK: Regions    Missed Regions     Cover   Functions  Missed Functions  Executed  Instantiations   Missed Insts.  Executed       Lines      Missed Lines     Cover
 // CHECK-NEXT: ---

Modified: llvm/trunk/tools/llvm-cov/CodeCoverage.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/CodeCoverage.cpp?rev=314175&r1=314174&r2=314175&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/CodeCoverage.cpp (original)
+++ llvm/trunk/tools/llvm-cov/CodeCoverage.cpp Mon Sep 25 16:10:03 2017
@@ -931,10 +931,17 @@ int CodeCoverageTool::report(int argc, c
     return 1;
 
   CoverageReport Report(ViewOpts, *Coverage.get());
-  if (!ShowFunctionSummaries)
+  if (!ShowFunctionSummaries) {
     Report.renderFileReports(llvm::outs());
-  else
+  } else {
+    if (SourceFiles.empty()) {
+      error("Source files must be specified when -show-functions=true is "
+            "specified");
+      return 1;
+    }
+
     Report.renderFunctionReports(SourceFiles, DC, llvm::outs());
+  }
   return 0;
 }
 




More information about the llvm-commits mailing list