blob: 8864d309fe9e146327bfabf5796003a63f59beac [file] [log] [blame]
Max Moroz1ef3a772018-01-04 19:33:29 +00001//===- CoverageReport.h - Code coverage report ----------------------------===//
Alex Lorenze82d89c2014-08-22 22:56:03 +00002//
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
Sean Evesonfa8ef352017-09-28 10:07:30 +000017#include "CoverageFilters.h"
Justin Bognerf91bc6c2015-02-14 02:01:24 +000018#include "CoverageSummaryInfo.h"
Chandler Carruthd9903882015-01-14 11:23:27 +000019#include "CoverageViewOptions.h"
Alex Lorenze82d89c2014-08-22 22:56:03 +000020
21namespace llvm {
22
23/// \brief Displays the code coverage report.
24class CoverageReport {
25 const CoverageViewOptions &Options;
Vedant Kumar702bb9d2016-09-06 22:45:57 +000026 const coverage::CoverageMapping &Coverage;
Alex Lorenze82d89c2014-08-22 22:56:03 +000027
Vedant Kumar627887b62016-09-09 01:32:49 +000028 void render(const FileCoverageSummary &File, raw_ostream &OS) const;
Vedant Kumarf2b067c2017-02-05 20:11:03 +000029 void render(const FunctionCoverageSummary &Function, const DemangleCache &DC,
30 raw_ostream &OS) const;
Alex Lorenze82d89c2014-08-22 22:56:03 +000031
32public:
Justin Bognerf91bc6c2015-02-14 02:01:24 +000033 CoverageReport(const CoverageViewOptions &Options,
Vedant Kumar702bb9d2016-09-06 22:45:57 +000034 const coverage::CoverageMapping &Coverage)
35 : Options(Options), Coverage(Coverage) {}
Alex Lorenze82d89c2014-08-22 22:56:03 +000036
Vedant Kumarf2b067c2017-02-05 20:11:03 +000037 void renderFunctionReports(ArrayRef<std::string> Files,
38 const DemangleCache &DC, raw_ostream &OS);
Alex Lorenze82d89c2014-08-22 22:56:03 +000039
Vedant Kumar627887b62016-09-09 01:32:49 +000040 /// Prepare file reports for the files specified in \p Files.
Vedant Kumar9cbf80a2016-09-19 00:38:25 +000041 static std::vector<FileCoverageSummary>
42 prepareFileReports(const coverage::CoverageMapping &Coverage,
Vedant Kumar72c3a112017-09-08 18:44:49 +000043 FileCoverageSummary &Totals, ArrayRef<std::string> Files,
Sean Evesonfa8ef352017-09-28 10:07:30 +000044 const CoverageViewOptions &Options,
45 const CoverageFilter &Filters = CoverageFiltersMatchAll());
Vedant Kumar627887b62016-09-09 01:32:49 +000046
Max Morozcc254ba2018-01-05 16:15:07 +000047 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
Vedant Kumar627887b62016-09-09 01:32:49 +000055 /// Render file reports for every unique file in the coverage mapping.
Max Moroz4220f892018-04-09 15:20:35 +000056 void renderFileReports(raw_ostream &OS,
57 const CoverageFilters &IgnoreFilenameFilters) const;
Vedant Kumar627887b62016-09-09 01:32:49 +000058
Max Moroz4a4bfa42017-10-13 14:44:51 +000059 /// Render file reports for the files specified in \p Files.
60 void renderFileReports(raw_ostream &OS, ArrayRef<std::string> Files) const;
61
Sean Evesonfa8ef352017-09-28 10:07:30 +000062 /// 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,
Sean Evesond932b2d2017-10-03 11:05:28 +000065 const CoverageFiltersMatchAll &Filters) const;
Alex Lorenze82d89c2014-08-22 22:56:03 +000066};
Vedant Kumar702bb9d2016-09-06 22:45:57 +000067
68} // end namespace llvm
Alex Lorenze82d89c2014-08-22 22:56:03 +000069
70#endif // LLVM_COV_COVERAGEREPORT_H