1 //===- SourceCoverageViewHTML.h - A html code coverage view ---------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 /// \file This file defines the interface to the html coverage renderer.
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_COV_SOURCECOVERAGEVIEWHTML_H
14 #define LLVM_COV_SOURCECOVERAGEVIEWHTML_H
16 #include "SourceCoverageView.h"
20 using namespace coverage
;
24 struct FileCoverageSummary
;
26 /// A coverage printer for html output.
27 class CoveragePrinterHTML
: public CoveragePrinter
{
29 Expected
<OwnedStream
> createViewFile(StringRef Path
,
30 bool InToplevel
) override
;
32 void closeViewFile(OwnedStream OS
) override
;
34 Error
createIndexFile(ArrayRef
<std::string
> SourceFiles
,
35 const coverage::CoverageMapping
&Coverage
,
36 const CoverageFiltersMatchAll
&Filters
) override
;
38 CoveragePrinterHTML(const CoverageViewOptions
&Opts
)
39 : CoveragePrinter(Opts
) {}
42 Error
emitStyleSheet();
43 void emitReportHeader(raw_ostream
&OSRef
, const std::string
&Title
);
46 void emitFileSummary(raw_ostream
&OS
, StringRef SF
,
47 const FileCoverageSummary
&FCS
,
48 bool IsTotals
= false) const;
49 std::string
buildLinkToFile(StringRef SF
,
50 const FileCoverageSummary
&FCS
) const;
53 /// A coverage printer for html output, but generates index files in every
54 /// subdirectory to show a hierarchical view.
55 class CoveragePrinterHTMLDirectory
: public CoveragePrinterHTML
{
57 using CoveragePrinterHTML::CoveragePrinterHTML
;
59 Error
createIndexFile(ArrayRef
<std::string
> SourceFiles
,
60 const coverage::CoverageMapping
&Coverage
,
61 const CoverageFiltersMatchAll
&Filters
) override
;
67 /// A code coverage view which supports html-based rendering.
68 class SourceCoverageViewHTML
: public SourceCoverageView
{
69 void renderViewHeader(raw_ostream
&OS
) override
;
71 void renderViewFooter(raw_ostream
&OS
) override
;
73 void renderSourceName(raw_ostream
&OS
, bool WholeFile
) override
;
75 void renderLinePrefix(raw_ostream
&OS
, unsigned ViewDepth
) override
;
77 void renderLineSuffix(raw_ostream
&OS
, unsigned ViewDepth
) override
;
79 void renderViewDivider(raw_ostream
&OS
, unsigned ViewDepth
) override
;
81 void renderLine(raw_ostream
&OS
, LineRef L
, const LineCoverageStats
&LCS
,
82 unsigned ExpansionCol
, unsigned ViewDepth
) override
;
84 void renderExpansionSite(raw_ostream
&OS
, LineRef L
,
85 const LineCoverageStats
&LCS
, unsigned ExpansionCol
,
86 unsigned ViewDepth
) override
;
88 void renderExpansionView(raw_ostream
&OS
, ExpansionView
&ESV
,
89 unsigned ViewDepth
) override
;
91 void renderBranchView(raw_ostream
&OS
, BranchView
&BRV
,
92 unsigned ViewDepth
) override
;
94 void renderMCDCView(raw_ostream
&OS
, MCDCView
&BRV
,
95 unsigned ViewDepth
) override
;
97 void renderInstantiationView(raw_ostream
&OS
, InstantiationView
&ISV
,
98 unsigned ViewDepth
) override
;
100 void renderLineCoverageColumn(raw_ostream
&OS
,
101 const LineCoverageStats
&Line
) override
;
103 void renderLineNumberColumn(raw_ostream
&OS
, unsigned LineNo
) override
;
105 void renderRegionMarkers(raw_ostream
&OS
, const LineCoverageStats
&Line
,
106 unsigned ViewDepth
) override
;
108 void renderTitle(raw_ostream
&OS
, StringRef Title
) override
;
110 void renderTableHeader(raw_ostream
&OS
, unsigned FirstUncoveredLineNo
,
111 unsigned IndentLevel
) override
;
114 SourceCoverageViewHTML(StringRef SourceName
, const MemoryBuffer
&File
,
115 const CoverageViewOptions
&Options
,
116 coverage::CoverageData
&&CoverageInfo
)
117 : SourceCoverageView(SourceName
, File
, Options
, std::move(CoverageInfo
)) {
123 #endif // LLVM_COV_SOURCECOVERAGEVIEWHTML_H