SourceCoverageViewHTML.h 3.6 KB

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