1 //===- SourceCoverageViewText.h - A text-based code coverage view ---------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 /// 10 /// \file This file defines the interface to the text-based coverage renderer. 11 /// 12 //===----------------------------------------------------------------------===// 13 14 #ifndef LLVM_COV_SOURCECOVERAGEVIEWTEXT_H 15 #define LLVM_COV_SOURCECOVERAGEVIEWTEXT_H 16 17 #include "SourceCoverageView.h" 18 19 namespace llvm { 20 21 /// \brief A coverage printer for text output. 22 class CoveragePrinterText : public CoveragePrinter { 23 public: 24 Expected<OwnedStream> createViewFile(StringRef Path, 25 bool InToplevel) override; 26 27 void closeViewFile(OwnedStream OS) override; 28 29 Error createIndexFile(ArrayRef<StringRef> SourceFiles) override; 30 CoveragePrinterText(const CoverageViewOptions & Opts)31 CoveragePrinterText(const CoverageViewOptions &Opts) 32 : CoveragePrinter(Opts) {} 33 }; 34 35 /// \brief A code coverage view which supports text-based rendering. 36 class SourceCoverageViewText : public SourceCoverageView { 37 void renderViewHeader(raw_ostream &OS) override; 38 39 void renderViewFooter(raw_ostream &OS) override; 40 41 void renderSourceName(raw_ostream &OS) override; 42 43 void renderLinePrefix(raw_ostream &OS, unsigned ViewDepth) override; 44 45 void renderLineSuffix(raw_ostream &OS, unsigned ViewDepth) override; 46 47 void renderViewDivider(raw_ostream &OS, unsigned ViewDepth) override; 48 49 void renderLine(raw_ostream &OS, LineRef L, 50 const coverage::CoverageSegment *WrappedSegment, 51 CoverageSegmentArray Segments, unsigned ExpansionCol, 52 unsigned ViewDepth) override; 53 54 void renderExpansionSite(raw_ostream &OS, LineRef L, 55 const coverage::CoverageSegment *WrappedSegment, 56 CoverageSegmentArray Segments, unsigned ExpansionCol, 57 unsigned ViewDepth) override; 58 59 void renderExpansionView(raw_ostream &OS, ExpansionView &ESV, 60 unsigned ViewDepth) override; 61 62 void renderInstantiationView(raw_ostream &OS, InstantiationView &ISV, 63 unsigned ViewDepth) override; 64 65 void renderLineCoverageColumn(raw_ostream &OS, 66 const LineCoverageStats &Line) override; 67 68 void renderLineNumberColumn(raw_ostream &OS, unsigned LineNo) override; 69 70 void renderRegionMarkers(raw_ostream &OS, CoverageSegmentArray Segments, 71 unsigned ViewDepth) override; 72 73 public: SourceCoverageViewText(StringRef SourceName,const MemoryBuffer & File,const CoverageViewOptions & Options,coverage::CoverageData && CoverageInfo)74 SourceCoverageViewText(StringRef SourceName, const MemoryBuffer &File, 75 const CoverageViewOptions &Options, 76 coverage::CoverageData &&CoverageInfo) 77 : SourceCoverageView(SourceName, File, Options, std::move(CoverageInfo)) { 78 } 79 }; 80 81 } // namespace llvm 82 83 #endif // LLVM_COV_SOURCECOVERAGEVIEWTEXT_H 84