[llvm] r342088 - [llvm-cov] Delete custom JSON serialization code (NFC)

Vedant Kumar via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 12 14:59:38 PDT 2018


Author: vedantk
Date: Wed Sep 12 14:59:38 2018
New Revision: 342088

URL: http://llvm.org/viewvc/llvm-project?rev=342088&view=rev
Log:
[llvm-cov] Delete custom JSON serialization code (NFC)

Teach llvm-cov to use the new llvm JSON library, and remove some
redundant/brittle JSON serialization tests.

Removed:
    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/universal-binary.json
Modified:
    llvm/trunk/test/tools/llvm-cov/Inputs/binary-formats.canonical.json
    llvm/trunk/test/tools/llvm-cov/Inputs/showExpansions.json
    llvm/trunk/test/tools/llvm-cov/binary-formats.c
    llvm/trunk/test/tools/llvm-cov/showHighlightedRanges.cpp
    llvm/trunk/test/tools/llvm-cov/showLineExecutionCounts.cpp
    llvm/trunk/test/tools/llvm-cov/showRegionMarkers.cpp
    llvm/trunk/test/tools/llvm-cov/universal-binary.c
    llvm/trunk/tools/llvm-cov/CoverageExporter.h
    llvm/trunk/tools/llvm-cov/CoverageExporterJson.cpp
    llvm/trunk/tools/llvm-cov/CoverageExporterJson.h

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=342088&r1=342087&r2=342088&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 Wed Sep 12 14:59:38 2018
@@ -1,39 +1,27 @@
-// Metadata section
-// CHECK: {"version":"{{[0-9]\.[0-9]\.[0-9]}}","type":"llvm.coverage.json.export","data":[
-
-// Open Export
-// CHECK-SAME: {"files":[
-
-// File Object
-// CHECK-SAME: {"filename":"{{[^"]+}}binary-formats.c",
-// CHECK-SAME: "segments":[
-// CHECK-SAME: [4,40,100,1,1],[4,42,0,0,0]],
-// CHECK-SAME: "expansions":[],
-
-// Verify the Summary Section for the first file
-// CHECK-SAME: "summary":{
-// CHECK-SAME: "lines":{"count":1,"covered":1,"percent":100},
-// CHECK-SAME: "functions":{"count":1,"covered":1,"percent":100},
-// CHECK-SAME: "regions":{"count":1,"covered":1,"notcovered":0,"percent":100}}}
-
-// Close Files Array
-// CHECK-SAME: ],
-
-// Functions List
-// CHECK-SAME: "functions":[
-// CHECK-SAME: {"name":"main","count":100,"regions":[
-// CHECK-SAME: [4,40,4,42,100,0,0,0]
-// CHECK-SAME: ],
-// CHECK-SAME: "filenames":["{{[^"]+}}binary-formats.c"]
-// CHECK-SAME: }],
-
-
-// Full Export Summary
-// CHECK-SAME: "totals":{
-// CHECK-SAME: "lines":{"count":1,"covered":1,"percent":100},
-// 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
-// CHECK-SAME: }]}
+CHECK: {"data":
+CHECK-SAME: [{
+CHECK-SAME:  "files":[
+CHECK-SAME:    {"expansions":[],
+CHECK-SAME:     "filename":"/tmp/binary-formats.c",
+CHECK-SAME:     "segments":
+CHECK-SAME:        4,40,100,true,true
+CHECK-SAME:        4,42,0,false,false
+CHECK-SAME:     "summary":{"functions":{"count":1,"covered":1,"percent":100},
+CHECK-SAME:                "instantiations":{"count":1,"covered":1,"percent":100},
+CHECK-SAME:                "lines":{"count":1,"covered":1,"percent":100},
+CHECK-SAME:                "regions":{"count":1,"covered":1,"notcovered":0,"percent":100}}}
+CHECK-SAME:  ],
+CHECK-SAME:  "functions":[
+CHECK-SAME:    {"count":100,"filenames":["/tmp/binary-formats.c"],"name":"main",
+CHECK-SAME:     "regions":
+CHECK-SAME:        4,40,4,42,100,0,0,0
+CHECK-SAME:    }
+CHECK-SAME:  ],
+CHECK-SAME:  "totals":
+CHECK-SAME:    {"functions":{"count":1,"covered":1,"percent":100},
+CHECK-SAME:     "instantiations":{"count":1,"covered":1,"percent":100},
+CHECK-SAME:     "lines":{"count":1,"covered":1,"percent":100},
+CHECK-SAME:     "regions":{"count":1,"covered":1,"notcovered":0,"percent":100}}}
+CHECK-SAME: ],
+CHECK-SAME: "type":"llvm.coverage.json.export"
+CHECK-SAME: "version":"2.0.0"

Removed: 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=342087&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-cov/Inputs/highlightedRanges.json (original)
+++ llvm/trunk/test/tools/llvm-cov/Inputs/highlightedRanges.json (removed)
@@ -1,51 +0,0 @@
-// Metadata section
-// CHECK: {"version":"{{[0-9]\.[0-9]\.[0-9]}}","type":"llvm.coverage.json.export","data":[
-
-// Open Export
-// CHECK-SAME: {"files":[
-
-// File Object
-// CHECK-SAME: {"filename":"{{[^"]+}}showHighlightedRanges.cpp",
-// CHECK-SAME: "segments":[
-// CHECK-SAME: {{(\[[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+\],?)+}}],
-// CHECK-SAME: "expansions":[],
-
-// Verify the Summary Section for the first file
-// CHECK-SAME: "summary":{
-// CHECK-SAME: "lines":{"count":40,"covered":33,"percent":82},
-// CHECK-SAME: "functions":{"count":4,"covered":4,"percent":100},
-// CHECK-SAME: "regions":{"count":21,"covered":13,"notcovered":8,"percent":61}}}
-
-// Close Files Array
-// CHECK-SAME: ],
-
-// Functions List
-// CHECK-SAME: "functions":[
-// CHECK-SAME: {"name":"_Z4funcv","count":1,"regions":[
-// CHECK-SAME: {{(\[[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+\],?)+}}
-// CHECK-SAME: ],
-// CHECK-SAME: "filenames":["{{[^"]+}}showHighlightedRanges.cpp"]
-// CHECK-SAME: },
-// CHECK-SAME: {"name":"_Z5func2i","count":1,"regions":[
-// CHECK-SAME: {{(\[[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+\],?)+}}
-// CHECK-SAME: ],
-// CHECK-SAME: "filenames":["{{[^"]+}}showHighlightedRanges.cpp"]
-// CHECK-SAME: }
-// CHECK-SAME: {"name":"_Z4testv","count":1,"regions":[
-// CHECK-SAME: {{(\[[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+\],?)+}}
-// CHECK-SAME: ],
-// CHECK-SAME: "filenames":["{{[^"]+}}showHighlightedRanges.cpp"]
-// CHECK-SAME: }
-// CHECK-SAME: {"name":"main","count":1,"regions":[
-// CHECK-SAME: {{(\[[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+\],?)+}}
-// CHECK-SAME: ],
-// CHECK-SAME: "filenames":["{{.*}}showHighlightedRanges.cpp"]
-// CHECK-SAME: }],
-
-
-// Full Export Summary
-// CHECK-SAME: "totals":{
-// CHECK-SAME: "lines":{"count":40,"covered":33,"percent":82},
-// CHECK-SAME: "functions":{"count":4,"covered":4,"percent":100},
-// CHECK-SAME: "instantiations":{"count":4,"covered":4,"percent":100},
-// CHECK-SAME: "regions":{"count":21,"covered":13,"notcovered":8,"percent":61}}}

Removed: 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=342087&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-cov/Inputs/lineExecutionCounts.json (original)
+++ llvm/trunk/test/tools/llvm-cov/Inputs/lineExecutionCounts.json (removed)
@@ -1,39 +0,0 @@
-// Metadata section
-// CHECK: {"version":"{{[0-9]\.[0-9]\.[0-9]}}","type":"llvm.coverage.json.export","data":[
-
-// Open Export
-// CHECK-SAME: {"files":[
-
-// File Object
-// CHECK-SAME: {"filename":"{{[^"]+}}showLineExecutionCounts.cpp",
-// CHECK-SAME: "segments":[
-// CHECK-SAME: {{(\[[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+\],?)+}}],
-// CHECK-SAME: "expansions":[],
-
-// Verify the Summary Section for the first file
-// CHECK-SAME: "summary":{
-// CHECK-SAME: "lines":{"count":20,"covered":18,"percent":90},
-// CHECK-SAME: "functions":{"count":1,"covered":1,"percent":100},
-// CHECK-SAME: "regions":{"count":11,"covered":8,"notcovered":3,"percent":72}}}
-
-// Close Files Array
-// CHECK-SAME: ],
-
-// Functions List
-// CHECK-SAME: "functions":[
-// CHECK-SAME: {"name":"main","count":161,"regions":[
-// CHECK-SAME: {{(\[[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+\],?)+}}
-// CHECK-SAME: ],
-// CHECK-SAME: "filenames":["{{[^"]+}}showLineExecutionCounts.cpp"]
-// CHECK-SAME: }],
-
-
-// Full Export Summary
-// CHECK-SAME: "totals":{
-// CHECK-SAME: "lines":{"count":20,"covered":18,"percent":90},
-// CHECK-SAME: "functions":{"count":1,"covered":1,"percent":100},
-// CHECK-SAME: "instantiations":{"count":1,"covered":1,"percent":100},
-// CHECK-SAME: "regions":{"count":11,"covered":8,"notcovered":3,"percent":72}}
-
-// Close the export object, data array, and root object
-// CHECK-SAME: }]}

Removed: 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=342087&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-cov/Inputs/regionMarkers.json (original)
+++ llvm/trunk/test/tools/llvm-cov/Inputs/regionMarkers.json (removed)
@@ -1,35 +0,0 @@
-// Metadata section
-// CHECK: {"version":"{{[0-9]\.[0-9]\.[0-9]}}","type":"llvm.coverage.json.export","data":[
-
-// Open Export
-// CHECK-SAME: {"files":[
-
-// File Object
-// CHECK-SAME: {"filename":"{{[^"]+}}showRegionMarkers.cpp",
-// CHECK-SAME: "segments":[
-// CHECK-SAME: {{(\[[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+\],?)+}}],
-// CHECK-SAME: "expansions":[],
-
-// Verify the Summary Section for the first file
-// CHECK-SAME: "summary":{
-// CHECK-SAME: "lines":{"count":21,"covered":19,"percent":90},
-// CHECK-SAME: "functions":{"count":1,"covered":1,"percent":100},
-// CHECK-SAME: "regions":{"count":11,"covered":8,"notcovered":3,"percent":72}}
-
-// Close Files Array
-// CHECK-SAME: ],
-
-// Functions List
-// CHECK-SAME: "functions":[
-// CHECK-SAME: {"name":"main","count":1111000,"regions":[
-// CHECK-SAME: {{(\[[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+\],?)+}}
-// CHECK-SAME: ],
-// CHECK-SAME: "filenames":["{{[^"]+}}showRegionMarkers.cpp"]
-// CHECK-SAME: }],
-
-// Full Export Summary
-// CHECK-SAME: "totals":{
-// CHECK-SAME: "lines":{"count":21,"covered":19,"percent":90},
-// CHECK-SAME: "functions":{"count":1,"covered":1,"percent":100},
-// CHECK-SAME: "instantiations":{"count":1,"covered":1,"percent":100},
-// CHECK-SAME: "regions":{"count":11,"covered":8,"notcovered":3,"percent":72}}

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=342088&r1=342087&r2=342088&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-cov/Inputs/showExpansions.json (original)
+++ llvm/trunk/test/tools/llvm-cov/Inputs/showExpansions.json Wed Sep 12 14:59:38 2018
@@ -1,52 +1,4 @@
-// Metadata section
-// CHECK: {"version":"{{[0-9]\.[0-9]\.[0-9]}}","type":"llvm.coverage.json.export","data":[
-
-// Open Export
-// CHECK-SAME: {"files":[
-
-// File Object
-// CHECK-SAME: {"filename":"{{[^"]+}}showExpansions.cpp",
-// CHECK-SAME: "segments":[
-// CHECK-SAME: {{(\[[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+\],?)+}}],
-// CHECK-SAME: "expansions":[
-// CHECK-SAME: {"source_region":[24,5,24,17,100,0,1,1],
-// CHECK-SAME: "target_regions":[
-// CHECK-SAME: {{(\[[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+\],?)+}}
-// CHECK-SAME: ],
-
-// Yes, 4 of the same filename in a row
-// CHECK-SAME: "filenames":[
-// CHECK-SAME: "{{[^"]+}}showExpansions.cpp","{{[^"]+}}showExpansions.cpp",
-// CHECK-SAME: "{{[^"]+}}showExpansions.cpp","{{[^"]+}}showExpansions.cpp"]
-// CHECK-SAME: }],
-
-// Verify the Summary Section for the first file
-// CHECK-SAME: "summary":{
-// CHECK-SAME: "lines":{"count":5,"covered":5,"percent":100},
-// CHECK-SAME: "functions":{"count":1,"covered":1,"percent":100},
-// CHECK-SAME: "regions":{"count":13,"covered":12,"notcovered":1,"percent":92}}
-
-// Close Files Array
-// CHECK-SAME: ],
-
-// Functions List
-// CHECK-SAME: "functions":[
-// CHECK-SAME: {"name":"main","count":1,"regions":[
-// CHECK-SAME: {{(\[[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+\],?)+}}
-// CHECK-SAME: ],
-// CHECK-SAME: "filenames":[
-// CHECK-SAME: "{{[^"]+}}showExpansions.cpp",
-// CHECK-SAME: "{{[^"]+}}showExpansions.cpp",
-// CHECK-SAME: "{{[^"]+}}showExpansions.cpp",
-// CHECK-SAME: "{{[^"]+}}showExpansions.cpp"]
-// CHECK-SAME: }],
-
-// Full Export Summary
-// CHECK-SAME: "totals":{
-// CHECK-SAME: "lines":{"count":5,"covered":5,"percent":100},
-// 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
-// CHECK-SAME: }]}
+CHECK: {"expansions":
+CHECK:    "filenames":["{{[^"]+}}showExpansions.cpp",
+CHECK:    "source_region":[24,5,24,17,100,0,1,1],
+CHECK:    "filename":"{{[^"]+}}showExpansions.cpp",

