<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/105489>105489</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [llvm-cov][MC/DC] `mcdc_records` in JSON output insufficient
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          Swatinem
      </td>
    </tr>
</table>

<pre>
    The `mcdc_records` field of the JSON output (`llvm-cov export -format=text`) is insufficient to reconstruct the "Executed MC/DC Test Vectors" output of `llvm-cov show`.

Consider this example:

**`llvm-cov show` output:**

```txt
    2| 4|    if (a || b) && (c || d) {
                                  ^3 ^2
  ------------------
  |  Branch (2:9): [True: 0, False: 4]
  | Branch (2:14): [True: 3, False: 1]
  |  Branch (2:21): [True: 1, False: 2]
  |  Branch (2:26): [True: 1, False: 1]
  ------------------
 |---> MC/DC Decision Region (2:8) to (2:28)
  |
  |  Number of Conditions: 4
  |     Condition C1 --> (2:9)
  |     Condition C2 --> (2:14)
  |     Condition C3 --> (2:21)
  |     Condition C4 --> (2:26)
  |
  |  Executed MC/DC Test Vectors:
  |
  |     C1, C2, C3, C4    Result
  |  1 { F,  F,  -,  -  = F      }
  |  2 { F,  T,  F, F  = F      }
  |  3 { F,  T,  T,  -  = T      }
  |  4 { F,  T,  F, T  = T      }
  |
  |  C1-Pair: not covered
  |  C2-Pair: covered: (1,3)
  |  C3-Pair: covered: (2,3)
  |  C4-Pair: covered: (2,4)
  | MC/DC Coverage for Decision: 75.00%
  |
 ------------------
```

**`llvm-cov export` output:**

```json
{
  "branches": [
    [2, 9, 2, 10, 0, 4, 0, 0, 6],
    [2, 14, 2, 15, 3, 1, 0, 0, 6],
    [2, 21, 2, 22, 1, 2, 0, 0, 6],
    [2, 26, 2, 27, 1, 1, 0, 0, 6],
  ],
 "mcdc_records": [
    [2, 8, 2, 28, 0, 5, [false, true, true, true]],
  ]
}
```

Using the JSON export, I can reconstruct:
- the "Number of Conditions" by collecting all the `branches` that have a source range within the `mcdc_record`
- the "Coverage for Decision" and C*X*-Pair as that is quite literally the trailing array in the `mcdc_record`

However the information in the JSON output is not enough to reconstruct the "Executed MC/DC Test Vectors" table, or infer which table row was covering each condition pair.

Ideally, the JSON output should encode the whole table of *relevant* test vectors, and flag the ones that were executed.

For example, this is how it could look like for the example above:

```json
"test_vectors": [
{"conditions": [false, false, null, null], "result": false, "executed": true},
{"conditions": [false, true, false, false], "result": false, "executed": true},
{"conditions": [false, true, true, null], "result": true, "executed": true},
{"conditions": [false, true, false, true], "result": true, "executed": true},
]
```

The output table of `llvm-cov show` only includes the *executed* vectors, however it would also be nice to show and include in the JSON all *relevant* vectors which were not executed as well.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8V1-PozYQ_zTOy2hXMEBIHvKQJRf1KvVa3aVV307GmOA7B29tk-x--8rmTyDJ5lat2igyYM9vZjye-TFQY8S-5nxFkieSbGa0sZXSqy8nakXND7NcFa-rXcWBzIMDK9hXzZnShSHzAErBZQGqBFtx-PnLr59ANfa5sUBwQeaBlMfDA1NH4C_PSlt4KJU-UEuijeUvlswDgksQBkRtmrIUTPDaglXgLNTG6oZZr5kgfnjhrLG8gF8ygttNBjtuLPzBmVXaEMTesCphbNhU6kTmwSMJNiRYt2OmaiMKrsFWwgB_oYdnyUm0HssQ9P9rTZ0dJ96KjEHzoP3bF9vOAAAgSTOI3QAAonShoUDSzM3kLgAE5wTnbp7184WfT5_OWu7_SPIhcgP2gIerX7_iHXnStGaVM4kkWi8JLkm0BpI87XTjQgEBwQy2VBr_FJNkM8ZP4WF8jY8m-PACf6EAw2sF4UQB_kDB_EcKxh68GRuSZu4h-jAk2YYzYYSq4TPfu0tnb-GOx6rBvHseuTfx9FNzyLl2eZmpuhBWqNq0MR1LAZyXIQuhdWN8Pm9L41S6PY63xaOpeBv8t8XjC_H5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