blob: 4c02bbcf2a386d12d8dc91420534b8aad64df4be [file] [log] [blame]
Alex Lorenze82d89c2014-08-22 22:56:03 +00001//===- CoverageReport.cpp - 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#include "CoverageReport.h"
Alex Lorenze82d89c2014-08-22 22:56:03 +000015#include "RenderingSupport.h"
Vedant Kumar016111f2016-09-19 00:38:23 +000016#include "llvm/ADT/DenseMap.h"
Alex Lorenze82d89c2014-08-22 22:56:03 +000017#include "llvm/Support/FileSystem.h"
Chandler Carruthd9903882015-01-14 11:23:27 +000018#include "llvm/Support/Format.h"
Vedant Kumard938dfb2016-09-09 17:37:11 +000019#include "llvm/Support/Path.h"
Vedant Kumar702bb9d2016-09-06 22:45:57 +000020#include <numeric>
Alex Lorenze82d89c2014-08-22 22:56:03 +000021
22using namespace llvm;
Vedant Kumar702bb9d2016-09-06 22:45:57 +000023
Alex Lorenze82d89c2014-08-22 22:56:03 +000024namespace {
Vedant Kumar702bb9d2016-09-06 22:45:57 +000025
Alex Lorenze82d89c2014-08-22 22:56:03 +000026/// \brief Helper struct which prints trimmed and aligned columns.
27struct Column {
Vedant Kumar702bb9d2016-09-06 22:45:57 +000028 enum TrimKind { NoTrim, WidthTrim, RightTrim };
Alex Lorenze82d89c2014-08-22 22:56:03 +000029
30 enum AlignmentKind { LeftAlignment, RightAlignment };
31
32 StringRef Str;
33 unsigned Width;
34 TrimKind Trim;
35 AlignmentKind Alignment;
36
37 Column(StringRef Str, unsigned Width)
Vedant Kumarc3c39e72015-09-14 23:26:36 +000038 : Str(Str), Width(Width), Trim(WidthTrim), Alignment(LeftAlignment) {}
Alex Lorenze82d89c2014-08-22 22:56:03 +000039
40 Column &set(TrimKind Value) {
41 Trim = Value;
42 return *this;
43 }
44
45 Column &set(AlignmentKind Value) {
46 Alignment = Value;
47 return *this;
48 }
49
Vedant Kumar702bb9d2016-09-06 22:45:57 +000050 void render(raw_ostream &OS) const {
51 if (Str.size() <= Width) {
52 if (Alignment == RightAlignment) {
53 OS.indent(Width - Str.size());
54 OS << Str;
55 return;
56 }
57 OS << Str;
58 OS.indent(Width - Str.size());
59 return;
60 }
61
62 switch (Trim) {
63 case NoTrim:
64 OS << Str;
65 break;
66 case WidthTrim:
67 OS << Str.substr(0, Width);
68 break;
69 case RightTrim:
70 OS << Str.substr(0, Width - 3) << "...";
71 break;
72 }
73 }
Alex Lorenze82d89c2014-08-22 22:56:03 +000074};
Vedant Kumarc3c39e72015-09-14 23:26:36 +000075
Alex Lorenze82d89c2014-08-22 22:56:03 +000076raw_ostream &operator<<(raw_ostream &OS, const Column &Value) {
77 Value.render(OS);
78 return OS;
79}
Alex Lorenze82d89c2014-08-22 22:56:03 +000080
Vedant Kumar702bb9d2016-09-06 22:45:57 +000081Column column(StringRef Str, unsigned Width) { return Column(Str, Width); }
Alex Lorenze82d89c2014-08-22 22:56:03 +000082
83template <typename T>
Vedant Kumar702bb9d2016-09-06 22:45:57 +000084Column column(StringRef Str, unsigned Width, const T &Value) {
Alex Lorenze82d89c2014-08-22 22:56:03 +000085 return Column(Str, Width).set(Value);
86}
87
Ying Yie59ee432016-07-22 12:46:13 +000088// Specify the default column widths.
Vedant Kumar016111f2016-09-19 00:38:23 +000089size_t FileReportColumns[] = {25, 12, 18, 10, 12, 18, 10,
90 16, 16, 10, 12, 18, 10};
Vedant Kumar702bb9d2016-09-06 22:45:57 +000091size_t FunctionReportColumns[] = {25, 10, 8, 8, 10, 8, 8};
Alex Lorenze82d89c2014-08-22 22:56:03 +000092
Vedant Kumar702bb9d2016-09-06 22:45:57 +000093/// \brief Adjust column widths to fit long file paths and function names.
Vedant Kumardab0ec12016-09-19 00:38:16 +000094void adjustColumnWidths(ArrayRef<StringRef> Files,
95 ArrayRef<StringRef> Functions) {
96 for (StringRef Filename : Files)
Vedant Kumaraaead332015-10-21 16:03:32 +000097 FileReportColumns[0] = std::max(FileReportColumns[0], Filename.size());
Vedant Kumardab0ec12016-09-19 00:38:16 +000098 for (StringRef Funcname : Functions)
99 FunctionReportColumns[0] =
100 std::max(FunctionReportColumns[0], Funcname.size());
Vedant Kumaraaead332015-10-21 16:03:32 +0000101}
102
Vedant Kumar702bb9d2016-09-06 22:45:57 +0000103/// \brief Prints a horizontal divider long enough to cover the given column
104/// widths.
105void renderDivider(ArrayRef<size_t> ColumnWidths, raw_ostream &OS) {
106 size_t Length = std::accumulate(ColumnWidths.begin(), ColumnWidths.end(), 0);
107 for (size_t I = 0; I < Length; ++I)
Alex Lorenze82d89c2014-08-22 22:56:03 +0000108 OS << '-';
109}
110
Vedant Kumar5053b112016-09-06 22:46:00 +0000111/// \brief Return the color which correponds to the coverage percentage of a
112/// certain metric.
Alex Lorenze82d89c2014-08-22 22:56:03 +0000113template <typename T>
Vedant Kumar702bb9d2016-09-06 22:45:57 +0000114raw_ostream::Colors determineCoveragePercentageColor(const T &Info) {
Alex Lorenze82d89c2014-08-22 22:56:03 +0000115 if (Info.isFullyCovered())
116 return raw_ostream::GREEN;
117 return Info.getPercentCovered() >= 80.0 ? raw_ostream::YELLOW
118 : raw_ostream::RED;
119}
120
Vedant Kumar11813282017-02-23 22:20:32 +0000121/// \brief Get the number of redundant path components in each path in \p Paths.
122unsigned getNumRedundantPathComponents(ArrayRef<std::string> Paths) {
123 // To start, set the number of redundant path components to the maximum
124 // possible value.
125 SmallVector<StringRef, 8> FirstPathComponents{sys::path::begin(Paths[0]),
126 sys::path::end(Paths[0])};
127 unsigned NumRedundant = FirstPathComponents.size();
128
129 for (unsigned I = 1, E = Paths.size(); NumRedundant > 0 && I < E; ++I) {
130 StringRef Path = Paths[I];
131 for (const auto &Component :
132 enumerate(make_range(sys::path::begin(Path), sys::path::end(Path)))) {
133 // Do not increase the number of redundant components: that would remove
134 // useful parts of already-visited paths.
Zachary Turner368c3fa2017-03-13 16:32:08 +0000135 if (Component.index() >= NumRedundant)
Vedant Kumar5cd496b2016-09-26 17:57:13 +0000136 break;
Vedant Kumar11813282017-02-23 22:20:32 +0000137
138 // Lower the number of redundant components when there's a mismatch
139 // between the first path, and the path under consideration.
Zachary Turner368c3fa2017-03-13 16:32:08 +0000140 if (FirstPathComponents[Component.index()] != Component.value()) {
141 NumRedundant = Component.index();
Vedant Kumar11813282017-02-23 22:20:32 +0000142 break;
143 }
144 }
Vedant Kumarfa754372016-09-08 00:56:43 +0000145 }
Vedant Kumar11813282017-02-23 22:20:32 +0000146
147 return NumRedundant;
148}
149
150/// \brief Determine the length of the longest redundant prefix of the paths in
151/// \p Paths.
152unsigned getRedundantPrefixLen(ArrayRef<std::string> Paths) {
153 // If there's at most one path, no path components are redundant.
154 if (Paths.size() <= 1)
155 return 0;
156
157 unsigned PrefixLen = 0;
158 unsigned NumRedundant = getNumRedundantPathComponents(Paths);
159 auto Component = sys::path::begin(Paths[0]);
160 for (unsigned I = 0; I < NumRedundant; ++I) {
161 auto LastComponent = Component;
162 ++Component;
163 PrefixLen += Component - LastComponent;
164 }
165 return PrefixLen;
Vedant Kumarfa754372016-09-08 00:56:43 +0000166}
167
Vedant Kumar702bb9d2016-09-06 22:45:57 +0000168} // end anonymous namespace
169
170namespace llvm {
171
Vedant Kumar627887b62016-09-09 01:32:49 +0000172void CoverageReport::render(const FileCoverageSummary &File,
173 raw_ostream &OS) const {
Vedant Kumar5053b112016-09-06 22:46:00 +0000174 auto FileCoverageColor =
175 determineCoveragePercentageColor(File.RegionCoverage);
176 auto FuncCoverageColor =
177 determineCoveragePercentageColor(File.FunctionCoverage);
Vedant Kumar016111f2016-09-19 00:38:23 +0000178 auto InstantiationCoverageColor =
179 determineCoveragePercentageColor(File.InstantiationCoverage);
Vedant Kumar5053b112016-09-06 22:46:00 +0000180 auto LineCoverageColor = determineCoveragePercentageColor(File.LineCoverage);
Vedant Kumard938dfb2016-09-09 17:37:11 +0000181 SmallString<256> FileName = File.Name;
182 sys::path::remove_dots(FileName, /*remove_dot_dots=*/true);
183 sys::path::native(FileName);
Eli Friedman50479f62017-09-11 22:56:20 +0000184 OS << column(FileName, FileReportColumns[0], Column::NoTrim);
185
186 if (Options.ShowRegionSummary) {
187 OS << format("%*u", FileReportColumns[1],
Vedant Kumarc445e652017-09-15 23:00:01 +0000188 (unsigned)File.RegionCoverage.getNumRegions());
189 Options.colored_ostream(OS, FileCoverageColor)
190 << format("%*u", FileReportColumns[2],
191 (unsigned)(File.RegionCoverage.getNumRegions() -
192 File.RegionCoverage.getCovered()));
193 if (File.RegionCoverage.getNumRegions())
Eli Friedman50479f62017-09-11 22:56:20 +0000194 Options.colored_ostream(OS, FileCoverageColor)
195 << format("%*.2f", FileReportColumns[3] - 1,
196 File.RegionCoverage.getPercentCovered())
197 << '%';
198 else
199 OS << column("-", FileReportColumns[3], Column::RightAlignment);
200 }
201
NAKAMURA Takumi46d2e0e2014-10-01 00:29:26 +0000202 OS << format("%*u", FileReportColumns[4],
Vedant Kumarc445e652017-09-15 23:00:01 +0000203 (unsigned)File.FunctionCoverage.getNumFunctions());
Ying Yie59ee432016-07-22 12:46:13 +0000204 OS << format("%*u", FileReportColumns[5],
Vedant Kumarc445e652017-09-15 23:00:01 +0000205 (unsigned)(File.FunctionCoverage.getNumFunctions() -
206 File.FunctionCoverage.getExecuted()));
207 if (File.FunctionCoverage.getNumFunctions())
Alex Lorenz35369c12016-11-21 14:00:04 +0000208 Options.colored_ostream(OS, FuncCoverageColor)
209 << format("%*.2f", FileReportColumns[6] - 1,
210 File.FunctionCoverage.getPercentCovered())
211 << '%';
212 else
213 OS << column("-", FileReportColumns[6], Column::RightAlignment);
Eli Friedman50479f62017-09-11 22:56:20 +0000214
215 if (Options.ShowInstantiationSummary) {
216 OS << format("%*u", FileReportColumns[7],
Vedant Kumarc445e652017-09-15 23:00:01 +0000217 (unsigned)File.InstantiationCoverage.getNumFunctions());
Eli Friedman50479f62017-09-11 22:56:20 +0000218 OS << format("%*u", FileReportColumns[8],
Vedant Kumarc445e652017-09-15 23:00:01 +0000219 (unsigned)(File.InstantiationCoverage.getNumFunctions() -
220 File.InstantiationCoverage.getExecuted()));
221 if (File.InstantiationCoverage.getNumFunctions())
Eli Friedman50479f62017-09-11 22:56:20 +0000222 Options.colored_ostream(OS, InstantiationCoverageColor)
223 << format("%*.2f", FileReportColumns[9] - 1,
224 File.InstantiationCoverage.getPercentCovered())
225 << '%';
226 else
227 OS << column("-", FileReportColumns[9], Column::RightAlignment);
228 }
229
Vedant Kumar016111f2016-09-19 00:38:23 +0000230 OS << format("%*u", FileReportColumns[10],
Vedant Kumarc445e652017-09-15 23:00:01 +0000231 (unsigned)File.LineCoverage.getNumLines());
Vedant Kumar5053b112016-09-06 22:46:00 +0000232 Options.colored_ostream(OS, LineCoverageColor) << format(
Vedant Kumarc445e652017-09-15 23:00:01 +0000233 "%*u", FileReportColumns[11], (unsigned)(File.LineCoverage.getNumLines() -
234 File.LineCoverage.getCovered()));
235 if (File.LineCoverage.getNumLines())
Alex Lorenz35369c12016-11-21 14:00:04 +0000236 Options.colored_ostream(OS, LineCoverageColor)
237 << format("%*.2f", FileReportColumns[12] - 1,
238 File.LineCoverage.getPercentCovered())
239 << '%';
240 else
241 OS << column("-", FileReportColumns[12], Column::RightAlignment);
Alex Lorenze82d89c2014-08-22 22:56:03 +0000242 OS << "\n";
243}
244
245void CoverageReport::render(const FunctionCoverageSummary &Function,
Vedant Kumarf2b067c2017-02-05 20:11:03 +0000246 const DemangleCache &DC,
Vedant Kumar627887b62016-09-09 01:32:49 +0000247 raw_ostream &OS) const {
Vedant Kumar5053b112016-09-06 22:46:00 +0000248 auto FuncCoverageColor =
249 determineCoveragePercentageColor(Function.RegionCoverage);
250 auto LineCoverageColor =
251 determineCoveragePercentageColor(Function.LineCoverage);
Vedant Kumarf2b067c2017-02-05 20:11:03 +0000252 OS << column(DC.demangle(Function.Name), FunctionReportColumns[0],
253 Column::RightTrim)
NAKAMURA Takumi46d2e0e2014-10-01 00:29:26 +0000254 << format("%*u", FunctionReportColumns[1],
Vedant Kumarc445e652017-09-15 23:00:01 +0000255 (unsigned)Function.RegionCoverage.getNumRegions());
Vedant Kumar5053b112016-09-06 22:46:00 +0000256 Options.colored_ostream(OS, FuncCoverageColor)
NAKAMURA Takumi46d2e0e2014-10-01 00:29:26 +0000257 << format("%*u", FunctionReportColumns[2],
Vedant Kumarc445e652017-09-15 23:00:01 +0000258 (unsigned)(Function.RegionCoverage.getNumRegions() -
259 Function.RegionCoverage.getCovered()));
Alex Lorenze82d89c2014-08-22 22:56:03 +0000260 Options.colored_ostream(
261 OS, determineCoveragePercentageColor(Function.RegionCoverage))
262 << format("%*.2f", FunctionReportColumns[3] - 1,
Vedant Kumar5053b112016-09-06 22:46:00 +0000263 Function.RegionCoverage.getPercentCovered())
264 << '%';
NAKAMURA Takumi46d2e0e2014-10-01 00:29:26 +0000265 OS << format("%*u", FunctionReportColumns[4],
Vedant Kumarc445e652017-09-15 23:00:01 +0000266 (unsigned)Function.LineCoverage.getNumLines());
Vedant Kumar5053b112016-09-06 22:46:00 +0000267 Options.colored_ostream(OS, LineCoverageColor)
NAKAMURA Takumi46d2e0e2014-10-01 00:29:26 +0000268 << format("%*u", FunctionReportColumns[5],
Vedant Kumarc445e652017-09-15 23:00:01 +0000269 (unsigned)(Function.LineCoverage.getNumLines() -
270 Function.LineCoverage.getCovered()));
Alex Lorenze82d89c2014-08-22 22:56:03 +0000271 Options.colored_ostream(
272 OS, determineCoveragePercentageColor(Function.LineCoverage))
273 << format("%*.2f", FunctionReportColumns[6] - 1,
Vedant Kumar5053b112016-09-06 22:46:00 +0000274 Function.LineCoverage.getPercentCovered())
275 << '%';
Alex Lorenze82d89c2014-08-22 22:56:03 +0000276 OS << "\n";
277}
278
Vedant Kumarbc647982016-09-23 18:57:32 +0000279void CoverageReport::renderFunctionReports(ArrayRef<std::string> Files,
Vedant Kumarf2b067c2017-02-05 20:11:03 +0000280 const DemangleCache &DC,
Justin Bogner0ef7a2a2015-02-14 02:05:05 +0000281 raw_ostream &OS) {
Alex Lorenze82d89c2014-08-22 22:56:03 +0000282 bool isFirst = true;
Justin Bogner0ef7a2a2015-02-14 02:05:05 +0000283 for (StringRef Filename : Files) {
Vedant Kumardab0ec12016-09-19 00:38:16 +0000284 auto Functions = Coverage.getCoveredFunctions(Filename);
285
Alex Lorenze82d89c2014-08-22 22:56:03 +0000286 if (isFirst)
287 isFirst = false;
288 else
289 OS << "\n";
Vedant Kumardab0ec12016-09-19 00:38:16 +0000290
291 std::vector<StringRef> Funcnames;
292 for (const auto &F : Functions)
Vedant Kumarf2b067c2017-02-05 20:11:03 +0000293 Funcnames.emplace_back(DC.demangle(F.Name));
Vedant Kumardab0ec12016-09-19 00:38:16 +0000294 adjustColumnWidths({}, Funcnames);
295
Justin Bognerf91bc6c2015-02-14 02:01:24 +0000296 OS << "File '" << Filename << "':\n";
Alex Lorenze82d89c2014-08-22 22:56:03 +0000297 OS << column("Name", FunctionReportColumns[0])
298 << column("Regions", FunctionReportColumns[1], Column::RightAlignment)
299 << column("Miss", FunctionReportColumns[2], Column::RightAlignment)
300 << column("Cover", FunctionReportColumns[3], Column::RightAlignment)
301 << column("Lines", FunctionReportColumns[4], Column::RightAlignment)
302 << column("Miss", FunctionReportColumns[5], Column::RightAlignment)
303 << column("Cover", FunctionReportColumns[6], Column::RightAlignment);
304 OS << "\n";
305 renderDivider(FunctionReportColumns, OS);
306 OS << "\n";
Justin Bognerf91bc6c2015-02-14 02:01:24 +0000307 FunctionCoverageSummary Totals("TOTAL");
Vedant Kumardab0ec12016-09-19 00:38:16 +0000308 for (const auto &F : Functions) {
Vedant Kumarb7fdaf22017-09-19 02:00:12 +0000309 auto Function = FunctionCoverageSummary::get(Coverage, F);
Justin Bognerf91bc6c2015-02-14 02:01:24 +0000310 ++Totals.ExecutionCount;
311 Totals.RegionCoverage += Function.RegionCoverage;
312 Totals.LineCoverage += Function.LineCoverage;
Vedant Kumarf2b067c2017-02-05 20:11:03 +0000313 render(Function, DC, OS);
Justin Bognerf91bc6c2015-02-14 02:01:24 +0000314 }
315 if (Totals.ExecutionCount) {
316 renderDivider(FunctionReportColumns, OS);
317 OS << "\n";
Vedant Kumarf2b067c2017-02-05 20:11:03 +0000318 render(Totals, DC, OS);
Justin Bognerf91bc6c2015-02-14 02:01:24 +0000319 }
Alex Lorenze82d89c2014-08-22 22:56:03 +0000320 }
321}
322
Vedant Kumar72c3a112017-09-08 18:44:49 +0000323std::vector<FileCoverageSummary> CoverageReport::prepareFileReports(
324 const coverage::CoverageMapping &Coverage, FileCoverageSummary &Totals,
325 ArrayRef<std::string> Files, const CoverageViewOptions &Options) {
Vedant Kumar627887b62016-09-09 01:32:49 +0000326 std::vector<FileCoverageSummary> FileReports;
Vedant Kumar11813282017-02-23 22:20:32 +0000327 unsigned LCP = getRedundantPrefixLen(Files);
Vedant Kumar627887b62016-09-09 01:32:49 +0000328
329 for (StringRef Filename : Files) {
330 FileCoverageSummary Summary(Filename.drop_front(LCP));
Vedant Kumar016111f2016-09-19 00:38:23 +0000331
Vedant Kumardde19c52017-08-02 23:35:25 +0000332 for (const auto &Group : Coverage.getInstantiationGroups(Filename)) {
333 std::vector<FunctionCoverageSummary> InstantiationSummaries;
334 for (const coverage::FunctionRecord *F : Group.getInstantiations()) {
Vedant Kumarb7fdaf22017-09-19 02:00:12 +0000335 auto InstantiationSummary = FunctionCoverageSummary::get(Coverage, *F);
Vedant Kumardde19c52017-08-02 23:35:25 +0000336 Summary.addInstantiation(InstantiationSummary);
337 Totals.addInstantiation(InstantiationSummary);
338 InstantiationSummaries.push_back(InstantiationSummary);
339 }
Vedant Kumar016111f2016-09-19 00:38:23 +0000340
Vedant Kumardde19c52017-08-02 23:35:25 +0000341 auto GroupSummary =
342 FunctionCoverageSummary::get(Group, InstantiationSummaries);
Vedant Kumar72c3a112017-09-08 18:44:49 +0000343
344 if (Options.Debug)
345 outs() << "InstantiationGroup: " << GroupSummary.Name << " with "
346 << "size = " << Group.size() << "\n";
347
Vedant Kumardde19c52017-08-02 23:35:25 +0000348 Summary.addFunction(GroupSummary);
349 Totals.addFunction(GroupSummary);
Vedant Kumar016111f2016-09-19 00:38:23 +0000350 }
351
Vedant Kumar627887b62016-09-09 01:32:49 +0000352 FileReports.push_back(Summary);
353 }
354
355 return FileReports;
356}
357
358void CoverageReport::renderFileReports(raw_ostream &OS) const {
Vedant Kumarbc647982016-09-23 18:57:32 +0000359 std::vector<std::string> UniqueSourceFiles;
360 for (StringRef SF : Coverage.getUniqueSourceFiles())
361 UniqueSourceFiles.emplace_back(SF.str());
Vedant Kumar627887b62016-09-09 01:32:49 +0000362 renderFileReports(OS, UniqueSourceFiles);
363}
364
365void CoverageReport::renderFileReports(raw_ostream &OS,
Vedant Kumarbc647982016-09-23 18:57:32 +0000366 ArrayRef<std::string> Files) const {
Vedant Kumardab0ec12016-09-19 00:38:16 +0000367 FileCoverageSummary Totals("TOTAL");
Vedant Kumar72c3a112017-09-08 18:44:49 +0000368 auto FileReports = prepareFileReports(Coverage, Totals, Files, Options);
Vedant Kumardab0ec12016-09-19 00:38:16 +0000369
370 std::vector<StringRef> Filenames;
371 for (const FileCoverageSummary &FCS : FileReports)
372 Filenames.emplace_back(FCS.Name);
373 adjustColumnWidths(Filenames, {});
374
Eli Friedman50479f62017-09-11 22:56:20 +0000375 OS << column("Filename", FileReportColumns[0]);
376 if (Options.ShowRegionSummary)
377 OS << column("Regions", FileReportColumns[1], Column::RightAlignment)
378 << column("Missed Regions", FileReportColumns[2], Column::RightAlignment)
379 << column("Cover", FileReportColumns[3], Column::RightAlignment);
380 OS << column("Functions", FileReportColumns[4], Column::RightAlignment)
Vedant Kumar5053b112016-09-06 22:46:00 +0000381 << column("Missed Functions", FileReportColumns[5], Column::RightAlignment)
Eli Friedman50479f62017-09-11 22:56:20 +0000382 << column("Executed", FileReportColumns[6], Column::RightAlignment);
383 if (Options.ShowInstantiationSummary)
384 OS << column("Instantiations", FileReportColumns[7], Column::RightAlignment)
385 << column("Missed Insts.", FileReportColumns[8], Column::RightAlignment)
386 << column("Executed", FileReportColumns[9], Column::RightAlignment);
387 OS << column("Lines", FileReportColumns[10], Column::RightAlignment)
Vedant Kumar016111f2016-09-19 00:38:23 +0000388 << column("Missed Lines", FileReportColumns[11], Column::RightAlignment)
389 << column("Cover", FileReportColumns[12], Column::RightAlignment) << "\n";
Alex Lorenze82d89c2014-08-22 22:56:03 +0000390 renderDivider(FileReportColumns, OS);
391 OS << "\n";
Vedant Kumarc3c39e72015-09-14 23:26:36 +0000392
Eli Friedmanc0c182c2017-08-09 20:43:31 +0000393 bool EmptyFiles = false;
394 for (const FileCoverageSummary &FCS : FileReports) {
Vedant Kumarc445e652017-09-15 23:00:01 +0000395 if (FCS.FunctionCoverage.getNumFunctions())
Eli Friedmanc0c182c2017-08-09 20:43:31 +0000396 render(FCS, OS);
397 else
398 EmptyFiles = true;
399 }
400
401 if (EmptyFiles) {
402 OS << "\n"
403 << "Files which contain no functions:\n";
404
405 for (const FileCoverageSummary &FCS : FileReports)
Vedant Kumarc445e652017-09-15 23:00:01 +0000406 if (!FCS.FunctionCoverage.getNumFunctions())
Eli Friedmanc0c182c2017-08-09 20:43:31 +0000407 render(FCS, OS);
408 }
Vedant Kumar627887b62016-09-09 01:32:49 +0000409
Alex Lorenze82d89c2014-08-22 22:56:03 +0000410 renderDivider(FileReportColumns, OS);
411 OS << "\n";
Justin Bognerf91bc6c2015-02-14 02:01:24 +0000412 render(Totals, OS);
Alex Lorenze82d89c2014-08-22 22:56:03 +0000413}
Vedant Kumar702bb9d2016-09-06 22:45:57 +0000414
415} // end namespace llvm