Removed: 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=342087&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-cov/Inputs/universal-binary.json (original)
+++ llvm/trunk/test/tools/llvm-cov/Inputs/universal-binary.json (removed)
@@ -1,37 +0,0 @@
-// Metadata section
-// CHECK: {"version":"{{[0-9]\.[0-9]\.[0-9]}}","type":"llvm.coverage.json.export","data":[
-
-// Open Export
-// CHECK-SAME: {"files":[
-
-// File Object
-// CHECK-SAME: {"filename":"{{[^"]+}}universal-binary.c",
-// CHECK-SAME: "segments":[
-// CHECK-SAME: {{(\[[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+\],?)+}}],
-// CHECK-SAME: "expansions":[],
-
-// Verify the Summary Section for the first file
-// CHECK-SAME: "summary":{
-// CHECK-SAME: "lines":{"count":1,"covered":1,"percent":100},
-// CHECK-SAME: "functions":{"count":1,"covered":1,"percent":100},
-// CHECK-SAME: "regions":{"count":1,"covered":1,"notcovered":0,"percent":100}}
-
-// Close Files Array
-// CHECK-SAME: ],
-
-// Functions List
-// CHECK-SAME: "functions":[
-// CHECK-SAME: {"name":"main","count":100,"regions":[
-// CHECK-SAME: {{(\[[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+\],?)+}}],
-// CHECK-SAME: "filenames":["{{[^"]+}}universal-binary.c"]
-// CHECK-SAME: }],
-
-// Full Export Summary
-// CHECK-SAME: "totals":{
-// CHECK-SAME: "lines":{"count":1,"covered":1,"percent":100},
-// 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
-// CHECK-SAME: }]}

