aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-cov/CodeCoverage.cpp
diff options
context:
space:
mode:
authorYuhao Gu <yhgu2000@outlook.com>2023-08-24 13:12:04 +0800
committerYuhao Gu <yhgu2000@outlook.com>2023-08-24 13:46:12 +0800
commitbea39c5443612b638aa1cc56d36e3b1fd06f6e96 (patch)
tree63bdf728f2bd4c184f7bbf3b9239e53945815829 /llvm/tools/llvm-cov/CodeCoverage.cpp
parent7a41af86041bd757b7f380d7f645403d4e1725ca (diff)
downloadllvm-bea39c5443612b638aa1cc56d36e3b1fd06f6e96.zip
llvm-bea39c5443612b638aa1cc56d36e3b1fd06f6e96.tar.gz
llvm-bea39c5443612b638aa1cc56d36e3b1fd06f6e96.tar.bz2
[llvm-cov] Support directory layout in coverage reports
This is a GSoC 2023 project ([discourse link](https://discourse.llvm.org/t/coverage-support-a-hierarchical-directory-structure-in-generated-coverage-html-reports/68239)). llvm-cov currently generates a single top-level index HTML file, which causes rendering scalability issues in large projects. This patch adds support for hierarchical directory structure into the HTML reports to solve scalability issues by introducing the following changes: - Added a new command line option `--show-directory-coverage` for `llvm-cov show`. It works both for `--format=html` and `--format=text`. - Two new classes: `CoveragePrinterHTMLDirectory` and `CoveragePrinterTextDirectory` was added to support the new option. - A tool class `DirectoryCoverageReport` was added to support the two classes above. - Updated the document. - Added a new regression test for `--show-directory-coverage`. Reviewed By: phosek, gulfem Differential Revision: https://reviews.llvm.org/D151283
Diffstat (limited to 'llvm/tools/llvm-cov/CodeCoverage.cpp')
-rw-r--r--llvm/tools/llvm-cov/CodeCoverage.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/tools/llvm-cov/CodeCoverage.cpp b/llvm/tools/llvm-cov/CodeCoverage.cpp
index 3992dfa..f26db15 100644
--- a/llvm/tools/llvm-cov/CodeCoverage.cpp
+++ b/llvm/tools/llvm-cov/CodeCoverage.cpp
@@ -982,6 +982,10 @@ int CodeCoverageTool::doShow(int argc, const char **argv,
cl::desc("Show function instantiations"),
cl::init(true), cl::cat(ViewCategory));
+ cl::opt<bool> ShowDirectoryCoverage("show-directory-coverage", cl::Optional,
+ cl::desc("Show directory coverage"),
+ cl::cat(ViewCategory));
+
cl::opt<std::string> ShowOutputDirectory(
"output-dir", cl::init(""),
cl::desc("Directory in which coverage information is written out"));
@@ -1062,6 +1066,7 @@ int CodeCoverageTool::doShow(int argc, const char **argv,
ViewOpts.ShowBranchPercents =
ShowBranches == CoverageViewOptions::BranchOutputType::Percent;
ViewOpts.ShowFunctionInstantiations = ShowInstantiations;
+ ViewOpts.ShowDirectoryCoverage = ShowDirectoryCoverage;
ViewOpts.ShowOutputDirectory = ShowOutputDirectory;
ViewOpts.TabSize = TabSize;
ViewOpts.ProjectTitle = ProjectTitle;