compiler: don't generate stubs for ambiguous direct interface methods
[official-gcc.git] / gcc / tree-diagnostic-client-data-hooks.cc
blobf8ff271d2f59b37eba4a0e4bcbb59f9e8923512a
1 /* Implementation of diagnostic_client_data_hooks for the compilers
2 (e.g. with knowledge of "tree" and lang_hooks).
3 Copyright (C) 2022 Free Software Foundation, Inc.
4 Contributed by David Malcolm <dmalcolm@redhat.com>.
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
11 version.
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 for more details.
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
22 #include "config.h"
23 #include "system.h"
24 #include "coretypes.h"
25 #include "version.h"
26 #include "tree.h"
27 #include "diagnostic.h"
28 #include "tree-logical-location.h"
29 #include "diagnostic-client-data-hooks.h"
30 #include "langhooks.h"
31 #include "plugin.h"
33 /* Concrete class for supplying a diagnostic_context with information
34 about a specific plugin within the client, when the client is the
35 compiler (i.e. a GCC plugin). */
37 class compiler_diagnostic_client_plugin_info
38 : public diagnostic_client_plugin_info
40 public:
41 compiler_diagnostic_client_plugin_info (const plugin_name_args *args)
42 : m_args (args)
46 const char *get_short_name () const final override
48 return m_args->base_name;
51 const char *get_full_name () const final override
53 return m_args->full_name;
56 const char *get_version () const final override
58 return m_args->version;
61 private:
62 const plugin_name_args *m_args;
65 /* Concrete subclass of client_version_info for use by compilers proper,
66 (i.e. using lang_hooks, and with knowledge of GCC plugins). */
68 class compiler_version_info : public client_version_info
70 public:
71 const char *get_tool_name () const final override
73 return lang_hooks.name;
76 /* Compare with toplev.cc: print_version.
77 TARGET_NAME is passed in by the Makefile. */
78 char *
79 maybe_make_full_name () const final override
81 return xasprintf ("%s %sversion %s (%s)",
82 get_tool_name (), pkgversion_string, version_string,
83 TARGET_NAME);
86 const char *get_version_string () const final override
88 return version_string;
91 char *maybe_make_version_url () const final override
93 return xasprintf ("https://gcc.gnu.org/gcc-%i/", GCC_major_version);
96 void for_each_plugin (plugin_visitor &visitor) const final override
98 ::for_each_plugin (on_plugin_cb, &visitor);
101 private:
102 static void
103 on_plugin_cb (const plugin_name_args *args,
104 void *user_data)
106 compiler_diagnostic_client_plugin_info cpi (args);
107 client_version_info::plugin_visitor *visitor
108 = (client_version_info::plugin_visitor *)user_data;
109 visitor->on_plugin (cpi);
113 /* Subclass of diagnostic_client_data_hooks for use by compilers proper
114 i.e. with knowledge of "tree", access to langhooks, etc. */
116 class compiler_data_hooks : public diagnostic_client_data_hooks
118 public:
119 const client_version_info *get_any_version_info () const final override
121 return &m_version_info;
124 const logical_location *get_current_logical_location () const final override
126 if (current_function_decl)
127 return &m_current_fndecl_logical_loc;
128 else
129 return NULL;
132 const char *
133 maybe_get_sarif_source_language (const char *filename) const final override
135 return lang_hooks.get_sarif_source_language (filename);
138 private:
139 compiler_version_info m_version_info;
140 current_fndecl_logical_location m_current_fndecl_logical_loc;
143 /* Create a compiler_data_hooks (so that the class can be local
144 to this file). */
146 diagnostic_client_data_hooks *
147 make_compiler_data_hooks ()
149 return new compiler_data_hooks ();