xref: /netbsd-src/external/gpl3/binutils/dist/include/gcc-cp-interface.h (revision cb63e24e8d6aae7ddac1859a9015f48b1d8bd90e)
1fc4f4269Schristos /* Interface between GCC C++ FE and GDB
2fc4f4269Schristos 
3*cb63e24eSchristos    Copyright (C) 2014-2024 Free Software Foundation, Inc.
4fc4f4269Schristos 
5fc4f4269Schristos    This file is part of GCC.
6fc4f4269Schristos 
7fc4f4269Schristos    This program is free software; you can redistribute it and/or modify
8fc4f4269Schristos    it under the terms of the GNU General Public License as published by
9fc4f4269Schristos    the Free Software Foundation; either version 3 of the License, or
10fc4f4269Schristos    (at your option) any later version.
11fc4f4269Schristos 
12fc4f4269Schristos    This program is distributed in the hope that it will be useful,
13fc4f4269Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
14fc4f4269Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15fc4f4269Schristos    GNU General Public License for more details.
16fc4f4269Schristos 
17fc4f4269Schristos    You should have received a copy of the GNU General Public License
18fc4f4269Schristos    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
19fc4f4269Schristos 
20fc4f4269Schristos #ifndef GCC_CP_INTERFACE_H
21fc4f4269Schristos #define GCC_CP_INTERFACE_H
22fc4f4269Schristos 
23fc4f4269Schristos #include "gcc-interface.h"
24fc4f4269Schristos 
25fc4f4269Schristos /* This header defines the interface to the GCC API.  It must be both
26fc4f4269Schristos    valid C and valid C++, because it is included by both programs.  */
27fc4f4269Schristos 
28fc4f4269Schristos #ifdef __cplusplus
29fc4f4269Schristos extern "C" {
30fc4f4269Schristos #endif
31fc4f4269Schristos 
32fc4f4269Schristos /* Forward declaration.  */
33fc4f4269Schristos 
34fc4f4269Schristos struct gcc_cp_context;
35fc4f4269Schristos 
36fc4f4269Schristos /*
37fc4f4269Schristos  * Definitions and declarations for the C++ front end.
38fc4f4269Schristos  */
39fc4f4269Schristos 
40fc4f4269Schristos /* Defined versions of the C++ front-end API.  */
41fc4f4269Schristos 
42fc4f4269Schristos enum gcc_cp_api_version
43fc4f4269Schristos {
44fc4f4269Schristos   GCC_CP_FE_VERSION_0 = 0
45fc4f4269Schristos };
46fc4f4269Schristos 
47fc4f4269Schristos /* Qualifiers.  */
48fc4f4269Schristos 
49fc4f4269Schristos enum gcc_cp_qualifiers
50fc4f4269Schristos {
51fc4f4269Schristos   GCC_CP_QUALIFIER_CONST = 1,
52fc4f4269Schristos   GCC_CP_QUALIFIER_VOLATILE = 2,
53fc4f4269Schristos   GCC_CP_QUALIFIER_RESTRICT = 4
54fc4f4269Schristos };
55fc4f4269Schristos 
56fc4f4269Schristos /* Ref qualifiers.  */
57fc4f4269Schristos 
58fc4f4269Schristos enum gcc_cp_ref_qualifiers {
59fc4f4269Schristos   GCC_CP_REF_QUAL_NONE = 0,
60fc4f4269Schristos   GCC_CP_REF_QUAL_LVALUE = 1,
61fc4f4269Schristos   GCC_CP_REF_QUAL_RVALUE = 2
62fc4f4269Schristos };
63fc4f4269Schristos 
64fc4f4269Schristos /* Opaque typedef for unbound class templates.  They are used for
65fc4f4269Schristos    template arguments, and defaults for template template
66fc4f4269Schristos    parameters.  */
67fc4f4269Schristos 
68fc4f4269Schristos typedef unsigned long long gcc_utempl;
69fc4f4269Schristos 
70fc4f4269Schristos /* Opaque typedef for expressions.  They are used for template
71fc4f4269Schristos    arguments, defaults for non-type template parameters, and defaults
72fc4f4269Schristos    for function arguments.  */
73fc4f4269Schristos 
74fc4f4269Schristos typedef unsigned long long gcc_expr;
75fc4f4269Schristos 
76fc4f4269Schristos typedef enum
77fc4f4269Schristos   { GCC_CP_TPARG_VALUE, GCC_CP_TPARG_CLASS,
78fc4f4269Schristos     GCC_CP_TPARG_TEMPL, GCC_CP_TPARG_PACK }
79fc4f4269Schristos gcc_cp_template_arg_kind;
80fc4f4269Schristos 
81fc4f4269Schristos typedef union
82fc4f4269Schristos { gcc_expr value; gcc_type type; gcc_utempl templ; gcc_type pack; }
83fc4f4269Schristos gcc_cp_template_arg;
84fc4f4269Schristos 
85fc4f4269Schristos /* An array of template arguments.  */
86fc4f4269Schristos 
87fc4f4269Schristos struct gcc_cp_template_args
88fc4f4269Schristos {
89fc4f4269Schristos   /* Number of elements.  */
90fc4f4269Schristos 
91fc4f4269Schristos   int n_elements;
92fc4f4269Schristos 
93fc4f4269Schristos   /* kind[i] indicates what kind of template argument type[i] is.  */
94fc4f4269Schristos 
95fc4f4269Schristos   char /* gcc_cp_template_arg_kind */ *kinds;
96fc4f4269Schristos 
97fc4f4269Schristos   /* The template arguments.  */
98fc4f4269Schristos 
99fc4f4269Schristos   gcc_cp_template_arg *elements;
100fc4f4269Schristos };
101fc4f4269Schristos 
102fc4f4269Schristos /* An array of (default) function arguments.  */
103fc4f4269Schristos 
104fc4f4269Schristos struct gcc_cp_function_args
105fc4f4269Schristos {
106fc4f4269Schristos   /* Number of elements.  */
107fc4f4269Schristos 
108fc4f4269Schristos   int n_elements;
109fc4f4269Schristos 
110fc4f4269Schristos   /* The (default) values for each argument.  */
111fc4f4269Schristos 
112fc4f4269Schristos   gcc_expr *elements;
113fc4f4269Schristos };
114fc4f4269Schristos 
115fc4f4269Schristos /* This enumerates the kinds of decls that GDB can create.  */
116fc4f4269Schristos 
117fc4f4269Schristos enum gcc_cp_symbol_kind
118fc4f4269Schristos {
119fc4f4269Schristos   /* A function.  */
120fc4f4269Schristos 
121fc4f4269Schristos   GCC_CP_SYMBOL_FUNCTION,
122fc4f4269Schristos 
123fc4f4269Schristos   /* A variable.  */
124fc4f4269Schristos 
125fc4f4269Schristos   GCC_CP_SYMBOL_VARIABLE,
126fc4f4269Schristos 
127fc4f4269Schristos   /* A typedef, or an alias declaration (including template ones).  */
128fc4f4269Schristos 
129fc4f4269Schristos   GCC_CP_SYMBOL_TYPEDEF,
130fc4f4269Schristos 
131fc4f4269Schristos   /* A label.  */
132fc4f4269Schristos 
133fc4f4269Schristos   GCC_CP_SYMBOL_LABEL,
134fc4f4269Schristos 
135fc4f4269Schristos   /* A class, forward declared in build_decl (to be later defined in
136fc4f4269Schristos      start_class_definition), or, in a template parameter list scope,
137fc4f4269Schristos      a declaration of a template class, closing the parameter
138fc4f4269Schristos      list.  */
139fc4f4269Schristos 
140fc4f4269Schristos   GCC_CP_SYMBOL_CLASS,
141fc4f4269Schristos 
142fc4f4269Schristos   /* A union, forward declared in build_decl (to be later defined in
143fc4f4269Schristos      start_class_definition).  */
144fc4f4269Schristos 
145fc4f4269Schristos   GCC_CP_SYMBOL_UNION,
146fc4f4269Schristos 
147fc4f4269Schristos   /* An enumeration type being introduced with start_new_enum_type.  */
148fc4f4269Schristos 
149fc4f4269Schristos   GCC_CP_SYMBOL_ENUM,
150fc4f4269Schristos 
151fc4f4269Schristos   /* A nonstatic data member being introduced with new_field.  */
152fc4f4269Schristos 
153fc4f4269Schristos   GCC_CP_SYMBOL_FIELD,
154fc4f4269Schristos 
155fc4f4269Schristos   /* A base class in a gcc_vbase_array.  */
156fc4f4269Schristos 
157fc4f4269Schristos   GCC_CP_SYMBOL_BASECLASS,
158fc4f4269Schristos 
159fc4f4269Schristos   /* A using declaration in new_using_decl.  */
160fc4f4269Schristos 
161fc4f4269Schristos   GCC_CP_SYMBOL_USING,
162fc4f4269Schristos 
163fc4f4269Schristos   /* A (lambda) closure class type.  In many regards this is just like
164fc4f4269Schristos      a regular class, but it's not supposed to have base classes, some
165fc4f4269Schristos      of the member functions that are usually implicitly-defined are
166fc4f4269Schristos      deleted, and it should have an operator() member function that
167fc4f4269Schristos      holds the lambda body.  We can't instantiate objects of lambda
168fc4f4269Schristos      types from the snippet, but we can interact with them in such
169fc4f4269Schristos      ways as passing them to functions that take their types, and
170fc4f4269Schristos      calling their body.  */
171fc4f4269Schristos 
172fc4f4269Schristos   GCC_CP_SYMBOL_LAMBDA_CLOSURE,
173fc4f4269Schristos 
174fc4f4269Schristos   /* Marker to check that we haven't exceeded GCC_CP_SYMBOL_MASK.  */
175fc4f4269Schristos   GCC_CP_SYMBOL_END,
176fc4f4269Schristos 
177fc4f4269Schristos   GCC_CP_SYMBOL_MASK = 15,
178fc4f4269Schristos 
179fc4f4269Schristos   /* When defining a class member, at least one of the
180fc4f4269Schristos      GCC_CP_ACCESS_MASK bits must be set; when defining a namespace-
181fc4f4269Schristos      or union-scoped symbol, none of them must be set.  */
182fc4f4269Schristos 
183fc4f4269Schristos   GCC_CP_ACCESS_PRIVATE,
184fc4f4269Schristos   GCC_CP_ACCESS_PUBLIC = GCC_CP_ACCESS_PRIVATE << 1,
185fc4f4269Schristos   GCC_CP_ACCESS_MASK = (GCC_CP_ACCESS_PUBLIC
186fc4f4269Schristos 			       | GCC_CP_ACCESS_PRIVATE),
187fc4f4269Schristos   GCC_CP_ACCESS_PROTECTED = GCC_CP_ACCESS_MASK,
188fc4f4269Schristos   GCC_CP_ACCESS_NONE = 0,
189fc4f4269Schristos 
190fc4f4269Schristos   GCC_CP_FLAG_BASE = GCC_CP_ACCESS_PRIVATE << 2,
191fc4f4269Schristos 
192fc4f4269Schristos   /* Flags to be used along with GCC_CP_SYMBOL_FUNCTION:  */
193fc4f4269Schristos 
194fc4f4269Schristos   /* This flag should be set for constructors, destructors and
195fc4f4269Schristos      operators.  */
196fc4f4269Schristos   GCC_CP_FLAG_SPECIAL_FUNCTION = GCC_CP_FLAG_BASE,
197fc4f4269Schristos 
198fc4f4269Schristos   /* We intentionally cannot express inline, constexpr, or virtual
199fc4f4269Schristos      override for functions.  We can't inline or constexpr-replace
200fc4f4269Schristos      without a source-level body.  The override keyword is only
201fc4f4269Schristos      meaningful within the definition of the containing class.  */
202fc4f4269Schristos 
203fc4f4269Schristos   /* This indicates a "virtual" member function, explicitly or
204fc4f4269Schristos      implicitly (due to a virtual function with the same name and
205fc4f4269Schristos      prototype in a base class) declared as such.  */
206fc4f4269Schristos   GCC_CP_FLAG_VIRTUAL_FUNCTION = GCC_CP_FLAG_BASE << 1,
207fc4f4269Schristos 
208fc4f4269Schristos   /* The following two flags should only be set when the flag above is
209fc4f4269Schristos      set.  */
210fc4f4269Schristos 
211fc4f4269Schristos   /* This indicates a pure virtual member function, i.e., one that is
212fc4f4269Schristos      declared with "= 0", even if a body is provided in the
213fc4f4269Schristos      definition.  */
214fc4f4269Schristos   GCC_CP_FLAG_PURE_VIRTUAL_FUNCTION = GCC_CP_FLAG_BASE << 2,
215fc4f4269Schristos 
216fc4f4269Schristos   /* This indicates a "final" virtual member function.  */
217fc4f4269Schristos   GCC_CP_FLAG_FINAL_VIRTUAL_FUNCTION = GCC_CP_FLAG_BASE << 3,
218fc4f4269Schristos 
219fc4f4269Schristos   /* This indicates a special member function should have its default
220fc4f4269Schristos      implementation.  This either means the function declaration
221fc4f4269Schristos      contains the "= default" tokens, or that the member function was
222fc4f4269Schristos      implicitly generated by the compiler, although the latter use is
223fc4f4269Schristos      discouraged: just let the compiler implicitly introduce it.
224fc4f4269Schristos 
225fc4f4269Schristos      A member function defaulted after its first declaration has
226fc4f4269Schristos      slightly different ABI implications from one implicitly generated
227fc4f4269Schristos      or explicitly defaulted at the declaration (and definition)
228fc4f4269Schristos      point.  To avoid silent (possibly harmless) violation of the one
229fc4f4269Schristos      definition rule, it is recommended that this flag not be used for
230fc4f4269Schristos      such functions, and that the address of the definition be
231fc4f4269Schristos      supplied instead.  */
232fc4f4269Schristos   GCC_CP_FLAG_DEFAULTED_FUNCTION = GCC_CP_FLAG_BASE << 4,
233fc4f4269Schristos 
234fc4f4269Schristos   /* This indicates a deleted member function, i.e., one that has been
235fc4f4269Schristos      defined as "= delete" at its declaration point, or one that has
236fc4f4269Schristos      been implicitly defined as deleted (with or without an explicit
237fc4f4269Schristos      "= default" definition).
238fc4f4269Schristos 
239fc4f4269Schristos      This should not be used for implicitly-declared member functions
240fc4f4269Schristos      that resolve to deleted definitions, as it may affect the
241fc4f4269Schristos      implicit declaration of other member functions.  */
242fc4f4269Schristos   GCC_CP_FLAG_DELETED_FUNCTION = GCC_CP_FLAG_BASE << 5,
243fc4f4269Schristos 
244fc4f4269Schristos   /* This indicates a constructor or type-conversion operator declared
245fc4f4269Schristos      as "explicit".  */
246fc4f4269Schristos 
247fc4f4269Schristos   GCC_CP_FLAG_EXPLICIT_FUNCTION = GCC_CP_FLAG_BASE << 6,
248fc4f4269Schristos 
249fc4f4269Schristos   GCC_CP_FLAG_END_FUNCTION,
250fc4f4269Schristos   GCC_CP_FLAG_MASK_FUNCTION = (((GCC_CP_FLAG_END_FUNCTION - 1) << 1)
251fc4f4269Schristos 			       - GCC_CP_FLAG_BASE),
252fc4f4269Schristos 
253fc4f4269Schristos   /* Flags to be used along with GCC_CP_SYMBOL_VARIABLE:  */
254fc4f4269Schristos 
255fc4f4269Schristos   /* This indicates a variable declared as "constexpr".  */
256fc4f4269Schristos 
257fc4f4269Schristos   GCC_CP_FLAG_CONSTEXPR_VARIABLE = GCC_CP_FLAG_BASE,
258fc4f4269Schristos 
259fc4f4269Schristos   /* This indicates a variable declared as "thread_local".  ??? What
260fc4f4269Schristos      should the ADDRESS be?  */
261fc4f4269Schristos 
262fc4f4269Schristos   GCC_CP_FLAG_THREAD_LOCAL_VARIABLE = GCC_CP_FLAG_BASE << 1,
263fc4f4269Schristos 
264fc4f4269Schristos   GCC_CP_FLAG_END_VARIABLE,
265fc4f4269Schristos   GCC_CP_FLAG_MASK_VARIABLE = (((GCC_CP_FLAG_END_VARIABLE - 1) << 1)
266fc4f4269Schristos 			       - GCC_CP_FLAG_BASE),
267fc4f4269Schristos 
268fc4f4269Schristos   /* Flags to be used when defining nonstatic data members of classes
269fc4f4269Schristos      with new_field.  */
270fc4f4269Schristos 
271fc4f4269Schristos   /* Use this when no flags are present.  */
272fc4f4269Schristos   GCC_CP_FLAG_FIELD_NOFLAG = 0,
273fc4f4269Schristos 
274fc4f4269Schristos   /* This indicates the field is declared as mutable.  */
275fc4f4269Schristos   GCC_CP_FLAG_FIELD_MUTABLE = GCC_CP_FLAG_BASE,
276fc4f4269Schristos 
277fc4f4269Schristos   GCC_CP_FLAG_END_FIELD,
278fc4f4269Schristos   GCC_CP_FLAG_MASK_FIELD = (((GCC_CP_FLAG_END_FIELD - 1) << 1)
279fc4f4269Schristos 			    - GCC_CP_FLAG_BASE),
280fc4f4269Schristos 
281fc4f4269Schristos   /* Flags to be used when defining an enum with
282fc4f4269Schristos      start_new_enum_type.  */
283fc4f4269Schristos 
284fc4f4269Schristos   /* This indicates an enum type without any flags.  */
285fc4f4269Schristos   GCC_CP_FLAG_ENUM_NOFLAG = 0,
286fc4f4269Schristos 
287fc4f4269Schristos   /* This indicates a scoped enum type.  */
288fc4f4269Schristos   GCC_CP_FLAG_ENUM_SCOPED = GCC_CP_FLAG_BASE,
289fc4f4269Schristos 
290fc4f4269Schristos   GCC_CP_FLAG_END_ENUM,
291fc4f4269Schristos   GCC_CP_FLAG_MASK_ENUM = (((GCC_CP_FLAG_END_ENUM - 1) << 1)
292fc4f4269Schristos 			       - GCC_CP_FLAG_BASE),
293fc4f4269Schristos 
294fc4f4269Schristos 
295fc4f4269Schristos   /* Flags to be used when introducing a class or a class template
296fc4f4269Schristos      with build_decl.  */
297fc4f4269Schristos 
298fc4f4269Schristos   /* This indicates an enum type without any flags.  */
299fc4f4269Schristos   GCC_CP_FLAG_CLASS_NOFLAG = 0,
300fc4f4269Schristos 
301fc4f4269Schristos   /* This indicates the class is actually a struct.  This has no
302fc4f4269Schristos      effect whatsoever on access control in this interface, since all
303fc4f4269Schristos      class members must have explicit access control bits set, but it
304fc4f4269Schristos      may affect error messages.  */
305fc4f4269Schristos   GCC_CP_FLAG_CLASS_IS_STRUCT = GCC_CP_FLAG_BASE,
306fc4f4269Schristos 
307fc4f4269Schristos   GCC_CP_FLAG_END_CLASS,
308fc4f4269Schristos   GCC_CP_FLAG_MASK_CLASS = (((GCC_CP_FLAG_END_CLASS - 1) << 1)
309fc4f4269Schristos 			       - GCC_CP_FLAG_BASE),
310fc4f4269Schristos 
311fc4f4269Schristos 
312fc4f4269Schristos   /* Flags to be used when introducing a virtual base class in a
313fc4f4269Schristos      gcc_vbase_array.  */
314fc4f4269Schristos 
315fc4f4269Schristos   /* This indicates an enum type without any flags.  */
316fc4f4269Schristos   GCC_CP_FLAG_BASECLASS_NOFLAG = 0,
317fc4f4269Schristos 
318fc4f4269Schristos   /* This indicates the class is actually a struct.  This has no
319fc4f4269Schristos      effect whatsoever on access control in this interface, since all
320fc4f4269Schristos      class members must have explicit access control bits set, but it
321fc4f4269Schristos      may affect error messages.  */
322fc4f4269Schristos   GCC_CP_FLAG_BASECLASS_VIRTUAL = GCC_CP_FLAG_BASE,
323fc4f4269Schristos 
324fc4f4269Schristos   GCC_CP_FLAG_END_BASECLASS,
325fc4f4269Schristos   GCC_CP_FLAG_MASK_BASECLASS = (((GCC_CP_FLAG_END_BASECLASS - 1) << 1)
326fc4f4269Schristos 				- GCC_CP_FLAG_BASE),
327fc4f4269Schristos 
328fc4f4269Schristos 
329fc4f4269Schristos   GCC_CP_FLAG_MASK = (GCC_CP_FLAG_MASK_FUNCTION
330fc4f4269Schristos 		      | GCC_CP_FLAG_MASK_VARIABLE
331fc4f4269Schristos 		      | GCC_CP_FLAG_MASK_FIELD
332fc4f4269Schristos 		      | GCC_CP_FLAG_MASK_ENUM
333fc4f4269Schristos 		      | GCC_CP_FLAG_MASK_CLASS
334fc4f4269Schristos 		      | GCC_CP_FLAG_MASK_BASECLASS
335fc4f4269Schristos 		      )
336fc4f4269Schristos };
337fc4f4269Schristos 
338fc4f4269Schristos 
339fc4f4269Schristos /* An array of types used for creating lists of base classes.  */
340fc4f4269Schristos 
341fc4f4269Schristos struct gcc_vbase_array
342fc4f4269Schristos {
343fc4f4269Schristos   /* Number of elements.  */
344fc4f4269Schristos 
345fc4f4269Schristos   int n_elements;
346fc4f4269Schristos 
347fc4f4269Schristos   /* The base classes.  */
348fc4f4269Schristos 
349fc4f4269Schristos   gcc_type *elements;
350fc4f4269Schristos 
351fc4f4269Schristos   /* Flags for each base class.  Used to indicate access control and
352fc4f4269Schristos      virtualness.  */
353fc4f4269Schristos 
354fc4f4269Schristos   enum gcc_cp_symbol_kind *flags;
355fc4f4269Schristos };
356fc4f4269Schristos 
357fc4f4269Schristos 
358fc4f4269Schristos /* This enumerates the types of symbols that GCC might request from
359fc4f4269Schristos    GDB.  */
360fc4f4269Schristos 
361fc4f4269Schristos enum gcc_cp_oracle_request
362fc4f4269Schristos {
363fc4f4269Schristos   /* An identifier in namespace scope -- type, variable, function,
364fc4f4269Schristos      namespace, template.  All namespace-scoped symbols with the
365fc4f4269Schristos      requested name, in any namespace (including the global
366fc4f4269Schristos      namespace), should be defined in response to this request.  */
367fc4f4269Schristos 
368fc4f4269Schristos   GCC_CP_ORACLE_IDENTIFIER
369fc4f4269Schristos };
370fc4f4269Schristos 
371fc4f4269Schristos /* The type of the function called by GCC to ask GDB for a symbol's
372fc4f4269Schristos    definition.  DATUM is an arbitrary value supplied when the oracle
373fc4f4269Schristos    function is registered.  CONTEXT is the GCC context in which the
374fc4f4269Schristos    request is being made.  REQUEST specifies what sort of symbol is
375fc4f4269Schristos    being requested, and IDENTIFIER is the name of the symbol.  */
376fc4f4269Schristos 
377fc4f4269Schristos typedef void gcc_cp_oracle_function (void *datum,
378fc4f4269Schristos 				     struct gcc_cp_context *context,
379fc4f4269Schristos 				     enum gcc_cp_oracle_request request,
380fc4f4269Schristos 				     const char *identifier);
381fc4f4269Schristos 
382fc4f4269Schristos /* The type of the function called by GCC to ask GDB for a symbol's
383fc4f4269Schristos    address.  This should return 0 if the address is not known.  */
384fc4f4269Schristos 
385fc4f4269Schristos typedef gcc_address gcc_cp_symbol_address_function (void *datum,
386fc4f4269Schristos 						    struct gcc_cp_context *ctxt,
387fc4f4269Schristos 						    const char *identifier);
388fc4f4269Schristos 
389fc4f4269Schristos /* The type of the function called by GCC to ask GDB to enter or leave
390fc4f4269Schristos    the user expression scope.  */
391fc4f4269Schristos 
392fc4f4269Schristos typedef void gcc_cp_enter_leave_user_expr_scope_function (void *datum,
393fc4f4269Schristos 							  struct gcc_cp_context
394fc4f4269Schristos 							  *context);
395fc4f4269Schristos 
396fc4f4269Schristos /* The vtable used by the C front end.  */
397fc4f4269Schristos 
398fc4f4269Schristos struct gcc_cp_fe_vtable
399fc4f4269Schristos {
400fc4f4269Schristos   /* The version of the C interface.  The value is one of the
401fc4f4269Schristos      gcc_cp_api_version constants.  */
402fc4f4269Schristos 
403fc4f4269Schristos   unsigned int cp_version;
404fc4f4269Schristos 
405fc4f4269Schristos   /* Set the callbacks for this context.
406fc4f4269Schristos 
407fc4f4269Schristos      The binding oracle is called whenever the C++ parser needs to
408fc4f4269Schristos      look up a symbol.  This gives the caller a chance to lazily
409fc4f4269Schristos      instantiate symbols using other parts of the gcc_cp_fe_interface
410fc4f4269Schristos      API.  The symbol is looked up without a scope, and the oracle
411fc4f4269Schristos      must supply a definition for ALL namespace-scoped definitions
412fc4f4269Schristos      bound to the symbol.
413fc4f4269Schristos 
414fc4f4269Schristos      The address oracle is called whenever the C++ parser needs to
415fc4f4269Schristos      look up a symbol.  This may be called for symbols not provided by
416fc4f4269Schristos      the symbol oracle, such as built-in functions where GCC provides
417fc4f4269Schristos      the declaration; other internal symbols, such as those related
418fc4f4269Schristos      with thunks, rtti, and virtual tables are likely to be queried
419fc4f4269Schristos      through this interface too.  The identifier is a mangled symbol
420fc4f4269Schristos      name.
421fc4f4269Schristos 
422fc4f4269Schristos      DATUM is an arbitrary piece of data that is passed back verbatim
423fc4f4269Schristos      to the callbacks in requests.  */
424fc4f4269Schristos 
425fc4f4269Schristos   void (*set_callbacks) (struct gcc_cp_context *self,
426fc4f4269Schristos 			 gcc_cp_oracle_function *binding_oracle,
427fc4f4269Schristos 			 gcc_cp_symbol_address_function *address_oracle,
428fc4f4269Schristos 			 gcc_cp_enter_leave_user_expr_scope_function *enter_scope,
429fc4f4269Schristos 			 gcc_cp_enter_leave_user_expr_scope_function *leave_scope,
430fc4f4269Schristos 			 void *datum);
431fc4f4269Schristos 
432fc4f4269Schristos #define GCC_METHOD0(R, N) \
433fc4f4269Schristos   R (*N) (struct gcc_cp_context *);
434fc4f4269Schristos #define GCC_METHOD1(R, N, A) \
435fc4f4269Schristos   R (*N) (struct gcc_cp_context *, A);
436fc4f4269Schristos #define GCC_METHOD2(R, N, A, B) \
437fc4f4269Schristos   R (*N) (struct gcc_cp_context *, A, B);
438fc4f4269Schristos #define GCC_METHOD3(R, N, A, B, C) \
439fc4f4269Schristos   R (*N) (struct gcc_cp_context *, A, B, C);
440fc4f4269Schristos #define GCC_METHOD4(R, N, A, B, C, D) \
441fc4f4269Schristos   R (*N) (struct gcc_cp_context *, A, B, C, D);
442fc4f4269Schristos #define GCC_METHOD5(R, N, A, B, C, D, E) \
443fc4f4269Schristos   R (*N) (struct gcc_cp_context *, A, B, C, D, E);
444fc4f4269Schristos #define GCC_METHOD7(R, N, A, B, C, D, E, F, G) \
445fc4f4269Schristos   R (*N) (struct gcc_cp_context *, A, B, C, D, E, F, G);
446fc4f4269Schristos 
447fc4f4269Schristos #include "gcc-cp-fe.def"
448fc4f4269Schristos 
449fc4f4269Schristos #undef GCC_METHOD0
450fc4f4269Schristos #undef GCC_METHOD1
451fc4f4269Schristos #undef GCC_METHOD2
452fc4f4269Schristos #undef GCC_METHOD3
453fc4f4269Schristos #undef GCC_METHOD4
454fc4f4269Schristos #undef GCC_METHOD5
455fc4f4269Schristos #undef GCC_METHOD7
456fc4f4269Schristos 
457fc4f4269Schristos };
458fc4f4269Schristos 
459fc4f4269Schristos /* The C front end object.  */
460fc4f4269Schristos 
461fc4f4269Schristos struct gcc_cp_context
462fc4f4269Schristos {
463fc4f4269Schristos   /* Base class.  */
464fc4f4269Schristos 
465fc4f4269Schristos   struct gcc_base_context base;
466fc4f4269Schristos 
467fc4f4269Schristos   /* Our vtable.  This is a separate field because this is simpler
468fc4f4269Schristos      than implementing a vtable inheritance scheme in C.  */
469fc4f4269Schristos 
470fc4f4269Schristos   const struct gcc_cp_fe_vtable *cp_ops;
471fc4f4269Schristos };
472fc4f4269Schristos 
473fc4f4269Schristos /* The name of the .so that the compiler builds.  We dlopen this
474fc4f4269Schristos    later.  */
475fc4f4269Schristos 
476fc4f4269Schristos #define GCC_CP_FE_LIBCC libcc1.so
477fc4f4269Schristos 
478fc4f4269Schristos /* The compiler exports a single initialization function.  This macro
479fc4f4269Schristos    holds its name as a symbol.  */
480fc4f4269Schristos 
481fc4f4269Schristos #define GCC_CP_FE_CONTEXT gcc_cp_fe_context
482fc4f4269Schristos 
483fc4f4269Schristos /* The type of the initialization function.  The caller passes in the
484fc4f4269Schristos    desired base version and desired C-specific version.  If the
485fc4f4269Schristos    request can be satisfied, a compatible gcc_context object will be
486fc4f4269Schristos    returned.  Otherwise, the function returns NULL.  */
487fc4f4269Schristos 
488fc4f4269Schristos typedef struct gcc_cp_context *gcc_cp_fe_context_function
489fc4f4269Schristos     (enum gcc_base_api_version,
490fc4f4269Schristos      enum gcc_cp_api_version);
491fc4f4269Schristos 
492fc4f4269Schristos #ifdef __cplusplus
493fc4f4269Schristos }
494fc4f4269Schristos #endif
495fc4f4269Schristos 
496fc4f4269Schristos #endif /* GCC_CP_INTERFACE_H */
497