summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-cov/CodeCoverage.cpp
diff options
context:
space:
mode:
authorVedant Kumar <vsk@apple.com>2016-06-28 16:12:24 +0000
committerVedant Kumar <vsk@apple.com>2016-06-28 16:12:24 +0000
commit9cbad2c2b8ca3a5db8979f8233612a781b8eb7c5 (patch)
treed70144a8d080a512ed50f6c0e7fef8b0dc3a2171 /llvm/tools/llvm-cov/CodeCoverage.cpp
parent64d8a029e9657538f7e89b932c0f20248ee0f23c (diff)
downloadbcm5719-llvm-9cbad2c2b8ca3a5db8979f8233612a781b8eb7c5.tar.gz
bcm5719-llvm-9cbad2c2b8ca3a5db8979f8233612a781b8eb7c5.zip
[llvm-cov] Create an index of reports in -output-dir mode
This index lists the reports available in the 'coverage' sub-directory. This will help navigate coverage output from large projects. This commit factors the file creation code out of SourceCoverageView and into CoveragePrinter. llvm-svn: 274029
Diffstat (limited to 'llvm/tools/llvm-cov/CodeCoverage.cpp')
-rw-r--r--llvm/tools/llvm-cov/CodeCoverage.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/llvm/tools/llvm-cov/CodeCoverage.cpp b/llvm/tools/llvm-cov/CodeCoverage.cpp
index 240acffa779..f2f97163ef1 100644
--- a/llvm/tools/llvm-cov/CodeCoverage.cpp
+++ b/llvm/tools/llvm-cov/CodeCoverage.cpp
@@ -448,6 +448,8 @@ int CodeCoverageTool::show(int argc, const char **argv,
if (!Coverage)
return 1;
+ auto Printer = CoveragePrinter::create(ViewOpts);
+
if (!Filters.empty()) {
// Show functions
for (const auto &Function : Coverage->getCoveredFunctions()) {
@@ -462,15 +464,14 @@ int CodeCoverageTool::show(int argc, const char **argv,
continue;
}
- auto OSOrErr =
- mainView->createOutputFile("functions", /*InToplevel=*/true);
+ auto OSOrErr = Printer->createViewFile("functions", /*InToplevel=*/true);
if (Error E = OSOrErr.takeError()) {
error(toString(std::move(E)));
return 1;
}
auto OS = std::move(OSOrErr.get());
mainView->print(*OS.get(), /*WholeFile=*/false, /*ShowSourceName=*/true);
- mainView->closeOutputFile(std::move(OS));
+ Printer->closeViewFile(std::move(OS));
}
return 0;
}
@@ -483,6 +484,14 @@ int CodeCoverageTool::show(int argc, const char **argv,
for (StringRef Filename : Coverage->getUniqueSourceFiles())
SourceFiles.push_back(Filename);
+ // Create an index out of the source files.
+ if (ViewOpts.hasOutputDirectory()) {
+ if (Error E = Printer->createIndexFile(SourceFiles)) {
+ error(toString(std::move(E)));
+ return 1;
+ }
+ }
+
for (const auto &SourceFile : SourceFiles) {
auto mainView = createSourceFileView(SourceFile, *Coverage);
if (!mainView) {
@@ -492,7 +501,7 @@ int CodeCoverageTool::show(int argc, const char **argv,
continue;
}
- auto OSOrErr = mainView->createOutputFile(SourceFile, /*InToplevel=*/false);
+ auto OSOrErr = Printer->createViewFile(SourceFile, /*InToplevel=*/false);
if (Error E = OSOrErr.takeError()) {
error(toString(std::move(E)));
return 1;
@@ -500,7 +509,7 @@ int CodeCoverageTool::show(int argc, const char **argv,
auto OS = std::move(OSOrErr.get());
mainView->print(*OS.get(), /*Wholefile=*/true,
/*ShowSourceName=*/ShowFilenames);
- mainView->closeOutputFile(std::move(OS));
+ Printer->closeViewFile(std::move(OS));
}
return 0;
OpenPOWER on IntegriCloud