-
Notifications
You must be signed in to change notification settings - Fork 15.5k
[llvm-cov] Export decision coverage to output json #144335
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -62,7 +62,7 @@ | |
| #include <utility> | ||
|
|
||
| /// The semantic version combined as a string. | ||
| #define LLVM_COVERAGE_EXPORT_JSON_STR "2.0.1" | ||
| #define LLVM_COVERAGE_EXPORT_JSON_STR "3.0.0" | ||
|
|
||
| /// Unique type identifier for JSON coverage export. | ||
| #define LLVM_COVERAGE_EXPORT_JSON_TYPE_STR "llvm.coverage.json.export" | ||
|
|
@@ -108,10 +108,22 @@ json::Array gatherConditions(const coverage::MCDCRecord &Record) { | |
| return Conditions; | ||
| } | ||
|
|
||
| std::pair<unsigned, unsigned> getDecisions(const coverage::MCDCRecord &Record) { | ||
|
||
| const coverage::MCDCRecord::TestVectors &TestVectors = Record.getTV(); | ||
| const unsigned TrueConditions = | ||
| std::count_if(TestVectors.begin(), TestVectors.end(), [](const auto &TV) { | ||
| return TV.second == coverage::MCDCRecord::CondState::MCDC_True; | ||
| }); | ||
|
|
||
| return {TrueConditions, TestVectors.size() - TrueConditions}; | ||
| } | ||
|
|
||
| json::Array renderMCDCRecord(const coverage::MCDCRecord &Record) { | ||
| const llvm::coverage::CounterMappingRegion &CMR = Record.getDecisionRegion(); | ||
| const auto [TrueConditions, FalseConditions] = getDecisions(Record); | ||
| return json::Array({CMR.LineStart, CMR.ColumnStart, CMR.LineEnd, | ||
| CMR.ColumnEnd, CMR.ExpandedFileID, int64_t(CMR.Kind), | ||
| CMR.ColumnEnd, TrueConditions, FalseConditions, | ||
| CMR.ExpandedFileID, int64_t(CMR.Kind), | ||
| gatherConditions(Record)}); | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for updating this. We have not been good about moving the version forward.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is actually very important to me, as I check this value to see whether the subsequent processing is still correct.