SourceCoverageViewText.h 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. //===----------------------------------------------------------------------===//
  12. #ifndef LLVM_COV_SOURCECOVERAGEVIEWTEXT_H
  13. #define LLVM_COV_SOURCECOVERAGEVIEWTEXT_H
  14. #include "SourceCoverageView.h"
  15. namespace llvm {
  16. using namespace coverage;
  17. /// A coverage printer for text output.
  18. class CoveragePrinterText : public CoveragePrinter {
  19. public:
  20. Expected<OwnedStream> createViewFile(StringRef Path,
  21. bool InToplevel) override;
  22. void closeViewFile(OwnedStream OS) override;
  23. Error createIndexFile(ArrayRef<std::string> SourceFiles,
  24. const CoverageMapping &Coverage,
  25. const CoverageFiltersMatchAll &Filters) override;
  26. CoveragePrinterText(const CoverageViewOptions &Opts)
  27. : CoveragePrinter(Opts) {}
  28. };
  29. /// A code coverage view which supports text-based rendering.
  30. class SourceCoverageViewText : public SourceCoverageView {
  31. void renderViewHeader(raw_ostream &OS) override;
  32. void renderViewFooter(raw_ostream &OS) override;
  33. void renderSourceName(raw_ostream &OS, bool WholeFile) override;
  34. void renderLinePrefix(raw_ostream &OS, unsigned ViewDepth) override;
  35. void renderLineSuffix(raw_ostream &OS, unsigned ViewDepth) override;
  36. void renderViewDivider(raw_ostream &OS, unsigned ViewDepth) override;
  37. void renderLine(raw_ostream &OS, LineRef L, const LineCoverageStats &LCS,
  38. unsigned ExpansionCol, unsigned ViewDepth) override;
  39. void renderExpansionSite(raw_ostream &OS, LineRef L,
  40. const LineCoverageStats &LCS, unsigned ExpansionCol,
  41. unsigned ViewDepth) override;
  42. void renderExpansionView(raw_ostream &OS, ExpansionView &ESV,
  43. unsigned ViewDepth) override;
  44. void renderBranchView(raw_ostream &OS, BranchView &BRV,
  45. unsigned ViewDepth) override;
  46. void renderInstantiationView(raw_ostream &OS, InstantiationView &ISV,
  47. unsigned ViewDepth) override;
  48. void renderLineCoverageColumn(raw_ostream &OS,
  49. const LineCoverageStats &Line) override;
  50. void renderLineNumberColumn(raw_ostream &OS, unsigned LineNo) override;
  51. void renderRegionMarkers(raw_ostream &OS, const LineCoverageStats &Line,
  52. unsigned ViewDepth) override;
  53. void renderTitle(raw_ostream &OS, StringRef Title) override;
  54. void renderTableHeader(raw_ostream &OS, unsigned FirstUncoveredLineNo,
  55. unsigned IndentLevel) override;
  56. public:
  57. SourceCoverageViewText(StringRef SourceName, const MemoryBuffer &File,
  58. const CoverageViewOptions &Options,
  59. CoverageData &&CoverageInfo)
  60. : SourceCoverageView(SourceName, File, Options, std::move(CoverageInfo)) {
  61. }
  62. };
  63. } // namespace llvm
  64. #endif // LLVM_COV_SOURCECOVERAGEVIEWTEXT_H