Daily bump.
[official-gcc.git] / libcc1 / libcc1plugin.cc
blob4d6a3a11ee221268ea20c0fa26fe2f7fe96f9bbd
1 /* Library interface to C front end
2 Copyright (C) 2014-2021 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 3, or (at your option) any later
9 version.
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 for more details.
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
20 #include <cc1plugin-config.h>
22 #undef PACKAGE_NAME
23 #undef PACKAGE_STRING
24 #undef PACKAGE_TARNAME
25 #undef PACKAGE_VERSION
27 #include "../gcc/config.h"
29 #undef PACKAGE_NAME
30 #undef PACKAGE_STRING
31 #undef PACKAGE_TARNAME
32 #undef PACKAGE_VERSION
34 #include "gcc-plugin.h"
35 #include "system.h"
36 #include "coretypes.h"
37 #include "stringpool.h"
39 #include "gcc-interface.h"
40 #include "hash-set.h"
41 #include "machmode.h"
42 #include "vec.h"
43 #include "double-int.h"
44 #include "input.h"
45 #include "alias.h"
46 #include "symtab.h"
47 #include "options.h"
48 #include "wide-int.h"
49 #include "inchash.h"
50 #include "tree.h"
51 #include "fold-const.h"
52 #include "stor-layout.h"
53 #include "c-tree.h"
54 #include "toplev.h"
55 #include "timevar.h"
56 #include "hash-table.h"
57 #include "tm.h"
58 #include "c-family/c-pragma.h"
59 #include "c-lang.h"
60 #include "diagnostic.h"
61 #include "langhooks.h"
62 #include "langhooks-def.h"
64 #include "callbacks.hh"
65 #include "connection.hh"
66 #include "marshall.hh"
67 #include "rpc.hh"
68 #include "gcc-c-interface.h"
69 #include "context.hh"
71 #include <vector>
73 using namespace cc1_plugin;
77 // A wrapper for pushdecl that doesn't let gdb have a chance to
78 // instantiate a symbol.
80 static void
81 pushdecl_safe (tree decl)
83 void (*save) (enum c_oracle_request, tree identifier);
85 save = c_binding_oracle;
86 c_binding_oracle = NULL;
87 pushdecl (decl);
88 c_binding_oracle = save;
93 static void
94 plugin_binding_oracle (enum c_oracle_request kind, tree identifier)
96 enum gcc_c_oracle_request request;
98 gcc_assert (current_context != NULL);
100 switch (kind)
102 case C_ORACLE_SYMBOL:
103 request = GCC_C_ORACLE_SYMBOL;
104 break;
105 case C_ORACLE_TAG:
106 request = GCC_C_ORACLE_TAG;
107 break;
108 case C_ORACLE_LABEL:
109 request = GCC_C_ORACLE_LABEL;
110 break;
111 default:
112 abort ();
115 int ignore;
116 cc1_plugin::call (current_context, "binding_oracle", &ignore,
117 request, IDENTIFIER_POINTER (identifier));
120 static void
121 plugin_pragma_user_expression (cpp_reader *)
123 c_binding_oracle = plugin_binding_oracle;
126 static void
127 plugin_init_extra_pragmas (void *, void *)
129 c_register_pragma ("GCC", "user_expression", plugin_pragma_user_expression);
134 // Maybe rewrite a decl to its address.
135 static tree
136 address_rewriter (tree *in, int *walk_subtrees, void *arg)
138 plugin_context *ctx = (plugin_context *) arg;
140 if (!DECL_P (*in) || DECL_NAME (*in) == NULL_TREE)
141 return NULL_TREE;
143 decl_addr_value value;
144 value.decl = *in;
145 decl_addr_value *found_value = ctx->address_map.find (&value);
146 if (found_value != NULL)
148 else if (DECL_IS_UNDECLARED_BUILTIN (*in))
150 gcc_address address;
152 if (!cc1_plugin::call (ctx, "address_oracle", &address,
153 IDENTIFIER_POINTER (DECL_NAME (*in))))
154 return NULL_TREE;
155 if (address == 0)
156 return NULL_TREE;
158 // Insert the decl into the address map in case it is referenced
159 // again.
160 value.address = build_int_cst_type (ptr_type_node, address);
161 decl_addr_value **slot = ctx->address_map.find_slot (&value, INSERT);
162 gcc_assert (*slot == NULL);
163 *slot
164 = static_cast<decl_addr_value *> (xmalloc (sizeof (decl_addr_value)));
165 **slot = value;
166 found_value = *slot;
168 else
169 return NULL_TREE;
171 if (found_value->address != error_mark_node)
173 // We have an address for the decl, so rewrite the tree.
174 tree ptr_type = build_pointer_type (TREE_TYPE (*in));
175 *in = fold_build1 (INDIRECT_REF, TREE_TYPE (*in),
176 fold_build1 (CONVERT_EXPR, ptr_type,
177 found_value->address));
180 *walk_subtrees = 0;
182 return NULL_TREE;
185 // When generating code for gdb, we want to be able to use absolute
186 // addresses to refer to otherwise external objects that gdb knows
187 // about. gdb passes in these addresses when building decls, and then
188 // before gimplification we go through the trees, rewriting uses to
189 // the equivalent of "*(TYPE *) ADDR".
190 static void
191 rewrite_decls_to_addresses (void *function_in, void *)
193 tree function = (tree) function_in;
195 // Do nothing if we're not in gdb.
196 if (current_context == NULL)
197 return;
199 walk_tree (&DECL_SAVED_TREE (function), address_rewriter, current_context,
200 NULL);
205 gcc_decl
206 plugin_build_decl (cc1_plugin::connection *self,
207 const char *name,
208 enum gcc_c_symbol_kind sym_kind,
209 gcc_type sym_type_in,
210 const char *substitution_name,
211 gcc_address address,
212 const char *filename,
213 unsigned int line_number)
215 plugin_context *ctx = static_cast<plugin_context *> (self);
216 tree identifier = get_identifier (name);
217 enum tree_code code;
218 tree decl;
219 tree sym_type = convert_in (sym_type_in);
221 switch (sym_kind)
223 case GCC_C_SYMBOL_FUNCTION:
224 code = FUNCTION_DECL;
225 break;
227 case GCC_C_SYMBOL_VARIABLE:
228 code = VAR_DECL;
229 break;
231 case GCC_C_SYMBOL_TYPEDEF:
232 code = TYPE_DECL;
233 break;
235 case GCC_C_SYMBOL_LABEL:
236 // FIXME: we aren't ready to handle labels yet.
237 // It isn't clear how to translate them properly
238 // and in any case a "goto" isn't likely to work.
239 return convert_out (error_mark_node);
241 default:
242 abort ();
245 location_t loc = ctx->get_location_t (filename, line_number);
247 decl = build_decl (loc, code, identifier, sym_type);
248 TREE_USED (decl) = 1;
249 TREE_ADDRESSABLE (decl) = 1;
251 if (sym_kind != GCC_C_SYMBOL_TYPEDEF)
253 decl_addr_value value;
255 DECL_EXTERNAL (decl) = 1;
256 value.decl = decl;
257 if (substitution_name != NULL)
259 // If the translator gave us a name without a binding,
260 // we can just substitute error_mark_node, since we know the
261 // translator will be reporting an error anyhow.
262 value.address
263 = lookup_name (get_identifier (substitution_name));
264 if (value.address == NULL_TREE)
265 value.address = error_mark_node;
267 else
268 value.address = build_int_cst_type (ptr_type_node, address);
269 decl_addr_value **slot = ctx->address_map.find_slot (&value, INSERT);
270 gcc_assert (*slot == NULL);
271 *slot
272 = static_cast<decl_addr_value *> (xmalloc (sizeof (decl_addr_value)));
273 **slot = value;
276 return convert_out (ctx->preserve (decl));
280 plugin_bind (cc1_plugin::connection *,
281 gcc_decl decl_in, int is_global)
283 tree decl = convert_in (decl_in);
284 c_bind (DECL_SOURCE_LOCATION (decl), decl, is_global);
285 rest_of_decl_compilation (decl, is_global, 0);
286 return 1;
290 plugin_tagbind (cc1_plugin::connection *self,
291 const char *name, gcc_type tagged_type,
292 const char *filename, unsigned int line_number)
294 plugin_context *ctx = static_cast<plugin_context *> (self);
295 tree t = convert_in (tagged_type), x;
296 c_pushtag (ctx->get_location_t (filename, line_number),
297 get_identifier (name), t);
299 /* Propagate the newly-added type name so that previously-created
300 variant types are not disconnected from their main variants. */
301 for (x = TYPE_MAIN_VARIANT (t); x; x = TYPE_NEXT_VARIANT (x))
302 TYPE_NAME (x) = TYPE_NAME (t);
304 return 1;
307 gcc_type
308 plugin_build_pointer_type (cc1_plugin::connection *,
309 gcc_type base_type)
311 // No need to preserve a pointer type as the base type is preserved.
312 return convert_out (build_pointer_type (convert_in (base_type)));
315 // TYPE_NAME needs to be a valid pointer, even if there is no name available.
317 static tree
318 build_anonymous_node (enum tree_code code)
320 tree node = make_node (code);
321 tree type_decl = build_decl (input_location, TYPE_DECL, NULL_TREE, node);
322 TYPE_NAME (node) = type_decl;
323 TYPE_STUB_DECL (node) = type_decl;
324 return node;
327 gcc_type
328 plugin_build_record_type (cc1_plugin::connection *self)
330 plugin_context *ctx = static_cast<plugin_context *> (self);
331 return convert_out (ctx->preserve (build_anonymous_node (RECORD_TYPE)));
334 gcc_type
335 plugin_build_union_type (cc1_plugin::connection *self)
337 plugin_context *ctx = static_cast<plugin_context *> (self);
338 return convert_out (ctx->preserve (build_anonymous_node (UNION_TYPE)));
342 plugin_build_add_field (cc1_plugin::connection *,
343 gcc_type record_or_union_type_in,
344 const char *field_name,
345 gcc_type field_type_in,
346 unsigned long bitsize,
347 unsigned long bitpos)
349 tree record_or_union_type = convert_in (record_or_union_type_in);
350 tree field_type = convert_in (field_type_in);
352 gcc_assert (TREE_CODE (record_or_union_type) == RECORD_TYPE
353 || TREE_CODE (record_or_union_type) == UNION_TYPE);
355 /* Note that gdb does not preserve the location of field decls, so
356 we can't provide a decent location here. */
357 tree decl = build_decl (BUILTINS_LOCATION, FIELD_DECL,
358 get_identifier (field_name), field_type);
359 DECL_FIELD_CONTEXT (decl) = record_or_union_type;
361 if (TREE_CODE (field_type) == INTEGER_TYPE
362 && TYPE_PRECISION (field_type) != bitsize)
364 DECL_BIT_FIELD_TYPE (decl) = field_type;
365 TREE_TYPE (decl)
366 = c_build_bitfield_integer_type (bitsize, TYPE_UNSIGNED (field_type));
369 SET_DECL_MODE (decl, TYPE_MODE (TREE_TYPE (decl)));
371 // There's no way to recover this from DWARF.
372 SET_DECL_OFFSET_ALIGN (decl, TYPE_PRECISION (pointer_sized_int_node));
374 tree pos = bitsize_int (bitpos);
375 pos_from_bit (&DECL_FIELD_OFFSET (decl), &DECL_FIELD_BIT_OFFSET (decl),
376 DECL_OFFSET_ALIGN (decl), pos);
378 DECL_SIZE (decl) = bitsize_int (bitsize);
379 DECL_SIZE_UNIT (decl) = size_int ((bitsize + BITS_PER_UNIT - 1)
380 / BITS_PER_UNIT);
382 DECL_CHAIN (decl) = TYPE_FIELDS (record_or_union_type);
383 TYPE_FIELDS (record_or_union_type) = decl;
385 return 1;
389 plugin_finish_record_or_union (cc1_plugin::connection *,
390 gcc_type record_or_union_type_in,
391 unsigned long size_in_bytes)
393 tree record_or_union_type = convert_in (record_or_union_type_in);
395 gcc_assert (TREE_CODE (record_or_union_type) == RECORD_TYPE
396 || TREE_CODE (record_or_union_type) == UNION_TYPE);
398 /* We built the field list in reverse order, so fix it now. */
399 TYPE_FIELDS (record_or_union_type)
400 = nreverse (TYPE_FIELDS (record_or_union_type));
402 if (TREE_CODE (record_or_union_type) == UNION_TYPE)
404 /* Unions can just be handled by the generic code. */
405 layout_type (record_or_union_type);
407 else
409 // FIXME there's no way to get this from DWARF,
410 // or even, it seems, a particularly good way to deduce it.
411 SET_TYPE_ALIGN (record_or_union_type,
412 TYPE_PRECISION (pointer_sized_int_node));
414 TYPE_SIZE (record_or_union_type) = bitsize_int (size_in_bytes
415 * BITS_PER_UNIT);
416 TYPE_SIZE_UNIT (record_or_union_type) = size_int (size_in_bytes);
418 compute_record_mode (record_or_union_type);
419 finish_bitfield_layout (record_or_union_type);
420 // FIXME we have no idea about TYPE_PACKED
423 tree t = record_or_union_type, x;
424 for (x = TYPE_MAIN_VARIANT (t); x; x = TYPE_NEXT_VARIANT (x))
426 /* Like finish_struct, update the qualified variant types. */
427 TYPE_FIELDS (x) = TYPE_FIELDS (t);
428 TYPE_LANG_SPECIFIC (x) = TYPE_LANG_SPECIFIC (t);
429 C_TYPE_FIELDS_READONLY (x) = C_TYPE_FIELDS_READONLY (t);
430 C_TYPE_FIELDS_VOLATILE (x) = C_TYPE_FIELDS_VOLATILE (t);
431 C_TYPE_VARIABLE_SIZE (x) = C_TYPE_VARIABLE_SIZE (t);
432 /* We copy these fields too. */
433 SET_TYPE_ALIGN (x, TYPE_ALIGN (t));
434 TYPE_SIZE (x) = TYPE_SIZE (t);
435 TYPE_SIZE_UNIT (x) = TYPE_SIZE_UNIT (t);
436 if (x != record_or_union_type)
437 compute_record_mode (x);
440 return 1;
443 gcc_type
444 plugin_build_enum_type (cc1_plugin::connection *self,
445 gcc_type underlying_int_type_in)
447 tree underlying_int_type = convert_in (underlying_int_type_in);
449 if (underlying_int_type == error_mark_node)
450 return convert_out (error_mark_node);
452 tree result = build_anonymous_node (ENUMERAL_TYPE);
454 TYPE_PRECISION (result) = TYPE_PRECISION (underlying_int_type);
455 TYPE_UNSIGNED (result) = TYPE_UNSIGNED (underlying_int_type);
457 plugin_context *ctx = static_cast<plugin_context *> (self);
458 return convert_out (ctx->preserve (result));
462 plugin_build_add_enum_constant (cc1_plugin::connection *,
463 gcc_type enum_type_in,
464 const char *name,
465 unsigned long value)
467 tree cst, decl, cons;
468 tree enum_type = convert_in (enum_type_in);
470 gcc_assert (TREE_CODE (enum_type) == ENUMERAL_TYPE);
472 cst = build_int_cst (enum_type, value);
473 /* Note that gdb does not preserve the location of enum constants,
474 so we can't provide a decent location here. */
475 decl = build_decl (BUILTINS_LOCATION, CONST_DECL,
476 get_identifier (name), enum_type);
477 DECL_INITIAL (decl) = cst;
478 pushdecl_safe (decl);
480 cons = tree_cons (DECL_NAME (decl), cst, TYPE_VALUES (enum_type));
481 TYPE_VALUES (enum_type) = cons;
483 return 1;
487 plugin_finish_enum_type (cc1_plugin::connection *,
488 gcc_type enum_type_in)
490 tree enum_type = convert_in (enum_type_in);
491 tree minnode, maxnode, iter;
493 iter = TYPE_VALUES (enum_type);
494 minnode = maxnode = TREE_VALUE (iter);
495 for (iter = TREE_CHAIN (iter);
496 iter != NULL_TREE;
497 iter = TREE_CHAIN (iter))
499 tree value = TREE_VALUE (iter);
500 if (tree_int_cst_lt (maxnode, value))
501 maxnode = value;
502 if (tree_int_cst_lt (value, minnode))
503 minnode = value;
505 TYPE_MIN_VALUE (enum_type) = minnode;
506 TYPE_MAX_VALUE (enum_type) = maxnode;
508 layout_type (enum_type);
510 return 1;
513 gcc_type
514 plugin_build_function_type (cc1_plugin::connection *self,
515 gcc_type return_type_in,
516 const struct gcc_type_array *argument_types_in,
517 int is_varargs)
519 tree return_type = convert_in (return_type_in);
520 tree result;
522 std::vector<tree> argument_types (argument_types_in->n_elements);
523 for (int i = 0; i < argument_types_in->n_elements; ++i)
524 argument_types[i] = convert_in (argument_types_in->elements[i]);
526 if (is_varargs)
527 result = build_varargs_function_type_array (return_type,
528 argument_types_in->n_elements,
529 argument_types.data ());
530 else
531 result = build_function_type_array (return_type,
532 argument_types_in->n_elements,
533 argument_types.data ());
535 plugin_context *ctx = static_cast<plugin_context *> (self);
536 return convert_out (ctx->preserve (result));
539 /* Return a builtin type associated with BUILTIN_NAME. */
541 static tree
542 safe_lookup_builtin_type (const char *builtin_name)
544 tree result = NULL_TREE;
546 if (!builtin_name)
547 return result;
549 result = identifier_global_value (get_identifier (builtin_name));
551 if (!result)
552 return result;
554 gcc_assert (TREE_CODE (result) == TYPE_DECL);
555 result = TREE_TYPE (result);
556 return result;
559 static gcc_type
560 plugin_int_check (cc1_plugin::connection *self,
561 int is_unsigned, unsigned long size_in_bytes,
562 tree result)
564 if (result == NULL_TREE)
565 result = error_mark_node;
566 else
568 gcc_assert (!TYPE_UNSIGNED (result) == !is_unsigned);
569 gcc_assert (TREE_CODE (TYPE_SIZE (result)) == INTEGER_CST);
570 gcc_assert (TYPE_PRECISION (result) == BITS_PER_UNIT * size_in_bytes);
572 plugin_context *ctx = static_cast<plugin_context *> (self);
573 ctx->preserve (result);
575 return convert_out (result);
578 gcc_type
579 plugin_int_type_v0 (cc1_plugin::connection *self,
580 int is_unsigned, unsigned long size_in_bytes)
582 tree result = c_common_type_for_size (BITS_PER_UNIT * size_in_bytes,
583 is_unsigned);
585 return plugin_int_check (self, is_unsigned, size_in_bytes, result);
588 gcc_type
589 plugin_int_type (cc1_plugin::connection *self,
590 int is_unsigned, unsigned long size_in_bytes,
591 const char *builtin_name)
593 if (!builtin_name)
594 return plugin_int_type_v0 (self, is_unsigned, size_in_bytes);
596 tree result = safe_lookup_builtin_type (builtin_name);
597 gcc_assert (!result || TREE_CODE (result) == INTEGER_TYPE);
599 return plugin_int_check (self, is_unsigned, size_in_bytes, result);
602 gcc_type
603 plugin_char_type (cc1_plugin::connection *)
605 return convert_out (char_type_node);
608 gcc_type
609 plugin_float_type_v0 (cc1_plugin::connection *,
610 unsigned long size_in_bytes)
612 if (BITS_PER_UNIT * size_in_bytes == TYPE_PRECISION (float_type_node))
613 return convert_out (float_type_node);
614 if (BITS_PER_UNIT * size_in_bytes == TYPE_PRECISION (double_type_node))
615 return convert_out (double_type_node);
616 if (BITS_PER_UNIT * size_in_bytes == TYPE_PRECISION (long_double_type_node))
617 return convert_out (long_double_type_node);
618 return convert_out (error_mark_node);
621 gcc_type
622 plugin_float_type (cc1_plugin::connection *self,
623 unsigned long size_in_bytes,
624 const char *builtin_name)
626 if (!builtin_name)
627 return plugin_float_type_v0 (self, size_in_bytes);
629 tree result = safe_lookup_builtin_type (builtin_name);
631 if (!result)
632 return convert_out (error_mark_node);
634 gcc_assert (TREE_CODE (result) == REAL_TYPE);
635 gcc_assert (BITS_PER_UNIT * size_in_bytes == TYPE_PRECISION (result));
637 return convert_out (result);
640 gcc_type
641 plugin_void_type (cc1_plugin::connection *)
643 return convert_out (void_type_node);
646 gcc_type
647 plugin_bool_type (cc1_plugin::connection *)
649 return convert_out (boolean_type_node);
652 gcc_type
653 plugin_build_array_type (cc1_plugin::connection *self,
654 gcc_type element_type_in, int num_elements)
656 tree element_type = convert_in (element_type_in);
657 tree result;
659 if (num_elements == -1)
660 result = build_array_type (element_type, NULL_TREE);
661 else
662 result = build_array_type_nelts (element_type, num_elements);
664 plugin_context *ctx = static_cast<plugin_context *> (self);
665 return convert_out (ctx->preserve (result));
668 gcc_type
669 plugin_build_vla_array_type (cc1_plugin::connection *self,
670 gcc_type element_type_in,
671 const char *upper_bound_name)
673 tree element_type = convert_in (element_type_in);
674 tree upper_bound = lookup_name (get_identifier (upper_bound_name));
675 tree range = build_index_type (upper_bound);
677 tree result = build_array_type (element_type, range);
678 C_TYPE_VARIABLE_SIZE (result) = 1;
680 plugin_context *ctx = static_cast<plugin_context *> (self);
681 return convert_out (ctx->preserve (result));
684 gcc_type
685 plugin_build_qualified_type (cc1_plugin::connection *,
686 gcc_type unqualified_type_in,
687 enum gcc_qualifiers qualifiers)
689 tree unqualified_type = convert_in (unqualified_type_in);
690 int quals = 0;
692 if ((qualifiers & GCC_QUALIFIER_CONST) != 0)
693 quals |= TYPE_QUAL_CONST;
694 if ((qualifiers & GCC_QUALIFIER_VOLATILE) != 0)
695 quals |= TYPE_QUAL_VOLATILE;
696 if ((qualifiers & GCC_QUALIFIER_RESTRICT) != 0)
697 quals |= TYPE_QUAL_RESTRICT;
699 return convert_out (build_qualified_type (unqualified_type, quals));
702 gcc_type
703 plugin_build_complex_type (cc1_plugin::connection *self,
704 gcc_type base_type)
706 plugin_context *ctx = static_cast<plugin_context *> (self);
707 return convert_out (ctx->preserve (build_complex_type (convert_in (base_type))));
710 gcc_type
711 plugin_build_vector_type (cc1_plugin::connection *self,
712 gcc_type base_type, int nunits)
714 plugin_context *ctx = static_cast<plugin_context *> (self);
715 return convert_out (ctx->preserve (build_vector_type (convert_in (base_type),
716 nunits)));
720 plugin_build_constant (cc1_plugin::connection *self, gcc_type type_in,
721 const char *name, unsigned long value,
722 const char *filename, unsigned int line_number)
724 plugin_context *ctx = static_cast<plugin_context *> (self);
725 tree cst, decl;
726 tree type = convert_in (type_in);
728 cst = build_int_cst (type, value);
729 decl = build_decl (ctx->get_location_t (filename, line_number),
730 CONST_DECL, get_identifier (name), type);
731 DECL_INITIAL (decl) = cst;
732 pushdecl_safe (decl);
734 return 1;
737 gcc_type
738 plugin_error (cc1_plugin::connection *,
739 const char *message)
741 error ("%s", message);
742 return convert_out (error_mark_node);
747 #ifdef __GNUC__
748 #pragma GCC visibility push(default)
749 #endif
752 plugin_init (struct plugin_name_args *plugin_info,
753 struct plugin_gcc_version *)
755 generic_plugin_init (plugin_info, GCC_C_FE_VERSION_1);
757 register_callback (plugin_info->base_name, PLUGIN_PRAGMAS,
758 plugin_init_extra_pragmas, NULL);
759 register_callback (plugin_info->base_name, PLUGIN_PRE_GENERICIZE,
760 rewrite_decls_to_addresses, NULL);
762 #define GCC_METHOD0(R, N) \
764 cc1_plugin::callback_ftype *fun \
765 = cc1_plugin::invoker<R>::invoke<plugin_ ## N>; \
766 current_context->add_callback (# N, fun); \
768 #define GCC_METHOD1(R, N, A) \
770 cc1_plugin::callback_ftype *fun \
771 = cc1_plugin::invoker<R, A>::invoke<plugin_ ## N>; \
772 current_context->add_callback (# N, fun); \
774 #define GCC_METHOD2(R, N, A, B) \
776 cc1_plugin::callback_ftype *fun \
777 = cc1_plugin::invoker<R, A, B>::invoke<plugin_ ## N>; \
778 current_context->add_callback (# N, fun); \
780 #define GCC_METHOD3(R, N, A, B, C) \
782 cc1_plugin::callback_ftype *fun \
783 = cc1_plugin::invoker<R, A, B, C>::invoke<plugin_ ## N>; \
784 current_context->add_callback (# N, fun); \
786 #define GCC_METHOD4(R, N, A, B, C, D) \
788 cc1_plugin::callback_ftype *fun \
789 = cc1_plugin::invoker<R, A, B, C, \
790 D>::invoke<plugin_ ## N>; \
791 current_context->add_callback (# N, fun); \
793 #define GCC_METHOD5(R, N, A, B, C, D, E) \
795 cc1_plugin::callback_ftype *fun \
796 = cc1_plugin::invoker<R, A, B, C, D, \
797 E>::invoke<plugin_ ## N>; \
798 current_context->add_callback (# N, fun); \
800 #define GCC_METHOD7(R, N, A, B, C, D, E, F, G) \
802 cc1_plugin::callback_ftype *fun \
803 = cc1_plugin::invoker<R, A, B, C, D, \
804 E, F, G>::invoke<plugin_ ## N>; \
805 current_context->add_callback (# N, fun); \
808 #include "gcc-c-fe.def"
810 #undef GCC_METHOD0
811 #undef GCC_METHOD1
812 #undef GCC_METHOD2
813 #undef GCC_METHOD3
814 #undef GCC_METHOD4
815 #undef GCC_METHOD5
816 #undef GCC_METHOD7
818 return 0;