GCC Middle and Back End API Reference
diagnostic-client-data-hooks.h
Go to the documentation of this file.
1/* Additional metadata about a client for a diagnostic context.
2 Copyright (C) 2022-2025 Free Software Foundation, Inc.
3 Contributed by David Malcolm <dmalcolm@redhat.com>
4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify it under
8the terms of the GNU General Public License as published by the Free
9Software Foundation; either version 3, or (at your option) any later
10version.
11
12GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13WARRANTY; without even the implied warranty of MERCHANTABILITY or
14FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15for more details.
16
17You should have received a copy of the GNU General Public License
18along with GCC; see the file COPYING3. If not see
19<http://www.gnu.org/licenses/>. */
20
21#ifndef GCC_DIAGNOSTIC_CLIENT_DATA_HOOKS_H
22#define GCC_DIAGNOSTIC_CLIENT_DATA_HOOKS_H
23
24#include "logical-location.h"
25
26class sarif_object;
28
29/* A bundle of additional metadata, owned by the diagnostic_context,
30 for querying things about the client, like version data. */
31
33{
34 public:
36
37 /* Get version info for this client, or NULL. */
38 virtual const client_version_info *get_any_version_info () const = 0;
39
40 /* Get the current logical_location_manager for this client, or NULL. */
42
43 /* Get the current logical_location, or null.
44 If this returns a non-null logical_location, then
45 get_logical_location_manager must return non-NULL. */
47
48 /* Get a sourceLanguage value for FILENAME, or return NULL.
49 See SARIF v2.1.0 Appendix J for suggested values. */
50 virtual const char *
51 maybe_get_sarif_source_language (const char *filename) const = 0;
52
53 /* Hook to allow client to populate a SARIF "invocation" object with
54 a custom property bag (see SARIF v2.1.0 section 3.8). */
55 virtual void
56 add_sarif_invocation_properties (sarif_object &invocation_obj) const = 0;
57};
58
59/* Factory function for making an instance of diagnostic_client_data_hooks
60 for use in the compiler (i.e. with knowledge of "tree", access to
61 langhooks, etc). */
62
63extern std::unique_ptr<diagnostic_client_data_hooks> make_compiler_data_hooks ();
64
66
67/* Abstract base class for a diagnostic_context to get at
68 version information about the client. */
69
71{
72public:
74 {
75 public:
76 virtual void on_plugin (const diagnostic_client_plugin_info &) = 0;
77 };
78
80
81 /* Get a string suitable for use as the value of the "name" property
82 (SARIF v2.1.0 section 3.19.8). */
83 virtual const char *get_tool_name () const = 0;
84
85 /* Create a string suitable for use as the value of the "fullName" property
86 (SARIF v2.1.0 section 3.19.9). */
87 virtual char *maybe_make_full_name () const = 0;
88
89 /* Get a string suitable for use as the value of the "version" property
90 (SARIF v2.1.0 section 3.19.13). */
91 virtual const char *get_version_string () const = 0;
92
93 /* Create a string suitable for use as the value of the "informationUri"
94 property (SARIF v2.1.0 section 3.19.17). */
95 virtual char *maybe_make_version_url () const = 0;
96
97 virtual void for_each_plugin (plugin_visitor &v) const = 0;
98};
99
100/* Abstract base class for a diagnostic_context to get at
101 information about a specific plugin within a client. */
102
104{
105public:
106 /* For use e.g. by SARIF "name" property (SARIF v2.1.0 section 3.19.8). */
107 virtual const char *get_short_name () const = 0;
108
109 /* For use e.g. by SARIF "fullName" property
110 (SARIF v2.1.0 section 3.19.9). */
111 virtual const char *get_full_name () const = 0;
112
113 /* For use e.g. by SARIF "version" property
114 (SARIF v2.1.0 section 3.19.13). */
115 virtual const char *get_version () const = 0;
116};
117
118#endif /* ! GCC_DIAGNOSTIC_CLIENT_DATA_HOOKS_H */
Definition diagnostic-client-data-hooks.h:74
virtual void on_plugin(const diagnostic_client_plugin_info &)=0
Definition diagnostic-client-data-hooks.h:71
virtual const char * get_version_string() const =0
virtual const char * get_tool_name() const =0
virtual char * maybe_make_version_url() const =0
virtual ~client_version_info()
Definition diagnostic-client-data-hooks.h:79
virtual void for_each_plugin(plugin_visitor &v) const =0
virtual char * maybe_make_full_name() const =0
Definition diagnostic-client-data-hooks.h:33
virtual const client_version_info * get_any_version_info() const =0
virtual ~diagnostic_client_data_hooks()
Definition diagnostic-client-data-hooks.h:35
virtual const char * maybe_get_sarif_source_language(const char *filename) const =0
virtual logical_location get_current_logical_location() const =0
virtual void add_sarif_invocation_properties(sarif_object &invocation_obj) const =0
virtual const logical_location_manager * get_logical_location_manager() const =0
Definition diagnostic-client-data-hooks.h:104
virtual const char * get_version() const =0
virtual const char * get_short_name() const =0
virtual const char * get_full_name() const =0
Definition logical-location.h:91
Definition diagnostic-format-sarif.h:137
std::unique_ptr< diagnostic_client_data_hooks > make_compiler_data_hooks()
Definition tree-diagnostic-client-data-hooks.cc:171
logical_location_manager::key logical_location
Definition logical-location.h:173