aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-inline.h
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2024-12-16 11:22:49 -0500
committerDavid Malcolm <dmalcolm@redhat.com>2024-12-16 11:22:49 -0500
commit778336e0e4f25745f76a127801dc3bab5e9c1334 (patch)
treeb29eadb91f722e16f254889455b687ad65bd3b37 /gcc/tree-inline.h
parentea7da640cf234ebde8d73d996dd14e6563c1ffcf (diff)
downloadgcc-778336e0e4f25745f76a127801dc3bab5e9c1334.zip
gcc-778336e0e4f25745f76a127801dc3bab5e9c1334.tar.gz
gcc-778336e0e4f25745f76a127801dc3bab5e9c1334.tar.bz2
sarif-replay: quote source from artifact contents [PR117943]
The diagnostic source-quoting machinery uses class file_cache implemented in gcc/input.cc for (re)reading the source when issuing diagnostics. When sarif-replay issues a saved diagnostic it might be running in a different path to where the .sarif file was captured, or on an entirely different machine. Previously such invocations would lead to the source-quoting silently failing, even if the content of the file is recorded in the .sarif file in the artifact "contents" property (which gcc populates when emitting .sarif output). This patch: - adds the ability for slots in file_cache to be populated from memory rather than from the filesystem - exposes it in libgdiagnostics via a new entrypoint - uses this in sarif-replay for any artifacts with a "contents" property, so that source-quoting uses that rather than trying to read from the path on the filesystem gcc/ChangeLog: PR sarif-replay/117943 * doc/libgdiagnostics/topics/physical-locations.rst (diagnostic_manager_new_file): Drop "const" from return type. * doc/libgdiagnostics/tutorial/02-physical-locations.rst: Drop "const" from "main_file" decl. * input.cc (file_cache::add_buffered_content): New. (file_cache_slot::set_content): New. (file_cache_slot::dump): Use m_file_path being null rather than m_fp to determine empty slots. Dump m_fp. (find_end_of_line): Drop "const" from return type and param. Add forward decl. (file_cache_slot::get_next_line): Fix "const"-ness. (selftest::test_reading_source_buffer): New. (selftest::input_cc_tests): Call it. * input.h (file_cache::add_buffered_content): New decl. * libgdiagnostics++.h (class file): Drop const-ness from m_inner. (file::set_buffered_content): New. * libgdiagnostics.cc (class content_buffer): New. (diagnostic_file::diagnostic_file): Add "mgr" param. (diagnostic_file::get_content): New. (diagnostic_file::set_buffered_content): New. (diagnostic_file::m_mgr): New. (diagnostic_file::m_content): New. (diagnostic_manager::new_file): Drop const-ness. Pass *this to ctor. (diagnostic_file::set_buffered_content): New. (diagnostic_manager_new_file): Drop "const" from return type. (diagnostic_file_set_buffered_content): New entrypoint. (diagnostic_manager_debug_dump_file): Dump the content size, if any. * libgdiagnostics.h (diagnostic_manager_new_file): Drop "const" from return type. (diagnostic_file_set_buffered_content): New decl. * libgdiagnostics.map (diagnostic_file_set_buffered_content): New symbol. * libsarifreplay.cc (sarif_replayer::m_artifacts_arr): Convert from json::value to json::array. (sarif_replayer::handle_run_obj): Call handle_artifact_obj on all artifacts. (sarif_replayer::handle_artifact_obj): New. gcc/testsuite/ChangeLog: PR sarif-replay/117943 * sarif-replay.dg/2.1.0-valid/error-with-note.sarif: Update expected output to include quoted source code and underlines. * sarif-replay.dg/2.1.0-valid/signal-1.c.moved.sarif: New test. * sarif-replay.dg/2.1.0-valid/signal-1.c.sarif: Update expected output to include quoted source code and underlines. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Diffstat (limited to 'gcc/tree-inline.h')
0 files changed, 0 insertions, 0 deletions