[llvm] r281877 - [llvm-cov] Teach the coverage exporter about instantiation coverage
Vedant Kumar via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 18 17:38:30 PDT 2016
Author: vedantk
Date: Sun Sep 18 19:38:29 2016
New Revision: 281877
URL: http://llvm.org/viewvc/llvm-project?rev=281877&view=rev
Log:
[llvm-cov] Teach the coverage exporter about instantiation coverage
While we're at it, re-use the logic from CoverageReport to compute
summaries.
Modified:
llvm/trunk/test/tools/llvm-cov/Inputs/binary-formats.canonical.json
llvm/trunk/test/tools/llvm-cov/Inputs/highlightedRanges.json
llvm/trunk/test/tools/llvm-cov/Inputs/lineExecutionCounts.json
llvm/trunk/test/tools/llvm-cov/Inputs/regionMarkers.json
llvm/trunk/test/tools/llvm-cov/Inputs/showExpansions.json
llvm/trunk/test/tools/llvm-cov/Inputs/universal-binary.json
llvm/trunk/tools/llvm-cov/CoverageExporterJson.cpp
Modified: llvm/trunk/test/tools/llvm-cov/Inputs/binary-formats.canonical.json
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-cov/Inputs/binary-formats.canonical.json?rev=281877&r1=281876&r2=281877&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-cov/Inputs/binary-formats.canonical.json (original)
+++ llvm/trunk/test/tools/llvm-cov/Inputs/binary-formats.canonical.json Sun Sep 18 19:38:29 2016
@@ -32,6 +32,7 @@
// CHECK-SAME: "totals":{
// CHECK-SAME: "lines":{"count":1,"covered":1,"percent":100,"noncode":0},
// CHECK-SAME: "functions":{"count":1,"covered":1,"percent":100},
+// CHECK-SAME: "instantiations":{"count":1,"covered":1,"percent":100},
// CHECK-SAME: "regions":{"count":1,"covered":1,"notcovered":0,"percent":100}}
// Close the export object, data array, and root object
Modified: llvm/trunk/test/tools/llvm-cov/Inputs/highlightedRanges.json
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-cov/Inputs/highlightedRanges.json?rev=281877&r1=281876&r2=281877&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-cov/Inputs/highlightedRanges.json (original)
+++ llvm/trunk/test/tools/llvm-cov/Inputs/highlightedRanges.json Sun Sep 18 19:38:29 2016
@@ -47,6 +47,7 @@
// CHECK-SAME: "totals":{
// CHECK-SAME: "lines":{"count":40,"covered":26,"percent":65,"noncode":0},
// CHECK-SAME: "functions":{"count":4,"covered":4,"percent":100},
+// CHECK-SAME: "instantiations":{"count":4,"covered":4,"percent":100},
// CHECK-SAME: "regions":{"count":19,"covered":11,"notcovered":8,"percent":57}}
// Close the export object, data array, and root object
Modified: llvm/trunk/test/tools/llvm-cov/Inputs/lineExecutionCounts.json
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-cov/Inputs/lineExecutionCounts.json?rev=281877&r1=281876&r2=281877&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-cov/Inputs/lineExecutionCounts.json (original)
+++ llvm/trunk/test/tools/llvm-cov/Inputs/lineExecutionCounts.json Sun Sep 18 19:38:29 2016
@@ -32,6 +32,7 @@
// CHECK-SAME: "totals":{
// CHECK-SAME: "lines":{"count":20,"covered":16,"percent":80,"noncode":0},
// CHECK-SAME: "functions":{"count":1,"covered":1,"percent":100},
+// CHECK-SAME: "instantiations":{"count":1,"covered":1,"percent":100},
// CHECK-SAME: "regions":{"count":10,"covered":7,"notcovered":3,"percent":70}}
// Close the export object, data array, and root object
Modified: llvm/trunk/test/tools/llvm-cov/Inputs/regionMarkers.json
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-cov/Inputs/regionMarkers.json?rev=281877&r1=281876&r2=281877&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-cov/Inputs/regionMarkers.json (original)
+++ llvm/trunk/test/tools/llvm-cov/Inputs/regionMarkers.json Sun Sep 18 19:38:29 2016
@@ -31,6 +31,7 @@
// CHECK-SAME: "totals":{
// CHECK-SAME: "lines":{"count":21,"covered":17,"percent":80,"noncode":0},
// CHECK-SAME: "functions":{"count":1,"covered":1,"percent":100},
+// CHECK-SAME: "instantiations":{"count":1,"covered":1,"percent":100},
// CHECK-SAME: "regions":{"count":10,"covered":7,"notcovered":3,"percent":70}}
// Close the export object, data array, and root object
Modified: llvm/trunk/test/tools/llvm-cov/Inputs/showExpansions.json
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-cov/Inputs/showExpansions.json?rev=281877&r1=281876&r2=281877&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-cov/Inputs/showExpansions.json (original)
+++ llvm/trunk/test/tools/llvm-cov/Inputs/showExpansions.json Sun Sep 18 19:38:29 2016
@@ -45,6 +45,7 @@
// CHECK-SAME: "totals":{
// CHECK-SAME: "lines":{"count":17,"covered":15,"percent":88,"noncode":0},
// CHECK-SAME: "functions":{"count":1,"covered":1,"percent":100},
+// CHECK-SAME: "instantiations":{"count":1,"covered":1,"percent":100},
// CHECK-SAME: "regions":{"count":13,"covered":12,"notcovered":1,"percent":92}}
// Close the export object, data array, and root object
Modified: llvm/trunk/test/tools/llvm-cov/Inputs/universal-binary.json
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-cov/Inputs/universal-binary.json?rev=281877&r1=281876&r2=281877&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-cov/Inputs/universal-binary.json (original)
+++ llvm/trunk/test/tools/llvm-cov/Inputs/universal-binary.json Sun Sep 18 19:38:29 2016
@@ -30,6 +30,7 @@
// CHECK-SAME: "totals":{
// CHECK-SAME: "lines":{"count":1,"covered":1,"percent":100,"noncode":0},
// CHECK-SAME: "functions":{"count":1,"covered":1,"percent":100},
+// CHECK-SAME: "instantiations":{"count":1,"covered":1,"percent":100},
// CHECK-SAME: "regions":{"count":1,"covered":1,"notcovered":0,"percent":100}
// Close the export object, data array, and root object
Modified: llvm/trunk/tools/llvm-cov/CoverageExporterJson.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/CoverageExporterJson.cpp?rev=281877&r1=281876&r2=281877&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/CoverageExporterJson.cpp (original)
+++ llvm/trunk/tools/llvm-cov/CoverageExporterJson.cpp Sun Sep 18 19:38:29 2016
@@ -36,10 +36,12 @@
// ---- Summary: dict => Object summarizing the coverage for the entire binary
// ------ LineCoverage: dict => Object summarizing line coverage
// ------ FunctionCoverage: dict => Object summarizing function coverage
+// ------ InstantiationCoverage: dict => Object summarizing inst. coverage
// ------ RegionCoverage: dict => Object summarizing region coverage
//
//===----------------------------------------------------------------------===//
+#include "CoverageReport.h"
#include "CoverageSummaryInfo.h"
#include "CoverageViewOptions.h"
#include "llvm/ProfileData/Coverage/CoverageMapping.h"
@@ -180,8 +182,12 @@ class CoverageExporterJson {
emitDictElement("object", getObjectFilename());
emitDictKey("files");
+
FileCoverageSummary Totals = FileCoverageSummary("Totals");
- renderFiles(Coverage.getUniqueSourceFiles(), Totals);
+ std::vector<StringRef> SourceFiles = Coverage.getUniqueSourceFiles();
+ auto FileReports =
+ CoverageReport::prepareFileReports(Coverage, Totals, SourceFiles);
+ renderFiles(SourceFiles, FileReports);
emitDictKey("functions");
renderFunctions(Coverage.getCoveredFunctions());
@@ -239,16 +245,14 @@ class CoverageExporterJson {
/// \brief Render an array of all the source files, also pass back a Summary.
void renderFiles(ArrayRef<StringRef> SourceFiles,
- FileCoverageSummary &Summary) {
+ ArrayRef<FileCoverageSummary> FileReports) {
// Start List of Files.
emitArrayStart();
- for (const auto &SourceFile : SourceFiles) {
- // Render the file.
- auto FileCoverage = Coverage.getCoverageForFile(SourceFile);
- renderFile(FileCoverage);
- for (const auto &F : Coverage.getCoveredFunctions(SourceFile))
- Summary.addFunction(FunctionCoverageSummary::get(F));
+ for (unsigned I = 0, E = SourceFiles.size(); I < E; ++I) {
+ // Render the file.
+ auto FileCoverage = Coverage.getCoverageForFile(SourceFiles[I]);
+ renderFile(FileCoverage, FileReports[I]);
}
// End List of Files.
@@ -256,7 +260,8 @@ class CoverageExporterJson {
}
/// \brief Render a single file.
- void renderFile(const CoverageData &FileCoverage) {
+ void renderFile(const CoverageData &FileCoverage,
+ const FileCoverageSummary &FileReport) {
// Start File.
emitDictStart();
@@ -283,14 +288,8 @@ class CoverageExporterJson {
// End List of Expansions.
emitArrayEnd();
- FileCoverageSummary Summary =
- FileCoverageSummary(FileCoverage.getFilename());
- for (const auto &F :
- Coverage.getCoveredFunctions(FileCoverage.getFilename()))
- Summary.addFunction(FunctionCoverageSummary::get(F));
-
emitDictKey("summary");
- renderSummary(Summary);
+ renderSummary(FileReport);
// End File.
emitDictEnd();
@@ -392,6 +391,17 @@ class CoverageExporterJson {
// End Function Coverage Summary.
emitDictEnd();
+ emitDictKey("instantiations");
+
+ // Start Instantiation Coverage Summary.
+ emitDictStart();
+ emitDictElement("count", Summary.InstantiationCoverage.NumFunctions);
+ emitDictElement("covered", Summary.InstantiationCoverage.Executed);
+ emitDictElement("percent",
+ Summary.InstantiationCoverage.getPercentCovered());
+ // End Function Coverage Summary.
+ emitDictEnd();
+
emitDictKey("regions");
// Start Region Coverage Summary.
More information about the llvm-commits
mailing list