xref: /openbsd-src/gnu/llvm/llvm/tools/llvm-cov/SourceCoverageViewText.h (revision 09467b48e8bc8b4905716062da846024139afbf2)
1*09467b48Spatrick //===- SourceCoverageViewText.h - A text-based code coverage view ---------===//
2*09467b48Spatrick //
3*09467b48Spatrick // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*09467b48Spatrick // See https://llvm.org/LICENSE.txt for license information.
5*09467b48Spatrick // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*09467b48Spatrick //
7*09467b48Spatrick //===----------------------------------------------------------------------===//
8*09467b48Spatrick ///
9*09467b48Spatrick /// \file This file defines the interface to the text-based coverage renderer.
10*09467b48Spatrick ///
11*09467b48Spatrick //===----------------------------------------------------------------------===//
12*09467b48Spatrick 
13*09467b48Spatrick #ifndef LLVM_COV_SOURCECOVERAGEVIEWTEXT_H
14*09467b48Spatrick #define LLVM_COV_SOURCECOVERAGEVIEWTEXT_H
15*09467b48Spatrick 
16*09467b48Spatrick #include "SourceCoverageView.h"
17*09467b48Spatrick 
18*09467b48Spatrick namespace llvm {
19*09467b48Spatrick 
20*09467b48Spatrick using namespace coverage;
21*09467b48Spatrick 
22*09467b48Spatrick /// A coverage printer for text output.
23*09467b48Spatrick class CoveragePrinterText : public CoveragePrinter {
24*09467b48Spatrick public:
25*09467b48Spatrick   Expected<OwnedStream> createViewFile(StringRef Path,
26*09467b48Spatrick                                        bool InToplevel) override;
27*09467b48Spatrick 
28*09467b48Spatrick   void closeViewFile(OwnedStream OS) override;
29*09467b48Spatrick 
30*09467b48Spatrick   Error createIndexFile(ArrayRef<std::string> SourceFiles,
31*09467b48Spatrick                         const CoverageMapping &Coverage,
32*09467b48Spatrick                         const CoverageFiltersMatchAll &Filters) override;
33*09467b48Spatrick 
34*09467b48Spatrick   CoveragePrinterText(const CoverageViewOptions &Opts)
35*09467b48Spatrick       : CoveragePrinter(Opts) {}
36*09467b48Spatrick };
37*09467b48Spatrick 
38*09467b48Spatrick /// A code coverage view which supports text-based rendering.
39*09467b48Spatrick class SourceCoverageViewText : public SourceCoverageView {
40*09467b48Spatrick   void renderViewHeader(raw_ostream &OS) override;
41*09467b48Spatrick 
42*09467b48Spatrick   void renderViewFooter(raw_ostream &OS) override;
43*09467b48Spatrick 
44*09467b48Spatrick   void renderSourceName(raw_ostream &OS, bool WholeFile) override;
45*09467b48Spatrick 
46*09467b48Spatrick   void renderLinePrefix(raw_ostream &OS, unsigned ViewDepth) override;
47*09467b48Spatrick 
48*09467b48Spatrick   void renderLineSuffix(raw_ostream &OS, unsigned ViewDepth) override;
49*09467b48Spatrick 
50*09467b48Spatrick   void renderViewDivider(raw_ostream &OS, unsigned ViewDepth) override;
51*09467b48Spatrick 
52*09467b48Spatrick   void renderLine(raw_ostream &OS, LineRef L, const LineCoverageStats &LCS,
53*09467b48Spatrick                   unsigned ExpansionCol, unsigned ViewDepth) override;
54*09467b48Spatrick 
55*09467b48Spatrick   void renderExpansionSite(raw_ostream &OS, LineRef L,
56*09467b48Spatrick                            const LineCoverageStats &LCS, unsigned ExpansionCol,
57*09467b48Spatrick                            unsigned ViewDepth) override;
58*09467b48Spatrick 
59*09467b48Spatrick   void renderExpansionView(raw_ostream &OS, ExpansionView &ESV,
60*09467b48Spatrick                            unsigned ViewDepth) override;
61*09467b48Spatrick 
62*09467b48Spatrick   void renderInstantiationView(raw_ostream &OS, InstantiationView &ISV,
63*09467b48Spatrick                                unsigned ViewDepth) override;
64*09467b48Spatrick 
65*09467b48Spatrick   void renderLineCoverageColumn(raw_ostream &OS,
66*09467b48Spatrick                                 const LineCoverageStats &Line) override;
67*09467b48Spatrick 
68*09467b48Spatrick   void renderLineNumberColumn(raw_ostream &OS, unsigned LineNo) override;
69*09467b48Spatrick 
70*09467b48Spatrick   void renderRegionMarkers(raw_ostream &OS, const LineCoverageStats &Line,
71*09467b48Spatrick                            unsigned ViewDepth) override;
72*09467b48Spatrick 
73*09467b48Spatrick   void renderTitle(raw_ostream &OS, StringRef Title) override;
74*09467b48Spatrick 
75*09467b48Spatrick   void renderTableHeader(raw_ostream &OS, unsigned FirstUncoveredLineNo,
76*09467b48Spatrick                          unsigned IndentLevel) override;
77*09467b48Spatrick 
78*09467b48Spatrick public:
79*09467b48Spatrick   SourceCoverageViewText(StringRef SourceName, const MemoryBuffer &File,
80*09467b48Spatrick                          const CoverageViewOptions &Options,
81*09467b48Spatrick                          CoverageData &&CoverageInfo)
82*09467b48Spatrick       : SourceCoverageView(SourceName, File, Options, std::move(CoverageInfo)) {
83*09467b48Spatrick   }
84*09467b48Spatrick };
85*09467b48Spatrick 
86*09467b48Spatrick } // namespace llvm
87*09467b48Spatrick 
88*09467b48Spatrick #endif // LLVM_COV_SOURCECOVERAGEVIEWTEXT_H
89