https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116253

--- Comment #14 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by David Malcolm <dmalc...@gcc.gnu.org>:

https://gcc.gnu.org/g:7969e4859ed0079b4a1462ea82aa6b2dd3d17f72

commit r16-2766-g7969e4859ed0079b4a1462ea82aa6b2dd3d17f72
Author: David Malcolm <dmalc...@redhat.com>
Date:   Mon Aug 4 10:45:31 2025 -0400

    diagnostics: improve support for nesting levels [PR116253]

    This patch adds support to sarif-replay for "nestingLevel"
    from "P3358R0 SARIF for Structured Diagnostics"
    https://wg21.link/P3358R0

    Doing so revealed a bug where libgdiagnostics was always
    creating new location_t values (and thus also
    diagnostic_physical_location instances), rather than reusing
    existing location_t values, leading to excess source printing.
    The patch also fixes this bug, adding a new flag to libgdiagnostics
    for debugging physical locations, and exposing this in sarif-replay
    via a new "-fdebug-physical-locations" maintainer option.

    Finally, the patch adds test coverage for the HTML sink's output
    of nested diagnostics (both from a GCC plugin, and from sarif-replay).

    gcc/ChangeLog:
            PR diagnostics/116253
            * diagnostics/context.cc (context::set_nesting_level): New.
            * diagnostics/context.h (context::set_nesting_level): New decl.
            * doc/libgdiagnostics/topics/compatibility.rst
            (LIBGDIAGNOSTICS_ABI_5): New.
            * doc/libgdiagnostics/topics/physical-locations.rst
            (diagnostic_manager_set_debug_physical_locations): New.
            * libgdiagnostics++.h (manager::set_debug_physical_locations):
            New.
            * libgdiagnostics-private.h
            (private_diagnostic_set_nesting_level): New decl.
            * libgdiagnostics.cc (diagnostic_manager::diagnostic_manager):
            Initialize m_debug_physical_locations.
            (diagnostic_manager::new_location_from_file_and_line): Add debug
            printing.
            (diagnostic_manager::new_location_from_file_line_column):
            Likewise.
            (diagnostic_manager::new_location_from_range): Likewise.
            (diagnostic_manager::set_debug_physical_locations): New.
            (diagnostic_manager::ensure_linemap_for_file_and_line): Avoid
            redundant calls to linemap_add.
            (diagnostic_manager::new_location): Add debug printing.
            (diagnostic_manager::m_debug_physical_locations): New field.
            (diagnostic::diagnostic): Initialize m_nesting_level.
            (diagnostic::get_nesting_level): New accessor.
            (diagnostic::set_nesting_level): New.
            (diagnostic::m_nesting_level): New field.
            (diagnostic_manager::emit_va): Set and reset the nesting level
            of the context from that of the diagnostic.
            (diagnostic_manager_set_debug_physical_locations): New.
            (private_diagnostic_set_nesting_level): New.
            * libgdiagnostics.h
            (diagnostic_manager_set_debug_physical_locations): New decl.
            * libgdiagnostics.map (LIBGDIAGNOSTICS_ABI_5): New.
            * libsarifreplay.cc (sarif_replayer::handle_result_obj): Support
            the "nestingLevel" property.
            * libsarifreplay.h (replay_options::m_debug_physical_locations):
            New field.
            * sarif-replay.cc: Add -fdebug-physical-locations.

    gcc/testsuite/ChangeLog:
            PR diagnostics/116253
            * gcc.dg/plugin/diagnostic-test-nesting-html.c: New test.
            * gcc.dg/plugin/diagnostic-test-nesting-html.py: New test script.
            * gcc.dg/plugin/plugin.exp: Add it.
            * libgdiagnostics.dg/test-multiple-lines.c: Update expected output
            to show fix-it hint.
            * sarif-replay.dg/2.1.0-valid/nested-diagnostics-1.sarif: New test.

    Signed-off-by: David Malcolm <dmalc...@redhat.com>
  • [Bug diagnostics/116253] RFE: s... cvs-commit at gcc dot gnu.org via Gcc-bugs

Reply via email to