Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / llvm / tools / llvm-cov / SourceCoverageViewText.h
blobade47ed3b5f5865578ba4bacb67ae66c768d0125
1 //===- SourceCoverageViewText.h - A text-based 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 text-based coverage renderer.
10 ///
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_COV_SOURCECOVERAGEVIEWTEXT_H
14 #define LLVM_COV_SOURCECOVERAGEVIEWTEXT_H
16 #include "SourceCoverageView.h"
18 namespace llvm {
20 using namespace coverage;
22 /// A coverage printer for text output.
23 class CoveragePrinterText : public CoveragePrinter {
24 public:
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 {
42 public:
43 using CoveragePrinterText::CoveragePrinterText;
45 Error createIndexFile(ArrayRef<std::string> SourceFiles,
46 const CoverageMapping &Coverage,
47 const CoverageFiltersMatchAll &Filters) override;
49 private:
50 struct Reporter;
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;
96 public:
97 SourceCoverageViewText(StringRef SourceName, const MemoryBuffer &File,
98 const CoverageViewOptions &Options,
99 CoverageData &&CoverageInfo)
100 : SourceCoverageView(SourceName, File, Options, std::move(CoverageInfo)) {
104 } // namespace llvm
106 #endif // LLVM_COV_SOURCECOVERAGEVIEWTEXT_H