diff options
Diffstat (limited to 'llvm/tools')
-rw-r--r-- | llvm/tools/llvm-cov/CodeCoverage.cpp | 3 | ||||
-rw-r--r-- | llvm/tools/llvm-cov/CoverageExporterJson.cpp | 14 | ||||
-rw-r--r-- | llvm/tools/llvm-cov/CoverageReport.cpp | 14 | ||||
-rw-r--r-- | llvm/tools/llvm-cov/CoverageReport.h | 3 | ||||
-rw-r--r-- | llvm/tools/llvm-cov/CoverageSummaryInfo.cpp | 2 | ||||
-rw-r--r-- | llvm/tools/llvm-cov/CoverageSummaryInfo.h | 8 | ||||
-rw-r--r-- | llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp | 2 |
7 files changed, 28 insertions, 18 deletions
diff --git a/llvm/tools/llvm-cov/CodeCoverage.cpp b/llvm/tools/llvm-cov/CodeCoverage.cpp index b99a4189b01..0e3d67e5691 100644 --- a/llvm/tools/llvm-cov/CodeCoverage.cpp +++ b/llvm/tools/llvm-cov/CodeCoverage.cpp @@ -42,6 +42,7 @@ using namespace llvm; using namespace coverage; void exportCoverageDataToJson(const coverage::CoverageMapping &CoverageMapping, + const CoverageViewOptions &Options, raw_ostream &OS); namespace { @@ -932,7 +933,7 @@ int CodeCoverageTool::export_(int argc, const char **argv, return 1; } - exportCoverageDataToJson(*Coverage.get(), outs()); + exportCoverageDataToJson(*Coverage.get(), ViewOpts, outs()); return 0; } diff --git a/llvm/tools/llvm-cov/CoverageExporterJson.cpp b/llvm/tools/llvm-cov/CoverageExporterJson.cpp index ef50bba2123..f891326ddfc 100644 --- a/llvm/tools/llvm-cov/CoverageExporterJson.cpp +++ b/llvm/tools/llvm-cov/CoverageExporterJson.cpp @@ -57,6 +57,8 @@ using namespace llvm; using namespace coverage; class CoverageExporterJson { + const CoverageViewOptions &Options; + /// \brief Output stream to print JSON to. raw_ostream &OS; @@ -171,8 +173,8 @@ class CoverageExporterJson { std::vector<std::string> SourceFiles; for (StringRef SF : Coverage.getUniqueSourceFiles()) SourceFiles.emplace_back(SF); - auto FileReports = - CoverageReport::prepareFileReports(Coverage, Totals, SourceFiles); + auto FileReports = CoverageReport::prepareFileReports(Coverage, Totals, + SourceFiles, Options); renderFiles(SourceFiles, FileReports); emitDictKey("functions"); @@ -403,8 +405,9 @@ class CoverageExporterJson { } public: - CoverageExporterJson(const CoverageMapping &CoverageMapping, raw_ostream &OS) - : OS(OS), Coverage(CoverageMapping) { + CoverageExporterJson(const CoverageMapping &CoverageMapping, + const CoverageViewOptions &Options, raw_ostream &OS) + : Options(Options), OS(OS), Coverage(CoverageMapping) { State.push(JsonState::None); } @@ -414,8 +417,9 @@ public: /// \brief Export the given CoverageMapping to a JSON Format. void exportCoverageDataToJson(const CoverageMapping &CoverageMapping, + const CoverageViewOptions &Options, raw_ostream &OS) { - auto Exporter = CoverageExporterJson(CoverageMapping, OS); + auto Exporter = CoverageExporterJson(CoverageMapping, Options, OS); Exporter.print(); } diff --git a/llvm/tools/llvm-cov/CoverageReport.cpp b/llvm/tools/llvm-cov/CoverageReport.cpp index 3c9bf3975b3..29440f43308 100644 --- a/llvm/tools/llvm-cov/CoverageReport.cpp +++ b/llvm/tools/llvm-cov/CoverageReport.cpp @@ -307,10 +307,9 @@ void CoverageReport::renderFunctionReports(ArrayRef<std::string> Files, } } -std::vector<FileCoverageSummary> -CoverageReport::prepareFileReports(const coverage::CoverageMapping &Coverage, - FileCoverageSummary &Totals, - ArrayRef<std::string> Files) { +std::vector<FileCoverageSummary> CoverageReport::prepareFileReports( + const coverage::CoverageMapping &Coverage, FileCoverageSummary &Totals, + ArrayRef<std::string> Files, const CoverageViewOptions &Options) { std::vector<FileCoverageSummary> FileReports; unsigned LCP = getRedundantPrefixLen(Files); @@ -328,6 +327,11 @@ CoverageReport::prepareFileReports(const coverage::CoverageMapping &Coverage, auto GroupSummary = FunctionCoverageSummary::get(Group, InstantiationSummaries); + + if (Options.Debug) + outs() << "InstantiationGroup: " << GroupSummary.Name << " with " + << "size = " << Group.size() << "\n"; + Summary.addFunction(GroupSummary); Totals.addFunction(GroupSummary); } @@ -348,7 +352,7 @@ void CoverageReport::renderFileReports(raw_ostream &OS) const { void CoverageReport::renderFileReports(raw_ostream &OS, ArrayRef<std::string> Files) const { FileCoverageSummary Totals("TOTAL"); - auto FileReports = prepareFileReports(Coverage, Totals, Files); + auto FileReports = prepareFileReports(Coverage, Totals, Files, Options); std::vector<StringRef> Filenames; for (const FileCoverageSummary &FCS : FileReports) diff --git a/llvm/tools/llvm-cov/CoverageReport.h b/llvm/tools/llvm-cov/CoverageReport.h index 071be2e2159..242dc7fe7ba 100644 --- a/llvm/tools/llvm-cov/CoverageReport.h +++ b/llvm/tools/llvm-cov/CoverageReport.h @@ -39,7 +39,8 @@ public: /// Prepare file reports for the files specified in \p Files. static std::vector<FileCoverageSummary> prepareFileReports(const coverage::CoverageMapping &Coverage, - FileCoverageSummary &Totals, ArrayRef<std::string> Files); + FileCoverageSummary &Totals, ArrayRef<std::string> Files, + const CoverageViewOptions &Options); /// Render file reports for every unique file in the coverage mapping. void renderFileReports(raw_ostream &OS) const; diff --git a/llvm/tools/llvm-cov/CoverageSummaryInfo.cpp b/llvm/tools/llvm-cov/CoverageSummaryInfo.cpp index 9c0027b148c..350c7a67004 100644 --- a/llvm/tools/llvm-cov/CoverageSummaryInfo.cpp +++ b/llvm/tools/llvm-cov/CoverageSummaryInfo.cpp @@ -82,7 +82,7 @@ FunctionCoverageSummary::get(const InstantiationGroup &Group, << Group.getColumn(); } - FunctionCoverageSummary Summary(std::move(Name)); + FunctionCoverageSummary Summary(Name); Summary.ExecutionCount = Group.getTotalExecutionCount(); Summary.RegionCoverage = Summaries[0].RegionCoverage; Summary.LineCoverage = Summaries[0].LineCoverage; diff --git a/llvm/tools/llvm-cov/CoverageSummaryInfo.h b/llvm/tools/llvm-cov/CoverageSummaryInfo.h index 1603731d982..e9e3f47108d 100644 --- a/llvm/tools/llvm-cov/CoverageSummaryInfo.h +++ b/llvm/tools/llvm-cov/CoverageSummaryInfo.h @@ -120,14 +120,14 @@ struct FunctionCoverageSummary { RegionCoverageInfo RegionCoverage; LineCoverageInfo LineCoverage; - FunctionCoverageSummary(StringRef Name) : Name(Name), ExecutionCount(0) {} + FunctionCoverageSummary(const std::string &Name) + : Name(Name), ExecutionCount(0) {} - FunctionCoverageSummary(StringRef Name, uint64_t ExecutionCount, + FunctionCoverageSummary(const std::string &Name, uint64_t ExecutionCount, const RegionCoverageInfo &RegionCoverage, const LineCoverageInfo &LineCoverage) : Name(Name), ExecutionCount(ExecutionCount), - RegionCoverage(RegionCoverage), LineCoverage(LineCoverage) { - } + RegionCoverage(RegionCoverage), LineCoverage(LineCoverage) {} /// \brief Compute the code coverage summary for the given function coverage /// mapping record. diff --git a/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp b/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp index eecc352f225..03f7a70cd8f 100644 --- a/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp +++ b/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp @@ -398,7 +398,7 @@ Error CoveragePrinterHTML::createIndexFile( emitColumnLabelsForIndex(OSRef); FileCoverageSummary Totals("TOTALS"); auto FileReports = - CoverageReport::prepareFileReports(Coverage, Totals, SourceFiles); + CoverageReport::prepareFileReports(Coverage, Totals, SourceFiles, Opts); bool EmptyFiles = false; for (unsigned I = 0, E = FileReports.size(); I < E; ++I) { if (FileReports[I].FunctionCoverage.NumFunctions) |