1 //===- SourceCoverageViewText.h - A text-based code coverage view ---------===//
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
7 //===----------------------------------------------------------------------===//
9 /// \file This file defines the interface to the text-based coverage renderer.
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_COV_SOURCECOVERAGEVIEWTEXT_H
14 #define LLVM_COV_SOURCECOVERAGEVIEWTEXT_H
16 #include "SourceCoverageView.h"
20 using namespace coverage
;
22 /// A coverage printer for text output.
23 class CoveragePrinterText
: public CoveragePrinter
{
25 Expected
<OwnedStream
> createViewFile(StringRef Path
,
26 bool InToplevel
) override
;
28 void closeViewFile(OwnedStream OS
) override
;
30 Error
createIndexFile(ArrayRef
<std::string
> SourceFiles
,
31 const CoverageMapping
&Coverage
,
32 const CoverageFiltersMatchAll
&Filters
) override
;
34 CoveragePrinterText(const CoverageViewOptions
&Opts
)
35 : CoveragePrinter(Opts
) {}
38 /// A coverage printer for text output, but generates index files in every
39 /// subdirectory to show a hierarchical view. The implementation is similar
40 /// to CoveragePrinterHTMLDirectory. So please refer to that for more comments.
41 class CoveragePrinterTextDirectory
: public CoveragePrinterText
{
43 using CoveragePrinterText::CoveragePrinterText
;
45 Error
createIndexFile(ArrayRef
<std::string
> SourceFiles
,
46 const CoverageMapping
&Coverage
,
47 const CoverageFiltersMatchAll
&Filters
) override
;
53 /// A code coverage view which supports text-based rendering.
54 class SourceCoverageViewText
: public SourceCoverageView
{
55 void renderViewHeader(raw_ostream
&OS
) override
;
57 void renderViewFooter(raw_ostream
&OS
) override
;
59 void renderSourceName(raw_ostream
&OS
, bool WholeFile
) override
;
61 void renderLinePrefix(raw_ostream
&OS
, unsigned ViewDepth
) override
;
63 void renderLineSuffix(raw_ostream
&OS
, unsigned ViewDepth
) override
;
65 void renderViewDivider(raw_ostream
&OS
, unsigned ViewDepth
) override
;
67 void renderLine(raw_ostream
&OS
, LineRef L
, const LineCoverageStats
&LCS
,
68 unsigned ExpansionCol
, unsigned ViewDepth
) override
;
70 void renderExpansionSite(raw_ostream
&OS
, LineRef L
,
71 const LineCoverageStats
&LCS
, unsigned ExpansionCol
,
72 unsigned ViewDepth
) override
;
74 void renderExpansionView(raw_ostream
&OS
, ExpansionView
&ESV
,
75 unsigned ViewDepth
) override
;
77 void renderBranchView(raw_ostream
&OS
, BranchView
&BRV
,
78 unsigned ViewDepth
) override
;
80 void renderInstantiationView(raw_ostream
&OS
, InstantiationView
&ISV
,
81 unsigned ViewDepth
) override
;
83 void renderLineCoverageColumn(raw_ostream
&OS
,
84 const LineCoverageStats
&Line
) override
;
86 void renderLineNumberColumn(raw_ostream
&OS
, unsigned LineNo
) override
;
88 void renderRegionMarkers(raw_ostream
&OS
, const LineCoverageStats
&Line
,
89 unsigned ViewDepth
) override
;
91 void renderTitle(raw_ostream
&OS
, StringRef Title
) override
;
93 void renderTableHeader(raw_ostream
&OS
, unsigned FirstUncoveredLineNo
,
94 unsigned IndentLevel
) override
;
97 SourceCoverageViewText(StringRef SourceName
, const MemoryBuffer
&File
,
98 const CoverageViewOptions
&Options
,
99 CoverageData
&&CoverageInfo
)
100 : SourceCoverageView(SourceName
, File
, Options
, std::move(CoverageInfo
)) {
106 #endif // LLVM_COV_SOURCECOVERAGEVIEWTEXT_H