]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/gdbtypes.h
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / gdbtypes.h
CommitLineData
80180f79 1
c906108c 2/* Internal type definitions for GDB.
1bac305b 3
1d506c26 4 Copyright (C) 1992-2024 Free Software Foundation, Inc.
1bac305b 5
c906108c
SS
6 Contributed by Cygnus Support, using pieces from other GDB modules.
7
c5aa993b 8 This file is part of GDB.
c906108c 9
c5aa993b
JM
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
a9762ec7 12 the Free Software Foundation; either version 3 of the License, or
c5aa993b 13 (at your option) any later version.
c906108c 14
c5aa993b
JM
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
c906108c 19
c5aa993b 20 You should have received a copy of the GNU General Public License
a9762ec7 21 along with this program. If not, see <http://www.gnu.org/licenses/>. */
c906108c
SS
22
23#if !defined (GDBTYPES_H)
24#define GDBTYPES_H 1
25
5e3a2c38
SS
26/* * \page gdbtypes GDB Types
27
28 GDB represents all the different kinds of types in programming
29 languages using a common representation defined in gdbtypes.h.
30
31 The main data structure is main_type; it consists of a code (such
71e50e83 32 as #TYPE_CODE_ENUM for enumeration types), a number of
5e3a2c38 33 generally-useful fields such as the printable name, and finally a
71e50e83
YQ
34 field main_type::type_specific that is a union of info specific to
35 particular languages or other special cases (such as calling
36 convention).
5e3a2c38 37
71e50e83 38 The available type codes are defined in enum #type_code. The enum
5e3a2c38
SS
39 includes codes both for types that are common across a variety
40 of languages, and for types that are language-specific.
41
71e50e83
YQ
42 Most accesses to type fields go through macros such as
43 #TYPE_CODE(thistype) and #TYPE_FN_FIELD_CONST(thisfn, n). These are
44 written such that they can be used as both rvalues and lvalues.
5e3a2c38
SS
45 */
46
ae5a43e0 47#include "hashtab.h"
268a13a5 48#include "gdbsupport/array-view.h"
0589ca4e 49#include "gdbsupport/gdb-hashtab.h"
6b09f134 50#include <optional>
268a13a5
TT
51#include "gdbsupport/offset-type.h"
52#include "gdbsupport/enum-flags.h"
53#include "gdbsupport/underlying.h"
54#include "gdbsupport/print-utils.h"
a0e0ca70 55#include "gdbsupport/function-view.h"
e35000a7 56#include "dwarf2.h"
bf31fd38 57#include "gdbsupport/gdb_obstack.h"
09584414 58#include "gmp-utils.h"
ae5a43e0 59
7fc73f38 60/* Forward declarations for prototypes. */
da3331ec 61struct field;
7fc73f38 62struct block;
79a45b7d 63struct value_print_options;
e6c014f2 64struct language_defn;
9f47c707
SM
65struct dwarf2_per_cu_data;
66struct dwarf2_per_objfile;
802dace1 67struct dwarf2_property_baton;
7fc73f38 68
5e3a2c38
SS
69/* * Different kinds of data types are distinguished by the `code'
70 field. */
c906108c
SS
71
72enum type_code
c5aa993b 73 {
5e3a2c38 74 TYPE_CODE_UNDEF = 0, /**< Not used; catches errors */
e6742ace 75
4881fcd7
TT
76#define OP(X) X,
77#include "type-codes.def"
78#undef OP
e6742ace 79
c5aa993b 80 };
c906108c 81
5e3a2c38 82/* * Some bits for the type's instance_flags word. See the macros
a9ff5f12 83 below for documentation on each bit. */
5e3a2c38 84
ad69edbb 85enum type_instance_flag_value : unsigned
876cecd0
TT
86{
87 TYPE_INSTANCE_FLAG_CONST = (1 << 0),
88 TYPE_INSTANCE_FLAG_VOLATILE = (1 << 1),
89 TYPE_INSTANCE_FLAG_CODE_SPACE = (1 << 2),
90 TYPE_INSTANCE_FLAG_DATA_SPACE = (1 << 3),
91 TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1 = (1 << 4),
2844d6b5
KW
92 TYPE_INSTANCE_FLAG_ADDRESS_CLASS_2 = (1 << 5),
93 TYPE_INSTANCE_FLAG_NOTTEXT = (1 << 6),
a2c2acaf
MW
94 TYPE_INSTANCE_FLAG_RESTRICT = (1 << 7),
95 TYPE_INSTANCE_FLAG_ATOMIC = (1 << 8)
876cecd0 96};
c906108c 97
3693fdb3
PA
98DEF_ENUM_FLAGS_TYPE (enum type_instance_flag_value, type_instance_flags);
99
5e3a2c38 100/* * Not textual. By default, GDB treats all single byte integers as
876cecd0
TT
101 characters (or elements of strings) unless this flag is set. */
102
10242f36 103#define TYPE_NOTTEXT(t) (((t)->instance_flags ()) & TYPE_INSTANCE_FLAG_NOTTEXT)
876cecd0 104
5e3a2c38 105/* * Constant type. If this is set, the corresponding type has a
0963b4bd 106 const modifier. */
876cecd0 107
10242f36 108#define TYPE_CONST(t) ((((t)->instance_flags ()) & TYPE_INSTANCE_FLAG_CONST) != 0)
876cecd0 109
5e3a2c38 110/* * Volatile type. If this is set, the corresponding type has a
0963b4bd 111 volatile modifier. */
876cecd0 112
3e43a32a 113#define TYPE_VOLATILE(t) \
10242f36 114 ((((t)->instance_flags ()) & TYPE_INSTANCE_FLAG_VOLATILE) != 0)
c906108c 115
5e3a2c38 116/* * Restrict type. If this is set, the corresponding type has a
06d66ee9
TT
117 restrict modifier. */
118
119#define TYPE_RESTRICT(t) \
10242f36 120 ((((t)->instance_flags ()) & TYPE_INSTANCE_FLAG_RESTRICT) != 0)
06d66ee9 121
a2c2acaf
MW
122/* * Atomic type. If this is set, the corresponding type has an
123 _Atomic modifier. */
124
125#define TYPE_ATOMIC(t) \
10242f36 126 ((((t)->instance_flags ()) & TYPE_INSTANCE_FLAG_ATOMIC) != 0)
a2c2acaf 127
f9aeb8d4
AV
128/* * True if this type represents either an lvalue or lvalue reference type. */
129
130#define TYPE_IS_REFERENCE(t) \
78134374 131 ((t)->code () == TYPE_CODE_REF || (t)->code () == TYPE_CODE_RVALUE_REF)
f9aeb8d4 132
bc68014d
AB
133/* * True if this type is allocatable. */
134#define TYPE_IS_ALLOCATABLE(t) \
24e99c6c 135 ((t)->dyn_prop (DYN_PROP_ALLOCATED) != NULL)
bc68014d 136
ef83a141
TT
137/* * True if this type has variant parts. */
138#define TYPE_HAS_VARIANT_PARTS(t) \
24e99c6c 139 ((t)->dyn_prop (DYN_PROP_VARIANT_PARTS) != nullptr)
ef83a141 140
f8e89861
TT
141/* * True if this type has a dynamic length. */
142#define TYPE_HAS_DYNAMIC_LENGTH(t) \
24e99c6c 143 ((t)->dyn_prop (DYN_PROP_BYTE_SIZE) != nullptr)
f8e89861 144
5e3a2c38 145/* * Instruction-space delimited type. This is for Harvard architectures
47663de5
MS
146 which have separate instruction and data address spaces (and perhaps
147 others).
148
149 GDB usually defines a flat address space that is a superset of the
150 architecture's two (or more) address spaces, but this is an extension
151 of the architecture's model.
152
a9ff5f12 153 If TYPE_INSTANCE_FLAG_CODE_SPACE is set, an object of the corresponding type
47663de5
MS
154 resides in instruction memory, even if its address (in the extended
155 flat address space) does not reflect this.
156
a9ff5f12 157 Similarly, if TYPE_INSTANCE_FLAG_DATA_SPACE is set, then an object of the
47663de5
MS
158 corresponding type resides in the data memory space, even if
159 this is not indicated by its (flat address space) address.
160
161 If neither flag is set, the default space for functions / methods
162 is instruction space, and for data objects is data memory. */
163
876cecd0 164#define TYPE_CODE_SPACE(t) \
10242f36 165 ((((t)->instance_flags ()) & TYPE_INSTANCE_FLAG_CODE_SPACE) != 0)
47663de5 166
876cecd0 167#define TYPE_DATA_SPACE(t) \
10242f36 168 ((((t)->instance_flags ()) & TYPE_INSTANCE_FLAG_DATA_SPACE) != 0)
f5f8a009 169
5e3a2c38
SS
170/* * Address class flags. Some environments provide for pointers
171 whose size is different from that of a normal pointer or address
172 types where the bits are interpreted differently than normal
a9ff5f12 173 addresses. The TYPE_INSTANCE_FLAG_ADDRESS_CLASS_n flags may be used in
5e3a2c38
SS
174 target specific ways to represent these different types of address
175 classes. */
176
10242f36 177#define TYPE_ADDRESS_CLASS_1(t) (((t)->instance_flags ()) \
dda83cd7 178 & TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1)
10242f36 179#define TYPE_ADDRESS_CLASS_2(t) (((t)->instance_flags ()) \
876cecd0
TT
180 & TYPE_INSTANCE_FLAG_ADDRESS_CLASS_2)
181#define TYPE_INSTANCE_FLAG_ADDRESS_CLASS_ALL \
182 (TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1 | TYPE_INSTANCE_FLAG_ADDRESS_CLASS_2)
10242f36 183#define TYPE_ADDRESS_CLASS_ALL(t) (((t)->instance_flags ()) \
876cecd0 184 & TYPE_INSTANCE_FLAG_ADDRESS_CLASS_ALL)
d77b6808 185
ef83a141
TT
186/* * Information about a single discriminant. */
187
188struct discriminant_range
189{
190 /* * The range of values for the variant. This is an inclusive
191 range. */
192 ULONGEST low, high;
193
194 /* * Return true if VALUE is contained in this range. IS_UNSIGNED
195 is true if this should be an unsigned comparison; false for
196 signed. */
197 bool contains (ULONGEST value, bool is_unsigned) const
198 {
199 if (is_unsigned)
200 return value >= low && value <= high;
201 LONGEST valuel = (LONGEST) value;
202 return valuel >= (LONGEST) low && valuel <= (LONGEST) high;
203 }
204};
205
206struct variant_part;
207
208/* * A single variant. A variant has a list of discriminant values.
209 When the discriminator matches one of these, the variant is
210 enabled. Each variant controls zero or more fields; and may also
211 control other variant parts as well. This struct corresponds to
212 DW_TAG_variant in DWARF. */
213
214struct variant : allocate_on_obstack
215{
216 /* * The discriminant ranges for this variant. */
217 gdb::array_view<discriminant_range> discriminants;
218
219 /* * The fields controlled by this variant. This is inclusive on
220 the low end and exclusive on the high end. A variant may not
221 control any fields, in which case the two values will be equal.
222 These are indexes into the type's array of fields. */
223 int first_field;
224 int last_field;
225
226 /* * Variant parts controlled by this variant. */
227 gdb::array_view<variant_part> parts;
228
229 /* * Return true if this is the default variant. The default
230 variant can be recognized because it has no associated
231 discriminants. */
232 bool is_default () const
233 {
234 return discriminants.empty ();
235 }
236
237 /* * Return true if this variant matches VALUE. IS_UNSIGNED is true
238 if this should be an unsigned comparison; false for signed. */
239 bool matches (ULONGEST value, bool is_unsigned) const;
240};
241
242/* * A variant part. Each variant part has an optional discriminant
243 and holds an array of variants. This struct corresponds to
244 DW_TAG_variant_part in DWARF. */
245
246struct variant_part : allocate_on_obstack
247{
248 /* * The index of the discriminant field in the outer type. This is
249 an index into the type's array of fields. If this is -1, there
250 is no discriminant, and only the default variant can be
251 considered to be selected. */
252 int discriminant_index;
253
254 /* * True if this discriminant is unsigned; false if signed. This
255 comes from the type of the discriminant. */
256 bool is_unsigned;
257
258 /* * The variants that are controlled by this variant part. Note
259 that these will always be sorted by field number. */
260 gdb::array_view<variant> variants;
261};
262
263
52059ffd
TT
264enum dynamic_prop_kind
265{
266 PROP_UNDEFINED, /* Not defined. */
267 PROP_CONST, /* Constant. */
268 PROP_ADDR_OFFSET, /* Address offset. */
269 PROP_LOCEXPR, /* Location expression. */
ef83a141
TT
270 PROP_LOCLIST, /* Location list. */
271 PROP_VARIANT_PARTS, /* Variant parts. */
272 PROP_TYPE, /* Type. */
386de171 273 PROP_VARIABLE_NAME, /* Variable name. */
52059ffd
TT
274};
275
276union dynamic_prop_data
277{
278 /* Storage for constant property. */
279
280 LONGEST const_val;
281
282 /* Storage for dynamic property. */
283
5f276037 284 const dwarf2_property_baton *baton;
ef83a141
TT
285
286 /* Storage of variant parts for a type. A type with variant parts
287 has all its fields "linearized" -- stored in a single field
288 array, just as if they had all been declared that way. The
289 variant parts are attached via a dynamic property, and then are
290 used to control which fields end up in the final type during
291 dynamic type resolution. */
292
293 const gdb::array_view<variant_part> *variant_parts;
294
295 /* Once a variant type is resolved, we may want to be able to go
296 from the resolved type to the original type. In this case we
297 rewrite the property's kind and set this field. */
298
299 struct type *original_type;
386de171
TT
300
301 /* Name of a variable to look up; the variable holds the value of
302 this property. */
303
304 const char *variable_name;
52059ffd
TT
305};
306
729efb13
SA
307/* * Used to store a dynamic property. */
308
309struct dynamic_prop
310{
8c2e4e06
SM
311 dynamic_prop_kind kind () const
312 {
313 return m_kind;
314 }
315
316 void set_undefined ()
317 {
318 m_kind = PROP_UNDEFINED;
319 }
320
321 LONGEST const_val () const
322 {
323 gdb_assert (m_kind == PROP_CONST);
324
325 return m_data.const_val;
326 }
327
328 void set_const_val (LONGEST const_val)
329 {
330 m_kind = PROP_CONST;
331 m_data.const_val = const_val;
332 }
333
9c0fb734
TT
334 /* Return true if this property has a constant value, false
335 otherwise. */
336 bool is_constant () const
337 { return m_kind == PROP_CONST; }
338
5f276037 339 const dwarf2_property_baton *baton () const
8c2e4e06
SM
340 {
341 gdb_assert (m_kind == PROP_LOCEXPR
342 || m_kind == PROP_LOCLIST
343 || m_kind == PROP_ADDR_OFFSET);
344
345 return m_data.baton;
346 }
347
5f276037 348 void set_locexpr (const dwarf2_property_baton *baton)
8c2e4e06
SM
349 {
350 m_kind = PROP_LOCEXPR;
351 m_data.baton = baton;
352 }
353
5f276037 354 void set_loclist (const dwarf2_property_baton *baton)
8c2e4e06
SM
355 {
356 m_kind = PROP_LOCLIST;
357 m_data.baton = baton;
358 }
359
5f276037 360 void set_addr_offset (const dwarf2_property_baton *baton)
8c2e4e06
SM
361 {
362 m_kind = PROP_ADDR_OFFSET;
363 m_data.baton = baton;
364 }
365
366 const gdb::array_view<variant_part> *variant_parts () const
367 {
368 gdb_assert (m_kind == PROP_VARIANT_PARTS);
369
370 return m_data.variant_parts;
371 }
372
373 void set_variant_parts (gdb::array_view<variant_part> *variant_parts)
374 {
375 m_kind = PROP_VARIANT_PARTS;
376 m_data.variant_parts = variant_parts;
377 }
378
379 struct type *original_type () const
380 {
381 gdb_assert (m_kind == PROP_TYPE);
382
383 return m_data.original_type;
384 }
385
386 void set_original_type (struct type *original_type)
387 {
388 m_kind = PROP_TYPE;
389 m_data.original_type = original_type;
390 }
391
386de171
TT
392 /* Return the name of the variable that holds this property's value.
393 Only valid for PROP_VARIABLE_NAME. */
394 const char *variable_name () const
395 {
396 gdb_assert (m_kind == PROP_VARIABLE_NAME);
397 return m_data.variable_name;
398 }
399
400 /* Set the name of the variable that holds this property's value,
401 and set this property to be of kind PROP_VARIABLE_NAME. */
402 void set_variable_name (const char *name)
403 {
404 m_kind = PROP_VARIABLE_NAME;
405 m_data.variable_name = name;
406 }
407
729efb13 408 /* Determine which field of the union dynamic_prop.data is used. */
8c2e4e06 409 enum dynamic_prop_kind m_kind;
729efb13
SA
410
411 /* Storage for dynamic or static value. */
8c2e4e06 412 union dynamic_prop_data m_data;
729efb13
SA
413};
414
0f59d5fc
PA
415/* Compare two dynamic_prop objects for equality. dynamic_prop
416 instances are equal iff they have the same type and storage. */
417extern bool operator== (const dynamic_prop &l, const dynamic_prop &r);
418
419/* Compare two dynamic_prop objects for inequality. */
420static inline bool operator!= (const dynamic_prop &l, const dynamic_prop &r)
421{
422 return !(l == r);
423}
424
d9823cbb
KB
425/* * Define a type's dynamic property node kind. */
426enum dynamic_prop_node_kind
427{
428 /* A property providing a type's data location.
429 Evaluating this field yields to the location of an object's data. */
93a8e227 430 DYN_PROP_DATA_LOCATION,
3f2f83dd
KB
431
432 /* A property representing DW_AT_allocated. The presence of this attribute
433 indicates that the object of the type can be allocated/deallocated. */
434 DYN_PROP_ALLOCATED,
435
a51119cd 436 /* A property representing DW_AT_associated. The presence of this attribute
3f2f83dd
KB
437 indicated that the object of the type can be associated. */
438 DYN_PROP_ASSOCIATED,
a405673c
JB
439
440 /* A property providing an array's byte stride. */
441 DYN_PROP_BYTE_STRIDE,
7c22600a 442
ef83a141
TT
443 /* A property holding variant parts. */
444 DYN_PROP_VARIANT_PARTS,
f8e89861 445
df7a7bdd 446 /* A property representing DW_AT_rank. The presence of this attribute
447 indicates that the object is of assumed rank array type. */
448 DYN_PROP_RANK,
449
f8e89861
TT
450 /* A property holding the size of the type. */
451 DYN_PROP_BYTE_SIZE,
d9823cbb
KB
452};
453
454/* * List for dynamic type attributes. */
455struct dynamic_prop_list
456{
457 /* The kind of dynamic prop in this node. */
458 enum dynamic_prop_node_kind prop_kind;
459
460 /* The dynamic property itself. */
283a9958 461 struct dynamic_prop prop;
d9823cbb
KB
462
463 /* A pointer to the next dynamic property. */
464 struct dynamic_prop_list *next;
465};
729efb13 466
5e3a2c38
SS
467/* * Determine which field of the union main_type.fields[x].loc is
468 used. */
d6a843b5
JK
469
470enum field_loc_kind
471 {
5e3a2c38
SS
472 FIELD_LOC_KIND_BITPOS, /**< bitpos */
473 FIELD_LOC_KIND_ENUMVAL, /**< enumval */
474 FIELD_LOC_KIND_PHYSADDR, /**< physaddr */
475 FIELD_LOC_KIND_PHYSNAME, /**< physname */
476 FIELD_LOC_KIND_DWARF_BLOCK /**< dwarf_block */
d6a843b5
JK
477 };
478
5e3a2c38
SS
479/* * A discriminant to determine which field in the
480 main_type.type_specific union is being used, if any.
b4ba55a1 481
09e2d7c7 482 For types such as TYPE_CODE_FLT, the use of this
b4ba55a1
JB
483 discriminant is really redundant, as we know from the type code
484 which field is going to be used. As such, it would be possible to
485 reduce the size of this enum in order to save a bit or two for
486 other fields of struct main_type. But, since we still have extra
487 room , and for the sake of clarity and consistency, we treat all fields
488 of the union the same way. */
489
490enum type_specific_kind
491{
492 TYPE_SPECIFIC_NONE,
493 TYPE_SPECIFIC_CPLUS_STUFF,
494 TYPE_SPECIFIC_GNAT_STUFF,
495 TYPE_SPECIFIC_FLOATFORMAT,
09e2d7c7
DE
496 /* Note: This is used by TYPE_CODE_FUNC and TYPE_CODE_METHOD. */
497 TYPE_SPECIFIC_FUNC,
20a5fcbd 498 TYPE_SPECIFIC_SELF_TYPE,
09584414
JB
499 TYPE_SPECIFIC_INT,
500 TYPE_SPECIFIC_FIXED_POINT,
b4ba55a1
JB
501};
502
52059ffd
TT
503union type_owner
504{
505 struct objfile *objfile;
506 struct gdbarch *gdbarch;
507};
508
509union field_location
510{
511 /* * Position of this field, counting in bits from start of
d5a22e77
TT
512 containing structure. For big-endian targets, it is the bit
513 offset to the MSB. For little-endian targets, it is the bit
514 offset to the LSB. */
52059ffd 515
6b850546 516 LONGEST bitpos;
52059ffd
TT
517
518 /* * Enum value. */
519 LONGEST enumval;
520
521 /* * For a static field, if TYPE_FIELD_STATIC_HAS_ADDR then
522 physaddr is the location (in the target) of the static
523 field. Otherwise, physname is the mangled label of the
524 static field. */
525
526 CORE_ADDR physaddr;
527 const char *physname;
528
529 /* * The field location can be computed by evaluating the
530 following DWARF block. Its DATA is allocated on
531 objfile_obstack - no CU load is needed to access it. */
532
533 struct dwarf2_locexpr_baton *dwarf_block;
534};
535
61461a5b 536/* Accessibility of a member. */
a54a99a6 537enum class accessibility : unsigned char
61461a5b
TT
538{
539 /* It's important that this be 0 so that fields default to
540 public. */
541 PUBLIC = 0,
542 PROTECTED = 1,
543 PRIVATE = 2,
544};
545
52059ffd
TT
546struct field
547{
5d14b6e5
SM
548 struct type *type () const
549 {
550 return this->m_type;
551 }
552
553 void set_type (struct type *type)
554 {
555 this->m_type = type;
556 }
557
d3fd12df
SM
558 const char *name () const
559 {
560 return m_name;
561 }
562
563 void set_name (const char *name)
564 {
565 m_name = name;
566 }
567
321d8b3f
SM
568 bool is_artificial () const
569 {
570 return m_artificial;
571 }
572
573 void set_is_artificial (bool is_artificial)
574 {
575 m_artificial = is_artificial;
576 }
577
886176b8
SM
578 unsigned int bitsize () const
579 {
580 return m_bitsize;
581 }
582
583 void set_bitsize (unsigned int bitsize)
584 {
585 m_bitsize = bitsize;
586 }
587
8c329d5c
SM
588 bool is_packed () const
589 {
590 return m_bitsize != 0;
591 }
592
c819a338
TT
593 /* Return true if this field is static; false if not. */
594 bool is_static () const
595 {
596 /* "static" fields are the fields whose location is not relative
597 to the address of the enclosing struct. It would be nice to
598 have a dedicated flag that would be set for static fields when
599 the type is being created. But in practice, checking the field
600 loc_kind should give us an accurate answer. */
601 return (m_loc_kind == FIELD_LOC_KIND_PHYSNAME
602 || m_loc_kind == FIELD_LOC_KIND_PHYSADDR);
603 }
604
cd3f655c
SM
605 /* Location getters / setters. */
606
607 field_loc_kind loc_kind () const
608 {
609 return m_loc_kind;
610 }
611
612 LONGEST loc_bitpos () const
613 {
614 gdb_assert (m_loc_kind == FIELD_LOC_KIND_BITPOS);
615 return m_loc.bitpos;
616 }
617
618 void set_loc_bitpos (LONGEST bitpos)
619 {
620 m_loc_kind = FIELD_LOC_KIND_BITPOS;
621 m_loc.bitpos = bitpos;
622 }
623
624 LONGEST loc_enumval () const
625 {
626 gdb_assert (m_loc_kind == FIELD_LOC_KIND_ENUMVAL);
627 return m_loc.enumval;
628 }
629
630 void set_loc_enumval (LONGEST enumval)
631 {
632 m_loc_kind = FIELD_LOC_KIND_ENUMVAL;
633 m_loc.enumval = enumval;
634 }
635
636 CORE_ADDR loc_physaddr () const
637 {
638 gdb_assert (m_loc_kind == FIELD_LOC_KIND_PHYSADDR);
639 return m_loc.physaddr;
640 }
641
642 void set_loc_physaddr (CORE_ADDR physaddr)
643 {
644 m_loc_kind = FIELD_LOC_KIND_PHYSADDR;
645 m_loc.physaddr = physaddr;
646 }
647
648 const char *loc_physname () const
649 {
650 gdb_assert (m_loc_kind == FIELD_LOC_KIND_PHYSNAME);
651 return m_loc.physname;
652 }
653
654 void set_loc_physname (const char *physname)
655 {
656 m_loc_kind = FIELD_LOC_KIND_PHYSNAME;
657 m_loc.physname = physname;
658 }
659
660 dwarf2_locexpr_baton *loc_dwarf_block () const
661 {
662 gdb_assert (m_loc_kind == FIELD_LOC_KIND_DWARF_BLOCK);
663 return m_loc.dwarf_block;
664 }
665
666 void set_loc_dwarf_block (dwarf2_locexpr_baton *dwarf_block)
667 {
668 m_loc_kind = FIELD_LOC_KIND_DWARF_BLOCK;
669 m_loc.dwarf_block = dwarf_block;
670 }
671
61461a5b
TT
672 /* Set the field's accessibility. */
673 void set_accessibility (accessibility acc)
674 { m_accessibility = acc; }
675
676 /* Fetch the field's accessibility. */
677 enum accessibility accessibility () const
678 { return m_accessibility; }
679
c3842cbe
TT
680 /* True if this field is 'public'. */
681 bool is_public () const
682 { return m_accessibility == accessibility::PUBLIC; }
683
61461a5b
TT
684 /* True if this field is 'private'. */
685 bool is_private () const
686 { return m_accessibility == accessibility::PRIVATE; }
687
688 /* True if this field is 'protected'. */
689 bool is_protected () const
690 { return m_accessibility == accessibility::PROTECTED; }
691
692 /* True if this field is 'virtual'. */
693 bool is_virtual () const
694 { return m_virtual; }
695
696 /* Set the field's "virtual" flag. */
697 void set_virtual ()
698 { m_virtual = true; }
699
700 /* True if this field is 'ignored'. */
701 bool is_ignored () const
702 { return m_ignored; }
703
704 /* Set the field's "ignored" flag. Note that the 'ignored' bit is
705 deprecated. It was used by some unknown stabs generator, and has
706 been replaced by the optimized-out approach -- however, it
707 remains because the stabs reader was never updated. */
708 void set_ignored ()
709 { m_ignored = true; }
710
cd3f655c 711 union field_location m_loc;
52059ffd
TT
712
713 /* * For a function or member type, this is 1 if the argument is
714 marked artificial. Artificial arguments should not be shown
715 to the user. For TYPE_CODE_RANGE it is set if the specific
716 bound is not defined. */
717
321d8b3f 718 unsigned int m_artificial : 1;
52059ffd 719
61461a5b
TT
720 /* Whether the field is 'virtual'. */
721 bool m_virtual : 1;
722 /* Whether the field is 'ignored'. */
723 bool m_ignored : 1;
724
52059ffd
TT
725 /* * Discriminant for union field_location. */
726
cd3f655c 727 ENUM_BITFIELD(field_loc_kind) m_loc_kind : 3;
52059ffd 728
a54a99a6
TT
729 /* Accessibility of the field. */
730 enum accessibility m_accessibility;
731
52059ffd
TT
732 /* * Size of this field, in bits, or zero if not packed.
733 If non-zero in an array type, indicates the element size in
734 bits (used only in Ada at the moment).
735 For an unpacked field, the field's type's length
736 says how many bytes the field occupies. */
737
a54a99a6 738 unsigned int m_bitsize;
52059ffd
TT
739
740 /* * In a struct or union type, type of this field.
741 - In a function or member type, type of this argument.
742 - In an array type, the domain-type of the array. */
743
5d14b6e5 744 struct type *m_type;
52059ffd
TT
745
746 /* * Name of field, value or argument.
747 NULL for range bounds, array domains, and member function
748 arguments. */
749
d3fd12df 750 const char *m_name;
52059ffd
TT
751};
752
753struct range_bounds
754{
107406b7
SM
755 ULONGEST bit_stride () const
756 {
757 if (this->flag_is_byte_stride)
758 return this->stride.const_val () * 8;
759 else
760 return this->stride.const_val ();
761 }
762
52059ffd
TT
763 /* * Low bound of range. */
764
765 struct dynamic_prop low;
766
767 /* * High bound of range. */
768
769 struct dynamic_prop high;
770
5bbd8269
AB
771 /* The stride value for this range. This can be stored in bits or bytes
772 based on the value of BYTE_STRIDE_P. It is optional to have a stride
773 value, if this range has no stride value defined then this will be set
774 to the constant zero. */
775
776 struct dynamic_prop stride;
777
4e962e74
TT
778 /* * The bias. Sometimes a range value is biased before storage.
779 The bias is added to the stored bits to form the true value. */
780
781 LONGEST bias;
782
52059ffd 783 /* True if HIGH range bound contains the number of elements in the
bfcdb852 784 subrange. This affects how the final high bound is computed. */
52059ffd 785
bab05c83 786 unsigned int flag_upper_bound_is_count : 1;
52059ffd
TT
787
788 /* True if LOW or/and HIGH are resolved into a static bound from
789 a dynamic one. */
790
bab05c83 791 unsigned int flag_bound_evaluated : 1;
5bbd8269
AB
792
793 /* If this is true this STRIDE is in bytes, otherwise STRIDE is in bits. */
794
795 unsigned int flag_is_byte_stride : 1;
52059ffd
TT
796};
797
0f59d5fc
PA
798/* Compare two range_bounds objects for equality. Simply does
799 memberwise comparison. */
800extern bool operator== (const range_bounds &l, const range_bounds &r);
801
802/* Compare two range_bounds objects for inequality. */
803static inline bool operator!= (const range_bounds &l, const range_bounds &r)
804{
805 return !(l == r);
806}
807
52059ffd
TT
808union type_specific
809{
810 /* * CPLUS_STUFF is for TYPE_CODE_STRUCT. It is initialized to
811 point to cplus_struct_default, a default static instance of a
812 struct cplus_struct_type. */
813
814 struct cplus_struct_type *cplus_stuff;
815
816 /* * GNAT_STUFF is for types for which the GNAT Ada compiler
817 provides additional information. */
818
819 struct gnat_aux_type *gnat_stuff;
820
0db7851f
UW
821 /* * FLOATFORMAT is for TYPE_CODE_FLT. It is a pointer to a
822 floatformat object that describes the floating-point value
823 that resides within the type. */
52059ffd 824
0db7851f 825 const struct floatformat *floatformat;
52059ffd
TT
826
827 /* * For TYPE_CODE_FUNC and TYPE_CODE_METHOD types. */
828
829 struct func_type *func_stuff;
830
831 /* * For types that are pointer to member types (TYPE_CODE_METHODPTR,
832 TYPE_CODE_MEMBERPTR), SELF_TYPE is the type that this pointer
833 is a member of. */
834
835 struct type *self_type;
20a5fcbd 836
09584414
JB
837 /* * For TYPE_CODE_FIXED_POINT types, the info necessary to decode
838 values of that type. */
839 struct fixed_point_type_info *fixed_point_info;
840
20a5fcbd
TT
841 /* * An integer-like scalar type may be stored in just part of its
842 enclosing storage bytes. This structure describes this
843 situation. */
844 struct
845 {
846 /* * The bit size of the integer. This can be 0. For integers
847 that fill their storage (the ordinary case), this field holds
848 the byte size times 8. */
849 unsigned short bit_size;
850 /* * The bit offset of the integer. This is ordinarily 0, and can
851 only be non-zero if the bit size is less than the storage
852 size. */
853 unsigned short bit_offset;
854 } int_stuff;
52059ffd
TT
855};
856
5e3a2c38
SS
857/* * Main structure representing a type in GDB.
858
859 This structure is space-critical. Its layout has been tweaked to
860 reduce the space used. */
0955bbf0 861
2fdde8f8
DJ
862struct main_type
863{
5e3a2c38 864 /* * Code for kind of type. */
2fdde8f8 865
0955bbf0
MC
866 ENUM_BITFIELD(type_code) code : 8;
867
5e3a2c38 868 /* * Flags about this type. These fields appear at this location
876cecd0
TT
869 because they packs nicely here. See the TYPE_* macros for
870 documentation about these fields. */
871
653223d3 872 unsigned int m_flag_unsigned : 1;
15152a54 873 unsigned int m_flag_nosign : 1;
b4b73759 874 unsigned int m_flag_stub : 1;
8f53807e 875 unsigned int m_flag_target_stub : 1;
27e69b7a 876 unsigned int m_flag_prototyped : 1;
1d6286ed 877 unsigned int m_flag_varargs : 1;
2062087b 878 unsigned int m_flag_vector : 1;
9baccff6 879 unsigned int m_flag_stub_supported : 1;
03cc7249 880 unsigned int m_flag_gnu_ifunc : 1;
9cdd0d12 881 unsigned int m_flag_fixed_instance : 1;
5b7d941b 882 unsigned int m_flag_objfile_owned : 1;
db558e34 883 unsigned int m_flag_endianity_not_default : 1;
5e3a2c38
SS
884
885 /* * True if this type was declared with "class" rather than
0cc2414c 886 "struct". */
5e3a2c38 887
aa70e35c 888 unsigned int m_flag_declared_class : 1;
876cecd0 889
5e3a2c38
SS
890 /* * True if this is an enum type with disjoint values. This
891 affects how the enum is printed. */
cafec441 892
9902b327 893 unsigned int m_flag_flag_enum : 1;
cafec441 894
6c849804
TT
895 /* * For TYPE_CODE_ARRAY, this is true if this type is part of a
896 multi-dimensional array. Multi-dimensional arrays are
897 represented internally as arrays of arrays, and this flag lets
898 gdb distinguish between multiple dimensions and an ordinary array
899 of arrays. The flag is set on each inner dimension, but not the
900 outermost dimension. */
901
902 unsigned int m_multi_dimensional : 1;
903
5e3a2c38
SS
904 /* * A discriminant telling us which field of the type_specific
905 union is being used for this type, if any. */
906
76fc0f62
TT
907 ENUM_BITFIELD(type_specific_kind) type_specific_field : 3;
908
909 /* The language for this type. */
910
911 ENUM_BITFIELD(language) m_lang : LANGUAGE_BITS;
b4ba55a1 912
5e3a2c38
SS
913 /* * Number of fields described for this type. This field appears
914 at this location because it packs nicely here. */
876cecd0 915
1775f8b3 916 unsigned int m_nfields;
876cecd0 917
5e3a2c38 918 /* * Name of this type, or NULL if none.
2fdde8f8 919
e86ca25f
TT
920 This is used for printing only. For looking up a name, look for
921 a symbol in the VAR_DOMAIN. This is generally allocated in the
922 objfile's obstack. However coffread.c uses malloc. */
2fdde8f8 923
0d5cff50 924 const char *name;
2fdde8f8 925
5e3a2c38
SS
926 /* * Every type is now associated with a particular objfile, and the
927 type is allocated on the objfile_obstack for that objfile. One
928 problem however, is that there are times when gdb allocates new
929 types while it is not in the process of reading symbols from a
930 particular objfile. Fortunately, these happen when the type
931 being created is a derived type of an existing type, such as in
932 lookup_pointer_type(). So we can just allocate the new type
933 using the same objfile as the existing type, but to do this we
934 need a backpointer to the objfile from the existing type. Yes
935 this is somewhat ugly, but without major overhaul of the internal
936 type system, it can't be avoided for now. */
2fdde8f8 937
5b7d941b 938 union type_owner m_owner;
2fdde8f8 939
5e3a2c38
SS
940 /* * For a pointer type, describes the type of object pointed to.
941 - For an array type, describes the type of the elements.
942 - For a function or method type, describes the type of the return value.
943 - For a range type, describes the type of the full range.
944 - For a complex type, describes the type of each coordinate.
945 - For a special record or union type encoding a dynamic-sized type
d09ce91e
JB
946 in GNAT, a memoized pointer to a corresponding static version of
947 the type.
5e3a2c38 948 - Unused otherwise. */
2fdde8f8 949
8a50fdce 950 struct type *m_target_type;
2fdde8f8 951
5e3a2c38 952 /* * For structure and union types, a description of each field.
2fdde8f8
DJ
953 For set and pascal array types, there is one "field",
954 whose type is the domain type of the set or array.
955 For range types, there are two "fields",
956 the minimum and maximum values (both inclusive).
957 For enum types, each possible value is described by one "field".
ad2f7632 958 For a function or method type, a "field" for each parameter.
2fdde8f8
DJ
959 For C++ classes, there is one field for each base class (if it is
960 a derived class) plus one field for each class data member. Member
961 functions are recorded elsewhere.
962
963 Using a pointer to a separate array of fields
964 allows all types to have the same size, which is useful
965 because we can allocate the space for a type before
966 we know what to put in it. */
967
43bbcdc2 968 union
c5aa993b 969 {
52059ffd 970 struct field *fields;
01ad7f36 971
5e3a2c38 972 /* * Union member used for range types. */
43bbcdc2 973
52059ffd 974 struct range_bounds *bounds;
c906108c 975
5b930b45
TT
976 /* If this is a scalar type, then this is its corresponding
977 complex type. */
978 struct type *complex_type;
979
43bbcdc2 980 } flds_bnds;
c906108c 981
5e3a2c38
SS
982 /* * Slot to point to additional language-specific fields of this
983 type. */
c906108c 984
52059ffd 985 union type_specific type_specific;
3cdcd0ce 986
d9823cbb
KB
987 /* * Contains all dynamic type properties. */
988 struct dynamic_prop_list *dyn_prop_list;
2fdde8f8 989};
c906108c 990
2b4424c3
TT
991/* * Number of bits allocated for alignment. */
992
993#define TYPE_ALIGN_BITS 8
994
5e3a2c38 995/* * A ``struct type'' describes a particular instance of a type, with
2fdde8f8 996 some particular qualification. */
5e3a2c38 997
2fdde8f8
DJ
998struct type
999{
67607e24
SM
1000 /* Get the type code of this type.
1001
1002 Note that the code can be TYPE_CODE_TYPEDEF, so if you want the real
1003 type, you need to do `check_typedef (type)->code ()`. */
1004 type_code code () const
1005 {
1006 return this->main_type->code;
1007 }
1008
1009 /* Set the type code of this type. */
1010 void set_code (type_code code)
1011 {
1012 this->main_type->code = code;
1013 }
1014
d0e39ea2
SM
1015 /* Get the name of this type. */
1016 const char *name () const
1017 {
1018 return this->main_type->name;
1019 }
1020
1021 /* Set the name of this type. */
1022 void set_name (const char *name)
1023 {
1024 this->main_type->name = name;
1025 }
1026
df86565b
SM
1027 /* Note that if thistype is a TYPEDEF type, you have to call check_typedef.
1028 But check_typedef does set the TYPE_LENGTH of the TYPEDEF type,
317c3ed9 1029 so you only have to call check_typedef once. Since value::allocate
d0c97917 1030 calls check_typedef, X->type ()->length () is safe. */
b6cdbc9a
SM
1031 ULONGEST length () const
1032 {
1033 return this->m_length;
1034 }
1035
1036 void set_length (ULONGEST length)
1037 {
1038 this->m_length = length;
1039 }
1040
5e33d5f4 1041 /* Get the number of fields of this type. */
1775f8b3 1042 unsigned int num_fields () const
5e33d5f4 1043 {
1775f8b3 1044 return this->main_type->m_nfields;
5e33d5f4
SM
1045 }
1046
1047 /* Set the number of fields of this type. */
1775f8b3 1048 void set_num_fields (unsigned int num_fields)
5e33d5f4 1049 {
1775f8b3 1050 this->main_type->m_nfields = num_fields;
5e33d5f4
SM
1051 }
1052
3cabb6b0 1053 /* Get the fields array of this type. */
80fc5e77 1054 struct field *fields () const
3cabb6b0
SM
1055 {
1056 return this->main_type->flds_bnds.fields;
1057 }
1058
80fc5e77
SM
1059 /* Get the field at index IDX. */
1060 struct field &field (int idx) const
1061 {
5a8edb75 1062 gdb_assert (idx >= 0 && idx < num_fields ());
80fc5e77
SM
1063 return this->fields ()[idx];
1064 }
1065
3cabb6b0 1066 /* Set the fields array of this type. */
80fc5e77 1067 void set_fields (struct field *fields)
3cabb6b0
SM
1068 {
1069 this->main_type->flds_bnds.fields = fields;
1070 }
1071
2774f2da
TV
1072 /* Allocate the fields array of this type, with NFIELDS elements. If INIT,
1073 zero-initialize the allocated memory. */
1074 void alloc_fields (unsigned int nfields, bool init = true);
1075
1076 /* Allocate the fields array of this type, and copy the fields from SRC. */
1077 void copy_fields (struct type *src);
1078 void copy_fields (std::vector<struct field> &src);
1079
262abc0d
SM
1080 type *index_type () const
1081 {
5d14b6e5 1082 return this->field (0).type ();
262abc0d
SM
1083 }
1084
8a50fdce
SM
1085 struct type *target_type () const
1086 {
1087 return this->main_type->m_target_type;
1088 }
1089
1090 void set_target_type (struct type *target_type)
1091 {
1092 this->main_type->m_target_type = target_type;
1093 }
1094
262abc0d
SM
1095 void set_index_type (type *index_type)
1096 {
5d14b6e5 1097 this->field (0).set_type (index_type);
262abc0d
SM
1098 }
1099
314ad88d
PA
1100 /* Return the instance flags converted to the correct type. */
1101 const type_instance_flags instance_flags () const
1102 {
1103 return (enum type_instance_flag_value) this->m_instance_flags;
1104 }
1105
1106 /* Set the instance flags. */
1107 void set_instance_flags (type_instance_flags flags)
1108 {
1109 this->m_instance_flags = flags;
1110 }
1111
c4dfcb36
SM
1112 /* Get the bounds bounds of this type. The type must be a range type. */
1113 range_bounds *bounds () const
1114 {
cf88be68
SM
1115 switch (this->code ())
1116 {
1117 case TYPE_CODE_RANGE:
1118 return this->main_type->flds_bnds.bounds;
1119
1120 case TYPE_CODE_ARRAY:
1121 case TYPE_CODE_STRING:
1122 return this->index_type ()->bounds ();
1123
1124 default:
1125 gdb_assert_not_reached
1126 ("type::bounds called on type with invalid code");
1127 }
c4dfcb36
SM
1128 }
1129
1130 /* Set the bounds of this type. The type must be a range type. */
1131 void set_bounds (range_bounds *bounds)
1132 {
1133 gdb_assert (this->code () == TYPE_CODE_RANGE);
1134
1135 this->main_type->flds_bnds.bounds = bounds;
1136 }
1137
107406b7
SM
1138 ULONGEST bit_stride () const
1139 {
886176b8
SM
1140 if (this->code () == TYPE_CODE_ARRAY && this->field (0).bitsize () != 0)
1141 return this->field (0).bitsize ();
107406b7
SM
1142 return this->bounds ()->bit_stride ();
1143 }
1144
c6d940a9
SM
1145 /* Unsigned integer type. If this is not set for a TYPE_CODE_INT,
1146 the type is signed (unless TYPE_NOSIGN is set). */
1147
653223d3
SM
1148 bool is_unsigned () const
1149 {
1150 return this->main_type->m_flag_unsigned;
1151 }
1152
1153 void set_is_unsigned (bool is_unsigned)
1154 {
1155 this->main_type->m_flag_unsigned = is_unsigned;
1156 }
1157
20ce4123
SM
1158 /* No sign for this type. In C++, "char", "signed char", and
1159 "unsigned char" are distinct types; so we need an extra flag to
1160 indicate the absence of a sign! */
1161
15152a54
SM
1162 bool has_no_signedness () const
1163 {
1164 return this->main_type->m_flag_nosign;
1165 }
1166
1167 void set_has_no_signedness (bool has_no_signedness)
1168 {
1169 this->main_type->m_flag_nosign = has_no_signedness;
1170 }
1171
e46d3488
SM
1172 /* This appears in a type's flags word if it is a stub type (e.g.,
1173 if someone referenced a type that wasn't defined in a source file
1174 via (struct sir_not_appearing_in_this_film *)). */
1175
b4b73759
SM
1176 bool is_stub () const
1177 {
1178 return this->main_type->m_flag_stub;
1179 }
1180
1181 void set_is_stub (bool is_stub)
1182 {
1183 this->main_type->m_flag_stub = is_stub;
1184 }
1185
d2183968
SM
1186 /* The target type of this type is a stub type, and this type needs
1187 to be updated if it gets un-stubbed in check_typedef. Used for
1188 arrays and ranges, in which TYPE_LENGTH of the array/range gets set
1189 based on the TYPE_LENGTH of the target type. Also, set for
1190 TYPE_CODE_TYPEDEF. */
1191
8f53807e
SM
1192 bool target_is_stub () const
1193 {
1194 return this->main_type->m_flag_target_stub;
1195 }
1196
1197 void set_target_is_stub (bool target_is_stub)
1198 {
1199 this->main_type->m_flag_target_stub = target_is_stub;
1200 }
1201
7f9f399b
SM
1202 /* This is a function type which appears to have a prototype. We
1203 need this for function calls in order to tell us if it's necessary
1204 to coerce the args, or to just do the standard conversions. This
1205 is used with a short field. */
1206
27e69b7a
SM
1207 bool is_prototyped () const
1208 {
1209 return this->main_type->m_flag_prototyped;
1210 }
1211
1212 void set_is_prototyped (bool is_prototyped)
1213 {
1214 this->main_type->m_flag_prototyped = is_prototyped;
1215 }
1216
a409645d
SM
1217 /* FIXME drow/2002-06-03: Only used for methods, but applies as well
1218 to functions. */
1219
1d6286ed
SM
1220 bool has_varargs () const
1221 {
1222 return this->main_type->m_flag_varargs;
1223 }
1224
1225 void set_has_varargs (bool has_varargs)
1226 {
1227 this->main_type->m_flag_varargs = has_varargs;
1228 }
1229
bd63c870
SM
1230 /* Identify a vector type. Gcc is handling this by adding an extra
1231 attribute to the array type. We slurp that in as a new flag of a
1232 type. This is used only in dwarf2read.c. */
1233
2062087b
SM
1234 bool is_vector () const
1235 {
1236 return this->main_type->m_flag_vector;
1237 }
1238
1239 void set_is_vector (bool is_vector)
1240 {
1241 this->main_type->m_flag_vector = is_vector;
1242 }
1243
3f46044c
SM
1244 /* This debug target supports TYPE_STUB(t). In the unsupported case
1245 we have to rely on NFIELDS to be zero etc., see TYPE_IS_OPAQUE().
1246 TYPE_STUB(t) with !TYPE_STUB_SUPPORTED(t) may exist if we only
1247 guessed the TYPE_STUB(t) value (see dwarfread.c). */
1248
9baccff6
SM
1249 bool stub_is_supported () const
1250 {
1251 return this->main_type->m_flag_stub_supported;
1252 }
1253
1254 void set_stub_is_supported (bool stub_is_supported)
1255 {
1256 this->main_type->m_flag_stub_supported = stub_is_supported;
1257 }
1258
0becda7a 1259 /* Used only for TYPE_CODE_FUNC where it specifies the real function
27710edb 1260 address is returned by this function call. The target_type method
0becda7a
SM
1261 determines the final returned function type to be presented to
1262 user. */
1263
03cc7249
SM
1264 bool is_gnu_ifunc () const
1265 {
1266 return this->main_type->m_flag_gnu_ifunc;
1267 }
1268
1269 void set_is_gnu_ifunc (bool is_gnu_ifunc)
1270 {
1271 this->main_type->m_flag_gnu_ifunc = is_gnu_ifunc;
1272 }
1273
22c4c60c
SM
1274 /* The debugging formats (especially STABS) do not contain enough
1275 information to represent all Ada types---especially those whose
1276 size depends on dynamic quantities. Therefore, the GNAT Ada
1277 compiler includes extra information in the form of additional type
1278 definitions connected by naming conventions. This flag indicates
1279 that the type is an ordinary (unencoded) GDB type that has been
1280 created from the necessary run-time information, and does not need
1281 further interpretation. Optionally marks ordinary, fixed-size GDB
1282 type. */
1283
9cdd0d12
SM
1284 bool is_fixed_instance () const
1285 {
1286 return this->main_type->m_flag_fixed_instance;
1287 }
1288
1289 void set_is_fixed_instance (bool is_fixed_instance)
1290 {
1291 this->main_type->m_flag_fixed_instance = is_fixed_instance;
1292 }
1293
04f5bab2
SM
1294 /* A compiler may supply dwarf instrumentation that indicates the desired
1295 endian interpretation of the variable differs from the native endian
1296 representation. */
1297
db558e34
SM
1298 bool endianity_is_not_default () const
1299 {
1300 return this->main_type->m_flag_endianity_not_default;
1301 }
1302
1303 void set_endianity_is_not_default (bool endianity_is_not_default)
1304 {
1305 this->main_type->m_flag_endianity_not_default = endianity_is_not_default;
1306 }
1307
aa70e35c
SM
1308
1309 /* True if this type was declared using the "class" keyword. This is
1310 only valid for C++ structure and enum types. If false, a structure
1311 was declared as a "struct"; if true it was declared "class". For
1312 enum types, this is true when "enum class" or "enum struct" was
1313 used to declare the type. */
1314
1315 bool is_declared_class () const
1316 {
1317 return this->main_type->m_flag_declared_class;
1318 }
1319
1320 void set_is_declared_class (bool is_declared_class) const
1321 {
1322 this->main_type->m_flag_declared_class = is_declared_class;
1323 }
1324
9902b327
SM
1325 /* True if this type is a "flag" enum. A flag enum is one where all
1326 the values are pairwise disjoint when "and"ed together. This
1327 affects how enum values are printed. */
1328
1329 bool is_flag_enum () const
1330 {
1331 return this->main_type->m_flag_flag_enum;
1332 }
1333
1334 void set_is_flag_enum (bool is_flag_enum)
1335 {
1336 this->main_type->m_flag_flag_enum = is_flag_enum;
1337 }
1338
6c849804
TT
1339 /* True if this array type is part of a multi-dimensional array. */
1340
1341 bool is_multi_dimensional () const
1342 {
1343 return this->main_type->m_multi_dimensional;
1344 }
1345
1346 void set_is_multi_dimensional (bool value)
1347 {
1348 this->main_type->m_multi_dimensional = value;
1349 }
1350
2a12c336
JB
1351 /* * Assuming that THIS is a TYPE_CODE_FIXED_POINT, return a reference
1352 to this type's fixed_point_info. */
1353
1354 struct fixed_point_type_info &fixed_point_info () const
1355 {
1356 gdb_assert (this->code () == TYPE_CODE_FIXED_POINT);
1357 gdb_assert (this->main_type->type_specific.fixed_point_info != nullptr);
1358
1359 return *this->main_type->type_specific.fixed_point_info;
1360 }
1361
1362 /* * Assuming that THIS is a TYPE_CODE_FIXED_POINT, set this type's
1363 fixed_point_info to INFO. */
1364
1365 void set_fixed_point_info (struct fixed_point_type_info *info) const
1366 {
1367 gdb_assert (this->code () == TYPE_CODE_FIXED_POINT);
1368
1369 this->main_type->type_specific.fixed_point_info = info;
1370 }
1371
d19937a7
JB
1372 /* * Assuming that THIS is a TYPE_CODE_FIXED_POINT, return its base type.
1373
1374 In other words, this returns the type after having peeled all
1375 intermediate type layers (such as TYPE_CODE_RANGE, for instance).
1376 The TYPE_CODE of the type returned is guaranteed to be
1377 a TYPE_CODE_FIXED_POINT. */
1378
1379 struct type *fixed_point_type_base_type ();
1380
e6fcee3a
JB
1381 /* * Assuming that THIS is a TYPE_CODE_FIXED_POINT, return its scaling
1382 factor. */
1383
1384 const gdb_mpq &fixed_point_scaling_factor ();
1385
24e99c6c
SM
1386 /* * Return the dynamic property of the requested KIND from this type's
1387 list of dynamic properties. */
1388 dynamic_prop *dyn_prop (dynamic_prop_node_kind kind) const;
1389
5c54719c
SM
1390 /* * Given a dynamic property PROP of a given KIND, add this dynamic
1391 property to this type.
1392
1393 This function assumes that this type is objfile-owned. */
1394 void add_dyn_prop (dynamic_prop_node_kind kind, dynamic_prop prop);
1395
7aa91313
SM
1396 /* * Remove dynamic property of kind KIND from this type, if it exists. */
1397 void remove_dyn_prop (dynamic_prop_node_kind kind);
1398
5b7d941b
SM
1399 /* Return true if this type is owned by an objfile. Return false if it is
1400 owned by an architecture. */
1401 bool is_objfile_owned () const
1402 {
1403 return this->main_type->m_flag_objfile_owned;
1404 }
1405
1406 /* Set the owner of the type to be OBJFILE. */
1407 void set_owner (objfile *objfile)
1408 {
dd5ca05f
SM
1409 gdb_assert (objfile != nullptr);
1410
5b7d941b
SM
1411 this->main_type->m_owner.objfile = objfile;
1412 this->main_type->m_flag_objfile_owned = true;
1413 }
1414
1415 /* Set the owner of the type to be ARCH. */
1416 void set_owner (gdbarch *arch)
1417 {
dd5ca05f
SM
1418 gdb_assert (arch != nullptr);
1419
5b7d941b
SM
1420 this->main_type->m_owner.gdbarch = arch;
1421 this->main_type->m_flag_objfile_owned = false;
1422 }
1423
1424 /* Return the objfile owner of this type.
1425
1426 Return nullptr if this type is not objfile-owned. */
6ac37371 1427 struct objfile *objfile_owner () const
5b7d941b
SM
1428 {
1429 if (!this->is_objfile_owned ())
1430 return nullptr;
1431
1432 return this->main_type->m_owner.objfile;
1433 }
1434
1435 /* Return the gdbarch owner of this type.
1436
1437 Return nullptr if this type is not gdbarch-owned. */
6ac37371 1438 gdbarch *arch_owner () const
5b7d941b
SM
1439 {
1440 if (this->is_objfile_owned ())
1441 return nullptr;
1442
1443 return this->main_type->m_owner.gdbarch;
1444 }
1445
8ee511af
SM
1446 /* Return the type's architecture. For types owned by an
1447 architecture, that architecture is returned. For types owned by an
1448 objfile, that objfile's architecture is returned.
1449
1450 The return value is always non-nullptr. */
1451 gdbarch *arch () const;
1452
20a5fcbd
TT
1453 /* * Return true if this is an integer type whose logical (bit) size
1454 differs from its storage size; false otherwise. Always return
1455 false for non-integer (i.e., non-TYPE_SPECIFIC_INT) types. */
1456 bool bit_size_differs_p () const
1457 {
1458 return (main_type->type_specific_field == TYPE_SPECIFIC_INT
b6cdbc9a 1459 && main_type->type_specific.int_stuff.bit_size != 8 * length ());
20a5fcbd
TT
1460 }
1461
1462 /* * Return the logical (bit) size for this integer type. Only
1463 valid for integer (TYPE_SPECIFIC_INT) types. */
1464 unsigned short bit_size () const
1465 {
1466 gdb_assert (main_type->type_specific_field == TYPE_SPECIFIC_INT);
1467 return main_type->type_specific.int_stuff.bit_size;
1468 }
1469
1470 /* * Return the bit offset for this integer type. Only valid for
1471 integer (TYPE_SPECIFIC_INT) types. */
1472 unsigned short bit_offset () const
1473 {
1474 gdb_assert (main_type->type_specific_field == TYPE_SPECIFIC_INT);
1475 return main_type->type_specific.int_stuff.bit_offset;
1476 }
1477
809f3be1
TT
1478 /* Return true if this is a pointer or reference type. */
1479 bool is_pointer_or_reference () const
1480 {
1481 return this->code () == TYPE_CODE_PTR || TYPE_IS_REFERENCE (this);
1482 }
1483
76fc0f62
TT
1484 /* Return true if this type is "string-like", according to its
1485 defining language. */
1486 bool is_string_like ();
1487
84914f59
TT
1488 /* Return true if this type is "array-like". This includes arrays,
1489 but also some forms of structure type that are recognized as
1490 representations of arrays by the type's language. */
1491 bool is_array_like ();
1492
76fc0f62
TT
1493 /* Return the language that this type came from. */
1494 enum language language () const
1495 { return main_type->m_lang; }
1496
5e3a2c38 1497 /* * Type that is a pointer to this type.
2fdde8f8
DJ
1498 NULL if no such pointer-to type is known yet.
1499 The debugger may add the address of such a type
1500 if it has to construct one later. */
c906108c 1501
2fdde8f8 1502 struct type *pointer_type;
c906108c 1503
5e3a2c38 1504 /* * C++: also need a reference type. */
c906108c 1505
2fdde8f8 1506 struct type *reference_type;
c906108c 1507
f9aeb8d4
AV
1508 /* * A C++ rvalue reference type added in C++11. */
1509
1510 struct type *rvalue_reference_type;
1511
5e3a2c38
SS
1512 /* * Variant chain. This points to a type that differs from this
1513 one only in qualifiers and length. Currently, the possible
1514 qualifiers are const, volatile, code-space, data-space, and
1515 address class. The length may differ only when one of the
1516 address class flags are set. The variants are linked in a
1517 circular ring and share MAIN_TYPE. */
1518
2fdde8f8 1519 struct type *chain;
c906108c 1520
2b4424c3
TT
1521 /* * The alignment for this type. Zero means that the alignment was
1522 not specified in the debug info. Note that this is stored in a
1523 funny way: as the log base 2 (plus 1) of the alignment; so a
1524 value of 1 means the alignment is 1, and a value of 9 means the
1525 alignment is 256. */
1526
1527 unsigned align_log2 : TYPE_ALIGN_BITS;
1528
5e3a2c38 1529 /* * Flags specific to this instance of the type, indicating where
92163a10
JK
1530 on the ring we are.
1531
5e3a2c38
SS
1532 For TYPE_CODE_TYPEDEF the flags of the typedef type should be
1533 binary or-ed with the target type, with a special case for
1534 address class and space class. For example if this typedef does
1535 not specify any new qualifiers, TYPE_INSTANCE_FLAGS is 0 and the
1536 instance flags are completely inherited from the target type. No
1537 qualifiers can be cleared by the typedef. See also
1538 check_typedef. */
314ad88d 1539 unsigned m_instance_flags : 9;
701c159d 1540
2e056931
SM
1541 /* * Length of storage for a value of this type. The value is the
1542 expression in host bytes of what sizeof(type) would return. This
1543 size includes padding. For example, an i386 extended-precision
1544 floating point value really only occupies ten bytes, but most
1545 ABI's declare its size to be 12 bytes, to preserve alignment.
1546 A `struct type' representing such a floating-point type would
1547 have a `length' value of 12, even though the last two bytes are
1548 unused.
1549
1550 Since this field is expressed in host bytes, its value is appropriate
1551 to pass to memcpy and such (it is assumed that GDB itself always runs
1552 on an 8-bits addressable architecture). However, when using it for
1553 target address arithmetic (e.g. adding it to a target address), the
1554 type_length_units function should be used in order to get the length
1555 expressed in target addressable memory units. */
1556
b6cdbc9a 1557 ULONGEST m_length;
ab5d3da6 1558
5e3a2c38
SS
1559 /* * Core type, shared by a group of qualified types. */
1560
2fdde8f8
DJ
1561 struct main_type *main_type;
1562};
c906108c 1563
52059ffd
TT
1564struct fn_fieldlist
1565{
1566
1567 /* * The overloaded name.
1568 This is generally allocated in the objfile's obstack.
1569 However stabsread.c sometimes uses malloc. */
1570
1571 const char *name;
1572
1573 /* * The number of methods with this name. */
1574
1575 int length;
1576
1577 /* * The list of methods. */
1578
1579 struct fn_field *fn_fields;
1580};
1581
1582
1583
1584struct fn_field
1585{
1586 /* * If is_stub is clear, this is the mangled name which we can look
1587 up to find the address of the method (FIXME: it would be cleaner
1588 to have a pointer to the struct symbol here instead).
1589
1590 If is_stub is set, this is the portion of the mangled name which
1591 specifies the arguments. For example, "ii", if there are two int
1592 arguments, or "" if there are no arguments. See gdb_mangle_name
1593 for the conversion from this format to the one used if is_stub is
1594 clear. */
1595
1596 const char *physname;
1597
1598 /* * The function type for the method.
1599
1600 (This comment used to say "The return value of the method", but
1601 that's wrong. The function type is expected here, i.e. something
1602 with TYPE_CODE_METHOD, and *not* the return-value type). */
1603
1604 struct type *type;
1605
1606 /* * For virtual functions. First baseclass that defines this
1607 virtual function. */
1608
1609 struct type *fcontext;
1610
1611 /* Attributes. */
1612
1613 unsigned int is_const:1;
1614 unsigned int is_volatile:1;
52059ffd
TT
1615 unsigned int is_artificial:1;
1616
1617 /* * A stub method only has some fields valid (but they are enough
1618 to reconstruct the rest of the fields). */
1619
1620 unsigned int is_stub:1;
1621
1622 /* * True if this function is a constructor, false otherwise. */
1623
1624 unsigned int is_constructor : 1;
1625
e35000a7
TBA
1626 /* * True if this function is deleted, false otherwise. */
1627
1628 unsigned int is_deleted : 1;
1629
1630 /* * DW_AT_defaulted attribute for this function. The value is one
1631 of the DW_DEFAULTED constants. */
1632
1633 ENUM_BITFIELD (dwarf_defaulted_attribute) defaulted : 2;
1634
a54a99a6
TT
1635 /* Accessibility of the field. */
1636 enum accessibility accessibility;
52059ffd
TT
1637
1638 /* * Index into that baseclass's virtual function table, minus 2;
1639 else if static: VOFFSET_STATIC; else: 0. */
1640
1641 unsigned int voffset:16;
1642
1643#define VOFFSET_STATIC 1
1644
1645};
1646
883fd55a 1647struct decl_field
52059ffd
TT
1648{
1649 /* * Unqualified name to be prefixed by owning class qualified
1650 name. */
1651
1652 const char *name;
1653
1654 /* * Type this typedef named NAME represents. */
1655
1656 struct type *type;
c191a687 1657
5028c9e2 1658 /* Accessibility of the field. */
a54a99a6 1659 enum accessibility accessibility;
52059ffd
TT
1660};
1661
5e3a2c38
SS
1662/* * C++ language-specific information for TYPE_CODE_STRUCT and
1663 TYPE_CODE_UNION nodes. */
c906108c
SS
1664
1665struct cplus_struct_type
c5aa993b 1666 {
5e3a2c38
SS
1667 /* * Number of base classes this type derives from. The
1668 baseclasses are stored in the first N_BASECLASSES fields
5e7cf078
DE
1669 (i.e. the `fields' field of the struct type). The only fields
1670 of struct field that are used are: type, name, loc.bitpos. */
c906108c 1671
c5aa993b 1672 short n_baseclasses;
c906108c 1673
ae6ae975
DE
1674 /* * Field number of the virtual function table pointer in VPTR_BASETYPE.
1675 All access to this field must be through TYPE_VPTR_FIELDNO as one
1676 thing it does is check whether the field has been initialized.
1677 Initially TYPE_RAW_CPLUS_SPECIFIC has the value of cplus_struct_default,
1678 which for portability reasons doesn't initialize this field.
1679 TYPE_VPTR_FIELDNO returns -1 for this case.
1680
1681 If -1, we were unable to find the virtual function table pointer in
1682 initial symbol reading, and get_vptr_fieldno should be called to find
1683 it if possible. get_vptr_fieldno will update this field if possible.
1684 Otherwise the value is left at -1.
1685
1686 Unused if this type does not have virtual functions. */
1687
1688 short vptr_fieldno;
1689
5e3a2c38
SS
1690 /* * Number of methods with unique names. All overloaded methods
1691 with the same name count only once. */
c906108c 1692
c5aa993b 1693 short nfn_fields;
c906108c 1694
5e3a2c38
SS
1695 /* * Number of template arguments. */
1696
34eaf542
TT
1697 unsigned short n_template_arguments;
1698
5e3a2c38 1699 /* * One if this struct is a dynamic class, as defined by the
48ea67a7
TT
1700 Itanium C++ ABI: if it requires a virtual table pointer,
1701 because it or any of its base classes have one or more virtual
1702 member functions or virtual base classes. Minus one if not
1703 dynamic. Zero if not yet computed. */
5e3a2c38 1704
48ea67a7 1705 int is_dynamic : 2;
c5aa993b 1706
e35000a7
TBA
1707 /* * The calling convention for this type, fetched from the
1708 DW_AT_calling_convention attribute. The value is one of the
1709 DW_CC constants. */
1710
1711 ENUM_BITFIELD (dwarf_calling_convention) calling_convention : 8;
1712
ae6ae975
DE
1713 /* * The base class which defined the virtual function table pointer. */
1714
1715 struct type *vptr_basetype;
1716
5e3a2c38
SS
1717 /* * For classes, structures, and unions, a description of each
1718 field, which consists of an overloaded name, followed by the
1719 types of arguments that the method expects, and then the name
1720 after it has been renamed to make it distinct.
c906108c 1721
0963b4bd 1722 fn_fieldlists points to an array of nfn_fields of these. */
c906108c 1723
52059ffd 1724 struct fn_fieldlist *fn_fieldlists;
c906108c 1725
5e3a2c38
SS
1726 /* * typedefs defined inside this class. typedef_field points to
1727 an array of typedef_field_count elements. */
1728
883fd55a 1729 struct decl_field *typedef_field;
5e3a2c38 1730
98751a41 1731 unsigned typedef_field_count;
34eaf542 1732
883fd55a
KS
1733 /* * The nested types defined by this type. nested_types points to
1734 an array of nested_types_count elements. */
1735
1736 struct decl_field *nested_types;
1737
1738 unsigned nested_types_count;
1739
5e3a2c38 1740 /* * The template arguments. This is an array with
34eaf542
TT
1741 N_TEMPLATE_ARGUMENTS elements. This is NULL for non-template
1742 classes. */
5e3a2c38 1743
34eaf542 1744 struct symbol **template_arguments;
c5aa993b 1745 };
c906108c 1746
5e3a2c38
SS
1747/* * Struct used to store conversion rankings. */
1748
6403aeea
SW
1749struct rank
1750 {
a9d5ef47
SW
1751 short rank;
1752
5e3a2c38
SS
1753 /* * When two conversions are of the same type and therefore have
1754 the same rank, subrank is used to differentiate the two.
1755
1756 Eg: Two derived-class-pointer to base-class-pointer conversions
1757 would both have base pointer conversion rank, but the
1758 conversion with the shorter distance to the ancestor is
1759 preferable. 'subrank' would be used to reflect that. */
1760
a9d5ef47 1761 short subrank;
6403aeea
SW
1762 };
1763
82ceee50 1764/* * Used for ranking a function for overload resolution. */
5e3a2c38 1765
82ceee50 1766typedef std::vector<rank> badness_vector;
c906108c 1767
5e3a2c38
SS
1768/* * GNAT Ada-specific information for various Ada types. */
1769
b4ba55a1
JB
1770struct gnat_aux_type
1771 {
5e3a2c38 1772 /* * Parallel type used to encode information about dynamic types
b4ba55a1
JB
1773 used in Ada (such as variant records, variable-size array,
1774 etc). */
1775 struct type* descriptive_type;
1776 };
1777
09e2d7c7 1778/* * For TYPE_CODE_FUNC and TYPE_CODE_METHOD types. */
5e3a2c38 1779
b6cdc2c1
JK
1780struct func_type
1781 {
5e3a2c38
SS
1782 /* * The calling convention for targets supporting multiple ABIs.
1783 Right now this is only fetched from the Dwarf-2
743649fd 1784 DW_AT_calling_convention attribute. The value is one of the
d0922fcf 1785 DW_CC constants. */
5e3a2c38 1786
d0922fcf 1787 ENUM_BITFIELD (dwarf_calling_convention) calling_convention : 8;
743649fd
MW
1788
1789 /* * Whether this function normally returns to its caller. It is
1790 set from the DW_AT_noreturn attribute if set on the
1791 DW_TAG_subprogram. */
1792
1793 unsigned int is_noreturn : 1;
bb984ff1 1794
216f72a1
JK
1795 /* * Only those DW_TAG_call_site's in this function that have
1796 DW_AT_call_tail_call set are linked in this list. Function
5e3a2c38 1797 without its tail call list complete
216f72a1
JK
1798 (DW_AT_call_all_tail_calls or its superset
1799 DW_AT_call_all_calls) has TAIL_CALL_LIST NULL, even if some
1800 DW_TAG_call_site's exist in such function. */
5e3a2c38 1801
bb984ff1 1802 struct call_site *tail_call_list;
09e2d7c7
DE
1803
1804 /* * For method types (TYPE_CODE_METHOD), the aggregate type that
1805 contains the method. */
1806
1807 struct type *self_type;
b6cdc2c1
JK
1808 };
1809
09584414
JB
1810/* The type-specific info for TYPE_CODE_FIXED_POINT types. */
1811
1812struct fixed_point_type_info
1813{
1814 /* The fixed point type's scaling factor. */
1815 gdb_mpq scaling_factor;
1816};
1817
5e3a2c38
SS
1818/* * The default value of TYPE_CPLUS_SPECIFIC(T) points to this shared
1819 static structure. */
c906108c
SS
1820
1821extern const struct cplus_struct_type cplus_struct_default;
1822
a14ed312 1823extern void allocate_cplus_struct_type (struct type *);
c906108c
SS
1824
1825#define INIT_CPLUS_SPECIFIC(type) \
b4ba55a1 1826 (TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_CPLUS_STUFF, \
3e43a32a
MS
1827 TYPE_RAW_CPLUS_SPECIFIC (type) = (struct cplus_struct_type*) \
1828 &cplus_struct_default)
b4ba55a1 1829
c906108c 1830#define ALLOCATE_CPLUS_STRUCT_TYPE(type) allocate_cplus_struct_type (type)
b4ba55a1 1831
c906108c 1832#define HAVE_CPLUS_STRUCT(type) \
b4ba55a1
JB
1833 (TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_CPLUS_STUFF \
1834 && TYPE_RAW_CPLUS_SPECIFIC (type) != &cplus_struct_default)
1835
8ecb59f8
TT
1836#define INIT_NONE_SPECIFIC(type) \
1837 (TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_NONE, \
1838 TYPE_MAIN_TYPE (type)->type_specific = {})
1839
b4ba55a1
JB
1840extern const struct gnat_aux_type gnat_aux_default;
1841
1842extern void allocate_gnat_aux_type (struct type *);
1843
1844#define INIT_GNAT_SPECIFIC(type) \
1845 (TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_GNAT_STUFF, \
1846 TYPE_GNAT_SPECIFIC (type) = (struct gnat_aux_type *) &gnat_aux_default)
1847#define ALLOCATE_GNAT_AUX_TYPE(type) allocate_gnat_aux_type (type)
5e3a2c38 1848/* * A macro that returns non-zero if the type-specific data should be
b4ba55a1
JB
1849 read as "gnat-stuff". */
1850#define HAVE_GNAT_AUX_INFO(type) \
1851 (TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_GNAT_STUFF)
c906108c 1852
8ecb59f8
TT
1853/* * True if TYPE is known to be an Ada type of some kind. */
1854#define ADA_TYPE_P(type) \
1855 (TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_GNAT_STUFF \
1856 || (TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_NONE \
22c4c60c 1857 && (type)->is_fixed_instance ()))
8ecb59f8 1858
b6cdc2c1
JK
1859#define INIT_FUNC_SPECIFIC(type) \
1860 (TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_FUNC, \
224c3ddb
SM
1861 TYPE_MAIN_TYPE (type)->type_specific.func_stuff = (struct func_type *) \
1862 TYPE_ZALLOC (type, \
1863 sizeof (*TYPE_MAIN_TYPE (type)->type_specific.func_stuff)))
b6cdc2c1 1864
09584414
JB
1865/* "struct fixed_point_type_info" has a field that has a destructor.
1866 See allocate_fixed_point_type_info to understand how this is
1867 handled. */
1868#define INIT_FIXED_POINT_SPECIFIC(type) \
1869 (TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_FIXED_POINT, \
2a12c336 1870 allocate_fixed_point_type_info (type))
09584414 1871
2fdde8f8 1872#define TYPE_MAIN_TYPE(thistype) (thistype)->main_type
c906108c
SS
1873#define TYPE_POINTER_TYPE(thistype) (thistype)->pointer_type
1874#define TYPE_REFERENCE_TYPE(thistype) (thistype)->reference_type
f9aeb8d4 1875#define TYPE_RVALUE_REFERENCE_TYPE(thistype) (thistype)->rvalue_reference_type
2fdde8f8 1876#define TYPE_CHAIN(thistype) (thistype)->chain
2b4424c3
TT
1877
1878/* * Return the alignment of the type in target addressable memory
1879 units, or 0 if no alignment was specified. */
1880#define TYPE_RAW_ALIGN(thistype) type_raw_align (thistype)
1881
1882/* * Return the alignment of the type in target addressable memory
1883 units, or 0 if no alignment was specified. */
1884extern unsigned type_raw_align (struct type *);
1885
1886/* * Return the alignment of the type in target addressable memory
1887 units. Return 0 if the alignment cannot be determined; but note
1888 that this makes an effort to compute the alignment even it it was
1889 not specified in the debug info. */
1890extern unsigned type_align (struct type *);
1891
1892/* * Set the alignment of the type. The alignment must be a power of
1893 2. Returns false if the given value does not fit in the available
1894 space in struct type. */
1895extern bool set_type_align (struct type *, ULONGEST);
1896
d9823cbb 1897/* Property accessors for the type data location. */
3cdcd0ce 1898#define TYPE_DATA_LOCATION(thistype) \
24e99c6c 1899 ((thistype)->dyn_prop (DYN_PROP_DATA_LOCATION))
3cdcd0ce
JB
1900#define TYPE_DATA_LOCATION_BATON(thistype) \
1901 TYPE_DATA_LOCATION (thistype)->data.baton
1902#define TYPE_DATA_LOCATION_ADDR(thistype) \
8c2e4e06 1903 (TYPE_DATA_LOCATION (thistype)->const_val ())
3cdcd0ce 1904#define TYPE_DATA_LOCATION_KIND(thistype) \
8c2e4e06 1905 (TYPE_DATA_LOCATION (thistype)->kind ())
f8e89861 1906#define TYPE_DYNAMIC_LENGTH(thistype) \
24e99c6c 1907 ((thistype)->dyn_prop (DYN_PROP_BYTE_SIZE))
3cdcd0ce 1908
3f2f83dd
KB
1909/* Property accessors for the type allocated/associated. */
1910#define TYPE_ALLOCATED_PROP(thistype) \
24e99c6c 1911 ((thistype)->dyn_prop (DYN_PROP_ALLOCATED))
3f2f83dd 1912#define TYPE_ASSOCIATED_PROP(thistype) \
24e99c6c 1913 ((thistype)->dyn_prop (DYN_PROP_ASSOCIATED))
df7a7bdd 1914#define TYPE_RANK_PROP(thistype) \
1915 ((thistype)->dyn_prop (DYN_PROP_RANK))
3f2f83dd 1916
c906108c
SS
1917/* C++ */
1918
09e2d7c7
DE
1919#define TYPE_SELF_TYPE(thistype) internal_type_self_type (thistype)
1920/* Do not call this, use TYPE_SELF_TYPE. */
1921extern struct type *internal_type_self_type (struct type *);
1922extern void set_type_self_type (struct type *, struct type *);
1923
ae6ae975
DE
1924extern int internal_type_vptr_fieldno (struct type *);
1925extern void set_type_vptr_fieldno (struct type *, int);
1926extern struct type *internal_type_vptr_basetype (struct type *);
1927extern void set_type_vptr_basetype (struct type *, struct type *);
1928#define TYPE_VPTR_FIELDNO(thistype) internal_type_vptr_fieldno (thistype)
1929#define TYPE_VPTR_BASETYPE(thistype) internal_type_vptr_basetype (thistype)
1930
c906108c 1931#define TYPE_NFN_FIELDS(thistype) TYPE_CPLUS_SPECIFIC(thistype)->nfn_fields
b4ba55a1
JB
1932#define TYPE_SPECIFIC_FIELD(thistype) \
1933 TYPE_MAIN_TYPE(thistype)->type_specific_field
b4ba55a1
JB
1934/* We need this tap-dance with the TYPE_RAW_SPECIFIC because of the case
1935 where we're trying to print an Ada array using the C language.
1936 In that case, there is no "cplus_stuff", but the C language assumes
1937 that there is. What we do, in that case, is pretend that there is
1938 an implicit one which is the default cplus stuff. */
1939#define TYPE_CPLUS_SPECIFIC(thistype) \
1940 (!HAVE_CPLUS_STRUCT(thistype) \
1941 ? (struct cplus_struct_type*)&cplus_struct_default \
1942 : TYPE_RAW_CPLUS_SPECIFIC(thistype))
1943#define TYPE_RAW_CPLUS_SPECIFIC(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.cplus_stuff
e35000a7
TBA
1944#define TYPE_CPLUS_CALLING_CONVENTION(thistype) \
1945 TYPE_MAIN_TYPE(thistype)->type_specific.cplus_stuff->calling_convention
2fdde8f8 1946#define TYPE_FLOATFORMAT(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.floatformat
b4ba55a1
JB
1947#define TYPE_GNAT_SPECIFIC(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.gnat_stuff
1948#define TYPE_DESCRIPTIVE_TYPE(thistype) TYPE_GNAT_SPECIFIC(thistype)->descriptive_type
b6cdc2c1 1949#define TYPE_CALLING_CONVENTION(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.func_stuff->calling_convention
743649fd 1950#define TYPE_NO_RETURN(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.func_stuff->is_noreturn
bb984ff1 1951#define TYPE_TAIL_CALL_LIST(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.func_stuff->tail_call_list
940da03e 1952#define TYPE_BASECLASS(thistype,index) ((thistype)->field (index).type ())
c906108c 1953#define TYPE_N_BASECLASSES(thistype) TYPE_CPLUS_SPECIFIC(thistype)->n_baseclasses
33d16dd9 1954#define TYPE_BASECLASS_NAME(thistype,index) (thistype->field (index).name ())
b610c045 1955#define TYPE_BASECLASS_BITPOS(thistype,index) (thistype->field (index).loc_bitpos ())
c906108c 1956#define BASETYPE_VIA_PUBLIC(thistype, index) \
c3842cbe 1957 ((thistype)->field (index).is_public ())
d48cc9dd 1958#define TYPE_CPLUS_DYNAMIC(thistype) TYPE_CPLUS_SPECIFIC (thistype)->is_dynamic
c906108c
SS
1959
1960#define BASETYPE_VIA_VIRTUAL(thistype, index) \
61461a5b
TT
1961 ((thistype)->field (index).is_virtual ())
1962
c906108c
SS
1963#define TYPE_FN_FIELDLISTS(thistype) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists
1964#define TYPE_FN_FIELDLIST(thistype, n) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists[n]
1965#define TYPE_FN_FIELDLIST1(thistype, n) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists[n].fn_fields
1966#define TYPE_FN_FIELDLIST_NAME(thistype, n) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists[n].name
1967#define TYPE_FN_FIELDLIST_LENGTH(thistype, n) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists[n].length
1968
34eaf542
TT
1969#define TYPE_N_TEMPLATE_ARGUMENTS(thistype) \
1970 TYPE_CPLUS_SPECIFIC (thistype)->n_template_arguments
1971#define TYPE_TEMPLATE_ARGUMENTS(thistype) \
1972 TYPE_CPLUS_SPECIFIC (thistype)->template_arguments
1973#define TYPE_TEMPLATE_ARGUMENT(thistype, n) \
1974 TYPE_CPLUS_SPECIFIC (thistype)->template_arguments[n]
1975
c906108c
SS
1976#define TYPE_FN_FIELD(thisfn, n) (thisfn)[n]
1977#define TYPE_FN_FIELD_PHYSNAME(thisfn, n) (thisfn)[n].physname
1978#define TYPE_FN_FIELD_TYPE(thisfn, n) (thisfn)[n].type
80fc5e77 1979#define TYPE_FN_FIELD_ARGS(thisfn, n) (((thisfn)[n].type)->fields ())
c906108c
SS
1980#define TYPE_FN_FIELD_CONST(thisfn, n) ((thisfn)[n].is_const)
1981#define TYPE_FN_FIELD_VOLATILE(thisfn, n) ((thisfn)[n].is_volatile)
5028c9e2
TT
1982#define TYPE_FN_FIELD_PRIVATE(thisfn, n) \
1983 ((thisfn)[n].accessibility == accessibility::PRIVATE)
1984#define TYPE_FN_FIELD_PROTECTED(thisfn, n) \
1985 ((thisfn)[n].accessibility == accessibility::PROTECTED)
b02dede2 1986#define TYPE_FN_FIELD_ARTIFICIAL(thisfn, n) ((thisfn)[n].is_artificial)
c906108c 1987#define TYPE_FN_FIELD_STUB(thisfn, n) ((thisfn)[n].is_stub)
7d27a96d 1988#define TYPE_FN_FIELD_CONSTRUCTOR(thisfn, n) ((thisfn)[n].is_constructor)
c906108c
SS
1989#define TYPE_FN_FIELD_FCONTEXT(thisfn, n) ((thisfn)[n].fcontext)
1990#define TYPE_FN_FIELD_VOFFSET(thisfn, n) ((thisfn)[n].voffset-2)
1991#define TYPE_FN_FIELD_VIRTUAL_P(thisfn, n) ((thisfn)[n].voffset > 1)
1992#define TYPE_FN_FIELD_STATIC_P(thisfn, n) ((thisfn)[n].voffset == VOFFSET_STATIC)
e35000a7
TBA
1993#define TYPE_FN_FIELD_DEFAULTED(thisfn, n) ((thisfn)[n].defaulted)
1994#define TYPE_FN_FIELD_DELETED(thisfn, n) ((thisfn)[n].is_deleted)
c906108c 1995
c191a687 1996/* Accessors for typedefs defined by a class. */
98751a41
JK
1997#define TYPE_TYPEDEF_FIELD_ARRAY(thistype) \
1998 TYPE_CPLUS_SPECIFIC (thistype)->typedef_field
1999#define TYPE_TYPEDEF_FIELD(thistype, n) \
2000 TYPE_CPLUS_SPECIFIC (thistype)->typedef_field[n]
2001#define TYPE_TYPEDEF_FIELD_NAME(thistype, n) \
2002 TYPE_TYPEDEF_FIELD (thistype, n).name
2003#define TYPE_TYPEDEF_FIELD_TYPE(thistype, n) \
2004 TYPE_TYPEDEF_FIELD (thistype, n).type
2005#define TYPE_TYPEDEF_FIELD_COUNT(thistype) \
2006 TYPE_CPLUS_SPECIFIC (thistype)->typedef_field_count
c191a687 2007#define TYPE_TYPEDEF_FIELD_PROTECTED(thistype, n) \
5028c9e2 2008 (TYPE_TYPEDEF_FIELD (thistype, n).accessibility == accessibility::PROTECTED)
c191a687 2009#define TYPE_TYPEDEF_FIELD_PRIVATE(thistype, n) \
5028c9e2 2010 (TYPE_TYPEDEF_FIELD (thistype, n).accessibility == accessibility::PRIVATE)
98751a41 2011
883fd55a
KS
2012#define TYPE_NESTED_TYPES_ARRAY(thistype) \
2013 TYPE_CPLUS_SPECIFIC (thistype)->nested_types
2014#define TYPE_NESTED_TYPES_FIELD(thistype, n) \
2015 TYPE_CPLUS_SPECIFIC (thistype)->nested_types[n]
2016#define TYPE_NESTED_TYPES_FIELD_NAME(thistype, n) \
2017 TYPE_NESTED_TYPES_FIELD (thistype, n).name
2018#define TYPE_NESTED_TYPES_FIELD_TYPE(thistype, n) \
2019 TYPE_NESTED_TYPES_FIELD (thistype, n).type
2020#define TYPE_NESTED_TYPES_COUNT(thistype) \
2021 TYPE_CPLUS_SPECIFIC (thistype)->nested_types_count
2022#define TYPE_NESTED_TYPES_FIELD_PROTECTED(thistype, n) \
5028c9e2
TT
2023 (TYPE_NESTED_TYPES_FIELD (thistype, n).accessibility \
2024 == accessibility::PROTECTED)
883fd55a 2025#define TYPE_NESTED_TYPES_FIELD_PRIVATE(thistype, n) \
5028c9e2
TT
2026 (TYPE_NESTED_TYPES_FIELD (thistype, n).accessibility \
2027 == accessibility::PRIVATE)
883fd55a 2028
4e4666e6 2029#define TYPE_IS_OPAQUE(thistype) \
78134374
SM
2030 ((((thistype)->code () == TYPE_CODE_STRUCT) \
2031 || ((thistype)->code () == TYPE_CODE_UNION)) \
1f704f76 2032 && ((thistype)->num_fields () == 0) \
4e4666e6
DE
2033 && (!HAVE_CPLUS_STRUCT (thistype) \
2034 || TYPE_NFN_FIELDS (thistype) == 0) \
3f46044c 2035 && ((thistype)->is_stub () || !(thistype)->stub_is_supported ()))
c5aa993b 2036
5e3a2c38
SS
2037/* * A helper macro that returns the name of a type or "unnamed type"
2038 if the type has no name. */
2039
0a07729b 2040#define TYPE_SAFE_NAME(type) \
7d93a1e0 2041 (type->name () != nullptr ? type->name () : _("<unnamed type>"))
0a07729b 2042
5e3a2c38
SS
2043/* * A helper macro that returns the name of an error type. If the
2044 type has a name, it is used; otherwise, a default is used. */
2045
b00fdb78 2046#define TYPE_ERROR_NAME(type) \
7d93a1e0 2047 (type->name () ? type->name () : _("<error type>"))
b00fdb78 2048
0db7851f
UW
2049/* Given TYPE, return its floatformat. */
2050const struct floatformat *floatformat_from_type (const struct type *type);
2051
000177f0
AC
2052struct builtin_type
2053{
46bf5051
UW
2054 /* Integral types. */
2055
b021a221 2056 /* Implicit size/sign (based on the architecture's ABI). */
cb275538
TT
2057 struct type *builtin_void = nullptr;
2058 struct type *builtin_char = nullptr;
2059 struct type *builtin_short = nullptr;
2060 struct type *builtin_int = nullptr;
2061 struct type *builtin_long = nullptr;
2062 struct type *builtin_signed_char = nullptr;
2063 struct type *builtin_unsigned_char = nullptr;
2064 struct type *builtin_unsigned_short = nullptr;
2065 struct type *builtin_unsigned_int = nullptr;
2066 struct type *builtin_unsigned_long = nullptr;
2067 struct type *builtin_bfloat16 = nullptr;
2068 struct type *builtin_half = nullptr;
2069 struct type *builtin_float = nullptr;
2070 struct type *builtin_double = nullptr;
2071 struct type *builtin_long_double = nullptr;
2072 struct type *builtin_complex = nullptr;
2073 struct type *builtin_double_complex = nullptr;
2074 struct type *builtin_string = nullptr;
2075 struct type *builtin_bool = nullptr;
2076 struct type *builtin_long_long = nullptr;
2077 struct type *builtin_unsigned_long_long = nullptr;
2078 struct type *builtin_decfloat = nullptr;
2079 struct type *builtin_decdouble = nullptr;
2080 struct type *builtin_declong = nullptr;
46bf5051 2081
69feb676
UW
2082 /* "True" character types.
2083 We use these for the '/c' print format, because c_char is just a
2084 one-byte integral type, which languages less laid back than C
2085 will print as ... well, a one-byte integral type. */
cb275538
TT
2086 struct type *builtin_true_char = nullptr;
2087 struct type *builtin_true_unsigned_char = nullptr;
69feb676 2088
df4df182
UW
2089 /* Explicit sizes - see C9X <intypes.h> for naming scheme. The "int0"
2090 is for when an architecture needs to describe a register that has
2091 no size. */
cb275538
TT
2092 struct type *builtin_int0 = nullptr;
2093 struct type *builtin_int8 = nullptr;
2094 struct type *builtin_uint8 = nullptr;
2095 struct type *builtin_int16 = nullptr;
2096 struct type *builtin_uint16 = nullptr;
2097 struct type *builtin_int24 = nullptr;
2098 struct type *builtin_uint24 = nullptr;
2099 struct type *builtin_int32 = nullptr;
2100 struct type *builtin_uint32 = nullptr;
2101 struct type *builtin_int64 = nullptr;
2102 struct type *builtin_uint64 = nullptr;
2103 struct type *builtin_int128 = nullptr;
2104 struct type *builtin_uint128 = nullptr;
df4df182 2105
9a22f0d0 2106 /* Wide character types. */
cb275538
TT
2107 struct type *builtin_char16 = nullptr;
2108 struct type *builtin_char32 = nullptr;
2109 struct type *builtin_wchar = nullptr;
46bf5051
UW
2110
2111 /* Pointer types. */
000177f0 2112
5e3a2c38 2113 /* * `pointer to data' type. Some target platforms use an implicitly
000177f0 2114 {sign,zero} -extended 32-bit ABI pointer on a 64-bit ISA. */
cb275538 2115 struct type *builtin_data_ptr = nullptr;
000177f0 2116
5e3a2c38 2117 /* * `pointer to function (returning void)' type. Harvard
000177f0
AC
2118 architectures mean that ABI function and code pointers are not
2119 interconvertible. Similarly, since ANSI, C standards have
2120 explicitly said that pointers to functions and pointers to data
2121 are not interconvertible --- that is, you can't cast a function
2122 pointer to void * and back, and expect to get the same value.
2123 However, all function pointer types are interconvertible, so void
2124 (*) () can server as a generic function pointer. */
5e3a2c38 2125
cb275538 2126 struct type *builtin_func_ptr = nullptr;
78267919 2127
5e3a2c38 2128 /* * `function returning pointer to function (returning void)' type.
0875794a 2129 The final void return type is not significant for it. */
0875794a 2130
cb275538 2131 struct type *builtin_func_func = nullptr;
78267919
UW
2132
2133 /* Special-purpose types. */
2134
5e3a2c38
SS
2135 /* * This type is used to represent a GDB internal function. */
2136
cb275538 2137 struct type *internal_fn = nullptr;
e81e7f5e
SC
2138
2139 /* * This type is used to represent an xmethod. */
cb275538 2140 struct type *xmethod = nullptr;
a9a775da
TT
2141
2142 /* * This type is used to represent symbol addresses. */
2143 struct type *builtin_core_addr = nullptr;
2144
2145 /* * This type represents a type that was unrecognized in symbol
2146 read-in. */
2147 struct type *builtin_error = nullptr;
2148
2149 /* * Types used for symbols with no debug information. */
2150 struct type *nodebug_text_symbol = nullptr;
2151 struct type *nodebug_text_gnu_ifunc_symbol = nullptr;
2152 struct type *nodebug_got_plt_symbol = nullptr;
2153 struct type *nodebug_data_symbol = nullptr;
2154 struct type *nodebug_unknown_symbol = nullptr;
2155 struct type *nodebug_tls_symbol = nullptr;
46bf5051 2156};
000177f0 2157
5e3a2c38 2158/* * Return the type table for the specified architecture. */
64c50499 2159
5e3a2c38 2160extern const struct builtin_type *builtin_type (struct gdbarch *gdbarch);
64c50499 2161
5e3a2c38 2162/* * Return the type table for the specified objfile. */
c5aa993b 2163
2d1bc552 2164extern const struct builtin_type *builtin_type (struct objfile *objfile);
5674de60 2165
598f52df 2166/* Explicit floating-point formats. See "floatformat.h". */
f9e9243a 2167extern const struct floatformat *floatformats_ieee_half[BFD_ENDIAN_UNKNOWN];
8da61cc4
DJ
2168extern const struct floatformat *floatformats_ieee_single[BFD_ENDIAN_UNKNOWN];
2169extern const struct floatformat *floatformats_ieee_double[BFD_ENDIAN_UNKNOWN];
552f1157 2170extern const struct floatformat *floatformats_ieee_quad[BFD_ENDIAN_UNKNOWN];
8da61cc4
DJ
2171extern const struct floatformat *floatformats_ieee_double_littlebyte_bigword[BFD_ENDIAN_UNKNOWN];
2172extern const struct floatformat *floatformats_i387_ext[BFD_ENDIAN_UNKNOWN];
2173extern const struct floatformat *floatformats_m68881_ext[BFD_ENDIAN_UNKNOWN];
2174extern const struct floatformat *floatformats_arm_ext[BFD_ENDIAN_UNKNOWN];
2175extern const struct floatformat *floatformats_ia64_spill[BFD_ENDIAN_UNKNOWN];
8da61cc4
DJ
2176extern const struct floatformat *floatformats_vax_f[BFD_ENDIAN_UNKNOWN];
2177extern const struct floatformat *floatformats_vax_d[BFD_ENDIAN_UNKNOWN];
b14d30e1 2178extern const struct floatformat *floatformats_ibm_long_double[BFD_ENDIAN_UNKNOWN];
2a67f09d 2179extern const struct floatformat *floatformats_bfloat16[BFD_ENDIAN_UNKNOWN];
fde6c819 2180
2fabdf33 2181/* Allocate space for storing data associated with a particular
5e3a2c38
SS
2182 type. We ensure that the space is allocated using the same
2183 mechanism that was used to allocate the space for the type
2184 structure itself. I.e. if the type is on an objfile's
2185 objfile_obstack, then the space for data associated with that type
2fabdf33
AB
2186 will also be allocated on the objfile_obstack. If the type is
2187 associated with a gdbarch, then the space for data associated with that
2188 type will also be allocated on the gdbarch_obstack.
2189
2190 If a type is not associated with neither an objfile or a gdbarch then
2191 you should not use this macro to allocate space for data, instead you
2192 should call xmalloc directly, and ensure the memory is correctly freed
2193 when it is no longer needed. */
2194
2195#define TYPE_ALLOC(t,size) \
30625020 2196 (obstack_alloc (((t)->is_objfile_owned () \
6ac37371
SM
2197 ? &((t)->objfile_owner ()->objfile_obstack) \
2198 : gdbarch_obstack ((t)->arch_owner ())), \
dda83cd7 2199 size))
2fabdf33
AB
2200
2201
2202/* See comment on TYPE_ALLOC. */
2203
2204#define TYPE_ZALLOC(t,size) (memset (TYPE_ALLOC (t, size), 0, size))
ae5a43e0 2205
5e3a2c38 2206/* * This returns the target type (or NULL) of TYPE, also skipping
99ad9427 2207 past typedefs. */
5e3a2c38 2208
99ad9427
YQ
2209extern struct type *get_target_type (struct type *type);
2210
2e056931
SM
2211/* Return the equivalent of TYPE_LENGTH, but in number of target
2212 addressable memory units of the associated gdbarch instead of bytes. */
2213
2214extern unsigned int type_length_units (struct type *type);
2215
6a4d297c
TT
2216/* An object of this type is passed when allocating certain types. It
2217 determines where the new type is allocated. Ultimately a type is
2218 either allocated on a on an objfile obstack or on a gdbarch
2219 obstack. However, it's also possible to request that a new type be
2220 allocated on the same obstack as some existing type, or that a
2221 "new" type instead overwrite a supplied type object. */
2222
2223class type_allocator
2224{
2225public:
2226
2227 /* Create new types on OBJFILE. */
76fc0f62
TT
2228 type_allocator (objfile *objfile, enum language lang)
2229 : m_is_objfile (true),
2230 m_lang (lang)
6a4d297c
TT
2231 {
2232 m_data.objfile = objfile;
2233 }
2234
2235 /* Create new types on GDBARCH. */
2236 explicit type_allocator (gdbarch *gdbarch)
76fc0f62 2237 : m_lang (language_minimal)
6a4d297c
TT
2238 {
2239 m_data.gdbarch = gdbarch;
2240 }
2241
2242 /* This determines whether a passed-in type should be rewritten in
2243 place, or whether it should simply determine where the new type
2244 is created. */
2245 enum type_allocator_kind
2246 {
2247 /* Allocate on same obstack as existing type. */
2248 SAME = 0,
2249 /* Smash the existing type. */
2250 SMASH = 1,
2251 };
2252
2253 /* Create new types either on the same obstack as TYPE; or if SMASH
2254 is passed, overwrite TYPE. */
2255 explicit type_allocator (struct type *type,
2256 type_allocator_kind kind = SAME)
76fc0f62 2257 : m_lang (type->language ())
6a4d297c
TT
2258 {
2259 if (kind == SAME)
2260 {
2261 if (type->is_objfile_owned ())
2262 {
2263 m_data.objfile = type->objfile_owner ();
2264 m_is_objfile = true;
2265 }
2266 else
2267 m_data.gdbarch = type->arch_owner ();
2268 }
2269 else
2270 {
2271 m_smash = true;
2272 m_data.type = type;
2273 }
2274 }
2275
2276 /* Create new types on the same obstack as TYPE. */
2277 explicit type_allocator (const struct type *type)
76fc0f62
TT
2278 : m_is_objfile (type->is_objfile_owned ()),
2279 m_lang (type->language ())
6a4d297c
TT
2280 {
2281 if (type->is_objfile_owned ())
2282 m_data.objfile = type->objfile_owner ();
2283 else
2284 m_data.gdbarch = type->arch_owner ();
2285 }
2286
2287 /* Create a new type on the desired obstack. Note that a "new" type
2288 is not created if type-smashing was selected at construction. */
2289 type *new_type ();
2290
2291 /* Create a new type on the desired obstack, and fill in its code,
2292 length, and name. If NAME is non-null, it is copied to the
2293 destination obstack first. Note that a "new" type is not created
2294 if type-smashing was selected at construction. */
2295 type *new_type (enum type_code code, int bit, const char *name);
2296
2297 /* Return the architecture associated with this allocator. This
2298 comes from whatever object was supplied to the constructor. */
2299 gdbarch *arch ();
2300
2301private:
2302
2303 /* Where the type should wind up. */
2304 union
2305 {
2306 struct objfile *objfile;
2307 struct gdbarch *gdbarch;
2308 struct type *type;
2309 } m_data {};
2310
2311 /* True if this allocator uses the objfile field above. */
2312 bool m_is_objfile = false;
2313 /* True if this allocator uses the type field above, indicating that
2314 the "allocation" should be done in-place. */
2315 bool m_smash = false;
76fc0f62
TT
2316 /* The language for types created by this allocator. */
2317 enum language m_lang;
6a4d297c
TT
2318};
2319
2d39ccd3
TT
2320/* Allocate a TYPE_CODE_INT type structure using ALLOC. BIT is the
2321 type size in bits. If UNSIGNED_P is non-zero, set the type's
2322 TYPE_UNSIGNED flag. NAME is the type name. */
5e3a2c38 2323
2d39ccd3
TT
2324extern struct type *init_integer_type (type_allocator &alloc, int bit,
2325 int unsigned_p, const char *name);
f50b437c
TT
2326
2327/* Allocate a TYPE_CODE_CHAR type structure using ALLOC. BIT is the
2328 type size in bits. If UNSIGNED_P is non-zero, set the type's
2329 TYPE_UNSIGNED flag. NAME is the type name. */
2330
2331extern struct type *init_character_type (type_allocator &alloc, int bit,
2332 int unsigned_p, const char *name);
46c04ea3
TT
2333
2334/* Allocate a TYPE_CODE_BOOL type structure using ALLOC. BIT is the
2335 type size in bits. If UNSIGNED_P is non-zero, set the type's
2336 TYPE_UNSIGNED flag. NAME is the type name. */
2337
2338extern struct type *init_boolean_type (type_allocator &alloc, int bit,
2339 int unsigned_p, const char *name);
2340
77c5f496
TT
2341/* Allocate a TYPE_CODE_FLT type structure using ALLOC.
2342 BIT is the type size in bits; if BIT equals -1, the size is
2343 determined by the floatformat. NAME is the type name. Set the
2344 TYPE_FLOATFORMAT from FLOATFORMATS. BYTE_ORDER is the byte order
2345 to use. If it is BFD_ENDIAN_UNKNOWN (the default), then the byte
2346 order of the objfile's architecture is used. */
2347
2348extern struct type *init_float_type
2349 (type_allocator &alloc, int bit, const char *name,
2350 const struct floatformat **floatformats,
2351 enum bfd_endian byte_order = BFD_ENDIAN_UNKNOWN);
2352
0776344a
TT
2353/* Allocate a TYPE_CODE_DECFLOAT type structure using ALLOC.
2354 BIT is the type size in bits. NAME is the type name. */
2355
2356extern struct type *init_decfloat_type (type_allocator &alloc, int bit,
2357 const char *name);
2358
ae710496 2359extern bool can_create_complex_type (struct type *);
5b930b45 2360extern struct type *init_complex_type (const char *, struct type *);
9c794d2d
TT
2361
2362/* Allocate a TYPE_CODE_PTR type structure using ALLOC.
2363 BIT is the pointer type size in bits. NAME is the type name.
2364 TARGET_TYPE is the pointer target type. Always sets the pointer type's
2365 TYPE_UNSIGNED flag. */
2366
2367extern struct type *init_pointer_type (type_allocator &alloc, int bit,
2368 const char *name,
2369 struct type *target_type);
2370
d5592272 2371extern struct type *init_fixed_point_type (type_allocator &, int, int,
09584414 2372 const char *);
c906108c 2373
0e101458 2374/* Helper functions to construct a struct or record type. An
e9bb382b 2375 initially empty type is created using arch_composite_type().
eb90ce83 2376 Fields are then added using append_composite_type_field*(). A union
0e101458
AC
2377 type has its size set to the largest field. A struct type has each
2378 field packed against the previous. */
2379
e9bb382b 2380extern struct type *arch_composite_type (struct gdbarch *gdbarch,
695bfa52
TT
2381 const char *name, enum type_code code);
2382extern void append_composite_type_field (struct type *t, const char *name,
0e101458 2383 struct type *field);
4aa995e1 2384extern void append_composite_type_field_aligned (struct type *t,
695bfa52 2385 const char *name,
4aa995e1
PA
2386 struct type *field,
2387 int alignment);
695bfa52 2388struct field *append_composite_type_field_raw (struct type *t, const char *name,
f5dff777 2389 struct type *field);
0e101458 2390
4f2aea11 2391/* Helper functions to construct a bit flags type. An initially empty
e9bb382b 2392 type is created using arch_flag_type(). Flags are then added using
81516450 2393 append_flag_type_field() and append_flag_type_flag(). */
e9bb382b 2394extern struct type *arch_flags_type (struct gdbarch *gdbarch,
77b7c781 2395 const char *name, int bit);
81516450
DE
2396extern void append_flags_type_field (struct type *type,
2397 int start_bitpos, int nr_bits,
695bfa52
TT
2398 struct type *field_type, const char *name);
2399extern void append_flags_type_flag (struct type *type, int bitpos,
2400 const char *name);
4f2aea11 2401
ea37ba09 2402extern void make_vector_type (struct type *array_type);
794ac428
UW
2403extern struct type *init_vector_type (struct type *elt_type, int n);
2404
3b224330
AV
2405extern struct type *lookup_reference_type (struct type *, enum type_code);
2406extern struct type *lookup_lvalue_reference_type (struct type *);
2407extern struct type *lookup_rvalue_reference_type (struct type *);
c906108c 2408
3b224330
AV
2409
2410extern struct type *make_reference_type (struct type *, struct type **,
dda83cd7 2411 enum type_code);
c906108c 2412
a14ed312 2413extern struct type *make_cv_type (int, int, struct type *, struct type **);
c906108c 2414
06d66ee9
TT
2415extern struct type *make_restrict_type (struct type *);
2416
f1660027
TT
2417extern struct type *make_unqualified_type (struct type *);
2418
a2c2acaf
MW
2419extern struct type *make_atomic_type (struct type *);
2420
dd6bda65
DJ
2421extern void replace_type (struct type *, struct type *);
2422
69896a2c
PA
2423extern type_instance_flags address_space_name_to_type_instance_flags
2424 (struct gdbarch *, const char *);
47663de5 2425
69896a2c
PA
2426extern const char *address_space_type_instance_flags_to_name
2427 (struct gdbarch *, type_instance_flags);
47663de5 2428
314ad88d
PA
2429extern struct type *make_type_with_address_space
2430 (struct type *type, type_instance_flags space_identifier);
47663de5 2431
0d5de010
DJ
2432extern struct type *lookup_memberptr_type (struct type *, struct type *);
2433
2434extern struct type *lookup_methodptr_type (struct type *);
c906108c 2435
09e2d7c7 2436extern void smash_to_method_type (struct type *type, struct type *self_type,
0d5de010
DJ
2437 struct type *to_type, struct field *args,
2438 int nargs, int varargs);
c906108c 2439
0d5de010
DJ
2440extern void smash_to_memberptr_type (struct type *, struct type *,
2441 struct type *);
c906108c 2442
0b92b5bb
TT
2443extern void smash_to_methodptr_type (struct type *, struct type *);
2444
a737d952 2445extern const char *type_name_or_error (struct type *type);
d8228535 2446
ef0bd204
JB
2447struct struct_elt
2448{
2449 /* The field of the element, or NULL if no element was found. */
2450 struct field *field;
2451
2452 /* The bit offset of the element in the parent structure. */
2453 LONGEST offset;
2454};
2455
2456/* Given a type TYPE, lookup the field and offset of the component named
2457 NAME.
2458
2459 TYPE can be either a struct or union, or a pointer or reference to
2460 a struct or union. If it is a pointer or reference, its target
33b5899f 2461 type is automatically used. Thus '.' and '->' are interchangeable,
ef0bd204
JB
2462 as specified for the definitions of the expression element types
2463 STRUCTOP_STRUCT and STRUCTOP_PTR.
2464
2465 If NOERR is nonzero, the returned structure will have field set to
2466 NULL if there is no component named NAME.
2467
2468 If the component NAME is a field in an anonymous substructure of
2469 TYPE, the returned offset is a "global" offset relative to TYPE
2470 rather than an offset within the substructure. */
2471
2472extern struct_elt lookup_struct_elt (struct type *, const char *, int);
2473
2474/* Given a type TYPE, lookup the type of the component named NAME.
2475
2476 TYPE can be either a struct or union, or a pointer or reference to
2477 a struct or union. If it is a pointer or reference, its target
33b5899f 2478 type is automatically used. Thus '.' and '->' are interchangeable,
ef0bd204
JB
2479 as specified for the definitions of the expression element types
2480 STRUCTOP_STRUCT and STRUCTOP_PTR.
2481
2482 If NOERR is nonzero, return NULL if there is no component named
2483 NAME. */
2484
d7561cbb 2485extern struct type *lookup_struct_elt_type (struct type *, const char *, int);
c906108c 2486
a14ed312 2487extern struct type *make_pointer_type (struct type *, struct type **);
c906108c 2488
a14ed312 2489extern struct type *lookup_pointer_type (struct type *);
c906108c 2490
0c8b41f1 2491extern struct type *make_function_type (struct type *, struct type **);
c906108c 2492
a14ed312 2493extern struct type *lookup_function_type (struct type *);
c906108c 2494
71918a86
TT
2495extern struct type *lookup_function_type_with_arguments (struct type *,
2496 int,
2497 struct type **);
2498
e727c536
TT
2499/* Create a range type using ALLOC.
2500
2501 Indices will be of type INDEX_TYPE, and will range from LOW_BOUND
2502 to HIGH_BOUND, inclusive. */
2503
2504extern struct type *create_static_range_type (type_allocator &alloc,
2505 struct type *index_type,
2506 LONGEST low_bound,
2507 LONGEST high_bound);
c906108c 2508
9e76b17a
TT
2509/* Create an array type using ALLOC.
2510
2511 Elements will be of type ELEMENT_TYPE, the indices will be of type
2512 RANGE_TYPE.
2513
2514 BYTE_STRIDE_PROP, when not NULL, provides the array's byte stride.
2515 This byte stride property is added to the resulting array type
2516 as a DYN_PROP_BYTE_STRIDE. As a consequence, the BYTE_STRIDE_PROP
2517 argument can only be used to create types that are objfile-owned
2518 (see add_dyn_prop), meaning that either this function must be called
2519 with an objfile-owned RESULT_TYPE, or an objfile-owned RANGE_TYPE.
2520
2521 BIT_STRIDE is taken into account only when BYTE_STRIDE_PROP is NULL.
2522 If BIT_STRIDE is not zero, build a packed array type whose element
2523 size is BIT_STRIDE. Otherwise, ignore this parameter. */
729efb13 2524
dc53a7ad 2525extern struct type *create_array_type_with_stride
9e76b17a
TT
2526 (type_allocator &alloc, struct type *element_type,
2527 struct type *range_type, struct dynamic_prop *byte_stride_prop,
2528 unsigned int bit_stride);
dc53a7ad 2529
e727c536
TT
2530/* Create a range type using ALLOC with a dynamic range from LOW_BOUND
2531 to HIGH_BOUND, inclusive. INDEX_TYPE is the underlying type. BIAS
2532 is the bias to be applied when storing or retrieving values of this
2533 type. */
2534
2535extern struct type *create_range_type (type_allocator &alloc,
2536 struct type *index_type,
2537 const struct dynamic_prop *low_bound,
2538 const struct dynamic_prop *high_bound,
2539 LONGEST bias);
729efb13 2540
5bbd8269
AB
2541/* Like CREATE_RANGE_TYPE but also sets up a stride. When BYTE_STRIDE_P
2542 is true the value in STRIDE is a byte stride, otherwise STRIDE is a bit
2543 stride. */
2544
e727c536
TT
2545extern struct type *create_range_type_with_stride
2546 (type_allocator &alloc, struct type *index_type,
5bbd8269
AB
2547 const struct dynamic_prop *low_bound,
2548 const struct dynamic_prop *high_bound, LONGEST bias,
2549 const struct dynamic_prop *stride, bool byte_stride_p);
2550
9e76b17a
TT
2551/* Same as create_array_type_with_stride but with no bit_stride
2552 (BIT_STRIDE = 0), thus building an unpacked array. */
2553
2554extern struct type *create_array_type (type_allocator &alloc,
2555 struct type *element_type,
2556 struct type *range_type);
dc53a7ad 2557
63375b74 2558extern struct type *lookup_array_range_type (struct type *, LONGEST, LONGEST);
c906108c 2559
9e76b17a
TT
2560/* Create a string type using ALLOC. String types are similar enough
2561 to array of char types that we can use create_array_type to build
2562 the basic type and then bash it into a string type.
2563
2564 For fixed length strings, the range type contains 0 as the lower
2565 bound and the length of the string minus one as the upper bound. */
2566
2567extern struct type *create_string_type (type_allocator &alloc,
2568 struct type *string_char_type,
2569 struct type *range_type);
2570
63375b74 2571extern struct type *lookup_string_range_type (struct type *, LONGEST, LONGEST);
c906108c 2572
52664858
TT
2573extern struct type *create_set_type (type_allocator &alloc,
2574 struct type *domain_type);
c906108c 2575
e6c014f2 2576extern struct type *lookup_unsigned_typename (const struct language_defn *,
b858499d 2577 const char *);
c906108c 2578
e6c014f2 2579extern struct type *lookup_signed_typename (const struct language_defn *,
b858499d 2580 const char *);
c906108c 2581
c3c1e645 2582extern ULONGEST get_unsigned_type_max (struct type *);
ed3ef339
DE
2583
2584extern void get_signed_type_minmax (struct type *, LONGEST *, LONGEST *);
2585
b5b591a8
GB
2586extern CORE_ADDR get_pointer_type_max (struct type *);
2587
80180f79
SA
2588/* * Resolve all dynamic values of a type e.g. array bounds to static values.
2589 ADDR specifies the location of the variable the type is bound to.
2590 If TYPE has no dynamic properties return TYPE; otherwise a new type with
52429bbd
TT
2591 static properties is returned.
2592
aeabe83d
TT
2593 If FRAME is given, it is used when evaluating dynamic properties.
2594 This can be important when a static link is seen. If not given,
2595 the selected frame is used.
2596
52429bbd
TT
2597 For an array type, if the element type is dynamic, then that will
2598 not be resolved. This is done because each individual element may
2599 have a different type when resolved (depending on the contents of
2600 memory). In this situation, 'is_dynamic_type' will still return
2601 true for the return value of this function. */
b249d2c2
TT
2602extern struct type *resolve_dynamic_type
2603 (struct type *type, gdb::array_view<const gdb_byte> valaddr,
aeabe83d 2604 CORE_ADDR addr, const frame_info_ptr *frame = nullptr);
80180f79 2605
52429bbd
TT
2606/* * Predicate if the type has dynamic values, which are not resolved yet.
2607 See the caveat in 'resolve_dynamic_type' to understand a scenario
2608 where an apparently-resolved type may still be considered
2609 "dynamic". */
80180f79
SA
2610extern int is_dynamic_type (struct type *type);
2611
a14ed312 2612extern struct type *check_typedef (struct type *);
c906108c 2613
de17c821 2614extern void check_stub_method_group (struct type *, int);
c906108c 2615
a14ed312 2616extern char *gdb_mangle_name (struct type *, int, int);
c906108c 2617
bde240e7
AB
2618/* Lookup a typedef or primitive type named NAME, visible in lexical block
2619 BLOCK. If NOERR is nonzero, return zero if NAME is not suitably
2620 defined.
2621
2622 If this function finds a suitable type then check_typedef is called on
2623 the type, this ensures that if the type being returned is a typedef
2624 then the length of the type will be correct. The original typedef will
2625 still be returned, not the result of calling check_typedef. */
2626
2627extern struct type *lookup_typename (const struct language_defn *language,
2628 const char *name,
2629 const struct block *block, int noerr);
c906108c 2630
61f4b350 2631extern struct type *lookup_template_type (const char *, struct type *,
270140bd 2632 const struct block *);
c906108c 2633
81fe8080 2634extern int get_vptr_fieldno (struct type *, struct type **);
c906108c 2635
1f8d2881
SM
2636/* Set *LOWP and *HIGHP to the lower and upper bounds of discrete type
2637 TYPE.
2638
2639 Return true if the two bounds are available, false otherwise. */
2640
2641extern bool get_discrete_bounds (struct type *type, LONGEST *lowp,
2642 LONGEST *highp);
c906108c 2643
5b56203a
SM
2644/* If TYPE's low bound is a known constant, return it, else return nullopt. */
2645
6b09f134 2646extern std::optional<LONGEST> get_discrete_low_bound (struct type *type);
5b56203a
SM
2647
2648/* If TYPE's high bound is a known constant, return it, else return nullopt. */
2649
6b09f134 2650extern std::optional<LONGEST> get_discrete_high_bound (struct type *type);
5b56203a 2651
584903d3
SM
2652/* Assuming TYPE is a simple, non-empty array type, compute its upper
2653 and lower bound. Save the low bound into LOW_BOUND if not NULL.
2654 Save the high bound into HIGH_BOUND if not NULL.
2655
2656 Return true if the operation was successful. Return false otherwise,
2657 in which case the values of LOW_BOUND and HIGH_BOUNDS are unmodified. */
2658
2659extern bool get_array_bounds (struct type *type, LONGEST *low_bound,
2660 LONGEST *high_bound);
dbc98a8b 2661
6b09f134 2662extern std::optional<LONGEST> discrete_position (struct type *type,
6244c119 2663 LONGEST val);
aa715135 2664
4e8f195d
TT
2665extern int class_types_same_p (const struct type *, const struct type *);
2666
a14ed312 2667extern int is_ancestor (struct type *, struct type *);
c906108c 2668
4e8f195d
TT
2669extern int is_public_ancestor (struct type *, struct type *);
2670
2671extern int is_unique_ancestor (struct type *, struct value *);
2672
c906108c
SS
2673/* Overload resolution */
2674
5e3a2c38 2675/* * Badness if parameter list length doesn't match arg list length. */
6403aeea
SW
2676extern const struct rank LENGTH_MISMATCH_BADNESS;
2677
5e3a2c38 2678/* * Dummy badness value for nonexistent parameter positions. */
6403aeea 2679extern const struct rank TOO_FEW_PARAMS_BADNESS;
5e3a2c38 2680/* * Badness if no conversion among types. */
6403aeea
SW
2681extern const struct rank INCOMPATIBLE_TYPE_BADNESS;
2682
5e3a2c38 2683/* * Badness of an exact match. */
6403aeea 2684extern const struct rank EXACT_MATCH_BADNESS;
c906108c 2685
5e3a2c38 2686/* * Badness of integral promotion. */
6403aeea 2687extern const struct rank INTEGER_PROMOTION_BADNESS;
5e3a2c38 2688/* * Badness of floating promotion. */
6403aeea 2689extern const struct rank FLOAT_PROMOTION_BADNESS;
5e3a2c38 2690/* * Badness of converting a derived class pointer
7062b0a0 2691 to a base class pointer. */
6403aeea 2692extern const struct rank BASE_PTR_CONVERSION_BADNESS;
5e3a2c38 2693/* * Badness of integral conversion. */
6403aeea 2694extern const struct rank INTEGER_CONVERSION_BADNESS;
5e3a2c38 2695/* * Badness of floating conversion. */
6403aeea 2696extern const struct rank FLOAT_CONVERSION_BADNESS;
5e3a2c38 2697/* * Badness of integer<->floating conversions. */
6403aeea 2698extern const struct rank INT_FLOAT_CONVERSION_BADNESS;
5e3a2c38 2699/* * Badness of conversion of pointer to void pointer. */
6403aeea 2700extern const struct rank VOID_PTR_CONVERSION_BADNESS;
5e3a2c38 2701/* * Badness of conversion to boolean. */
5b4f6e25 2702extern const struct rank BOOL_CONVERSION_BADNESS;
5e3a2c38 2703/* * Badness of converting derived to base class. */
6403aeea 2704extern const struct rank BASE_CONVERSION_BADNESS;
e15c3eb4
KS
2705/* * Badness of converting from non-reference to reference. Subrank
2706 is the type of reference conversion being done. */
6403aeea 2707extern const struct rank REFERENCE_CONVERSION_BADNESS;
06acc08f 2708extern const struct rank REFERENCE_SEE_THROUGH_BADNESS;
e15c3eb4
KS
2709/* * Conversion to rvalue reference. */
2710#define REFERENCE_CONVERSION_RVALUE 1
2711/* * Conversion to const lvalue reference. */
2712#define REFERENCE_CONVERSION_CONST_LVALUE 2
2713
5e3a2c38 2714/* * Badness of converting integer 0 to NULL pointer. */
da096638 2715extern const struct rank NULL_POINTER_CONVERSION;
e15c3eb4
KS
2716/* * Badness of cv-conversion. Subrank is a flag describing the conversions
2717 being done. */
2718extern const struct rank CV_CONVERSION_BADNESS;
2719#define CV_CONVERSION_CONST 1
2720#define CV_CONVERSION_VOLATILE 2
7b83ea04 2721
c906108c 2722/* Non-standard conversions allowed by the debugger */
5e3a2c38
SS
2723
2724/* * Converting a pointer to an int is usually OK. */
6403aeea
SW
2725extern const struct rank NS_POINTER_CONVERSION_BADNESS;
2726
5e3a2c38 2727/* * Badness of converting a (non-zero) integer constant
a451cb65
KS
2728 to a pointer. */
2729extern const struct rank NS_INTEGER_POINTER_CONVERSION_BADNESS;
c906108c 2730
6403aeea
SW
2731extern struct rank sum_ranks (struct rank a, struct rank b);
2732extern int compare_ranks (struct rank a, struct rank b);
c906108c 2733
82ceee50
PA
2734extern int compare_badness (const badness_vector &,
2735 const badness_vector &);
c906108c 2736
82ceee50 2737extern badness_vector rank_function (gdb::array_view<type *> parms,
1d2f86b6
HD
2738 gdb::array_view<value *> args,
2739 bool varargs = false);
c906108c 2740
da096638
KS
2741extern struct rank rank_one_type (struct type *, struct type *,
2742 struct value *);
c906108c 2743
a14ed312 2744extern void recursive_dump_type (struct type *, int);
c906108c
SS
2745
2746/* printcmd.c */
2747
7c543f7b 2748extern void print_scalar_formatted (const gdb_byte *, struct type *,
79a45b7d
TT
2749 const struct value_print_options *,
2750 int, struct ui_file *);
c906108c 2751
a14ed312 2752extern int can_dereference (struct type *);
c906108c 2753
a14ed312 2754extern int is_integral_type (struct type *);
adf40b2e 2755
70100014
UW
2756extern int is_floating_type (struct type *);
2757
220475ed
JB
2758extern int is_scalar_type (struct type *type);
2759
e09342b5
TJB
2760extern int is_scalar_type_recursive (struct type *);
2761
6c659fc2
SC
2762extern int class_or_union_p (const struct type *);
2763
58971144 2764extern void maintenance_print_type (const char *, int);
c906108c 2765
bde539c2 2766extern htab_up create_copied_types_hash ();
ae5a43e0 2767
bde539c2 2768extern struct type *copy_type_recursive (struct type *type,
ae5a43e0
DJ
2769 htab_t copied_types);
2770
4af88198
JB
2771extern struct type *copy_type (const struct type *type);
2772
894882e3 2773extern bool types_equal (struct type *, struct type *);
bd69fc68 2774
894882e3 2775extern bool types_deeply_equal (struct type *, struct type *);
ca092b61 2776
3f2f83dd
KB
2777extern int type_not_allocated (const struct type *type);
2778
2779extern int type_not_associated (const struct type *type);
2780
09584414
JB
2781/* Return True if TYPE is a TYPE_CODE_FIXED_POINT or if TYPE is
2782 a range type whose base type is a TYPE_CODE_FIXED_POINT. */
2783extern bool is_fixed_point_type (struct type *type);
2784
09584414
JB
2785/* Allocate a fixed-point type info for TYPE. This should only be
2786 called by INIT_FIXED_POINT_SPECIFIC. */
2a12c336 2787extern void allocate_fixed_point_type_info (struct type *type);
09584414 2788
34877895 2789/* * When the type includes explicit byte ordering, return that.
8ee511af
SM
2790 Otherwise, the byte ordering from gdbarch_byte_order for
2791 the type's arch is returned. */
2792
34877895
PJ
2793extern enum bfd_endian type_byte_order (const struct type *type);
2794
79bb1944
CB
2795/* A flag to enable printing of debugging information of C++
2796 overloading. */
2797
2798extern unsigned int overload_debug;
2799
0b35f123
LS
2800/* Return whether the function type represented by TYPE is marked as unsafe
2801 to call by the debugger.
2802
2803 This usually indicates that the function does not follow the target's
78554598 2804 standard calling convention. */
0b35f123
LS
2805
2806extern bool is_nocall_function (const struct type *type);
2807
c5aa993b 2808#endif /* GDBTYPES_H */