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 code coverage view which supports text-based rendering.
39 class SourceCoverageViewText
: public SourceCoverageView
{
40 void renderViewHeader(raw_ostream
&OS
) override
;
42 void renderViewFooter(raw_ostream
&OS
) override
;
44 void renderSourceName(raw_ostream
&OS
, bool WholeFile
) override
;
46 void renderLinePrefix(raw_ostream
&OS
, unsigned ViewDepth
) override
;
48 void renderLineSuffix(raw_ostream
&OS
, unsigned ViewDepth
) override
;
50 void renderViewDivider(raw_ostream
&OS
, unsigned ViewDepth
) override
;
52 void renderLine(raw_ostream
&OS
, LineRef L
, const LineCoverageStats
&LCS
,
53 unsigned ExpansionCol
, unsigned ViewDepth
) override
;
55 void renderExpansionSite(raw_ostream
&OS
, LineRef L
,
56 const LineCoverageStats
&LCS
, unsigned ExpansionCol
,
57 unsigned ViewDepth
) override
;
59 void renderExpansionView(raw_ostream
&OS
, ExpansionView
&ESV
,
60 unsigned ViewDepth
) override
;
62 void renderInstantiationView(raw_ostream
&OS
, InstantiationView
&ISV
,
63 unsigned ViewDepth
) override
;
65 void renderLineCoverageColumn(raw_ostream
&OS
,
66 const LineCoverageStats
&Line
) override
;
68 void renderLineNumberColumn(raw_ostream
&OS
, unsigned LineNo
) override
;
70 void renderRegionMarkers(raw_ostream
&OS
, const LineCoverageStats
&Line
,
71 unsigned ViewDepth
) override
;
73 void renderTitle(raw_ostream
&OS
, StringRef Title
) override
;
75 void renderTableHeader(raw_ostream
&OS
, unsigned FirstUncoveredLineNo
,
76 unsigned IndentLevel
) override
;
79 SourceCoverageViewText(StringRef SourceName
, const MemoryBuffer
&File
,
80 const CoverageViewOptions
&Options
,
81 CoverageData
&&CoverageInfo
)
82 : SourceCoverageView(SourceName
, File
, Options
, std::move(CoverageInfo
)) {
88 #endif // LLVM_COV_SOURCECOVERAGEVIEWTEXT_H