Skip to content

Commit 653f815

Browse files
authored
[llvm-cov] Add FileID to MCDC records of the json code coverage export (#145236)
At the moment MCDC Record contains ExpandedFileID. If FileID != ExpandedFileID, the record's lines LineStart and LineEnd relate to the `FileID` file, but the record doesn't contain this id. So we can't distinguish multiple MCDC records with the same lines and columns, but different FileIDs. This adds FileID to MCDC records as it is done for regions and branches.
1 parent 4a68562 commit 653f815

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

llvm/test/tools/llvm-cov/Inputs/binary-formats.canonical.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ CHECK-SAME: "mcdc":{"count":0,"covered":0,"notcovered":0,"percent":0},
3333
CHECK-SAME: "regions":{"count":1,"covered":1,"notcovered":0,"percent":100}}}
3434
CHECK-SAME: ],
3535
CHECK-SAME: "type":"llvm.coverage.json.export"
36-
CHECK-SAME: "version":"3.0.0"
36+
CHECK-SAME: "version":"3.0.1"

llvm/test/tools/llvm-cov/mcdc-export-json.test

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// RUN: llvm-profdata merge %S/Inputs/mcdc-general.proftext -o %t.profdata
22
// RUN: llvm-cov export --format=text %S/Inputs/mcdc-general.o -instr-profile %t.profdata | FileCheck %s
33

4-
// CHECK: 12,7,12,27,2,4,0,5,[true,true,true,true]
5-
// CHECK: 15,7,15,13,1,2,0,5,[true,true]
6-
// CHECK: 15,19,15,25,1,1,0,5,[true,false]
7-
// CHECK: 18,7,19,15,1,3,0,5,[true,true,false,true]
4+
// CHECK: 12,7,12,27,2,4,0,0,5,[true,true,true,true]
5+
// CHECK: 15,7,15,13,1,2,0,0,5,[true,true]
6+
// CHECK: 15,19,15,25,1,1,0,0,5,[true,false]
7+
// CHECK: 18,7,19,15,1,3,0,0,5,[true,true,false,true]
88
// CHECK: "mcdc":{"count":12,"covered":10,"notcovered":2,"percent":83.333333333333343}
99

1010
Instructions for regenerating the test:

llvm/tools/llvm-cov/CoverageExporterJson.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
#include <utility>
6363

6464
/// The semantic version combined as a string.
65-
#define LLVM_COVERAGE_EXPORT_JSON_STR "3.0.0"
65+
#define LLVM_COVERAGE_EXPORT_JSON_STR "3.0.1"
6666

6767
/// Unique type identifier for JSON coverage export.
6868
#define LLVM_COVERAGE_EXPORT_JSON_TYPE_STR "llvm.coverage.json.export"
@@ -113,7 +113,7 @@ json::Array renderMCDCRecord(const coverage::MCDCRecord &Record) {
113113
const auto [TrueDecisions, FalseDecisions] = Record.getDecisions();
114114
return json::Array({CMR.LineStart, CMR.ColumnStart, CMR.LineEnd,
115115
CMR.ColumnEnd, TrueDecisions, FalseDecisions,
116-
CMR.ExpandedFileID, int64_t(CMR.Kind),
116+
CMR.FileID, CMR.ExpandedFileID, int64_t(CMR.Kind),
117117
gatherConditions(Record)});
118118
}
119119

0 commit comments

Comments
 (0)