[NFC][Py Reformat] Reformat python files in llvm
[llvm-project.git] / llvm / tools / llvm-cov / SourceCoverageViewHTML.h
blob7d94675f4b0b7c5e24255a1a3bbee44d5a911ccc
1 //===- SourceCoverageViewHTML.h - A html code coverage view ---------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
8 ///
9 /// \file This file defines the interface to the html coverage renderer.
10 ///
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_COV_SOURCECOVERAGEVIEWHTML_H
14 #define LLVM_COV_SOURCECOVERAGEVIEWHTML_H
16 #include "SourceCoverageView.h"
18 namespace llvm {
20 using namespace coverage;
22 struct FileCoverageSummary;
24 /// A coverage printer for html output.
25 class CoveragePrinterHTML : public CoveragePrinter {
26 public:
27 Expected<OwnedStream> createViewFile(StringRef Path,
28 bool InToplevel) override;
30 void closeViewFile(OwnedStream OS) override;
32 Error createIndexFile(ArrayRef<std::string> SourceFiles,
33 const coverage::CoverageMapping &Coverage,
34 const CoverageFiltersMatchAll &Filters) override;
36 CoveragePrinterHTML(const CoverageViewOptions &Opts)
37 : CoveragePrinter(Opts) {}
39 private:
40 void emitFileSummary(raw_ostream &OS, StringRef SF,
41 const FileCoverageSummary &FCS,
42 bool IsTotals = false) const;
43 std::string buildLinkToFile(StringRef SF,
44 const FileCoverageSummary &FCS) const;
47 /// A code coverage view which supports html-based rendering.
48 class SourceCoverageViewHTML : public SourceCoverageView {
49 void renderViewHeader(raw_ostream &OS) override;
51 void renderViewFooter(raw_ostream &OS) override;
53 void renderSourceName(raw_ostream &OS, bool WholeFile) override;
55 void renderLinePrefix(raw_ostream &OS, unsigned ViewDepth) override;
57 void renderLineSuffix(raw_ostream &OS, unsigned ViewDepth) override;
59 void renderViewDivider(raw_ostream &OS, unsigned ViewDepth) override;
61 void renderLine(raw_ostream &OS, LineRef L, const LineCoverageStats &LCS,
62 unsigned ExpansionCol, unsigned ViewDepth) override;
64 void renderExpansionSite(raw_ostream &OS, LineRef L,
65 const LineCoverageStats &LCS, unsigned ExpansionCol,
66 unsigned ViewDepth) override;
68 void renderExpansionView(raw_ostream &OS, ExpansionView &ESV,
69 unsigned ViewDepth) override;
71 void renderBranchView(raw_ostream &OS, BranchView &BRV,
72 unsigned ViewDepth) override;
74 void renderInstantiationView(raw_ostream &OS, InstantiationView &ISV,
75 unsigned ViewDepth) override;
77 void renderLineCoverageColumn(raw_ostream &OS,
78 const LineCoverageStats &Line) override;
80 void renderLineNumberColumn(raw_ostream &OS, unsigned LineNo) override;
82 void renderRegionMarkers(raw_ostream &OS, const LineCoverageStats &Line,
83 unsigned ViewDepth) override;
85 void renderTitle(raw_ostream &OS, StringRef Title) override;
87 void renderTableHeader(raw_ostream &OS, unsigned FirstUncoveredLineNo,
88 unsigned IndentLevel) override;
90 public:
91 SourceCoverageViewHTML(StringRef SourceName, const MemoryBuffer &File,
92 const CoverageViewOptions &Options,
93 coverage::CoverageData &&CoverageInfo)
94 : SourceCoverageView(SourceName, File, Options, std::move(CoverageInfo)) {
98 } // namespace llvm
100 #endif // LLVM_COV_SOURCECOVERAGEVIEWHTML_H