blob: cb41fcaf37b934df92e78d3adf4a8838029546fc [file] [log] [blame]
Vedant Kumar55c8c002016-07-06 21:44:05 +00001//===- SourceCoverageViewHTML.h - A html code coverage view ---------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9///
10/// \file This file defines the interface to the html coverage renderer.
11///
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_COV_SOURCECOVERAGEVIEWHTML_H
15#define LLVM_COV_SOURCECOVERAGEVIEWHTML_H
16
17#include "SourceCoverageView.h"
18
19namespace llvm {
20
Vedant Kumar34ea0de2017-10-18 23:58:27 +000021using namespace coverage;
22
Vedant Kumar84dc7512016-09-09 01:32:55 +000023struct FileCoverageSummary;
24
Adrian Prantl26b584c2018-05-01 15:54:18 +000025/// A coverage printer for html output.
Vedant Kumar55c8c002016-07-06 21:44:05 +000026class CoveragePrinterHTML : public CoveragePrinter {
27public:
28 Expected<OwnedStream> createViewFile(StringRef Path,
29 bool InToplevel) override;
30
31 void closeViewFile(OwnedStream OS) override;
32
Vedant Kumarfd066352016-09-23 18:57:32 +000033 Error createIndexFile(ArrayRef<std::string> SourceFiles,
Sean Eveson078c2c32017-09-28 10:07:30 +000034 const coverage::CoverageMapping &Coverage,
Sean Evesonb863c402017-10-03 11:05:28 +000035 const CoverageFiltersMatchAll &Filters) override;
Vedant Kumar55c8c002016-07-06 21:44:05 +000036
37 CoveragePrinterHTML(const CoverageViewOptions &Opts)
38 : CoveragePrinter(Opts) {}
Vedant Kumar84dc7512016-09-09 01:32:55 +000039
40private:
41 void emitFileSummary(raw_ostream &OS, StringRef SF,
42 const FileCoverageSummary &FCS,
43 bool IsTotals = false) const;
Eli Friedman9bcc2d42017-08-09 20:43:31 +000044 std::string buildLinkToFile(StringRef SF,
45 const FileCoverageSummary &FCS) const;
Vedant Kumar55c8c002016-07-06 21:44:05 +000046};
47
Adrian Prantl26b584c2018-05-01 15:54:18 +000048/// A code coverage view which supports html-based rendering.
Vedant Kumar55c8c002016-07-06 21:44:05 +000049class SourceCoverageViewHTML : public SourceCoverageView {
50 void renderViewHeader(raw_ostream &OS) override;
51
52 void renderViewFooter(raw_ostream &OS) override;
53
Vedant Kumara8edd762016-09-10 19:37:26 +000054 void renderSourceName(raw_ostream &OS, bool WholeFile) override;
Vedant Kumar55c8c002016-07-06 21:44:05 +000055
56 void renderLinePrefix(raw_ostream &OS, unsigned ViewDepth) override;
57
58 void renderLineSuffix(raw_ostream &OS, unsigned ViewDepth) override;
59
60 void renderViewDivider(raw_ostream &OS, unsigned ViewDepth) override;
61
Vedant Kumard35bb382017-10-18 18:52:28 +000062 void renderLine(raw_ostream &OS, LineRef L, const LineCoverageStats &LCS,
63 unsigned ExpansionCol, unsigned ViewDepth) override;
Vedant Kumar55c8c002016-07-06 21:44:05 +000064
65 void renderExpansionSite(raw_ostream &OS, LineRef L,
Vedant Kumard35bb382017-10-18 18:52:28 +000066 const LineCoverageStats &LCS, unsigned ExpansionCol,
Vedant Kumar55c8c002016-07-06 21:44:05 +000067 unsigned ViewDepth) override;
68
69 void renderExpansionView(raw_ostream &OS, ExpansionView &ESV,
70 unsigned ViewDepth) override;
71
72 void renderInstantiationView(raw_ostream &OS, InstantiationView &ISV,
73 unsigned ViewDepth) override;
74
75 void renderLineCoverageColumn(raw_ostream &OS,
76 const LineCoverageStats &Line) override;
77
78 void renderLineNumberColumn(raw_ostream &OS, unsigned LineNo) override;
79
Vedant Kumard35bb382017-10-18 18:52:28 +000080 void renderRegionMarkers(raw_ostream &OS, const LineCoverageStats &Line,
Vedant Kumar55c8c002016-07-06 21:44:05 +000081 unsigned ViewDepth) override;
82
Vedant Kumar7551d482016-09-15 04:45:59 +000083 void renderTitle(raw_ostream &OS, StringRef Title) override;
Ying Yi1461e992016-08-24 14:27:23 +000084
Vedant Kumara8edd762016-09-10 19:37:26 +000085 void renderTableHeader(raw_ostream &OS, unsigned FirstUncoveredLineNo,
86 unsigned IndentLevel) override;
Ying Yi1461e992016-08-24 14:27:23 +000087
Vedant Kumar55c8c002016-07-06 21:44:05 +000088public:
89 SourceCoverageViewHTML(StringRef SourceName, const MemoryBuffer &File,
90 const CoverageViewOptions &Options,
Vedant Kumard2e36ca2016-09-08 00:56:48 +000091 coverage::CoverageData &&CoverageInfo)
92 : SourceCoverageView(SourceName, File, Options, std::move(CoverageInfo)) {
93 }
Vedant Kumar55c8c002016-07-06 21:44:05 +000094};
95
96} // namespace llvm
97
98#endif // LLVM_COV_SOURCECOVERAGEVIEWHTML_H