blob: 4026aad3f73dc8d75a1c7abeb11738636fb53377 [file] [log] [blame]
Vedant Kumar4c010922016-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 Kumara59334d2016-09-09 01:32:55 +000021struct FileCoverageSummary;
22
Vedant Kumar4c010922016-07-06 21:44:05 +000023/// \brief A coverage printer for html output.
24class CoveragePrinterHTML : public CoveragePrinter {
25public:
26 Expected<OwnedStream> createViewFile(StringRef Path,
27 bool InToplevel) override;
28
29 void closeViewFile(OwnedStream OS) override;
30
Vedant Kumarbc647982016-09-23 18:57:32 +000031 Error createIndexFile(ArrayRef<std::string> SourceFiles,
Sean Evesonfa8ef352017-09-28 10:07:30 +000032 const coverage::CoverageMapping &Coverage,
Sean Evesond932b2d2017-10-03 11:05:28 +000033 const CoverageFiltersMatchAll &Filters) override;
Vedant Kumar4c010922016-07-06 21:44:05 +000034
35 CoveragePrinterHTML(const CoverageViewOptions &Opts)
36 : CoveragePrinter(Opts) {}
Vedant Kumara59334d2016-09-09 01:32:55 +000037
38private:
39 void emitFileSummary(raw_ostream &OS, StringRef SF,
40 const FileCoverageSummary &FCS,
41 bool IsTotals = false) const;
Eli Friedmanc0c182c2017-08-09 20:43:31 +000042 std::string buildLinkToFile(StringRef SF,
43 const FileCoverageSummary &FCS) const;
Vedant Kumar4c010922016-07-06 21:44:05 +000044};
45
46/// \brief A code coverage view which supports html-based rendering.
47class SourceCoverageViewHTML : public SourceCoverageView {
48 void renderViewHeader(raw_ostream &OS) override;
49
50 void renderViewFooter(raw_ostream &OS) override;
51
Vedant Kumarb1c174a2016-09-10 19:37:26 +000052 void renderSourceName(raw_ostream &OS, bool WholeFile) override;
Vedant Kumar4c010922016-07-06 21:44:05 +000053
54 void renderLinePrefix(raw_ostream &OS, unsigned ViewDepth) override;
55
56 void renderLineSuffix(raw_ostream &OS, unsigned ViewDepth) override;
57
58 void renderViewDivider(raw_ostream &OS, unsigned ViewDepth) override;
59
Vedant Kumar08a0a312017-10-18 18:52:28 +000060 void renderLine(raw_ostream &OS, LineRef L, const LineCoverageStats &LCS,
61 unsigned ExpansionCol, unsigned ViewDepth) override;
Vedant Kumar4c010922016-07-06 21:44:05 +000062
63 void renderExpansionSite(raw_ostream &OS, LineRef L,
Vedant Kumar08a0a312017-10-18 18:52:28 +000064 const LineCoverageStats &LCS, unsigned ExpansionCol,
Vedant Kumar4c010922016-07-06 21:44:05 +000065 unsigned ViewDepth) override;
66
67 void renderExpansionView(raw_ostream &OS, ExpansionView &ESV,
68 unsigned ViewDepth) override;
69
70 void renderInstantiationView(raw_ostream &OS, InstantiationView &ISV,
71 unsigned ViewDepth) override;
72
73 void renderLineCoverageColumn(raw_ostream &OS,
74 const LineCoverageStats &Line) override;
75
76 void renderLineNumberColumn(raw_ostream &OS, unsigned LineNo) override;
77
Vedant Kumar08a0a312017-10-18 18:52:28 +000078 void renderRegionMarkers(raw_ostream &OS, const LineCoverageStats &Line,
Vedant Kumar4c010922016-07-06 21:44:05 +000079 unsigned ViewDepth) override;
80
Vedant Kumarb2edd112016-09-15 04:45:59 +000081 void renderTitle(raw_ostream &OS, StringRef Title) override;
Ying Yi84dc9712016-08-24 14:27:23 +000082
Vedant Kumarb1c174a2016-09-10 19:37:26 +000083 void renderTableHeader(raw_ostream &OS, unsigned FirstUncoveredLineNo,
84 unsigned IndentLevel) override;
Ying Yi84dc9712016-08-24 14:27:23 +000085
Vedant Kumar4c010922016-07-06 21:44:05 +000086public:
87 SourceCoverageViewHTML(StringRef SourceName, const MemoryBuffer &File,
88 const CoverageViewOptions &Options,
Vedant Kumar0053c0b2016-09-08 00:56:48 +000089 coverage::CoverageData &&CoverageInfo)
90 : SourceCoverageView(SourceName, File, Options, std::move(CoverageInfo)) {
91 }
Vedant Kumar4c010922016-07-06 21:44:05 +000092};
93
94} // namespace llvm
95
96#endif // LLVM_COV_SOURCECOVERAGEVIEWHTML_H