================
@@ -409,9 +412,9 @@ void SarifDocumentWriter::appendResult(const SarifResult 
&Result) {
 
   if (!Result.RelatedLocations.empty()) {
----------------
zeyi2 wrote:

I found a case where repeated notes produce schema-invalid SARIF. With 
`-checks='-*,bugprone-*'` on cppcheck's `simplecpp.cpp`, the regular text 
output contains the following notes (messages shortened):

```
simplecpp.cpp:2723:5: note:
simplecpp.cpp:2724:5: note: 'int' and 'std::ptrdiff_t' may be implicitly 
converted ...

simplecpp.cpp:2723:5: note:
simplecpp.cpp:2725:5: note: 'int' and 'std::size_t' may be implicitly converted 
...
```

The exporter turns them into identical `relatedLocations` entries (Other 
entries are omitted):

```
"relatedLocations": [
  {
    "physicalLocation": {
      "artifactLocation": { "index": 0, "uri": "file:///.../simplecpp.cpp" },
      "region": {
        "startLine": 2723, "startColumn": 5,
        "endLine": 2723, "endColumn": 6
      }
    }
  },
  {
    "physicalLocation": {
      "artifactLocation": { "index": 0, "uri": "file:///.../simplecpp.cpp" },
      "region": {
        "startLine": 2723, "startColumn": 5,
        "endLine": 2723, "endColumn": 6
      }
    }
  }
]
```

Although the empty messages appear to come from an existing check issue, there 
may be other cases that produce repeated notes. IMO it would be better for the 
exporter to help handle these diagnostics in a way that still produces valid 
SARIF.

https://github.com/llvm/llvm-project/pull/219182
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to