]> granicus.if.org Git - llvm/commitdiff
[llvm-cov] Warn if -show-functions is used without query files
authorVedant Kumar <vsk@apple.com>
Mon, 25 Sep 2017 23:10:03 +0000 (23:10 +0000)
committerVedant Kumar <vsk@apple.com>
Mon, 25 Sep 2017 23:10:03 +0000 (23:10 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314175 91177308-0d34-0410-b5e6-96231b3b80d8

test/tools/llvm-cov/report.cpp
tools/llvm-cov/CodeCoverage.cpp

index af2ef98d6877a2a17cfa021aa2387bc5c30061e9..4c35401d41c3cc7889260a073ba8f0135aaa3ef7 100644 (file)
@@ -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: ---
index ed87e9e8e618ca8832675ca96be570a5894a0843..1ea54a8cffd48484489cd7e14f45da1b74067d01 100644 (file)
@@ -931,10 +931,17 @@ int CodeCoverageTool::report(int argc, const char **argv,
     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;
 }