xref: /freebsd/contrib/llvm-project/llvm/tools/llvm-cov/SourceCoverageViewHTML.h (revision e8d8bef961a50d4dc22501cde4fb9fb0be1b2532)
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 
360b57cec5SDimitry Andric   CoveragePrinterHTML(const CoverageViewOptions &Opts)
370b57cec5SDimitry Andric       : CoveragePrinter(Opts) {}
380b57cec5SDimitry Andric 
390b57cec5SDimitry Andric private:
400b57cec5SDimitry Andric   void emitFileSummary(raw_ostream &OS, StringRef SF,
410b57cec5SDimitry Andric                        const FileCoverageSummary &FCS,
420b57cec5SDimitry Andric                        bool IsTotals = false) const;
430b57cec5SDimitry Andric   std::string buildLinkToFile(StringRef SF,
440b57cec5SDimitry Andric                               const FileCoverageSummary &FCS) const;
450b57cec5SDimitry Andric };
460b57cec5SDimitry Andric 
470b57cec5SDimitry Andric /// A code coverage view which supports html-based rendering.
480b57cec5SDimitry Andric class SourceCoverageViewHTML : public SourceCoverageView {
490b57cec5SDimitry Andric   void renderViewHeader(raw_ostream &OS) override;
500b57cec5SDimitry Andric 
510b57cec5SDimitry Andric   void renderViewFooter(raw_ostream &OS) override;
520b57cec5SDimitry Andric 
530b57cec5SDimitry Andric   void renderSourceName(raw_ostream &OS, bool WholeFile) override;
540b57cec5SDimitry Andric 
550b57cec5SDimitry Andric   void renderLinePrefix(raw_ostream &OS, unsigned ViewDepth) override;
560b57cec5SDimitry Andric 
570b57cec5SDimitry Andric   void renderLineSuffix(raw_ostream &OS, unsigned ViewDepth) override;
580b57cec5SDimitry Andric 
590b57cec5SDimitry Andric   void renderViewDivider(raw_ostream &OS, unsigned ViewDepth) override;
600b57cec5SDimitry Andric 
610b57cec5SDimitry Andric   void renderLine(raw_ostream &OS, LineRef L, const LineCoverageStats &LCS,
620b57cec5SDimitry Andric                   unsigned ExpansionCol, unsigned ViewDepth) override;
630b57cec5SDimitry Andric 
640b57cec5SDimitry Andric   void renderExpansionSite(raw_ostream &OS, LineRef L,
650b57cec5SDimitry Andric                            const LineCoverageStats &LCS, unsigned ExpansionCol,
660b57cec5SDimitry Andric                            unsigned ViewDepth) override;
670b57cec5SDimitry Andric 
680b57cec5SDimitry Andric   void renderExpansionView(raw_ostream &OS, ExpansionView &ESV,
690b57cec5SDimitry Andric                            unsigned ViewDepth) override;
700b57cec5SDimitry Andric 
71*e8d8bef9SDimitry Andric   void renderBranchView(raw_ostream &OS, BranchView &BRV,
72*e8d8bef9SDimitry Andric                         unsigned ViewDepth) override;
73*e8d8bef9SDimitry Andric 
740b57cec5SDimitry Andric   void renderInstantiationView(raw_ostream &OS, InstantiationView &ISV,
750b57cec5SDimitry Andric                                unsigned ViewDepth) override;
760b57cec5SDimitry Andric 
770b57cec5SDimitry Andric   void renderLineCoverageColumn(raw_ostream &OS,
780b57cec5SDimitry Andric                                 const LineCoverageStats &Line) override;
790b57cec5SDimitry Andric 
800b57cec5SDimitry Andric   void renderLineNumberColumn(raw_ostream &OS, unsigned LineNo) override;
810b57cec5SDimitry Andric 
820b57cec5SDimitry Andric   void renderRegionMarkers(raw_ostream &OS, const LineCoverageStats &Line,
830b57cec5SDimitry Andric                            unsigned ViewDepth) override;
840b57cec5SDimitry Andric 
850b57cec5SDimitry Andric   void renderTitle(raw_ostream &OS, StringRef Title) override;
860b57cec5SDimitry Andric 
870b57cec5SDimitry Andric   void renderTableHeader(raw_ostream &OS, unsigned FirstUncoveredLineNo,
880b57cec5SDimitry Andric                          unsigned IndentLevel) override;
890b57cec5SDimitry Andric 
900b57cec5SDimitry Andric public:
910b57cec5SDimitry Andric   SourceCoverageViewHTML(StringRef SourceName, const MemoryBuffer &File,
920b57cec5SDimitry Andric                          const CoverageViewOptions &Options,
930b57cec5SDimitry Andric                          coverage::CoverageData &&CoverageInfo)
940b57cec5SDimitry Andric       : SourceCoverageView(SourceName, File, Options, std::move(CoverageInfo)) {
950b57cec5SDimitry Andric   }
960b57cec5SDimitry Andric };
970b57cec5SDimitry Andric 
980b57cec5SDimitry Andric } // namespace llvm
990b57cec5SDimitry Andric 
1000b57cec5SDimitry Andric #endif // LLVM_COV_SOURCECOVERAGEVIEWHTML_H
101