Modified: llvm/trunk/test/tools/llvm-cov/binary-formats.c
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-cov/binary-formats.c?rev=342088&r1=342087&r2=342088&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-cov/binary-formats.c (original)
+++ llvm/trunk/test/tools/llvm-cov/binary-formats.c Wed Sep 12 14:59:38 2018
@@ -8,6 +8,4 @@ int main(int argc, const char *argv[]) {
 // RUN: llvm-cov show %S/Inputs/binary-formats.macho64l -instr-profile %t.profdata -path-equivalence=/tmp,%S %s | FileCheck %s
 // RUN: llvm-cov show %S/Inputs/binary-formats.macho32b -instr-profile %t.profdata -path-equivalence=/tmp,%S %s | FileCheck %s
 
-// RUN: llvm-cov export %S/Inputs/binary-formats.macho32l -instr-profile %t.profdata | FileCheck %S/Inputs/binary-formats.canonical.json
 // RUN: llvm-cov export %S/Inputs/binary-formats.macho64l -instr-profile %t.profdata | FileCheck %S/Inputs/binary-formats.canonical.json
-// RUN: llvm-cov export %S/Inputs/binary-formats.macho32b -instr-profile %t.profdata | FileCheck %S/Inputs/binary-formats.canonical.json

Modified: llvm/trunk/test/tools/llvm-cov/showHighlightedRanges.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-cov/showHighlightedRanges.cpp?rev=342088&r1=342087&r2=342088&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-cov/showHighlightedRanges.cpp (original)
+++ llvm/trunk/test/tools/llvm-cov/showHighlightedRanges.cpp Wed Sep 12 14:59:38 2018
@@ -45,4 +45,3 @@ int main() {
 }
 
 // RUN: llvm-cov show %S/Inputs/highlightedRanges.covmapping -instr-profile %S/Inputs/highlightedRanges.profdata -format html -dump -path-equivalence=/tmp,%S %s 2>&1 | FileCheck %s -check-prefixes=HTML,SHARED
-// RUN: llvm-cov export %S/Inputs/highlightedRanges.covmapping -instr-profile %S/Inputs/highlightedRanges.profdata 2>&1 | FileCheck %S/Inputs/highlightedRanges.json

Modified: llvm/trunk/test/tools/llvm-cov/showLineExecutionCounts.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-cov/showLineExecutionCounts.cpp?rev=342088&r1=342087&r2=342088&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-cov/showLineExecutionCounts.cpp (original)
+++ llvm/trunk/test/tools/llvm-cov/showLineExecutionCounts.cpp Wed Sep 12 14:59:38 2018
@@ -35,10 +35,6 @@ int main() {
 // RUN: FileCheck -check-prefixes=TEXT,WHOLE-FILE -input-file %t.dir/coverage/tmp/showLineExecutionCounts.cpp.txt %s
 // RUN: FileCheck -check-prefixes=TEXT,FILTER -input-file %t.filtered.dir/coverage/tmp/showLineExecutionCounts.cpp.txt %s
 //
-// RUN: llvm-cov export %S/Inputs/lineExecutionCounts.covmapping -instr-profile %t.profdata -name=main 2>/dev/null > %t.export.json
-// RUN: FileCheck -input-file %t.export.json %S/Inputs/lineExecutionCounts.json
-// RUN: cat %t.export.json | %python -c "import json, sys; json.loads(sys.stdin.read())"
-//
 // RUN: llvm-cov export %S/Inputs/lineExecutionCounts.covmapping -instr-profile %t.profdata 2>/dev/null -summary-only > %t.export-summary.json
 // RUN: not grep '"name":"main"' %t.export-summary.json
 //

Modified: llvm/trunk/test/tools/llvm-cov/showRegionMarkers.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-cov/showRegionMarkers.cpp?rev=342088&r1=342087&r2=342088&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-cov/showRegionMarkers.cpp (original)
+++ llvm/trunk/test/tools/llvm-cov/showRegionMarkers.cpp Wed Sep 12 14:59:38 2018
@@ -24,5 +24,3 @@ int main() {                      // CHE
 
 // RUN: llvm-cov show %S/Inputs/regionMarkers.covmapping -instr-profile %t.profdata -show-regions -dump -path-equivalence=/tmp,%S/ %s 2>&1 | FileCheck %s
 // RUN: llvm-cov show %S/Inputs/regionMarkers.covmapping -instr-profile %t.profdata -show-regions -format=html -dump -path-equivalence=/tmp,%S %s 2>&1 | FileCheck %s
-
-// RUN: llvm-cov export %S/Inputs/regionMarkers.covmapping -instr-profile %t.profdata 2>&1 | FileCheck %S/Inputs/regionMarkers.json

Modified: llvm/trunk/test/tools/llvm-cov/universal-binary.c
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-cov/universal-binary.c?rev=342088&r1=342087&r2=342088&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-cov/universal-binary.c (original)
+++ llvm/trunk/test/tools/llvm-cov/universal-binary.c Wed Sep 12 14:59:38 2018
@@ -5,7 +5,6 @@ int main(int argc, const char *argv[]) {
 
 // RUN: llvm-profdata merge %S/Inputs/universal-binary.proftext -o %t.profdata
 // RUN: llvm-cov show %S/Inputs/universal-binary -instr-profile %t.profdata -path-equivalence=/tmp,%S %s -arch x86_64 | FileCheck %s
-// RUN: llvm-cov export %S/Inputs/universal-binary -instr-profile %t.profdata -arch x86_64 2>&1 | FileCheck %S/Inputs/universal-binary.json
 
 // RUN: llvm-cov report %S/Inputs/universal-binary -arch x86_64 -object %S/Inputs/templateInstantiations.covmapping -arch i386 -instr-profile %t.profdata 2>&1 | FileCheck %s --check-prefix=COMBINED
 // COMBINED: showTemplateInstantiations.cpp

Modified: llvm/trunk/tools/llvm-cov/CoverageExporter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/CoverageExporter.h?rev=342088&r1=342087&r2=342088&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/CoverageExporter.h (original)
+++ llvm/trunk/tools/llvm-cov/CoverageExporter.h Wed Sep 12 14:59:38 2018
@@ -30,7 +30,7 @@ protected:
   /// The options passed to the tool.
   const CoverageViewOptions &Options;
 
-  /// Output stream to print JSON to.
+  /// Output stream to print to.
   raw_ostream &OS;
 
   CoverageExporter(const coverage::CoverageMapping &CoverageMapping,
@@ -41,10 +41,10 @@ public:
   virtual ~CoverageExporter(){};
 
   /// Render the CoverageMapping object.
-  virtual void renderRoot(const CoverageFilters &IgnoreFilenameFilters) = 0;
+  virtual void renderRoot(const CoverageFilters &IgnoreFilters) = 0;
 
   /// Render the CoverageMapping object for specified source files.
-  virtual void renderRoot(const std::vector<std::string> &SourceFiles) = 0;
+  virtual void renderRoot(ArrayRef<std::string> SourceFiles) = 0;
 };
 
 } // end namespace llvm

Modified: llvm/trunk/tools/llvm-cov/CoverageExporterJson.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/CoverageExporterJson.cpp?rev=342088&r1=342087&r2=342088&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/CoverageExporterJson.cpp (original)
+++ llvm/trunk/tools/llvm-cov/CoverageExporterJson.cpp Wed Sep 12 14:59:38 2018
@@ -16,33 +16,34 @@
 // The json code coverage export follows the following format
 // Root: dict => Root Element containing metadata
 // -- Data: array => Homogeneous array of one or more export objects
-// ---- Export: dict => Json representation of one CoverageMapping
-// ------ Files: array => List of objects describing coverage for files
-// -------- File: dict => Coverage for a single file
-// ---------- Segments: array => List of Segments contained in the file
-// ------------ Segment: dict => Describes a segment of the file with a counter
-// ---------- Expansions: array => List of expansion records
-// ------------ Expansion: dict => Object that descibes a single expansion
-// -------------- CountedRegion: dict => The region to be expanded
-// -------------- TargetRegions: array => List of Regions in the expansion
-// ---------------- CountedRegion: dict => Single Region in the expansion
-// ---------- Summary: dict => Object summarizing the coverage for this file
-// ------------ LineCoverage: dict => Object summarizing line coverage
-// ------------ FunctionCoverage: dict => Object summarizing function coverage
-// ------------ RegionCoverage: dict => Object summarizing region coverage
-// ------ Functions: array => List of objects describing coverage for functions
-// -------- Function: dict => Coverage info for a single function
-// ---------- Filenames: array => List of filenames that the function relates to
-// ---- 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
+//   -- Export: dict => Json representation of one CoverageMapping
+//     -- Files: array => List of objects describing coverage for files
+//       -- File: dict => Coverage for a single file
+//         -- Segments: array => List of Segments contained in the file
+//           -- Segment: dict => Describes a segment of the file with a counter
+//         -- Expansions: array => List of expansion records
+//           -- Expansion: dict => Object that descibes a single expansion
+//             -- CountedRegion: dict => The region to be expanded
+//             -- TargetRegions: array => List of Regions in the expansion
+//               -- CountedRegion: dict => Single Region in the expansion
+//         -- Summary: dict => Object summarizing the coverage for this file
+//           -- LineCoverage: dict => Object summarizing line coverage
+//           -- FunctionCoverage: dict => Object summarizing function coverage
+//           -- RegionCoverage: dict => Object summarizing region coverage
+//     -- Functions: array => List of objects describing coverage for functions
+//       -- Function: dict => Coverage info for a single function
+//         -- Filenames: array => List of filenames that the function relates to
+//   -- 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 "CoverageExporterJson.h"
 #include "CoverageReport.h"
+#include "llvm/Support/JSON.h"
 
 /// The semantic version combined as a string.
 #define LLVM_COVERAGE_EXPORT_JSON_STR "2.0.0"
@@ -52,335 +53,142 @@
 
 using namespace llvm;
 
-CoverageExporterJson::CoverageExporterJson(
-    const coverage::CoverageMapping &CoverageMapping,
-    const CoverageViewOptions &Options, raw_ostream &OS)
-    : CoverageExporter(CoverageMapping, Options, OS) {
-  State.push(JsonState::None);
-}
-
-void CoverageExporterJson::emitSerialized(const int64_t Value) { OS << Value; }
-
-void CoverageExporterJson::emitSerialized(const std::string &Value) {
-  OS << "\"";
-  for (char C : Value) {
-    if (C != '\\')
-      OS << C;
-    else
-      OS << "\\\\";
-  }
-  OS << "\"";
+namespace {
+
+json::Array renderSegment(const coverage::CoverageSegment &Segment) {
+  return json::Array({Segment.Line, Segment.Col, int64_t(Segment.Count),
+                      Segment.HasCount, Segment.IsRegionEntry});
 }
 
-void CoverageExporterJson::emitComma() {
-  if (State.top() == JsonState::NonEmptyElement) {
-    OS << ",";
-  } else if (State.top() == JsonState::EmptyElement) {
-    State.pop();
-    assert((State.size() >= 1) && "Closed too many JSON elements");
-    State.push(JsonState::NonEmptyElement);
-  }
+json::Array renderRegion(const coverage::CountedRegion &Region) {
+  return json::Array({Region.LineStart, Region.ColumnStart, Region.LineEnd,
+                      Region.ColumnEnd, int64_t(Region.ExecutionCount),
+                      Region.FileID, Region.ExpandedFileID,
+                      int64_t(Region.Kind)});
 }
 
-void CoverageExporterJson::emitDictStart() {
-  emitComma();
-  State.push(JsonState::EmptyElement);
-  OS << "{";
+json::Array renderRegions(ArrayRef<coverage::CountedRegion> Regions) {
+  json::Array RegionArray;
+  for (const auto &Region : Regions)
+    RegionArray.push_back(renderRegion(Region));
+  return RegionArray;
 }
 
-void CoverageExporterJson::emitDictKey(const std::string &Key) {
-  emitComma();
-  emitSerialized(Key);
-  OS << ":";
-  State.pop();
-  assert((State.size() >= 1) && "Closed too many JSON elements");
+json::Object renderExpansion(const coverage::ExpansionRecord &Expansion) {
+  return json::Object(
+      {{"filenames", json::Array(Expansion.Function.Filenames)},
+       // Mark the beginning and end of this expansion in the source file.
+       {"source_region", renderRegion(Expansion.Region)},
+       // Enumerate the coverage information for the expansion.
+       {"target_regions", renderRegions(Expansion.Function.CountedRegions)}});
+}
+
+json::Object renderSummary(const FileCoverageSummary &Summary) {
+  return json::Object(
+      {{"lines",
+        json::Object({{"count", int64_t(Summary.LineCoverage.getNumLines())},
+                      {"covered", int64_t(Summary.LineCoverage.getCovered())},
+                      {"percent", Summary.LineCoverage.getPercentCovered()}})},
+       {"functions",
+        json::Object(
+            {{"count", int64_t(Summary.FunctionCoverage.getNumFunctions())},
+             {"covered", int64_t(Summary.FunctionCoverage.getExecuted())},
+             {"percent", Summary.FunctionCoverage.getPercentCovered()}})},
+       {"instantiations",
+        json::Object(
+            {{"count",
+              int64_t(Summary.InstantiationCoverage.getNumFunctions())},
+             {"covered", int64_t(Summary.InstantiationCoverage.getExecuted())},
+             {"percent", Summary.InstantiationCoverage.getPercentCovered()}})},
+       {"regions",
+        json::Object(
+            {{"count", int64_t(Summary.RegionCoverage.getNumRegions())},
+             {"covered", int64_t(Summary.RegionCoverage.getCovered())},
+             {"notcovered", int64_t(Summary.RegionCoverage.getNumRegions() -
+                                    Summary.RegionCoverage.getCovered())},
+             {"percent", Summary.RegionCoverage.getPercentCovered()}})}});
+}
+
+json::Array renderFileExpansions(const coverage::CoverageData &FileCoverage,
+                                 const FileCoverageSummary &FileReport) {
+  json::Array ExpansionArray;
+  for (const auto &Expansion : FileCoverage.getExpansions())
+    ExpansionArray.push_back(renderExpansion(Expansion));
+  return ExpansionArray;
+}
 
-  // We do not want to emit a comma after this key.
-  State.push(JsonState::EmptyElement);
+json::Array renderFileSegments(const coverage::CoverageData &FileCoverage,
+                               const FileCoverageSummary &FileReport) {
+  json::Array SegmentArray;
+  for (const auto &Segment : FileCoverage)
+    SegmentArray.push_back(renderSegment(Segment));
+  return SegmentArray;
 }
 
-void CoverageExporterJson::emitDictEnd() {
-  State.pop();
-  assert((State.size() >= 1) && "Closed too many JSON elements");
-  OS << "}";
+json::Object renderFile(const coverage::CoverageMapping &Coverage,
+                        const std::string &Filename,
+                        const FileCoverageSummary &FileReport,
+                        bool ExportSummaryOnly) {
+  json::Object File({{"filename", Filename}});
+  if (!ExportSummaryOnly) {
+    // Calculate and render detailed coverage information for given file.
+    auto FileCoverage = Coverage.getCoverageForFile(Filename);
+    File["segments"] = renderFileSegments(FileCoverage, FileReport);
+    File["expansions"] = renderFileExpansions(FileCoverage, FileReport);
+  }
+  File["summary"] = renderSummary(FileReport);
+  return File;
 }
 
-void CoverageExporterJson::emitArrayStart() {
-  emitComma();
-  State.push(JsonState::EmptyElement);
-  OS << "[";
+json::Array renderFiles(const coverage::CoverageMapping &Coverage,
+                        ArrayRef<std::string> SourceFiles,
+                        ArrayRef<FileCoverageSummary> FileReports,
+                        bool ExportSummaryOnly) {
+  json::Array FileArray;
+  for (unsigned I = 0, E = SourceFiles.size(); I < E; ++I)
+    FileArray.push_back(renderFile(Coverage, SourceFiles[I], FileReports[I],
+                                   ExportSummaryOnly));
+  return FileArray;
 }
 
-void CoverageExporterJson::emitArrayEnd() {
-  State.pop();
-  assert((State.size() >= 1) && "Closed too many JSON elements");
-  OS << "]";
+json::Array renderFunctions(
+    const iterator_range<coverage::FunctionRecordIterator> &Functions) {
+  json::Array FunctionArray;
+  for (const auto &F : Functions)
+    FunctionArray.push_back(
+        json::Object({{"name", F.Name},
+                      {"count", int64_t(F.ExecutionCount)},
+                      {"regions", renderRegions(F.CountedRegions)},
+                      {"filenames", json::Array(F.Filenames)}}));
+  return FunctionArray;
 }
 
-void CoverageExporterJson::renderRoot(
-    const CoverageFilters &IgnoreFilenameFilters) {
+} // end anonymous namespace
+
+void CoverageExporterJson::renderRoot(const CoverageFilters &IgnoreFilters) {
   std::vector<std::string> SourceFiles;
   for (StringRef SF : Coverage.getUniqueSourceFiles()) {
-    if (!IgnoreFilenameFilters.matchesFilename(SF))
+    if (!IgnoreFilters.matchesFilename(SF))
       SourceFiles.emplace_back(SF);
   }
   renderRoot(SourceFiles);
 }
 
-void CoverageExporterJson::renderRoot(
-    const std::vector<std::string> &SourceFiles) {
-  // Start Root of JSON object.
-  emitDictStart();
-
-  emitDictElement("version", LLVM_COVERAGE_EXPORT_JSON_STR);
-  emitDictElement("type", LLVM_COVERAGE_EXPORT_JSON_TYPE_STR);
-  emitDictKey("data");
-
-  // Start List of Exports.
-  emitArrayStart();
-
-  // Start Export.
-  emitDictStart();
-
-  emitDictKey("files");
-
+void CoverageExporterJson::renderRoot(ArrayRef<std::string> SourceFiles) {
   FileCoverageSummary Totals = FileCoverageSummary("Totals");
   auto FileReports = CoverageReport::prepareFileReports(Coverage, Totals,
                                                         SourceFiles, Options);
-  renderFiles(SourceFiles, FileReports);
-
+  auto Export =
+      json::Object({{"files", renderFiles(Coverage, SourceFiles, FileReports,
+                                          Options.ExportSummaryOnly)},
+                    {"totals", renderSummary(Totals)}});
   // Skip functions-level information for summary-only export mode.
-  if (!Options.ExportSummaryOnly) {
-    emitDictKey("functions");
-    renderFunctions(Coverage.getCoveredFunctions());
-  }
-
-  emitDictKey("totals");
-  renderSummary(Totals);
-
-  // End Export.
-  emitDictEnd();
-
-  // End List of Exports.
-  emitArrayEnd();
-
-  // End Root of JSON Object.
-  emitDictEnd();
-
-  assert((State.top() == JsonState::None) &&
-         "All Elements In JSON were Closed");
-}
-
-void CoverageExporterJson::renderFunctions(
-    const iterator_range<coverage::FunctionRecordIterator> &Functions) {
-  // Start List of Functions.
-  emitArrayStart();
-
-  for (const auto &Function : Functions) {
-    // Start Function.
-    emitDictStart();
-
-    emitDictElement("name", Function.Name);
-    emitDictElement("count", Function.ExecutionCount);
-    emitDictKey("regions");
-
-    renderRegions(Function.CountedRegions);
-
-    emitDictKey("filenames");
-
-    // Start Filenames for Function.
-    emitArrayStart();
-
-    for (const auto &FileName : Function.Filenames)
-      emitArrayElement(FileName);
-
-    // End Filenames for Function.
-    emitArrayEnd();
-
-    // End Function.
-    emitDictEnd();
-  }
-
-  // End List of Functions.
-  emitArrayEnd();
-}
-
-void CoverageExporterJson::renderFiles(
-    ArrayRef<std::string> SourceFiles,
-    ArrayRef<FileCoverageSummary> FileReports) {
-  // Start List of Files.
-  emitArrayStart();
-
-  for (unsigned I = 0, E = SourceFiles.size(); I < E; ++I) {
-    renderFile(SourceFiles[I], FileReports[I]);
-  }
-
-  // End List of Files.
-  emitArrayEnd();
-}
-
-void CoverageExporterJson::renderFile(const std::string &Filename,
-                                      const FileCoverageSummary &FileReport) {
-  // Start File.
-  emitDictStart();
-
-  emitDictElement("filename", Filename);
-
-  if (!Options.ExportSummaryOnly) {
-    // Calculate and render detailed coverage information for given file.
-    auto FileCoverage = Coverage.getCoverageForFile(Filename);
-    renderFileCoverage(FileCoverage, FileReport);
-  }
-
-  emitDictKey("summary");
-  renderSummary(FileReport);
-
-  // End File.
-  emitDictEnd();
-}
-
-
-void CoverageExporterJson::renderFileCoverage(
-    const coverage::CoverageData &FileCoverage,
-    const FileCoverageSummary &FileReport) {
-  emitDictKey("segments");
-
-  // Start List of Segments.
-  emitArrayStart();
-
-  for (const auto &Segment : FileCoverage)
-    renderSegment(Segment);
-
-  // End List of Segments.
-  emitArrayEnd();
-
-  emitDictKey("expansions");
-
-  // Start List of Expansions.
-  emitArrayStart();
-
-  for (const auto &Expansion : FileCoverage.getExpansions())
-    renderExpansion(Expansion);
-
-  // End List of Expansions.
-  emitArrayEnd();
-}
-
-void CoverageExporterJson::renderSegment(
-    const coverage::CoverageSegment &Segment) {
-  // Start Segment.
-  emitArrayStart();
-
-  emitArrayElement(Segment.Line);
-  emitArrayElement(Segment.Col);
-  emitArrayElement(Segment.Count);
-  emitArrayElement(Segment.HasCount);
-  emitArrayElement(Segment.IsRegionEntry);
-
-  // End Segment.
-  emitArrayEnd();
-}
-
-void CoverageExporterJson::renderExpansion(
-    const coverage::ExpansionRecord &Expansion) {
-  // Start Expansion.
-  emitDictStart();
-
-  // Mark the beginning and end of this expansion in the source file.
-  emitDictKey("source_region");
-  renderRegion(Expansion.Region);
-
-  // Enumerate the coverage information for the expansion.
-  emitDictKey("target_regions");
-  renderRegions(Expansion.Function.CountedRegions);
-
-  emitDictKey("filenames");
-  // Start List of Filenames to map the fileIDs.
-  emitArrayStart();
-  for (const auto &Filename : Expansion.Function.Filenames)
-    emitArrayElement(Filename);
-  // End List of Filenames.
-  emitArrayEnd();
-
-  // End Expansion.
-  emitDictEnd();
-}
-
-void CoverageExporterJson::renderRegions(
-    ArrayRef<coverage::CountedRegion> Regions) {
-  // Start List of Regions.
-  emitArrayStart();
-
-  for (const auto &Region : Regions)
-    renderRegion(Region);
-
-  // End List of Regions.
-  emitArrayEnd();
-}
+  if (!Options.ExportSummaryOnly)
+    Export["functions"] = renderFunctions(Coverage.getCoveredFunctions());
 
-void CoverageExporterJson::renderRegion(const coverage::CountedRegion &Region) {
-  // Start CountedRegion.
-  emitArrayStart();
-
-  emitArrayElement(Region.LineStart);
-  emitArrayElement(Region.ColumnStart);
-  emitArrayElement(Region.LineEnd);
-  emitArrayElement(Region.ColumnEnd);
-  emitArrayElement(Region.ExecutionCount);
-  emitArrayElement(Region.FileID);
-  emitArrayElement(Region.ExpandedFileID);
-  emitArrayElement(Region.Kind);
-
-  // End CountedRegion.
-  emitArrayEnd();
-}
-
-void CoverageExporterJson::renderSummary(const FileCoverageSummary &Summary) {
-  // Start Summary for the file.
-  emitDictStart();
-
-  emitDictKey("lines");
-
-  // Start Line Coverage Summary.
-  emitDictStart();
-  emitDictElement("count", Summary.LineCoverage.getNumLines());
-  emitDictElement("covered", Summary.LineCoverage.getCovered());
-  emitDictElement("percent", Summary.LineCoverage.getPercentCovered());
-  // End Line Coverage Summary.
-  emitDictEnd();
-
-  emitDictKey("functions");
-
-  // Start Function Coverage Summary.
-  emitDictStart();
-  emitDictElement("count", Summary.FunctionCoverage.getNumFunctions());
-  emitDictElement("covered", Summary.FunctionCoverage.getExecuted());
-  emitDictElement("percent", Summary.FunctionCoverage.getPercentCovered());
-  // End Function Coverage Summary.
-  emitDictEnd();
-
-  emitDictKey("instantiations");
-
-  // Start Instantiation Coverage Summary.
-  emitDictStart();
-  emitDictElement("count", Summary.InstantiationCoverage.getNumFunctions());
-  emitDictElement("covered", Summary.InstantiationCoverage.getExecuted());
-  emitDictElement("percent", Summary.InstantiationCoverage.getPercentCovered());
-  // End Function Coverage Summary.
-  emitDictEnd();
-
-  emitDictKey("regions");
-
-  // Start Region Coverage Summary.
-  emitDictStart();
-  emitDictElement("count", Summary.RegionCoverage.getNumRegions());
-  emitDictElement("covered", Summary.RegionCoverage.getCovered());
-  emitDictElement("notcovered", Summary.RegionCoverage.getNumRegions() -
-                                    Summary.RegionCoverage.getCovered());
-  emitDictElement("percent", Summary.RegionCoverage.getPercentCovered());
-  // End Region Coverage Summary.
-  emitDictEnd();
+  auto ExportArray = json::Array({std::move(Export)});
 
-  // End Summary for the file.
-  emitDictEnd();
+  OS << json::Object({{"version", LLVM_COVERAGE_EXPORT_JSON_STR},
+                      {"type", LLVM_COVERAGE_EXPORT_JSON_TYPE_STR},
+                      {"data", std::move(ExportArray)}});
 }

Modified: llvm/trunk/tools/llvm-cov/CoverageExporterJson.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/CoverageExporterJson.h?rev=342088&r1=342087&r2=342088&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/CoverageExporterJson.h (original)
+++ llvm/trunk/tools/llvm-cov/CoverageExporterJson.h Wed Sep 12 14:59:38 2018
@@ -15,96 +15,20 @@
 #define LLVM_COV_COVERAGEEXPORTERJSON_H
 
 #include "CoverageExporter.h"
-#include <stack>
 
 namespace llvm {
 
 class CoverageExporterJson : public CoverageExporter {
-  /// States that the JSON rendering machine can be in.
-  enum JsonState { None, NonEmptyElement, EmptyElement };
-
-  /// Tracks state of the JSON output.
-  std::stack<JsonState> State;
-
-  /// Emit a serialized scalar.
-  void emitSerialized(const int64_t Value);
-
-  /// Emit a serialized string.
-  void emitSerialized(const std::string &Value);
-
-  /// Emit a comma if there is a previous element to delimit.
-  void emitComma();
-
-  /// Emit a starting dictionary/object character.
-  void emitDictStart();
-
-  /// Emit a dictionary/object key but no value.
-  void emitDictKey(const std::string &Key);
-
-  /// Emit a dictionary/object key/value pair.
-  template <typename V>
-  void emitDictElement(const std::string &Key, const V &Value) {
-    emitComma();
-    emitSerialized(Key);
-    OS << ":";
-    emitSerialized(Value);
-  }
-
-  /// Emit a closing dictionary/object character.
-  void emitDictEnd();
-
-  /// Emit a starting array character.
-  void emitArrayStart();
-
-  /// Emit an array element.
-  template <typename V> void emitArrayElement(const V &Value) {
-    emitComma();
-    emitSerialized(Value);
-  }
-
-  /// emit a closing array character.
-  void emitArrayEnd();
-
-  /// Render an array of all the given functions.
-  void renderFunctions(
-      const iterator_range<coverage::FunctionRecordIterator> &Functions);
-
-  /// Render an array of all the source files, also pass back a Summary.
-  void renderFiles(ArrayRef<std::string> SourceFiles,
-                   ArrayRef<FileCoverageSummary> FileReports);
-
-  /// Render a single file.
-  void renderFile(const std::string &Filename,
-                  const FileCoverageSummary &FileReport);
-
-  /// Render summary for a single file.
-  void renderFileCoverage(const coverage::CoverageData &FileCoverage,
-                          const FileCoverageSummary &FileReport);
-
-  /// Render a CoverageSegment.
-  void renderSegment(const coverage::CoverageSegment &Segment);
-
-  /// Render an ExpansionRecord.
-  void renderExpansion(const coverage::ExpansionRecord &Expansion);
-
-  /// Render a list of CountedRegions.
-  void renderRegions(ArrayRef<coverage::CountedRegion> Regions);
-
-  /// Render a single CountedRegion.
-  void renderRegion(const coverage::CountedRegion &Region);
-
-  /// Render a FileCoverageSummary.
-  void renderSummary(const FileCoverageSummary &Summary);
-
 public:
   CoverageExporterJson(const coverage::CoverageMapping &CoverageMapping,
-                       const CoverageViewOptions &Options, raw_ostream &OS);
+                       const CoverageViewOptions &Options, raw_ostream &OS)
+      : CoverageExporter(CoverageMapping, Options, OS) {}
 
   /// Render the CoverageMapping object.
-  void renderRoot(const CoverageFilters &IgnoreFilenameFilters) override;
+  void renderRoot(const CoverageFilters &IgnoreFilters) override;
 
   /// Render the CoverageMapping object for specified source files.
-  void renderRoot(const std::vector<std::string> &SourceFiles) override;
+  void renderRoot(ArrayRef<std::string> SourceFiles) override;
 };
 
 } // end namespace llvm




More information about the llvm-commits mailing list