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