blob: 7a416497e258eda35296619299ebf62a54815de4 [file] [log] [blame]
Alex Lorenze82d89c2014-08-22 22:56:03 +00001//===- 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
Justin Bognerf91bc6c2015-02-14 02:01:24 +000017#include "CoverageSummaryInfo.h"
Chandler Carruthd9903882015-01-14 11:23:27 +000018#include "CoverageViewOptions.h"
Alex Lorenze82d89c2014-08-22 22:56:03 +000019
20namespace llvm {
21
22/// \brief Displays the code coverage report.
23class CoverageReport {
24 const CoverageViewOptions &Options;
Vedant Kumar702bb9d2016-09-06 22:45:57 +000025 const coverage::CoverageMapping &Coverage;
Alex Lorenze82d89c2014-08-22 22:56:03 +000026
Vedant Kumar627887b62016-09-09 01:32:49 +000027 void render(const FileCoverageSummary &File, raw_ostream &OS) const;
28 void render(const FunctionCoverageSummary &Function, raw_ostream &OS) const;
Alex Lorenze82d89c2014-08-22 22:56:03 +000029
30public:
Justin Bognerf91bc6c2015-02-14 02:01:24 +000031 CoverageReport(const CoverageViewOptions &Options,
Vedant Kumar702bb9d2016-09-06 22:45:57 +000032 const coverage::CoverageMapping &Coverage)
33 : Options(Options), Coverage(Coverage) {}
Alex Lorenze82d89c2014-08-22 22:56:03 +000034
Vedant Kumarbc647982016-09-23 18:57:32 +000035 void renderFunctionReports(ArrayRef<std::string> Files, raw_ostream &OS);
Alex Lorenze82d89c2014-08-22 22:56:03 +000036
Vedant Kumar627887b62016-09-09 01:32:49 +000037 /// Prepare file reports for the files specified in \p Files.
Vedant Kumar9cbf80a2016-09-19 00:38:25 +000038 static std::vector<FileCoverageSummary>
39 prepareFileReports(const coverage::CoverageMapping &Coverage,
Vedant Kumarbc647982016-09-23 18:57:32 +000040 FileCoverageSummary &Totals, ArrayRef<std::string> Files);
Vedant Kumar627887b62016-09-09 01:32:49 +000041
42 /// Render file reports for every unique file in the coverage mapping.
43 void renderFileReports(raw_ostream &OS) const;
44
45 /// Render file reports for the files specified in \p Files.
Vedant Kumarbc647982016-09-23 18:57:32 +000046 void renderFileReports(raw_ostream &OS, ArrayRef<std::string> Files) const;
Alex Lorenze82d89c2014-08-22 22:56:03 +000047};
Vedant Kumar702bb9d2016-09-06 22:45:57 +000048
49} // end namespace llvm
Alex Lorenze82d89c2014-08-22 22:56:03 +000050
51#endif // LLVM_COV_COVERAGEREPORT_H