]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/diagnostic-client-data-hooks.h
Update copyright years.
[thirdparty/gcc.git] / gcc / diagnostic-client-data-hooks.h
CommitLineData
6cf276dd 1/* Additional metadata about a client for a diagnostic context.
aeee4812 2 Copyright (C) 2022-2023 Free Software Foundation, Inc.
6cf276dd
DM
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
24class client_version_info;
25
26/* A bundle of additional metadata, owned by the diagnostic_context,
27 for querying things about the client, like version data. */
28
29class diagnostic_client_data_hooks
30{
31 public:
32 virtual ~diagnostic_client_data_hooks () {}
33
34 /* Get version info for this client, or NULL. */
35 virtual const client_version_info *get_any_version_info () const = 0;
36
37 /* Get the current logical_location for this client, or NULL. */
38 virtual const logical_location *get_current_logical_location () const = 0;
39
40 /* Get a sourceLanguage value for FILENAME, or return NULL.
41 See SARIF v2.1.0 Appendix J for suggested values. */
42 virtual const char *
43 maybe_get_sarif_source_language (const char *filename) const = 0;
44};
45
46/* Factory function for making an instance of diagnostic_client_data_hooks
47 for use in the compiler (i.e. with knowledge of "tree", access to
48 langhooks, etc). */
49
50extern diagnostic_client_data_hooks *make_compiler_data_hooks ();
51
52class diagnostic_client_plugin_info;
53
54/* Abstract base class for a diagnostic_context to get at
55 version information about the client. */
56
57class client_version_info
58{
59public:
60 class plugin_visitor
61 {
62 public:
63 virtual void on_plugin (const diagnostic_client_plugin_info &) = 0;
64 };
65
66 virtual ~client_version_info () {}
67
68 /* Get a string suitable for use as the value of the "name" property
69 (SARIF v2.1.0 section 3.19.8). */
70 virtual const char *get_tool_name () const = 0;
71
72 /* Create a string suitable for use as the value of the "fullName" property
73 (SARIF v2.1.0 section 3.19.9). */
74 virtual char *maybe_make_full_name () const = 0;
75
76 /* Get a string suitable for use as the value of the "version" property
77 (SARIF v2.1.0 section 3.19.13). */
78 virtual const char *get_version_string () const = 0;
79
80 /* Create a string suitable for use as the value of the "informationUri"
81 property (SARIF v2.1.0 section 3.19.17). */
82 virtual char *maybe_make_version_url () const = 0;
83
84 virtual void for_each_plugin (plugin_visitor &v) const = 0;
85};
86
87/* Abstract base class for a diagnostic_context to get at
88 information about a specific plugin within a client. */
89
90class diagnostic_client_plugin_info
91{
92public:
93 /* For use e.g. by SARIF "name" property (SARIF v2.1.0 section 3.19.8). */
94 virtual const char *get_short_name () const = 0;
95
96 /* For use e.g. by SARIF "fullName" property
97 (SARIF v2.1.0 section 3.19.9). */
98 virtual const char *get_full_name () const = 0;
99
100 /* For use e.g. by SARIF "version" property
101 (SARIF v2.1.0 section 3.19.13). */
102 virtual const char *get_version () const = 0;
103};
104
105#endif /* ! GCC_DIAGNOSTIC_CLIENT_DATA_HOOKS_H */