1 //===- CoverageReport.h - Code coverage report ----------------------------===// 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 // This class implements rendering of a code coverage report. 10 // 11 //===----------------------------------------------------------------------===// 12 13 #ifndef LLVM_COV_COVERAGEREPORT_H 14 #define LLVM_COV_COVERAGEREPORT_H 15 16 #include "CoverageFilters.h" 17 #include "CoverageSummaryInfo.h" 18 #include "CoverageViewOptions.h" 19 20 namespace llvm { 21 22 /// Displays the code coverage report. 23 class CoverageReport { 24 const CoverageViewOptions &Options; 25 const coverage::CoverageMapping &Coverage; 26 27 void render(const FileCoverageSummary &File, raw_ostream &OS) const; 28 void render(const FunctionCoverageSummary &Function, const DemangleCache &DC, 29 raw_ostream &OS) const; 30 31 public: 32 CoverageReport(const CoverageViewOptions &Options, 33 const coverage::CoverageMapping &Coverage) 34 : Options(Options), Coverage(Coverage) {} 35 36 void renderFunctionReports(ArrayRef<std::string> Files, 37 const DemangleCache &DC, raw_ostream &OS); 38 39 /// Prepare file reports for the files specified in \p Files. 40 static std::vector<FileCoverageSummary> 41 prepareFileReports(const coverage::CoverageMapping &Coverage, 42 FileCoverageSummary &Totals, ArrayRef<std::string> Files, 43 const CoverageViewOptions &Options, 44 const CoverageFilter &Filters = CoverageFiltersMatchAll()); 45 46 static void 47 prepareSingleFileReport(const StringRef Filename, 48 const coverage::CoverageMapping *Coverage, 49 const CoverageViewOptions &Options, 50 const unsigned LCP, 51 FileCoverageSummary *FileReport, 52 const CoverageFilter *Filters); 53 54 /// Render file reports for every unique file in the coverage mapping. 55 void renderFileReports(raw_ostream &OS, 56 const CoverageFilters &IgnoreFilenameFilters) const; 57 58 /// Render file reports for the files specified in \p Files. 59 void renderFileReports(raw_ostream &OS, ArrayRef<std::string> Files) const; 60 61 /// Render file reports for the files specified in \p Files and the functions 62 /// in \p Filters. 63 void renderFileReports(raw_ostream &OS, ArrayRef<std::string> Files, 64 const CoverageFiltersMatchAll &Filters) const; 65 }; 66 67 } // end namespace llvm 68 69 #endif // LLVM_COV_COVERAGEREPORT_H 70