10b57cec5SDimitry Andric //===- SourceCoverageViewHTML.h - A html 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 html coverage renderer. 100b57cec5SDimitry Andric /// 110b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 120b57cec5SDimitry Andric 130b57cec5SDimitry Andric #ifndef LLVM_COV_SOURCECOVERAGEVIEWHTML_H 140b57cec5SDimitry Andric #define LLVM_COV_SOURCECOVERAGEVIEWHTML_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 struct FileCoverageSummary; 230b57cec5SDimitry Andric 240b57cec5SDimitry Andric /// A coverage printer for html output. 250b57cec5SDimitry Andric class CoveragePrinterHTML : public CoveragePrinter { 260b57cec5SDimitry Andric public: 270b57cec5SDimitry Andric Expected<OwnedStream> createViewFile(StringRef Path, 280b57cec5SDimitry Andric bool InToplevel) override; 290b57cec5SDimitry Andric 300b57cec5SDimitry Andric void closeViewFile(OwnedStream OS) override; 310b57cec5SDimitry Andric 320b57cec5SDimitry Andric Error createIndexFile(ArrayRef<std::string> SourceFiles, 330b57cec5SDimitry Andric const coverage::CoverageMapping &Coverage, 340b57cec5SDimitry Andric const CoverageFiltersMatchAll &Filters) override; 350b57cec5SDimitry Andric CoveragePrinterHTML(const CoverageViewOptions & Opts)360b57cec5SDimitry Andric CoveragePrinterHTML(const CoverageViewOptions &Opts) 370b57cec5SDimitry Andric : CoveragePrinter(Opts) {} 380b57cec5SDimitry Andric 395f757f3fSDimitry Andric protected: 405f757f3fSDimitry Andric Error emitStyleSheet(); 41*0fca6ea1SDimitry Andric Error emitJavaScript(); 425f757f3fSDimitry Andric void emitReportHeader(raw_ostream &OSRef, const std::string &Title); 435f757f3fSDimitry Andric 440b57cec5SDimitry Andric private: 450b57cec5SDimitry Andric void emitFileSummary(raw_ostream &OS, StringRef SF, 460b57cec5SDimitry Andric const FileCoverageSummary &FCS, 470b57cec5SDimitry Andric bool IsTotals = false) const; 480b57cec5SDimitry Andric std::string buildLinkToFile(StringRef SF, 490b57cec5SDimitry Andric const FileCoverageSummary &FCS) const; 500b57cec5SDimitry Andric }; 510b57cec5SDimitry Andric 525f757f3fSDimitry Andric /// A coverage printer for html output, but generates index files in every 535f757f3fSDimitry Andric /// subdirectory to show a hierarchical view. 545f757f3fSDimitry Andric class CoveragePrinterHTMLDirectory : public CoveragePrinterHTML { 555f757f3fSDimitry Andric public: 565f757f3fSDimitry Andric using CoveragePrinterHTML::CoveragePrinterHTML; 575f757f3fSDimitry Andric 585f757f3fSDimitry Andric Error createIndexFile(ArrayRef<std::string> SourceFiles, 595f757f3fSDimitry Andric const coverage::CoverageMapping &Coverage, 605f757f3fSDimitry Andric const CoverageFiltersMatchAll &Filters) override; 615f757f3fSDimitry Andric 625f757f3fSDimitry Andric private: 635f757f3fSDimitry Andric struct Reporter; 645f757f3fSDimitry Andric }; 655f757f3fSDimitry Andric 660b57cec5SDimitry Andric /// A code coverage view which supports html-based rendering. 670b57cec5SDimitry Andric class SourceCoverageViewHTML : public SourceCoverageView { 680b57cec5SDimitry Andric void renderViewHeader(raw_ostream &OS) override; 690b57cec5SDimitry Andric 700b57cec5SDimitry Andric void renderViewFooter(raw_ostream &OS) override; 710b57cec5SDimitry Andric 720b57cec5SDimitry Andric void renderSourceName(raw_ostream &OS, bool WholeFile) override; 730b57cec5SDimitry Andric 740b57cec5SDimitry Andric void renderLinePrefix(raw_ostream &OS, unsigned ViewDepth) override; 750b57cec5SDimitry Andric 760b57cec5SDimitry Andric void renderLineSuffix(raw_ostream &OS, unsigned ViewDepth) override; 770b57cec5SDimitry Andric 780b57cec5SDimitry Andric void renderViewDivider(raw_ostream &OS, unsigned ViewDepth) override; 790b57cec5SDimitry Andric 800b57cec5SDimitry Andric void renderLine(raw_ostream &OS, LineRef L, const LineCoverageStats &LCS, 810b57cec5SDimitry Andric unsigned ExpansionCol, unsigned ViewDepth) override; 820b57cec5SDimitry Andric 830b57cec5SDimitry Andric void renderExpansionSite(raw_ostream &OS, LineRef L, 840b57cec5SDimitry Andric const LineCoverageStats &LCS, unsigned ExpansionCol, 850b57cec5SDimitry Andric unsigned ViewDepth) override; 860b57cec5SDimitry Andric 870b57cec5SDimitry Andric void renderExpansionView(raw_ostream &OS, ExpansionView &ESV, 880b57cec5SDimitry Andric unsigned ViewDepth) override; 890b57cec5SDimitry Andric 90e8d8bef9SDimitry Andric void renderBranchView(raw_ostream &OS, BranchView &BRV, 91e8d8bef9SDimitry Andric unsigned ViewDepth) override; 92e8d8bef9SDimitry Andric 935f757f3fSDimitry Andric void renderMCDCView(raw_ostream &OS, MCDCView &BRV, 945f757f3fSDimitry Andric unsigned ViewDepth) override; 955f757f3fSDimitry Andric 960b57cec5SDimitry Andric void renderInstantiationView(raw_ostream &OS, InstantiationView &ISV, 970b57cec5SDimitry Andric unsigned ViewDepth) override; 980b57cec5SDimitry Andric 990b57cec5SDimitry Andric void renderLineCoverageColumn(raw_ostream &OS, 1000b57cec5SDimitry Andric const LineCoverageStats &Line) override; 1010b57cec5SDimitry Andric 1020b57cec5SDimitry Andric void renderLineNumberColumn(raw_ostream &OS, unsigned LineNo) override; 1030b57cec5SDimitry Andric 1040b57cec5SDimitry Andric void renderRegionMarkers(raw_ostream &OS, const LineCoverageStats &Line, 1050b57cec5SDimitry Andric unsigned ViewDepth) override; 1060b57cec5SDimitry Andric 1070b57cec5SDimitry Andric void renderTitle(raw_ostream &OS, StringRef Title) override; 1080b57cec5SDimitry Andric 109*0fca6ea1SDimitry Andric void renderTableHeader(raw_ostream &OS, unsigned IndentLevel) override; 1100b57cec5SDimitry Andric 1110b57cec5SDimitry Andric public: SourceCoverageViewHTML(StringRef SourceName,const MemoryBuffer & File,const CoverageViewOptions & Options,coverage::CoverageData && CoverageInfo)1120b57cec5SDimitry Andric SourceCoverageViewHTML(StringRef SourceName, const MemoryBuffer &File, 1130b57cec5SDimitry Andric const CoverageViewOptions &Options, 1140b57cec5SDimitry Andric coverage::CoverageData &&CoverageInfo) 1150b57cec5SDimitry Andric : SourceCoverageView(SourceName, File, Options, std::move(CoverageInfo)) { 1160b57cec5SDimitry Andric } 1170b57cec5SDimitry Andric }; 1180b57cec5SDimitry Andric 1190b57cec5SDimitry Andric } // namespace llvm 1200b57cec5SDimitry Andric 1210b57cec5SDimitry Andric #endif // LLVM_COV_SOURCECOVERAGEVIEWHTML_H 122