Coverage Report

Created: 2019-05-19 14:56

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/llvm-cov/SourceCoverageViewHTML.h
Line
Count
Source
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
//===----------------------------------------------------------------------===//
12
13
#ifndef LLVM_COV_SOURCECOVERAGEVIEWHTML_H
14
#define LLVM_COV_SOURCECOVERAGEVIEWHTML_H
15
16
#include "SourceCoverageView.h"
17
18
namespace llvm {
19
20
using namespace coverage;
21
22
struct FileCoverageSummary;
23
24
/// A coverage printer for html output.
25
class CoveragePrinterHTML : public CoveragePrinter {
26
public:
27
  Expected<OwnedStream> createViewFile(StringRef Path,
28
                                       bool InToplevel) override;
29
30
  void closeViewFile(OwnedStream OS) override;
31
32
  Error createIndexFile(ArrayRef<std::string> SourceFiles,
33
                        const coverage::CoverageMapping &Coverage,
34
                        const CoverageFiltersMatchAll &Filters) override;
35
36
  CoveragePrinterHTML(const CoverageViewOptions &Opts)
37
24
      : CoveragePrinter(Opts) {}
38
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;
45
};
46
47
/// A code coverage view which supports html-based rendering.
48
class SourceCoverageViewHTML : public SourceCoverageView {
49
  void renderViewHeader(raw_ostream &OS) override;
50
51
  void renderViewFooter(raw_ostream &OS) override;
52
53
  void renderSourceName(raw_ostream &OS, bool WholeFile) override;
54
55
  void renderLinePrefix(raw_ostream &OS, unsigned ViewDepth) override;
56
57
  void renderLineSuffix(raw_ostream &OS, unsigned ViewDepth) override;
58
59
  void renderViewDivider(raw_ostream &OS, unsigned ViewDepth) override;
60
61
  void renderLine(raw_ostream &OS, LineRef L, const LineCoverageStats &LCS,
62
                  unsigned ExpansionCol, unsigned ViewDepth) override;
63
64
  void renderExpansionSite(raw_ostream &OS, LineRef L,
65
                           const LineCoverageStats &LCS, unsigned ExpansionCol,
66
                           unsigned ViewDepth) override;
67
68
  void renderExpansionView(raw_ostream &OS, ExpansionView &ESV,
69
                           unsigned ViewDepth) override;
70
71
  void renderInstantiationView(raw_ostream &OS, InstantiationView &ISV,
72
                               unsigned ViewDepth) override;
73
74
  void renderLineCoverageColumn(raw_ostream &OS,
75
                                const LineCoverageStats &Line) override;
76
77
  void renderLineNumberColumn(raw_ostream &OS, unsigned LineNo) override;
78
79
  void renderRegionMarkers(raw_ostream &OS, const LineCoverageStats &Line,
80
                           unsigned ViewDepth) override;
81
82
  void renderTitle(raw_ostream &OS, StringRef Title) override;
83
84
  void renderTableHeader(raw_ostream &OS, unsigned FirstUncoveredLineNo,
85
                         unsigned IndentLevel) override;
86
87
public:
88
  SourceCoverageViewHTML(StringRef SourceName, const MemoryBuffer &File,
89
                         const CoverageViewOptions &Options,
90
                         coverage::CoverageData &&CoverageInfo)
91
73
      : SourceCoverageView(SourceName, File, Options, std::move(CoverageInfo)) {
92
73
  }
93
};
94
95
} // namespace llvm
96
97
#endif // LLVM_COV_SOURCECOVERAGEVIEWHTML_H