|
62 | 62 | #include <utility> |
63 | 63 |
|
64 | 64 | /// The semantic version combined as a string. |
65 | | -#define LLVM_COVERAGE_EXPORT_JSON_STR "2.0.1" |
| 65 | +#define LLVM_COVERAGE_EXPORT_JSON_STR "3.0.0" |
66 | 66 |
|
67 | 67 | /// Unique type identifier for JSON coverage export. |
68 | 68 | #define LLVM_COVERAGE_EXPORT_JSON_TYPE_STR "llvm.coverage.json.export" |
@@ -108,10 +108,22 @@ json::Array gatherConditions(const coverage::MCDCRecord &Record) { |
108 | 108 | return Conditions; |
109 | 109 | } |
110 | 110 |
|
| 111 | +std::pair<unsigned, unsigned> getDecisions(const coverage::MCDCRecord &Record) { |
| 112 | + const coverage::MCDCRecord::TestVectors &TestVectors = Record.getTV(); |
| 113 | + const unsigned TrueConditions = |
| 114 | + std::count_if(TestVectors.begin(), TestVectors.end(), [](const auto &TV) { |
| 115 | + return TV.second == coverage::MCDCRecord::CondState::MCDC_True; |
| 116 | + }); |
| 117 | + |
| 118 | + return {TrueConditions, TestVectors.size() - TrueConditions}; |
| 119 | +} |
| 120 | + |
111 | 121 | json::Array renderMCDCRecord(const coverage::MCDCRecord &Record) { |
112 | 122 | const llvm::coverage::CounterMappingRegion &CMR = Record.getDecisionRegion(); |
| 123 | + const auto [TrueConditions, FalseConditions] = getDecisions(Record); |
113 | 124 | return json::Array({CMR.LineStart, CMR.ColumnStart, CMR.LineEnd, |
114 | | - CMR.ColumnEnd, CMR.ExpandedFileID, int64_t(CMR.Kind), |
| 125 | + CMR.ColumnEnd, TrueConditions, FalseConditions, |
| 126 | + CMR.ExpandedFileID, int64_t(CMR.Kind), |
115 | 127 | gatherConditions(Record)}); |
116 | 128 | } |
117 | 129 |
|
|
0 commit comments