]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/compile/compile-cplus-types.c
Remove unused tui_win_element::highlight
[thirdparty/binutils-gdb.git] / gdb / compile / compile-cplus-types.c
CommitLineData
078a0207
KS
1/* Convert types from GDB to GCC
2
3 Copyright (C) 2014-2018 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
21#include "defs.h"
22#include "common/preprocessor.h"
23#include "gdbtypes.h"
24#include "compile-internal.h"
25#include "compile-cplus.h"
26#include "gdb_assert.h"
27#include "symtab.h"
28#include "source.h"
29#include "cp-support.h"
30#include "cp-abi.h"
31#include "symtab.h"
32#include "objfiles.h"
33#include "block.h"
34#include "gdbcmd.h"
35#include "c-lang.h"
36#include "compile-c.h" /* Included for c_get_range_decl_name
37 et al. */
38#include <algorithm>
39
40/* Default compile flags for C++. */
41
42const char *compile_cplus_instance::m_default_cflags = "-std=gnu++11";
43
44/* Flag to enable internal debugging. */
45
46static int debug_compile_cplus_types = 0;
47
48/* Flag to enable internal scope switching debugging. */
49
50static int debug_compile_cplus_scopes = 0;
51
52/* Forward declarations. */
53
54static gcc_type compile_cplus_convert_func (compile_cplus_instance *instance,
55 struct type *type,
56 bool strip_artificial);
57
58/* See description in compile-cplus.h. */
59
60gdb::unique_xmalloc_ptr<char>
61compile_cplus_instance::decl_name (const char *natural)
62{
63 if (natural == nullptr)
64 return nullptr;
65
66 char *name = cp_func_name (natural);
67 if (name != nullptr)
68 return gdb::unique_xmalloc_ptr<char> (name);
69
70 return gdb::unique_xmalloc_ptr<char> (xstrdup (natural));
71}
72
73/* Get the access flag for the NUM'th field of TYPE. */
74
75static enum gcc_cp_symbol_kind
76get_field_access_flag (const struct type *type, int num)
77{
78 if (TYPE_FIELD_PROTECTED (type, num))
79 return GCC_CP_ACCESS_PROTECTED;
80 else if (TYPE_FIELD_PRIVATE (type, num))
81 return GCC_CP_ACCESS_PRIVATE;
82
83 /* GDB assumes everything else is public. */
84 return GCC_CP_ACCESS_PUBLIC;
85}
86
87/* Get the access flag for the NUM'th method of TYPE's FNI'th
88 fieldlist. */
89
90enum gcc_cp_symbol_kind
91get_method_access_flag (const struct type *type, int fni, int num)
92{
93 gdb_assert (TYPE_CODE (type) == TYPE_CODE_STRUCT);
94
95 /* If this type was not declared a class, everything is public. */
96 if (!TYPE_DECLARED_CLASS (type))
97 return GCC_CP_ACCESS_PUBLIC;
98
99 /* Otherwise, read accessibility from the fn_field. */
100 const struct fn_field *methods = TYPE_FN_FIELDLIST1 (type, fni);
101 if (TYPE_FN_FIELD_PROTECTED (methods, num))
102 return GCC_CP_ACCESS_PROTECTED;
103 else if (TYPE_FN_FIELD_PRIVATE (methods, num))
104 return GCC_CP_ACCESS_PRIVATE;
105 else
106 return GCC_CP_ACCESS_PUBLIC;
107}
108
109/* A useful debugging function to output the scope SCOPE to stdout. */
110
111static void __attribute__ ((used))
112debug_print_scope (const compile_scope &scope)
113{
114 for (const auto &comp: scope)
115 {
116 const char *symbol = (comp.bsymbol.symbol != nullptr
117 ? SYMBOL_NATURAL_NAME (comp.bsymbol.symbol)
118 : "<none>");
119
120 printf_unfiltered ("\tname = %s, symbol = %s\n", comp.name.c_str (),
121 symbol);
122 }
123}
124
125/* See description in compile-cplus.h. */
126
127compile_scope
128type_name_to_scope (const char *type_name, const struct block *block)
129{
130 compile_scope scope;
131
132 if (type_name == nullptr)
133 {
134 /* An anonymous type. We cannot really do much here. We simply cannot
135 look up anonymous types easily/at all. */
136 return scope;
137 }
138
139 const char *p = type_name;
140 std::string lookup_name;
141
142 while (*p != '\0')
143 {
144 /* Create a string token of the first component of TYPE_NAME. */
145 int len = cp_find_first_component (p);
146 std::string s (p, len);
147
148 /* Advance past the last token. */
149 p += len;
150
151 /* Look up the symbol and decide when to stop. */
152 if (!lookup_name.empty ())
153 lookup_name += "::";
154 lookup_name += s;
155
156 /* Look up the resulting name. */
157 struct block_symbol bsymbol
158 = lookup_symbol (lookup_name.c_str (), block, VAR_DOMAIN, nullptr);
159
160 if (bsymbol.symbol != nullptr)
161 {
162 scope_component comp = {s, bsymbol};
163
164 scope.push_back (comp);
165
166 if (TYPE_CODE (SYMBOL_TYPE (bsymbol.symbol)) != TYPE_CODE_NAMESPACE)
167 {
168 /* We're done. */
169 break;
170 }
171 }
172
173 if (*p == ':')
174 {
175 ++p;
176 if (*p == ':')
177 ++p;
178 else
179 {
180 /* This shouldn't happen since we are not attempting to
181 loop over user input. This name is generated by GDB
182 from debug info. */
183 internal_error (__FILE__, __LINE__,
184 _("malformed TYPE_NAME during parsing"));
185 }
186 }
187 }
188
189 return scope;
190}
191
192/* Compare two scope_components for equality. These are equal if the names
193 of the two components' are the same. */
194
195bool
196operator== (const scope_component &lhs, const scope_component &rhs)
197{
198 return lhs.name == rhs.name;
199}
200
201/* Compare two scope_components for inequality. These are not equal if
202 the two components' names are not equal. */
203
204bool
205operator!= (const scope_component &lhs, const scope_component &rhs)
206{
207 return lhs.name != rhs.name;
208}
209
210/* Compare two compile_scopes for equality. These are equal if they are both
211 contain the same number of components and each component is equal. */
212
213bool
214operator== (const compile_scope &lhs, const compile_scope &rhs)
215{
216 if (lhs.size () != rhs.size ())
217 return false;
218
219 for (int i = 0; i < lhs.size (); ++i)
220 {
221 if (lhs[i] != rhs[i])
222 return false;
223 }
224
225 return true;
226}
227
228/* Compare two compile_scopes for inequality. These are inequal if they
229 contain unequal number of elements or if any of the components are not
230 the same. */
231
232bool
233operator!= (const compile_scope &lhs, const compile_scope &rhs)
234{
235 if (lhs.size () != rhs.size ())
236 return true;
237
238 for (int i = 0; i < lhs.size (); ++i)
239 {
240 if (lhs[i] != rhs[i])
241 return true;
242 }
243
244 return false;
245}
246
247/* See description in compile-cplus.h. */
248
249void
250compile_cplus_instance::enter_scope (compile_scope &new_scope)
251{
252 bool must_push = m_scopes.empty () || m_scopes.back () != new_scope;
253
254 new_scope.m_pushed = must_push;
255
256 /* Save the new scope. */
257 m_scopes.push_back (new_scope);
258
259 if (must_push)
260 {
261 if (debug_compile_cplus_scopes)
fdad7678
KS
262 {
263 fprintf_unfiltered (gdb_stdlog, "entering new scope %s\n",
264 host_address_to_string (&new_scope));
265 }
078a0207
KS
266
267 /* Push the global namespace. */
268 plugin ().push_namespace ("");
269
270 /* Push all other namespaces. Note that we do not push the last
271 scope_component -- that's the actual type we are converting. */
272 std::for_each
273 (new_scope.begin (), new_scope.end () - 1,
274 [this] (const scope_component &comp)
275 {
276 gdb_assert (TYPE_CODE (SYMBOL_TYPE (comp.bsymbol.symbol))
277 == TYPE_CODE_NAMESPACE);
278
279 const char *ns = (comp.name == CP_ANONYMOUS_NAMESPACE_STR ? nullptr
280 : comp.name.c_str ());
281
282 this->plugin ().push_namespace (ns);
283 });
284 }
285 else
286 {
287 if (debug_compile_cplus_scopes)
288 {
289 fprintf_unfiltered (gdb_stdlog, "staying in current scope -- "
290 "scopes are identical\n");
291 }
292 }
293}
294
295/* See description in compile-cplus.h. */
296
297void
298compile_cplus_instance::leave_scope ()
299{
300 /* Get the current scope and remove it from the internal list of
301 scopes. */
302 compile_scope current = m_scopes.back ();
303
304 m_scopes.pop_back ();
305
306 if (current.m_pushed)
307 {
308 if (debug_compile_cplus_scopes)
a0dc02a6
SM
309 {
310 fprintf_unfiltered (gdb_stdlog, "leaving scope %s\n",
311 host_address_to_string (&current));
312 }
078a0207
KS
313
314 /* Pop namespaces. */
315 std::for_each
316 (current.begin (),current.end () - 1,
317 [this] (const scope_component &comp) {
318 gdb_assert (TYPE_CODE (SYMBOL_TYPE (comp.bsymbol.symbol))
319 == TYPE_CODE_NAMESPACE);
320 this->plugin ().pop_binding_level (comp.name.c_str ());
321 });
322
323 /* Pop global namespace. */
324 plugin ().pop_binding_level ("");
325 }
326 else
327 {
328 if (debug_compile_cplus_scopes)
329 fprintf_unfiltered (gdb_stdlog,
330 "identical scopes -- not leaving scope\n");
331 }
332}
333
334/* See description in compile-cplus.h. */
335
336compile_scope
337compile_cplus_instance::new_scope (const char *type_name, struct type *type)
338{
339 /* Break the type name into components. If TYPE was defined in some
340 superclass, we do not process TYPE but process the enclosing type
341 instead. */
342 compile_scope scope = type_name_to_scope (type_name, block ());
343
344 if (!scope.empty ())
345 {
346 /* Get the name of the last component, which should be the
347 unqualified name of the type to process. */
348 scope_component &comp = scope.back ();
349
350 if (!types_equal (type, SYMBOL_TYPE (comp.bsymbol.symbol))
351 && (m_scopes.empty ()
352 || (m_scopes.back ().back ().bsymbol.symbol
353 != comp.bsymbol.symbol)))
354 {
355 /* The type is defined inside another class(es). Convert that
356 type instead of defining this type. */
357 convert_type (SYMBOL_TYPE (comp.bsymbol.symbol));
358
359 /* If the original type (passed in to us) is defined in a nested
360 class, the previous call will give us that type's gcc_type.
361 Upper layers are expecting to get the original type's
362 gcc_type! */
363 get_cached_type (type, scope.m_nested_type);
364 return scope;
365 }
366 }
367 else
368 {
369 if (TYPE_NAME (type) == nullptr)
370 {
371 /* Anonymous type */
372
373 /* We don't have a qualified name for this to look up, but
374 we need a scope. We have to assume, then, that it is the same
375 as the current scope, if any. */
376 if (!m_scopes.empty ())
377 {
378 scope = m_scopes.back ();
379 scope.m_pushed = false;
380 }
381 else
382 scope.push_back (scope_component ());
383 }
384 else
385 {
386 scope_component comp
387 = {
388 decl_name (TYPE_NAME (type)).get (),
389 lookup_symbol (TYPE_NAME (type), block (), VAR_DOMAIN, nullptr)
390 };
391 scope.push_back (comp);
392 }
393 }
394
395 /* There must be at least one component in the compile_scope. */
396 gdb_assert (scope.size () > 0);
397 return scope;
398}
399
400/* See description in compile-cplus.h. */
401
402gcc_type
403compile_cplus_instance::convert_reference_base
404 (gcc_type base, enum gcc_cp_ref_qualifiers rquals)
405{
406 return this->plugin ().build_reference_type (base, rquals);
407}
408
409/* Convert a reference type to its gcc representation. */
410
411static gcc_type
412compile_cplus_convert_reference (compile_cplus_instance *instance,
413 struct type *type)
414{
415 gcc_type target = instance->convert_type (TYPE_TARGET_TYPE (type));
416
417 enum gcc_cp_ref_qualifiers quals = GCC_CP_REF_QUAL_NONE;
418 switch (TYPE_CODE (type))
419 {
420 case TYPE_CODE_REF:
421 quals = GCC_CP_REF_QUAL_LVALUE;
422 break;
423 case TYPE_CODE_RVALUE_REF:
424 quals = GCC_CP_REF_QUAL_RVALUE;
425 break;
426 default:
427 gdb_assert_not_reached ("unexpected type code for reference type");
428 }
429
430 return instance->convert_reference_base (target, quals);
431}
432
433/* See description in compile-cplus.h. */
434
435gcc_type
436compile_cplus_instance::convert_pointer_base(gcc_type target)
437{
438 return plugin ().build_pointer_type (target);
439}
440
441/* Convert a pointer type to its gcc representation. */
442
443static gcc_type
444compile_cplus_convert_pointer (compile_cplus_instance *instance,
445 struct type *type)
446{
447 gcc_type target = instance->convert_type (TYPE_TARGET_TYPE (type));
448
449 return instance->convert_pointer_base (target);
450}
451
452/* Convert an array type to its gcc representation. */
453
454static gcc_type
455compile_cplus_convert_array (compile_cplus_instance *instance,
456 struct type *type)
457{
458 struct type *range = TYPE_INDEX_TYPE (type);
459 gcc_type element_type = instance->convert_type (TYPE_TARGET_TYPE (type));
460
461 if (TYPE_LOW_BOUND_KIND (range) != PROP_CONST)
462 {
463 const char *s = _("array type with non-constant"
464 " lower bound is not supported");
465
466 return instance->plugin ().error (s);
467 }
468
469 if (TYPE_LOW_BOUND (range) != 0)
470 {
471 const char *s = _("cannot convert array type with "
472 "non-zero lower bound to C");
473
474 return instance->plugin ().error (s);
475 }
476
477 if (TYPE_HIGH_BOUND_KIND (range) == PROP_LOCEXPR
478 || TYPE_HIGH_BOUND_KIND (range) == PROP_LOCLIST)
479 {
480 if (TYPE_VECTOR (type))
481 {
482 const char *s = _("variably-sized vector type is not supported");
483
484 return instance->plugin ().error (s);
485 }
486
487 std::string upper_bound
488 = c_get_range_decl_name (&TYPE_RANGE_DATA (range)->high);
489 return instance->plugin ().build_vla_array_type (element_type,
490 upper_bound.c_str ());
491 }
492 else
493 {
494 LONGEST low_bound, high_bound, count;
495
496 if (get_array_bounds (type, &low_bound, &high_bound) == 0)
497 count = -1;
498 else
499 {
500 gdb_assert (low_bound == 0); /* Ensured above. */
501 count = high_bound + 1;
502 }
503
504 if (TYPE_VECTOR (type))
505 return instance->plugin ().build_vector_type (element_type, count);
506
507 return instance->plugin ().build_array_type (element_type, count);
508 }
509}
510
511/* Convert a typedef of TYPE. If not GCC_CP_ACCESS_NONE, NESTED_ACCESS
512 will define the accessibility of the typedef definition in its
513 containing class. */
514
515static gcc_type
516compile_cplus_convert_typedef (compile_cplus_instance *instance,
517 struct type *type,
518 enum gcc_cp_symbol_kind nested_access)
519{
520 compile_scope scope = instance->new_scope (TYPE_NAME (type), type);
521
522 if (scope.nested_type () != GCC_TYPE_NONE)
523 return scope.nested_type ();
524
525 gdb::unique_xmalloc_ptr<char> name
526 = compile_cplus_instance::decl_name (TYPE_NAME (type));
527
528 /* Make sure the scope for this type has been pushed. */
529 instance->enter_scope (scope);
530
531 /* Convert the typedef's real type. */
532 gcc_type typedef_type = instance->convert_type (check_typedef (type));
533
534 instance->plugin ().build_decl ("typedef", name.get (),
535 GCC_CP_SYMBOL_TYPEDEF | nested_access,
536 typedef_type, 0, 0, nullptr, 0);
537
538 /* Completed this scope. */
539 instance->leave_scope ();
540 return typedef_type;
541}
542
543/* Convert types defined in TYPE. */
544
545static void
546compile_cplus_convert_type_defns (compile_cplus_instance *instance,
547 struct type *type)
548{
549 int i;
550 enum gcc_cp_symbol_kind accessibility;
551
552 /* Convert typedefs. */
553 for (i = 0; i < TYPE_TYPEDEF_FIELD_COUNT (type); ++i)
554 {
555 if (TYPE_TYPEDEF_FIELD_PROTECTED (type, i))
556 accessibility = GCC_CP_ACCESS_PROTECTED;
557 else if (TYPE_TYPEDEF_FIELD_PRIVATE (type, i))
558 accessibility = GCC_CP_ACCESS_PRIVATE;
559 else
560 accessibility = GCC_CP_ACCESS_PUBLIC;
561 instance->convert_type (TYPE_TYPEDEF_FIELD_TYPE (type, i), accessibility);
562 }
563
564 /* Convert nested types. */
565 for (i = 0; i < TYPE_NESTED_TYPES_COUNT (type); ++i)
566 {
567 if (TYPE_NESTED_TYPES_FIELD_PROTECTED (type, i))
568 accessibility = GCC_CP_ACCESS_PROTECTED;
569 else if (TYPE_NESTED_TYPES_FIELD_PRIVATE (type, i))
570 accessibility = GCC_CP_ACCESS_PRIVATE;
571 else
572 accessibility = GCC_CP_ACCESS_PUBLIC;
573 instance->convert_type (TYPE_NESTED_TYPES_FIELD_TYPE (type, i),
574 accessibility);
575 }
576}
577
578/* Convert data members defined in TYPE, which should be struct/class/union
579 with gcc_type COMP_TYPE. */
580
581static void
582compile_cplus_convert_struct_or_union_members
583 (compile_cplus_instance *instance, struct type *type, gcc_type comp_type)
584{
585 for (int i = TYPE_N_BASECLASSES (type); i < TYPE_NFIELDS (type); ++i)
586 {
587 const char *field_name = TYPE_FIELD_NAME (type, i);
588
589 if (TYPE_FIELD_IGNORE (type, i)
590 || TYPE_FIELD_ARTIFICIAL (type, i))
591 continue;
592
593 /* GDB records unnamed/anonymous fields with empty string names. */
594 if (*field_name == '\0')
595 field_name = nullptr;
596
597 gcc_type field_type
598 = instance->convert_type (TYPE_FIELD_TYPE (type, i));
599
600 if (field_is_static (&TYPE_FIELD (type, i)))
601 {
602 CORE_ADDR physaddr;
603
604 switch (TYPE_FIELD_LOC_KIND (type, i))
605 {
606 case FIELD_LOC_KIND_PHYSADDR:
607 {
608 physaddr = TYPE_FIELD_STATIC_PHYSADDR (type, i);
609
610 instance->plugin ().build_decl
611 ("field physaddr", field_name,
612 (GCC_CP_SYMBOL_VARIABLE | get_field_access_flag (type, i)),
613 field_type, nullptr, physaddr, nullptr, 0);
614 }
615 break;
616
617 case FIELD_LOC_KIND_PHYSNAME:
618 {
619 const char *physname = TYPE_FIELD_STATIC_PHYSNAME (type, i);
620 struct block_symbol sym
621 = lookup_symbol (physname, instance->block (),
622 VAR_DOMAIN, nullptr);
623
624 if (sym.symbol == nullptr)
625 {
626 /* We didn't actually find the symbol. There's little
627 we can do but ignore this member. */
628 continue;
629 }
630 const char *filename = symbol_symtab (sym.symbol)->filename;
631 unsigned int line = SYMBOL_LINE (sym.symbol);
632
633 physaddr = SYMBOL_VALUE_ADDRESS (sym.symbol);
634 instance->plugin ().build_decl
635 ("field physname", field_name,
636 (GCC_CP_SYMBOL_VARIABLE| get_field_access_flag (type, i)),
637 field_type, nullptr, physaddr, filename, line);
638 }
639 break;
640
641 default:
642 gdb_assert_not_reached
643 ("unexpected static field location kind");
644 }
645 }
646 else
647 {
648 unsigned long bitsize = TYPE_FIELD_BITSIZE (type, i);
649 enum gcc_cp_symbol_kind field_flags = GCC_CP_SYMBOL_FIELD
650 | get_field_access_flag (type, i);
651
652 if (bitsize == 0)
653 bitsize = 8 * TYPE_LENGTH (TYPE_FIELD_TYPE (type, i));
654
655 instance->plugin ().build_field
656 (field_name, field_type, field_flags, bitsize,
657 TYPE_FIELD_BITPOS (type, i));
658 }
659 }
660}
661
662/* Convert a method type to its gcc representation. */
663
664static gcc_type
665compile_cplus_convert_method (compile_cplus_instance *instance,
666 struct type *parent_type,
667 struct type *method_type)
668{
669 /* Get the actual function type of the method, the corresponding class's
670 type and corresponding qualifier flags. */
671 gcc_type func_type = compile_cplus_convert_func (instance, method_type, true);
672 gcc_type class_type = instance->convert_type (parent_type);
673 gcc_cp_qualifiers_flags quals = (enum gcc_cp_qualifiers) 0;
674
675 if (TYPE_CONST (method_type))
676 quals |= GCC_CP_QUALIFIER_CONST;
677 if (TYPE_VOLATILE (method_type))
678 quals |= GCC_CP_QUALIFIER_VOLATILE;
679 if (TYPE_RESTRICT (method_type))
680 quals |= GCC_CP_QUALIFIER_RESTRICT;
681
682 /* Not yet implemented. */
683 gcc_cp_ref_qualifiers_flags rquals = GCC_CP_REF_QUAL_NONE;
684
685 return instance->plugin ().build_method_type
686 (class_type, func_type, quals, rquals);
687}
688
689/* Convert a member or method pointer represented by TYPE. */
690
691static gcc_type
692compile_cplus_convert_memberptr (compile_cplus_instance *instance,
693 struct type *type)
694{
695 struct type *containing_class = TYPE_SELF_TYPE (type);
696
697 if (containing_class == nullptr)
698 return GCC_TYPE_NONE;
699
700 gcc_type class_type = instance->convert_type (containing_class);
701 gcc_type member_type
702 = instance->convert_type (TYPE_TARGET_TYPE (type));
703
704 return instance->plugin ().build_pointer_to_member_type
705 (class_type, member_type);
706}
707
708/* Convert all methods defined in TYPE, which should be a class/struct/union
709 with gcc_type CLASS_TYPE. */
710
711static void
712compile_cplus_convert_struct_or_union_methods (compile_cplus_instance *instance,
713 struct type *type,
714 gcc_type class_type)
715{
716 for (int i = 0; i < TYPE_NFN_FIELDS (type); ++i)
717 {
718 struct fn_field *methods = TYPE_FN_FIELDLIST1 (type, i);
719 gdb::unique_xmalloc_ptr<char> overloaded_name
720 = compile_cplus_instance::decl_name (TYPE_FN_FIELDLIST_NAME (type, i));
721
722 /* Loop through the fieldlist, adding decls to the compiler's
723 representation of the class. */
724 for (int j = 0; j < TYPE_FN_FIELDLIST_LENGTH (type, i); ++j)
725 {
726 /* Skip artificial methods. */
727 if (TYPE_FN_FIELD_ARTIFICIAL (methods, j))
728 continue;
729
730 gcc_cp_symbol_kind_flags sym_kind = GCC_CP_SYMBOL_FUNCTION;
731 gcc_type method_type;
732 struct block_symbol sym
733 = lookup_symbol (TYPE_FN_FIELD_PHYSNAME (methods, j),
734 instance->block (), VAR_DOMAIN, nullptr);
735
736 if (sym.symbol == nullptr)
737 {
738 if (TYPE_FN_FIELD_VIRTUAL_P (methods, j))
739 {
740 /* This is beyond hacky, and is really only a workaround for
741 detecting pure virtual methods. */
742 method_type = compile_cplus_convert_method
743 (instance, type, TYPE_FN_FIELD_TYPE (methods, j));
744
745 instance->plugin ().build_decl
746 ("pure virtual method", overloaded_name.get (),
747 (sym_kind
748 | get_method_access_flag (type, i, j)
749 | GCC_CP_FLAG_VIRTUAL_FUNCTION
750 | GCC_CP_FLAG_PURE_VIRTUAL_FUNCTION),
751 method_type, nullptr, 0, nullptr, 0);
752 continue;
753 }
754
755 /* This can happen if we have a DW_AT_declaration DIE
756 for the method, but no "definition"-type DIE (with
757 DW_AT_specification referencing the decl DIE), i.e.,
758 the compiler has probably optimized the method away.
759
760 In this case, all we can hope to do is issue a warning
761 to the user letting him know. If the user has not actually
762 requested using this method, things should still work. */
763 warning (_("Method %s appears to be optimized out.\n"
764 "All references to this method will be undefined."),
765 TYPE_FN_FIELD_PHYSNAME (methods, j));
766 continue;
767 }
768
769 const char *filename = symbol_symtab (sym.symbol)->filename;
770 unsigned int line = SYMBOL_LINE (sym.symbol);
771 CORE_ADDR address = BLOCK_START (SYMBOL_BLOCK_VALUE (sym.symbol));
772 const char *kind;
773
774 if (TYPE_FN_FIELD_STATIC_P (methods, j))
775 {
776 kind = "static method";
777 method_type = compile_cplus_convert_func
778 (instance, TYPE_FN_FIELD_TYPE (methods, j), true);
779 }
780 else
781 {
782 kind = "method";
783 method_type = (compile_cplus_convert_method
784 (instance, type, TYPE_FN_FIELD_TYPE (methods, j)));
785 }
786
787 if (TYPE_FN_FIELD_VIRTUAL_P (methods, j))
788 sym_kind |= GCC_CP_FLAG_VIRTUAL_FUNCTION;
789
790 instance->plugin ().build_decl
791 (kind, overloaded_name.get (),
792 sym_kind | get_method_access_flag (type, i, j),
793 method_type, nullptr, address, filename, line);
794 }
795 }
796}
797
798/* Convert a struct or union type to its gcc representation. If this type
799 was defined in another type, NESTED_ACCESS should indicate the
800 accessibility of this type. */
801
802static gcc_type
803compile_cplus_convert_struct_or_union (compile_cplus_instance *instance,
804 struct type *type,
805 enum gcc_cp_symbol_kind nested_access)
806{
807 const char *filename = nullptr;
808 unsigned short line = 0;
809
810 /* Get the decl name of this type. */
811 gdb::unique_xmalloc_ptr<char> name
812 = compile_cplus_instance::decl_name (TYPE_NAME (type));
813
814 /* Create a new scope for TYPE. */
815 compile_scope scope = instance->new_scope (TYPE_NAME (type), type);
816
817 if (scope.nested_type () != GCC_TYPE_NONE)
818 {
819 /* The type requested was actually defined inside another type,
820 such as a nested class definition. Return that type. */
821 return scope.nested_type ();
822 }
823
824 /* Push all scopes. */
825 instance->enter_scope (scope);
826
827 /* First we create the resulting type and enter it into our hash
828 table. This lets recursive types work. */
829
830 gcc_decl resuld;
831 if (TYPE_CODE (type) == TYPE_CODE_STRUCT)
832 {
833 const char *what = TYPE_DECLARED_CLASS (type) ? "struct" : "class";
834
835 resuld = instance->plugin ().build_decl
836 (what, name.get (), (GCC_CP_SYMBOL_CLASS | nested_access
837 | (TYPE_DECLARED_CLASS (type)
838 ? GCC_CP_FLAG_CLASS_NOFLAG
839 : GCC_CP_FLAG_CLASS_IS_STRUCT)),
840 0, nullptr, 0, filename, line);
841 }
842 else
843 {
844 gdb_assert (TYPE_CODE (type) == TYPE_CODE_UNION);
845 resuld = instance->plugin ().build_decl
846 ("union", name.get (), GCC_CP_SYMBOL_UNION | nested_access,
847 0, nullptr, 0, filename, line);
848 }
849
850 gcc_type result;
851 if (TYPE_CODE (type) == TYPE_CODE_STRUCT)
852 {
853 struct gcc_vbase_array bases;
854 int num_baseclasses = TYPE_N_BASECLASSES (type);
855
856 memset (&bases, 0, sizeof (bases));
857
858 if (num_baseclasses > 0)
859 {
860 bases.elements = XNEWVEC (gcc_type, num_baseclasses);
861 bases.flags = XNEWVEC (enum gcc_cp_symbol_kind, num_baseclasses);
862 bases.n_elements = num_baseclasses;
863 for (int i = 0; i < num_baseclasses; ++i)
864 {
865 struct type *base_type = TYPE_BASECLASS (type, i);
866
867 bases.flags[i] = GCC_CP_SYMBOL_BASECLASS
868 | get_field_access_flag (type, i)
869 | (BASETYPE_VIA_VIRTUAL (type, i)
870 ? GCC_CP_FLAG_BASECLASS_VIRTUAL
871 : GCC_CP_FLAG_BASECLASS_NOFLAG);
872 bases.elements[i] = instance->convert_type (base_type);
873 }
874 }
875
876 result = instance->plugin ().start_class_type
877 (name.get (), resuld, &bases, filename, line);
878 xfree (bases.flags);
879 xfree (bases.elements);
880 }
881 else
882 {
883 gdb_assert (TYPE_CODE (type) == TYPE_CODE_UNION);
884 result = instance->plugin ().start_class_type
885 (name.get (), resuld, nullptr, filename, line);
886 }
887
888 instance->insert_type (type, result);
889
890 /* Add definitions. */
891 compile_cplus_convert_type_defns (instance, type);
892
893 /* Add methods. */
894 compile_cplus_convert_struct_or_union_methods (instance, type, result);
895
896 /* Add members. */
897 compile_cplus_convert_struct_or_union_members (instance, type, result);
898
899 /* All finished. */
900 instance->plugin ().finish_class_type (name.get (), TYPE_LENGTH (type));
901
902 /* Pop all scopes. */
903 instance->leave_scope ();
904 return result;
905}
906
907/* Convert an enum type to its gcc representation. If this type
908 was defined in another type, NESTED_ACCESS should indicate the
909 accessibility of this type.*/
910
911static gcc_type
912compile_cplus_convert_enum (compile_cplus_instance *instance, struct type *type,
913 enum gcc_cp_symbol_kind nested_access)
914{
915 int scoped_enum_p = FALSE;
916
917 /* Create a new scope for this type. */
918 compile_scope scope = instance->new_scope (TYPE_NAME (type), type);
919
920 if (scope.nested_type () != GCC_TYPE_NONE)
921 {
922 /* The type requested was actually defined inside another type,
923 such as a nested class definition. Return that type. */
924 return scope.nested_type ();
925 }
926
927 gdb::unique_xmalloc_ptr<char> name
928 = compile_cplus_instance::decl_name (TYPE_NAME (type));
929
930 /* Push all scopes. */
931 instance->enter_scope (scope);
932
933 gcc_type int_type
934 = instance->plugin ().get_int_type (TYPE_UNSIGNED (type),
935 TYPE_LENGTH (type), nullptr);
936 gcc_type result
937 = instance->plugin ().start_enum_type (name.get (), int_type,
938 GCC_CP_SYMBOL_ENUM | nested_access
939 | (scoped_enum_p
940 ? GCC_CP_FLAG_ENUM_SCOPED
941 : GCC_CP_FLAG_ENUM_NOFLAG),
942 nullptr, 0);
943 for (int i = 0; i < TYPE_NFIELDS (type); ++i)
944 {
945 gdb::unique_xmalloc_ptr<char> fname
946 = compile_cplus_instance::decl_name (TYPE_FIELD_NAME (type, i));
947
948 if (TYPE_FIELD_LOC_KIND (type, i) != FIELD_LOC_KIND_ENUMVAL
949 || fname == nullptr)
950 continue;
951
952 instance->plugin ().build_enum_constant (result, fname.get (),
953 TYPE_FIELD_ENUMVAL (type, i));
954 }
955
956 /* Finish enum definition and pop scopes. */
957 instance->plugin ().finish_enum_type (result);
958 instance->leave_scope ();
959 return result;
960}
961
962/* Convert a function type to its gcc representation. This function does
963 not deal with function templates. */
964
965static gcc_type
966compile_cplus_convert_func (compile_cplus_instance *instance,
967 struct type *type, bool strip_artificial)
968{
969 int is_varargs = TYPE_VARARGS (type);
970 struct type *target_type = TYPE_TARGET_TYPE (type);
971
972 /* Functions with no debug info have no return type. Ideally we'd
973 want to fallback to the type of the cast just before the
974 function, like GDB's built-in expression parser, but we don't
975 have access to that type here. For now, fallback to int, like
976 GDB's parser used to do. */
977 if (target_type == nullptr)
978 {
979 if (TYPE_OBJFILE_OWNED (type))
980 target_type = objfile_type (TYPE_OWNER (type).objfile)->builtin_int;
981 else
982 target_type = builtin_type (TYPE_OWNER (type).gdbarch)->builtin_int;
983 warning (_("function has unknown return type; assuming int"));
984 }
985
986 /* This approach means we can't make self-referential function
987 types. Those are impossible in C, though. */
988 gcc_type return_type = instance->convert_type (target_type);
989
990 struct gcc_type_array array =
991 { TYPE_NFIELDS (type), XNEWVEC (gcc_type, TYPE_NFIELDS (type)) };
992 int artificials = 0;
993 for (int i = 0; i < TYPE_NFIELDS (type); ++i)
994 {
995 if (strip_artificial && TYPE_FIELD_ARTIFICIAL (type, i))
996 {
997 --array.n_elements;
998 ++artificials;
999 }
1000 else
1001 {
1002 array.elements[i - artificials]
1003 = instance->convert_type (TYPE_FIELD_TYPE (type, i));
1004 }
1005 }
1006
1007 /* We omit setting the argument types to `void' to be a little flexible
1008 with some minsyms like printf (compile-cplus.exp has examples). */
1009 gcc_type result = instance->plugin ().build_function_type
1010 (return_type, &array, is_varargs);
1011 xfree (array.elements);
1012 return result;
1013}
1014
1015/* Convert an integer type to its gcc representation. */
1016
1017static gcc_type
1018compile_cplus_convert_int (compile_cplus_instance *instance, struct type *type)
1019{
1020 if (TYPE_NOSIGN (type))
1021 {
1022 gdb_assert (TYPE_LENGTH (type) == 1);
1023 return instance->plugin ().get_char_type ();
1024 }
1025
1026 return instance->plugin ().get_int_type
1027 (TYPE_UNSIGNED (type), TYPE_LENGTH (type), TYPE_NAME (type));
1028}
1029
1030/* Convert a floating-point type to its gcc representation. */
1031
1032static gcc_type
1033compile_cplus_convert_float (compile_cplus_instance *instance,
1034 struct type *type)
1035{
1036 return instance->plugin ().get_float_type
1037 (TYPE_LENGTH (type), TYPE_NAME (type));
1038}
1039
1040/* Convert the 'void' type to its gcc representation. */
1041
1042static gcc_type
1043compile_cplus_convert_void (compile_cplus_instance *instance, struct type *type)
1044{
1045 return instance->plugin ().get_void_type ();
1046}
1047
1048/* Convert a boolean type to its gcc representation. */
1049
1050static gcc_type
1051compile_cplus_convert_bool (compile_cplus_instance *instance, struct type *type)
1052{
1053 return instance->plugin ().get_bool_type ();
1054}
1055
1056/* See description in compile-cplus.h. */
1057
1058gcc_type
1059compile_cplus_instance::convert_qualified_base (gcc_type base,
1060 gcc_cp_qualifiers_flags quals)
1061{
1062 gcc_type result = base;
1063
a0dc02a6 1064 if (quals != 0)
078a0207
KS
1065 result = plugin ().build_qualified_type (base, quals);
1066
1067 return result;
1068}
1069
1070/* See description in compile-cplus.h. */
1071
1072static gcc_type
1073compile_cplus_convert_qualified (compile_cplus_instance *instance,
1074 struct type *type)
1075{
1076 struct type *unqual = make_unqualified_type (type);
1077 gcc_cp_qualifiers_flags quals = (enum gcc_cp_qualifiers) 0;
1078 gcc_type unqual_converted = instance->convert_type (unqual);
1079
1080 if (TYPE_CONST (type))
1081 quals |= GCC_CP_QUALIFIER_CONST;
1082 if (TYPE_VOLATILE (type))
1083 quals |= GCC_CP_QUALIFIER_VOLATILE;
1084 if (TYPE_RESTRICT (type))
1085 quals |= GCC_CP_QUALIFIER_RESTRICT;
1086
1087 return instance->convert_qualified_base (unqual_converted, quals);
1088}
1089
1090/* Convert a complex type to its gcc representation. */
1091
1092static gcc_type
1093compile_cplus_convert_complex (compile_cplus_instance *instance,
1094 struct type *type)
1095{
1096 gcc_type base = instance->convert_type (TYPE_TARGET_TYPE (type));
1097
1098 return instance->plugin ().build_complex_type (base);
1099}
1100
1101/* Convert a namespace of TYPE. */
1102
1103static gcc_type
1104compile_cplus_convert_namespace (compile_cplus_instance *instance,
1105 struct type *type)
1106{
1107 compile_scope scope = instance->new_scope (TYPE_NAME (type), type);
1108 gdb::unique_xmalloc_ptr<char> name
1109 = compile_cplus_instance::decl_name (TYPE_NAME (type));
1110
1111 /* Push scope. */
1112 instance->enter_scope (scope);
1113
1114 /* Convert this namespace. */
1115 instance->plugin ().push_namespace (name.get ());
1116 instance->plugin ().pop_binding_level (name.get ());
1117
1118 /* Pop scope. */
1119 instance->leave_scope ();
1120
1121 /* Namespaces are non-cacheable types. */
1122 return GCC_TYPE_NONE;
1123}
1124
1125/* A helper function which knows how to convert most types from their
1126 gdb representation to the corresponding gcc form. This examines
1127 the TYPE and dispatches to the appropriate conversion function. It
1128 returns the gcc type.
1129
1130 If the type was defined in another type, NESTED_ACCESS should indicate the
1131 accessibility of this type. */
1132
1133static gcc_type
1134convert_type_cplus_basic (compile_cplus_instance *instance,
1135 struct type *type,
1136 enum gcc_cp_symbol_kind nested_access)
1137{
1138 /* If we are converting a qualified type, first convert the
1139 unqualified type and then apply the qualifiers. */
1140 if ((TYPE_INSTANCE_FLAGS (type) & (TYPE_INSTANCE_FLAG_CONST
1141 | TYPE_INSTANCE_FLAG_VOLATILE
1142 | TYPE_INSTANCE_FLAG_RESTRICT)) != 0)
1143 return compile_cplus_convert_qualified (instance, type);
1144
1145 switch (TYPE_CODE (type))
1146 {
1147 case TYPE_CODE_REF:
1148 case TYPE_CODE_RVALUE_REF:
1149 return compile_cplus_convert_reference (instance, type);
1150
1151 case TYPE_CODE_PTR:
1152 return compile_cplus_convert_pointer (instance, type);
1153
1154 case TYPE_CODE_ARRAY:
1155 return compile_cplus_convert_array (instance, type);
1156
1157 case TYPE_CODE_STRUCT:
1158 case TYPE_CODE_UNION:
1159 return
1160 compile_cplus_convert_struct_or_union (instance, type, nested_access);
1161
1162 case TYPE_CODE_ENUM:
1163 return compile_cplus_convert_enum (instance, type, nested_access);
1164
1165 case TYPE_CODE_FUNC:
1166 return compile_cplus_convert_func (instance, type, false);
1167
1168 case TYPE_CODE_METHOD:
1169 return
1170 compile_cplus_convert_method (instance, TYPE_SELF_TYPE (type), type);
1171
1172 case TYPE_CODE_MEMBERPTR:
1173 case TYPE_CODE_METHODPTR:
1174 return compile_cplus_convert_memberptr (instance, type);
1175 break;
1176
1177 case TYPE_CODE_INT:
1178 return compile_cplus_convert_int (instance, type);
1179
1180 case TYPE_CODE_FLT:
1181 return compile_cplus_convert_float (instance, type);
1182
1183 case TYPE_CODE_VOID:
1184 return compile_cplus_convert_void (instance, type);
1185
1186 case TYPE_CODE_BOOL:
1187 return compile_cplus_convert_bool (instance, type);
1188
1189 case TYPE_CODE_COMPLEX:
1190 return compile_cplus_convert_complex (instance, type);
1191
1192 case TYPE_CODE_NAMESPACE:
1193 return compile_cplus_convert_namespace (instance, type);
1194
1195 case TYPE_CODE_TYPEDEF:
1196 return compile_cplus_convert_typedef (instance, type, nested_access);
1197
1198 default:
1199 break;
1200 }
1201
1202 std::string s = string_printf (_("unhandled TYPE_CODE %d"),
1203 TYPE_CODE (type));
1204
1205 return instance->plugin ().error (s.c_str ());
1206}
1207
1208gcc_type
1209compile_cplus_instance::convert_type (struct type *type,
1210 enum gcc_cp_symbol_kind nested_access)
1211{
1212 /* Check if TYPE has already been converted. */
1213 gcc_type result;
1214 if (get_cached_type (type, result))
1215 return result;
1216
1217 /* It is the first time this type has been seen -- convert it
1218 and cache it, if appropriate.. */
1219 result = convert_type_cplus_basic (this, type, nested_access);
1220 if (result != GCC_TYPE_NONE)
1221 insert_type (type, result);
1222 return result;
1223}
1224
1225void
1226compile_cplus_instance::gcc_cplus_enter_scope
1227 (void *datum, struct gcc_cp_context *gcc_context)
1228{
1229}
1230
1231void
1232compile_cplus_instance::gcc_cplus_leave_scope
1233 (void *datum, struct gcc_cp_context *gcc_context)
1234{
1235}
1236
1237\f
1238
1239/* Plug-in forwards. */
1240
1241/* C++ plug-in wrapper. */
1242
1243/* A result printer for plug-in calls that return a gcc_type or
1244 gcc_decl. */
1245
1246static void
5c889512 1247compile_cplus_debug_output_1 (ULONGEST arg)
078a0207 1248{
5c889512 1249 fprintf_unfiltered (gdb_stdlog, "%s", pulongest (arg));
078a0207
KS
1250}
1251
1252static void
1253compile_cplus_debug_output_1 (const char *arg)
1254{
1255 if (arg == nullptr)
1256 fputs_unfiltered ("NULL", gdb_stdlog);
1257 else
1258 fputs_unfiltered (arg, gdb_stdlog);
1259}
1260
1261static void
1262compile_cplus_debug_output ()
1263{
1264}
1265
1266template <typename T>
1267static void
1268compile_cplus_debug_output_1 (const T *arg)
1269{
1270}
1271
1272template <typename T, typename... Targs>
1273static void
1274compile_cplus_debug_output (T arg, Targs... Args)
1275{
1276 compile_cplus_debug_output_1 (arg);
1277 fputc_unfiltered (' ', gdb_stdlog);
1278 compile_cplus_debug_output (Args...);
1279}
1280
1281#define FORWARD(OP,...) m_context->cp_ops->OP(m_context, ##__VA_ARGS__)
1282#define OUTPUT_DEBUG_RESULT(R) \
1283 if (debug_compile_cplus_types) \
1284 { \
1285 fputs_unfiltered (": ", gdb_stdlog); \
1286 compile_cplus_debug_output (R); \
1287 fputc_unfiltered ('\n', gdb_stdlog); \
1288 } \
1289
1290#define GCC_METHOD0(R, N) \
1291 R gcc_cp_plugin::N () const \
1292 { \
1293 if (debug_compile_cplus_types) \
1294 compile_cplus_debug_output (STRINGIFY (N)); \
1295 auto result = FORWARD (N); \
1296 OUTPUT_DEBUG_RESULT (result); \
1297 return result; \
1298 }
1299#define GCC_METHOD1(R, N, A) \
1300 R gcc_cp_plugin::N (A a) const \
1301 { \
1302 if (debug_compile_cplus_types) \
1303 compile_cplus_debug_output (STRINGIFY (N), a); \
1304 auto result = FORWARD (N, a); \
1305 OUTPUT_DEBUG_RESULT (result); \
1306 return result; \
1307 }
1308#define GCC_METHOD2(R, N, A, B) \
1309 R gcc_cp_plugin::N (A a, B b) const \
1310 { \
1311 if (debug_compile_cplus_types) \
1312 compile_cplus_debug_output (STRINGIFY (N), a, b); \
1313 auto result = FORWARD (N, a, b); \
1314 OUTPUT_DEBUG_RESULT (result); \
1315 return result; \
1316 }
1317#define GCC_METHOD3(R, N, A, B, C) \
1318 R gcc_cp_plugin::N (A a, B b, C c) const \
1319 { \
1320 if (debug_compile_cplus_types) \
1321 compile_cplus_debug_output (STRINGIFY (N), a, b, c); \
1322 auto result = FORWARD (N, a, b, c); \
1323 OUTPUT_DEBUG_RESULT (result); \
1324 return result; \
1325 }
1326#define GCC_METHOD4(R, N, A, B, C, D) \
1327 R gcc_cp_plugin::N (A a, B b, C c, D d) const \
1328 { \
1329 if (debug_compile_cplus_types) \
1330 compile_cplus_debug_output (STRINGIFY (N), a, b, c, d); \
1331 auto result = FORWARD (N, a, b, c, d); \
1332 OUTPUT_DEBUG_RESULT (result); \
1333 return result; \
1334 }
1335#define GCC_METHOD5(R, N, A, B, C, D, E) \
1336 R gcc_cp_plugin::N (A a, B b, C c, D d, E e) const \
1337 { \
1338 if (debug_compile_cplus_types) \
1339 compile_cplus_debug_output (STRINGIFY (N), a, b, c, d, e); \
1340 auto result = FORWARD (N, a, b, c, d, e); \
1341 OUTPUT_DEBUG_RESULT (result); \
1342 return result; \
1343 }
1344#define GCC_METHOD7(R, N, A, B, C, D, E, F, G) \
1345 R gcc_cp_plugin::N (A a, B b, C c, D d, E e, F f, G g) const \
1346 { \
1347 if (debug_compile_cplus_types) \
1348 compile_cplus_debug_output (STRINGIFY (N), a, b, c, d, e, f, g); \
1349 auto result = FORWARD (N, a, b, c, d, e, f, g); \
1350 OUTPUT_DEBUG_RESULT (result); \
1351 return result; \
1352 }
1353
1354#include "gcc-cp-fe.def"
1355
1356#undef GCC_METHOD0
1357#undef GCC_METHOD1
1358#undef GCC_METHOD2
1359#undef GCC_METHOD3
1360#undef GCC_METHOD4
1361#undef GCC_METHOD5
1362#undef GCC_METHOD7
1363#undef FORWARD
1364#undef OUTPUT_DEBUG_RESULT
1365
1366gcc_expr
1367gcc_cp_plugin::build_decl (const char *debug_decltype, const char *name,
1368 enum gcc_cp_symbol_kind sym_kind, gcc_type sym_type,
1369 const char *substitution_name, gcc_address address,
1370 const char *filename, unsigned int line_number)
1371{
1372 if (debug_compile_cplus_types)
1373 fprintf_unfiltered (gdb_stdlog, "<%s> ", debug_decltype);
1374
1375 return build_decl (name, sym_kind, sym_type, substitution_name,
1376 address, filename, line_number);
1377}
1378
1379gcc_type
1380gcc_cp_plugin::start_class_type (const char *debug_name, gcc_decl typedecl,
1381 const struct gcc_vbase_array *base_classes,
1382 const char *filename, unsigned int line_number)
1383{
1384 if (debug_compile_cplus_types)
1385 fprintf_unfiltered (gdb_stdlog, "<%s> ", debug_name);
1386
1387 return start_class_type (typedecl, base_classes, filename, line_number);
1388}
1389
1390int
1391gcc_cp_plugin::finish_class_type (const char *debug_name,
1392 unsigned long size_in_bytes)
1393{
1394 if (debug_compile_cplus_types)
1395 fprintf_unfiltered (gdb_stdlog, "<%s> ", debug_name);
1396
1397 return finish_class_type (size_in_bytes);
1398}
1399
1400int
1401gcc_cp_plugin::pop_binding_level (const char *debug_name)
1402{
1403 if (debug_compile_cplus_types)
1404 fprintf_unfiltered (gdb_stdlog, "<%s> ", debug_name);
1405
1406 return pop_binding_level ();
1407}
1408
1409void
1410_initialize_compile_cplus_types ()
1411{
1412 add_setshow_boolean_cmd ("compile-cplus-types", no_class,
1413 &debug_compile_cplus_types, _("\
1414Set debugging of C++ compile type conversion."), _("\
1415Show debugging of C++ compile type conversion."), _("\
1416When enabled debugging messages are printed during C++ type conversion for\n\
1417the compile commands."),
1418 nullptr,
1419 nullptr,
1420 &setdebuglist,
1421 &showdebuglist);
1422
1423 add_setshow_boolean_cmd ("compile-cplus-scopes", no_class,
1424 &debug_compile_cplus_scopes, _("\
1425Set debugging of C++ compile scopes."), _("\
1426Show debugging of C++ compile scopes."), _("\
1427When enabled debugging messages are printed about definition scopes during\n\
1428C++ type conversion for the compile commands."),
1429 nullptr,
1430 nullptr,
1431 &setdebuglist,
1432 &showdebuglist);
1433}