On Wed, 2023-08-09 at 18:14 -0400, Lewis Hyatt wrote: > The diagnostics routines for SARIF output need to read the source code back > in, so that they can generate "snippet" and "content" records, so they need to > be able to cope with generated data locations. Add support for that in > diagnostic-format-sarif.cc. > > gcc/ChangeLog: > > * diagnostic-format-sarif.cc (class sarif_builder): Adapt interface > to support generated data locations. > (sarif_builder::maybe_make_physical_location_object): Change the > m_filenames hash_set to support generated data. > (sarif_builder::make_artifact_location_object): Use a source_id rather > than a plain file name. > (sarif_builder::maybe_make_region_object): Adapt to > expanded_location interface changes. > (sarif_builder::maybe_make_region_object_for_context): Likewise. > (sarif_builder::make_artifact_object): Likewise. > (sarif_builder::make_run_object): Handle generated data. > (sarif_builder::maybe_make_artifact_content_object): Likewise. > (get_source_lines): Likewise. > > gcc/testsuite/ChangeLog: > > * c-c++-common/diagnostic-format-sarif-file-5.c: New test.
I'm not sure if generated data is allowed as part of a SARIF artefact, or if there's a more standard-compliant way of representing this; SARIF says an artefact is a "sequence of bytes addressable via a URI". Can you post a simple example of the generated .sarif JSON please? e.g. from the new test, so that we can see it looks like. You could run it through: python -m json.tool to format it for easier reading. Thanks Dave