From bea39c5443612b638aa1cc56d36e3b1fd06f6e96 Mon Sep 17 00:00:00 2001 From: Yuhao Gu Date: Thu, 24 Aug 2023 13:12:04 +0800 Subject: [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 --- llvm/tools/llvm-cov/SourceCoverageView.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'llvm/tools/llvm-cov/SourceCoverageView.cpp') 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::create(const CoverageViewOptions &Opts) { switch (Opts.Format) { case CoverageViewOptions::OutputFormat::Text: + if (Opts.ShowDirectoryCoverage) + return std::make_unique(Opts); return std::make_unique(Opts); case CoverageViewOptions::OutputFormat::HTML: + if (Opts.ShowDirectoryCoverage) + return std::make_unique(Opts); return std::make_unique(Opts); case CoverageViewOptions::OutputFormat::Lcov: // Unreachable because CodeCoverage.cpp should terminate with an error -- cgit v1.1