aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVedant Kumar <vsk@apple.com>2017-09-25 23:10:03 +0000
committerVedant Kumar <vsk@apple.com>2017-09-25 23:10:03 +0000
commit35ccd0b31ce4a4f291cc81907b6ea944406ca703 (patch)
tree0d42c0f6c08b4c5527895ef5446926e3848008e5
parenta83f8fe1f1f228ec33cc8d8b27c6a15513121c94 (diff)
[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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314175 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--test/tools/llvm-cov/report.cpp3
-rw-r--r--tools/llvm-cov/CodeCoverage.cpp11
2 files changed, 12 insertions, 2 deletions
diff --git a/test/tools/llvm-cov/report.cpp b/test/tools/llvm-cov/report.cpp
index af2ef98d687..4c35401d41c 100644
--- a/test/tools/llvm-cov/report.cpp
+++ b/test/tools/llvm-cov/report.cpp
@@ -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: ---
diff --git a/tools/llvm-cov/CodeCoverage.cpp b/tools/llvm-cov/CodeCoverage.cpp
index ed87e9e8e61..1ea54a8cffd 100644
--- a/tools/llvm-cov/CodeCoverage.cpp
+++ b/tools/llvm-cov/CodeCoverage.cpp
@@ -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;
}