[llvm-cov] Make a helper method static for re-use (NFC)

llvm-svn: 281876
This commit is contained in:
Vedant Kumar
2016-09-19 00:38:25 +00:00
parent 016111f7b9
commit 9cbf80afc8
3 changed files with 9 additions and 8 deletions

View File

@@ -259,8 +259,9 @@ void CoverageReport::renderFunctionReports(ArrayRef<StringRef> Files,
} }
std::vector<FileCoverageSummary> std::vector<FileCoverageSummary>
CoverageReport::prepareFileReports(FileCoverageSummary &Totals, CoverageReport::prepareFileReports(const coverage::CoverageMapping &Coverage,
ArrayRef<StringRef> Files) const { FileCoverageSummary &Totals,
ArrayRef<StringRef> Files) {
std::vector<FileCoverageSummary> FileReports; std::vector<FileCoverageSummary> FileReports;
unsigned LCP = 0; unsigned LCP = 0;
if (Files.size() > 1) if (Files.size() > 1)
@@ -304,7 +305,7 @@ void CoverageReport::renderFileReports(raw_ostream &OS) const {
void CoverageReport::renderFileReports(raw_ostream &OS, void CoverageReport::renderFileReports(raw_ostream &OS,
ArrayRef<StringRef> Files) const { ArrayRef<StringRef> Files) const {
FileCoverageSummary Totals("TOTAL"); FileCoverageSummary Totals("TOTAL");
auto FileReports = prepareFileReports(Totals, Files); auto FileReports = prepareFileReports(Coverage, Totals, Files);
std::vector<StringRef> Filenames; std::vector<StringRef> Filenames;
for (const FileCoverageSummary &FCS : FileReports) for (const FileCoverageSummary &FCS : FileReports)

View File

@@ -35,9 +35,9 @@ public:
void renderFunctionReports(ArrayRef<StringRef> Files, raw_ostream &OS); void renderFunctionReports(ArrayRef<StringRef> Files, raw_ostream &OS);
/// Prepare file reports for the files specified in \p Files. /// Prepare file reports for the files specified in \p Files.
std::vector<FileCoverageSummary> static std::vector<FileCoverageSummary>
prepareFileReports(FileCoverageSummary &Totals, prepareFileReports(const coverage::CoverageMapping &Coverage,
ArrayRef<StringRef> Files) const; FileCoverageSummary &Totals, ArrayRef<StringRef> Files);
/// Render file reports for every unique file in the coverage mapping. /// Render file reports for every unique file in the coverage mapping.
void renderFileReports(raw_ostream &OS) const; void renderFileReports(raw_ostream &OS) const;

View File

@@ -375,11 +375,11 @@ Error CoveragePrinterHTML::createIndexFile(
OSRef << tag(CreatedTimeTag, escape(Opts.CreatedTimeStr, Opts)); OSRef << tag(CreatedTimeTag, escape(Opts.CreatedTimeStr, Opts));
// Emit a table containing links to reports for each file in the covmapping. // Emit a table containing links to reports for each file in the covmapping.
CoverageReport Report(Opts, Coverage);
OSRef << BeginCenteredDiv << BeginTable; OSRef << BeginCenteredDiv << BeginTable;
emitColumnLabelsForIndex(OSRef); emitColumnLabelsForIndex(OSRef);
FileCoverageSummary Totals("TOTALS"); FileCoverageSummary Totals("TOTALS");
auto FileReports = Report.prepareFileReports(Totals, SourceFiles); auto FileReports =
CoverageReport::prepareFileReports(Coverage, Totals, SourceFiles);
for (unsigned I = 0, E = FileReports.size(); I < E; ++I) for (unsigned I = 0, E = FileReports.size(); I < E; ++I)
emitFileSummary(OSRef, SourceFiles[I], FileReports[I]); emitFileSummary(OSRef, SourceFiles[I], FileReports[I]);
emitFileSummary(OSRef, "Totals", Totals, /*IsTotals=*/true); emitFileSummary(OSRef, "Totals", Totals, /*IsTotals=*/true);