* :func:`diagnostic_logical_location_get_decorated_name`
+.. _LIBGDIAGNOSTICS_ABI_2:
+
``LIBGDIAGNOSTICS_ABI_2``
-------------------------
``LIBGDIAGNOSTICS_ABI_2`` covers the addition of these functions for
diagnostic_manager *control_mgr)
This function can be used to support option processing similar to GCC's
- :option:`-fdiagnostics-add-output=`. This allows command-line tools to
- support the same domain-specific language for specifying output sink
- as GCC does.
-
- The function will attempt to parse :param:`spec` as if it were
- an argument to GCC's :option:`-fdiagnostics-add-output=OUTPUT-SPEC`.
- If successful, it will add an output sink to :param:`affected_mgr` and return zero.
- Otherwise, it will emit an error diagnostic to :param:`control_mgr` and
+ `-fdiagnostics-add-output= <https://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Message-Formatting-Options.html#index-fdiagnostics-add-output>`_.
+ This allows command-line tools to support the same domain-specific
+ language for specifying output sinks as GCC does.
+
+ The function will attempt to parse ``spec`` as if it were
+ an argument to GCC's `-fdiagnostics-add-output= <https://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Message-Formatting-Options.html#index-fdiagnostics-add-output>`_.
+ If successful, it will add an output sink to ``affected_mgr`` and return zero.
+ Otherwise, it will emit an error diagnostic to ``control_mgr`` and
return non-zero.
- :param:`affected_mgr` and :param:`control_mgr` can be the same manager,
+ ``affected_mgr`` and ``control_mgr`` can be the same manager,
or be different managers.
This function was added in :ref:`LIBGDIAGNOSTICS_ABI_2`; you can
#ifdef LIBDIAGNOSTICS_HAVE_diagnostic_manager_add_sink_from_spec
-
.. function:: void diagnostic_manager_set_analysis_target (diagnostic_manager *mgr, \
const diagnostic_file *file)
- This function sets the "main input file" of :param:`mgr` to be
- :param:`file`.
+ This function sets the "main input file" of ``mgr`` to be
+ ``file``.
This affects the :code:`<title>` of generated HTML and
- the :code:`role` of the artifact in SARIF output (SARIF v2.1.0 section 3.24.6).
+ the :code:`role` of the :code:`artifact` in SARIF output
+ (`SARIF v2.1.0 section 3.24.6 <https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/sarif-v2.1.0-errata01-os-complete.html#_Toc141790867>`_).
This function was added in :ref:`LIBGDIAGNOSTICS_ABI_2`; you can
test for its presence using
"equal" input values on the same :type:`diagnostic_manager` will return
the same instance of :type:`diagnostic_logical_location`. "Equal" here
includes different string buffers that compare as equal with
- :func:``strcmp`.
+ :func:`strcmp`.
.. function:: void diagnostic_manager_debug_dump_logical_location (const diagnostic_manager *diag_mgr, \
const diagnostic_logical_location *loc, \
The following functions can be used to access the data that was passed to a
:type:`diagnostic_logical_location` when it was created. In each case, the
-``loc`` parameter must be non-NULL. :type:`const char *` values will point
-at copies of the original buffer.
+``loc`` parameter must be non-NULL. The return values will point
+at *copies* of the original buffer owned by the
+:type:`diagnostic_logical_location`, or be null.
.. function:: enum diagnostic_logical_location_kind_t diagnostic_logical_location_get_kind (const diagnostic_logical_location *loc)
foo.c:17: error: can't find 'foo.h'"
17 | #include <foo.h>
-where libgdiagnostics will attempt to load the source file and
+where libgdiagnostics will attempt to load ``foo.c`` and
quote the pertinent line.
-If libgdiagnostics cannot open the file, it will merely print::
+If libgdiagnostics cannot open ``foo.c``, it will merely print::
foo.c:17: error: can't find 'foo.h'
17 | #include <foo.h>
| ^~~~~
-where libgdiagnostics will attempt to load the source file and
+where libgdiagnostics will attempt to load ``foo.c`` and
underling the pertinent part of the given line.
-If libgdiagnostics cannot open the file, it will merely print::
+If libgdiagnostics cannot open ``foo.c``, it will merely print::
foo.c:17:8: error: can't find 'foo.h'
-A range can span multiple lines within the same file.
+A range can span multiple lines within the same file, but cannot
+span multiple files.
As before, you can use :func:`diagnostic_manager_debug_dump_location` to
dump the locations. For the above example::