blob: f9a092f510b504616c03c5a6030fad8582696be8 [file] [log] [blame]
Max Moroz1ef3a772018-01-04 19:33:29 +00001//===- CoverageReport.h - Code coverage report ----------------------------===//
Alex Lorenze82d89c2014-08-22 22:56:03 +00002//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// 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
Alex Lorenze82d89c2014-08-22 22:56:03 +00006//
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
Sean Evesonfa8ef352017-09-28 10:07:30 +000016#include "CoverageFilters.h"
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
Adrian Prantl5f8f34e42018-05-01 15:54:18 +000022/// Displays the code coverage report.
Alex Lorenze82d89c2014-08-22 22:56:03 +000023class 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;
Vedant Kumarf2b067c2017-02-05 20:11:03 +000028 void render(const FunctionCoverageSummary &Function, const DemangleCache &DC,
29 raw_ostream &OS) const;
Alex Lorenze82d89c2014-08-22 22:56:03 +000030
31public:
Justin Bognerf91bc6c2015-02-14 02:01:24 +000032 CoverageReport(const CoverageViewOptions &Options,
Vedant Kumar702bb9d2016-09-06 22:45:57 +000033 const coverage::CoverageMapping &Coverage)
34 : Options(Options), Coverage(Coverage) {}
Alex Lorenze82d89c2014-08-22 22:56:03 +000035
Vedant Kumarf2b067c2017-02-05 20:11:03 +000036 void renderFunctionReports(ArrayRef<std::string> Files,
37 const DemangleCache &DC, raw_ostream &OS);
Alex Lorenze82d89c2014-08-22 22:56:03 +000038
Vedant Kumar627887b62016-09-09 01:32:49 +000039 /// Prepare file reports for the files specified in \p Files.
Vedant Kumar9cbf80a2016-09-19 00:38:25 +000040 static std::vector<FileCoverageSummary>
41 prepareFileReports(const coverage::CoverageMapping &Coverage,
Vedant Kumar72c3a112017-09-08 18:44:49 +000042 FileCoverageSummary &Totals, ArrayRef<std::string> Files,
Sean Evesonfa8ef352017-09-28 10:07:30 +000043 const CoverageViewOptions &Options,
44 const CoverageFilter &Filters = CoverageFiltersMatchAll());
Vedant Kumar627887b62016-09-09 01:32:49 +000045
Max Morozcc254ba2018-01-05 16:15:07 +000046 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
Vedant Kumar627887b62016-09-09 01:32:49 +000054 /// Render file reports for every unique file in the coverage mapping.
Max Moroz4220f892018-04-09 15:20:35 +000055 void renderFileReports(raw_ostream &OS,
56 const CoverageFilters &IgnoreFilenameFilters) const;
Vedant Kumar627887b62016-09-09 01:32:49 +000057
Max Moroz4a4bfa42017-10-13 14:44:51 +000058 /// Render file reports for the files specified in \p Files.
59 void renderFileReports(raw_ostream &OS, ArrayRef<std::string> Files) const;
60
Sean Evesonfa8ef352017-09-28 10:07:30 +000061 /// 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,
Sean Evesond932b2d2017-10-03 11:05:28 +000064 const CoverageFiltersMatchAll &Filters) const;
Alex Lorenze82d89c2014-08-22 22:56:03 +000065};
Vedant Kumar702bb9d2016-09-06 22:45:57 +000066
67} // end namespace llvm
Alex Lorenze82d89c2014-08-22 22:56:03 +000068
69#endif // LLVM_COV_COVERAGEREPORT_H