xref: /netbsd-src/external/gpl3/gdb.old/dist/gdb/compile/gcc-cp-plugin.h (revision 6881a4007f077b54e5f51159c52b9b25f57deb0d)
1 /* GCC C++ plug-in wrapper for GDB.
2 
3    Copyright (C) 2018-2023 Free Software Foundation, Inc.
4 
5    This file is part of GDB.
6 
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 3 of the License, or
10    (at your option) any later version.
11 
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16 
17    You should have received a copy of the GNU General Public License
18    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
19 
20 #ifndef COMPILE_GCC_CP_PLUGIN_H
21 #define COMPILE_GCC_CP_PLUGIN_H
22 
23 /* A class representing the GCC C++ plug-in.  */
24 
25 #include "gcc-cp-interface.h"
26 
27 class gcc_cp_plugin
28 {
29 public:
30 
31   explicit gcc_cp_plugin (struct gcc_cp_context *gcc_cp)
32     : m_context (gcc_cp)
33   {
34   }
35 
36   /* Set the oracle callbacks to be used by the compiler plug-in.  */
37   void set_callbacks (gcc_cp_oracle_function *binding_oracle,
38 		      gcc_cp_symbol_address_function *address_oracle,
39 		      gcc_cp_enter_leave_user_expr_scope_function *enter_scope,
40 		      gcc_cp_enter_leave_user_expr_scope_function *leave_scope,
41 		      void *datum)
42   {
43     m_context->cp_ops->set_callbacks (m_context, binding_oracle,
44 				      address_oracle, enter_scope, leave_scope,
45 				      datum);
46   }
47 
48   /* Returns the interface version of the compiler plug-in.  */
49   int version () const { return m_context->cp_ops->cp_version; }
50 
51 #define GCC_METHOD0(R, N) R N () const;
52 #define GCC_METHOD1(R, N, A) R N (A) const;
53 #define GCC_METHOD2(R, N, A, B) R N (A, B) const;
54 #define GCC_METHOD3(R, N, A, B, C) R N (A, B, C) const;
55 #define GCC_METHOD4(R, N, A, B, C, D) R N (A, B, C, D) const;
56 #define GCC_METHOD5(R, N, A, B, C, D, E) R N (A, B, C, D, E) const;
57 #define GCC_METHOD7(R, N, A, B, C, D, E, F, G) R N (A, B, C, D, E, F, G) const;
58 
59 #include "gcc-cp-fe.def"
60 
61 #undef GCC_METHOD0
62 #undef GCC_METHOD1
63 #undef GCC_METHOD2
64 #undef GCC_METHOD3
65 #undef GCC_METHOD4
66 #undef GCC_METHOD5
67 #undef GCC_METHOD7
68 
69   /* Special overloads of plug-in methods with added debugging information.  */
70 
71   gcc_expr build_decl (const char *debug_decltype, const char *name,
72 		       enum gcc_cp_symbol_kind sym_kind, gcc_type sym_type,
73 		       const char *substitution_name, gcc_address address,
74 		       const char *filename, unsigned int line_number);
75 
76   gcc_type start_class_type (const char *debug_name, gcc_decl typedecl,
77 			     const struct gcc_vbase_array *base_classes,
78 			     const char *filename, unsigned int line_number);
79 
80   int finish_class_type (const char *debug_name, unsigned long size_in_bytes);
81 
82   int pop_binding_level (const char *debug_name);
83 
84 private:
85 
86   /* The GCC C++ context.  */
87   struct gcc_cp_context *m_context;
88 };
89 
90 #endif /* COMPILE_GCC_CP_PLUGIN_H */
91