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