[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

llvm-svn: 314175
This commit is contained in:
Vedant Kumar 2017-09-25 23:10:03 +00:00
parent 2d690975d9
commit d0c6992660
2 changed files with 12 additions and 2 deletions

View 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: ---

View 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;
}