xref: /freebsd-src/contrib/llvm-project/llvm/tools/llvm-cov/SourceCoverageViewText.h (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
10b57cec5SDimitry Andric //===- SourceCoverageViewText.h - A text-based code coverage view ---------===//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric ///
90b57cec5SDimitry Andric /// \file This file defines the interface to the text-based coverage renderer.
100b57cec5SDimitry Andric ///
110b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
120b57cec5SDimitry Andric 
130b57cec5SDimitry Andric #ifndef LLVM_COV_SOURCECOVERAGEVIEWTEXT_H
140b57cec5SDimitry Andric #define LLVM_COV_SOURCECOVERAGEVIEWTEXT_H
150b57cec5SDimitry Andric 
160b57cec5SDimitry Andric #include "SourceCoverageView.h"
170b57cec5SDimitry Andric 
180b57cec5SDimitry Andric namespace llvm {
190b57cec5SDimitry Andric 
200b57cec5SDimitry Andric using namespace coverage;
210b57cec5SDimitry Andric 
220b57cec5SDimitry Andric /// A coverage printer for text output.
230b57cec5SDimitry Andric class CoveragePrinterText : public CoveragePrinter {
240b57cec5SDimitry Andric public:
250b57cec5SDimitry Andric   Expected<OwnedStream> createViewFile(StringRef Path,
260b57cec5SDimitry Andric                                        bool InToplevel) override;
270b57cec5SDimitry Andric 
280b57cec5SDimitry Andric   void closeViewFile(OwnedStream OS) override;
290b57cec5SDimitry Andric 
300b57cec5SDimitry Andric   Error createIndexFile(ArrayRef<std::string> SourceFiles,
310b57cec5SDimitry Andric                         const CoverageMapping &Coverage,
320b57cec5SDimitry Andric                         const CoverageFiltersMatchAll &Filters) override;
330b57cec5SDimitry Andric 
340b57cec5SDimitry Andric   CoveragePrinterText(const CoverageViewOptions &Opts)
350b57cec5SDimitry Andric       : CoveragePrinter(Opts) {}
360b57cec5SDimitry Andric };
370b57cec5SDimitry Andric 
385f757f3fSDimitry Andric /// A coverage printer for text output, but generates index files in every
395f757f3fSDimitry Andric /// subdirectory to show a hierarchical view. The implementation is similar
405f757f3fSDimitry Andric /// to CoveragePrinterHTMLDirectory. So please refer to that for more comments.
415f757f3fSDimitry Andric class CoveragePrinterTextDirectory : public CoveragePrinterText {
425f757f3fSDimitry Andric public:
435f757f3fSDimitry Andric   using CoveragePrinterText::CoveragePrinterText;
445f757f3fSDimitry Andric 
455f757f3fSDimitry Andric   Error createIndexFile(ArrayRef<std::string> SourceFiles,
465f757f3fSDimitry Andric                         const CoverageMapping &Coverage,
475f757f3fSDimitry Andric                         const CoverageFiltersMatchAll &Filters) override;
485f757f3fSDimitry Andric 
495f757f3fSDimitry Andric private:
505f757f3fSDimitry Andric   struct Reporter;
515f757f3fSDimitry Andric };
525f757f3fSDimitry Andric 
530b57cec5SDimitry Andric /// A code coverage view which supports text-based rendering.
540b57cec5SDimitry Andric class SourceCoverageViewText : public SourceCoverageView {
550b57cec5SDimitry Andric   void renderViewHeader(raw_ostream &OS) override;
560b57cec5SDimitry Andric 
570b57cec5SDimitry Andric   void renderViewFooter(raw_ostream &OS) override;
580b57cec5SDimitry Andric 
590b57cec5SDimitry Andric   void renderSourceName(raw_ostream &OS, bool WholeFile) override;
600b57cec5SDimitry Andric 
610b57cec5SDimitry Andric   void renderLinePrefix(raw_ostream &OS, unsigned ViewDepth) override;
620b57cec5SDimitry Andric 
630b57cec5SDimitry Andric   void renderLineSuffix(raw_ostream &OS, unsigned ViewDepth) override;
640b57cec5SDimitry Andric 
650b57cec5SDimitry Andric   void renderViewDivider(raw_ostream &OS, unsigned ViewDepth) override;
660b57cec5SDimitry Andric 
670b57cec5SDimitry Andric   void renderLine(raw_ostream &OS, LineRef L, const LineCoverageStats &LCS,
680b57cec5SDimitry Andric                   unsigned ExpansionCol, unsigned ViewDepth) override;
690b57cec5SDimitry Andric 
700b57cec5SDimitry Andric   void renderExpansionSite(raw_ostream &OS, LineRef L,
710b57cec5SDimitry Andric                            const LineCoverageStats &LCS, unsigned ExpansionCol,
720b57cec5SDimitry Andric                            unsigned ViewDepth) override;
730b57cec5SDimitry Andric 
740b57cec5SDimitry Andric   void renderExpansionView(raw_ostream &OS, ExpansionView &ESV,
750b57cec5SDimitry Andric                            unsigned ViewDepth) override;
760b57cec5SDimitry Andric 
77e8d8bef9SDimitry Andric   void renderBranchView(raw_ostream &OS, BranchView &BRV,
78e8d8bef9SDimitry Andric                         unsigned ViewDepth) override;
79e8d8bef9SDimitry Andric 
805f757f3fSDimitry Andric   void renderMCDCView(raw_ostream &OS, MCDCView &BRV,
815f757f3fSDimitry Andric                       unsigned ViewDepth) override;
825f757f3fSDimitry Andric 
830b57cec5SDimitry Andric   void renderInstantiationView(raw_ostream &OS, InstantiationView &ISV,
840b57cec5SDimitry Andric                                unsigned ViewDepth) override;
850b57cec5SDimitry Andric 
860b57cec5SDimitry Andric   void renderLineCoverageColumn(raw_ostream &OS,
870b57cec5SDimitry Andric                                 const LineCoverageStats &Line) override;
880b57cec5SDimitry Andric 
890b57cec5SDimitry Andric   void renderLineNumberColumn(raw_ostream &OS, unsigned LineNo) override;
900b57cec5SDimitry Andric 
910b57cec5SDimitry Andric   void renderRegionMarkers(raw_ostream &OS, const LineCoverageStats &Line,
920b57cec5SDimitry Andric                            unsigned ViewDepth) override;
930b57cec5SDimitry Andric 
940b57cec5SDimitry Andric   void renderTitle(raw_ostream &OS, StringRef Title) override;
950b57cec5SDimitry Andric 
96*0fca6ea1SDimitry Andric   void renderTableHeader(raw_ostream &OS, unsigned IndentLevel) override;
970b57cec5SDimitry Andric 
980b57cec5SDimitry Andric public:
990b57cec5SDimitry Andric   SourceCoverageViewText(StringRef SourceName, const MemoryBuffer &File,
1000b57cec5SDimitry Andric                          const CoverageViewOptions &Options,
1010b57cec5SDimitry Andric                          CoverageData &&CoverageInfo)
1020b57cec5SDimitry Andric       : SourceCoverageView(SourceName, File, Options, std::move(CoverageInfo)) {
1030b57cec5SDimitry Andric   }
1040b57cec5SDimitry Andric };
1050b57cec5SDimitry Andric 
1060b57cec5SDimitry Andric } // namespace llvm
1070b57cec5SDimitry Andric 
1080b57cec5SDimitry Andric #endif // LLVM_COV_SOURCECOVERAGEVIEWTEXT_H
109