aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-cov/SourceCoverageView.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/SourceCoverageView.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/SourceCoverageView.cpp')
-rw-r--r--llvm/tools/llvm-cov/SourceCoverageView.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/tools/llvm-cov/SourceCoverageView.cpp b/llvm/tools/llvm-cov/SourceCoverageView.cpp
index ea86aca..7480b7f 100644
--- a/llvm/tools/llvm-cov/SourceCoverageView.cpp
+++ b/llvm/tools/llvm-cov/SourceCoverageView.cpp
@@ -76,8 +76,12 @@ std::unique_ptr<CoveragePrinter>
CoveragePrinter::create(const CoverageViewOptions &Opts) {
switch (Opts.Format) {
case CoverageViewOptions::OutputFormat::Text:
+ if (Opts.ShowDirectoryCoverage)
+ return std::make_unique<CoveragePrinterTextDirectory>(Opts);
return std::make_unique<CoveragePrinterText>(Opts);
case CoverageViewOptions::OutputFormat::HTML:
+ if (Opts.ShowDirectoryCoverage)
+ return std::make_unique<CoveragePrinterHTMLDirectory>(Opts);
return std::make_unique<CoveragePrinterHTML>(Opts);
case CoverageViewOptions::OutputFormat::Lcov:
// Unreachable because CodeCoverage.cpp should terminate with an error