Index: tools/llvm-cov/CodeCoverage.cpp =================================================================== --- tools/llvm-cov/CodeCoverage.cpp +++ tools/llvm-cov/CodeCoverage.cpp @@ -39,6 +39,7 @@ #include #include +#include #include using namespace llvm; @@ -536,6 +537,8 @@ } int CodeCoverageTool::run(Command Cmd, int argc, const char **argv) { + errs() << "Started: "; + printTimestamp(); cl::opt CovFilename( cl::Positional, cl::desc("Covered executable or object file.")); @@ -769,6 +772,8 @@ case Export: return doExport(argc, argv, commandLineParser); } + errs() << "Done: "; + printTimestamp(); return 0; } Index: tools/llvm-cov/CoverageExporterJson.h =================================================================== --- tools/llvm-cov/CoverageExporterJson.h +++ tools/llvm-cov/CoverageExporterJson.h @@ -77,6 +77,10 @@ void renderFile(const coverage::CoverageData &FileCoverage, const FileCoverageSummary &FileReport); + /// \brief Render summary for a single file. + void renderFileSummary(const std::string &Filename, + const FileCoverageSummary &FileReport); + /// \brief Render a CoverageSegment. void renderSegment(const coverage::CoverageSegment &Segment); Index: tools/llvm-cov/CoverageExporterJson.cpp =================================================================== --- tools/llvm-cov/CoverageExporterJson.cpp +++ tools/llvm-cov/CoverageExporterJson.cpp @@ -118,6 +118,8 @@ } void CoverageExporterJson::renderRoot() { + errs() << "renderRoot(), getting unique source files: "; + printTimestamp(); std::vector SourceFiles; for (StringRef SF : Coverage.getUniqueSourceFiles()) SourceFiles.emplace_back(SF); @@ -126,6 +128,8 @@ void CoverageExporterJson::renderRoot( const std::vector &SourceFiles) { + errs() << "renderRoot(sourceFiles): "; + printTimestamp(); // Start Root of JSON object. emitDictStart(); @@ -142,9 +146,15 @@ emitDictKey("files"); FileCoverageSummary Totals = FileCoverageSummary("Totals"); + errs() << "prepareFileReports: "; + printTimestamp(); auto FileReports = CoverageReport::prepareFileReports(Coverage, Totals, SourceFiles, Options); + errs() << "renderFiles: "; + printTimestamp(); renderFiles(SourceFiles, FileReports); + errs() << "render leftovers: "; + printTimestamp(); // Skip functions-level information for summary-only export mode. if (!Options.ExportSummaryOnly) { @@ -210,8 +220,13 @@ for (unsigned I = 0, E = SourceFiles.size(); I < E; ++I) { // Render the file. - auto FileCoverage = Coverage.getCoverageForFile(SourceFiles[I]); - renderFile(FileCoverage, FileReports[I]); + if (Options.ExportSummaryOnly) { + // Skip segments and expansions for summary-only export mode. + renderFileSummary(SourceFiles[I], FileReports[I]); + } else { + auto FileCoverage = Coverage.getCoverageForFile(SourceFiles[I]); + renderFile(FileCoverage, FileReports[I]); + } } // End List of Files. @@ -226,30 +241,42 @@ emitDictElement("filename", FileCoverage.getFilename()); - // Skip segments and expansions for summary-only export mode. - if (!Options.ExportSummaryOnly) { - emitDictKey("segments"); + emitDictKey("segments"); - // Start List of Segments. - emitArrayStart(); + // Start List of Segments. + emitArrayStart(); - for (const auto &Segment : FileCoverage) - renderSegment(Segment); + for (const auto &Segment : FileCoverage) + renderSegment(Segment); - // End List of Segments. - emitArrayEnd(); + // End List of Segments. + emitArrayEnd(); - emitDictKey("expansions"); + emitDictKey("expansions"); - // Start List of Expansions. - emitArrayStart(); + // Start List of Expansions. + emitArrayStart(); - for (const auto &Expansion : FileCoverage.getExpansions()) - renderExpansion(Expansion); + for (const auto &Expansion : FileCoverage.getExpansions()) + renderExpansion(Expansion); - // End List of Expansions. - emitArrayEnd(); - } + // End List of Expansions. + emitArrayEnd(); + + emitDictKey("summary"); + renderSummary(FileReport); + + // End File. + emitDictEnd(); +} + +void CoverageExporterJson::renderFileSummary( + const std::string &Filename, + const FileCoverageSummary &FileReport) { + // Start File. + emitDictStart(); + + emitDictElement("filename", Filename); emitDictKey("summary"); renderSummary(FileReport); Index: tools/llvm-cov/CoverageReport.h =================================================================== --- tools/llvm-cov/CoverageReport.h +++ tools/llvm-cov/CoverageReport.h @@ -64,6 +64,8 @@ const CoverageFiltersMatchAll &Filters) const; }; +void printTimestamp(); + } // end namespace llvm #endif // LLVM_COV_COVERAGEREPORT_H Index: tools/llvm-cov/CoverageReport.cpp =================================================================== --- tools/llvm-cov/CoverageReport.cpp +++ tools/llvm-cov/CoverageReport.cpp @@ -20,6 +20,10 @@ #include "llvm/Support/Threading.h" #include +#include +#include +#include + using namespace llvm; namespace { @@ -443,4 +447,11 @@ render(Totals, OS); } +void printTimestamp() { + using namespace std::chrono; + system_clock::time_point today = system_clock::now(); + time_t tt = system_clock::to_time_t ( today ); + std::cerr << ctime(&tt) << "\n"; +} + } // end namespace llvm