/* Support for printing C and C++ types for GDB, the GNU debugger.
- Copyright (C) 1986-2020 Free Software Foundation, Inc.
+ Copyright (C) 1986-2021 Free Software Foundation, Inc.
This file is part of GDB.
&& (code == TYPE_CODE_PTR || code == TYPE_CODE_FUNC
|| code == TYPE_CODE_METHOD
|| (code == TYPE_CODE_ARRAY
- && !TYPE_VECTOR (type))
+ && !type->is_vector ())
|| code == TYPE_CODE_MEMBERPTR
|| code == TYPE_CODE_METHODPTR
|| TYPE_IS_REFERENCE (type))))
fputs_styled (varstring, variable_name_style.style (), stream);
/* For demangled function names, we have the arglist as part of
- the name, so don't print an additional pair of ()'s. */
+ the name, so don't print an additional pair of ()'s. */
if (local_name == NULL)
{
demangled_args = strchr (varstring, '(') != NULL;
int show, int level,
const struct type_print_options *flags)
{
- struct print_offset_data podata;
+ struct print_offset_data podata (flags);
c_print_type_1 (type, varstring, stream, show, level,
current_language->la_language, flags, &podata);
enum language language,
const struct type_print_options *flags)
{
- struct print_offset_data podata;
+ struct print_offset_data podata (flags);
c_print_type_1 (type, varstring, stream, show, level, language, flags,
&podata);
enum language language,
const struct type_print_options *flags)
{
- struct field *args = TYPE_FIELDS (mtype);
- int nargs = TYPE_NFIELDS (mtype);
- int varargs = TYPE_VARARGS (mtype);
+ struct field *args = mtype->fields ();
+ int nargs = mtype->num_fields ();
+ int varargs = mtype->has_varargs ();
int i;
fprintf_symbol_filtered (stream, prefix,
if (FIELD_ARTIFICIAL (arg))
continue;
- c_print_type (arg.type, "", stream, 0, 0, flags);
+ c_print_type (arg.type (), "", stream, 0, 0, flags);
if (i == nargs && varargs)
fprintf_filtered (stream, ", ...");
struct type *domain;
gdb_assert (nargs > 0);
- gdb_assert (args[0].type->code () == TYPE_CODE_PTR);
- domain = TYPE_TARGET_TYPE (args[0].type);
+ gdb_assert (args[0].type ()->code () == TYPE_CODE_PTR);
+ domain = TYPE_TARGET_TYPE (args[0].type ());
if (TYPE_CONST (domain))
fprintf_filtered (stream, " const");
case TYPE_CODE_COMPLEX:
case TYPE_CODE_NAMESPACE:
case TYPE_CODE_DECFLOAT:
+ case TYPE_CODE_FIXED_POINT:
/* These types need no prefix. They are listed here so that
- gcc -Wall will reveal any types that haven't been handled. */
+ gcc -Wall will reveal any types that haven't been handled. */
break;
default:
error (_("type not handled in c_type_print_varspec_prefix()"));
did_print_modifier = 1;
}
- address_space_id = address_space_int_to_name (get_type_arch (type),
- TYPE_INSTANCE_FLAGS (type));
+ address_space_id
+ = address_space_type_instance_flags_to_name (type->arch (),
+ type->instance_flags ());
if (address_space_id)
{
if (did_print_modifier || need_pre_space)
fprintf_filtered (stream, "(");
- for (i = 0; i < TYPE_NFIELDS (type); i++)
+ for (i = 0; i < type->num_fields (); i++)
{
struct type *param_type;
wrap_here (" ");
}
- param_type = TYPE_FIELD_TYPE (type, i);
+ param_type = type->field (i).type ();
if (language == language_cplus && linkage_name)
{
printed_any = 1;
}
- if (printed_any && TYPE_VARARGS (type))
+ if (printed_any && type->has_varargs ())
{
/* Print out a trailing ellipsis for varargs functions. Ignore
TYPE_VARARGS if the function has no named arguments; that
represents unprototyped (K&R style) C functions. */
- if (printed_any && TYPE_VARARGS (type))
+ if (printed_any && type->has_varargs ())
{
fprintf_filtered (stream, ", ");
wrap_here (" ");
}
}
else if (!printed_any
- && (TYPE_PROTOTYPED (type) || language == language_cplus))
+ && (type->is_prototyped () || language == language_cplus))
fprintf_filtered (stream, "void");
fprintf_filtered (stream, ")");
case TYPE_CODE_ARRAY:
{
LONGEST low_bound, high_bound;
- int is_vector = TYPE_VECTOR (type);
+ int is_vector = type->is_vector ();
if (passed_a_ptr)
fprintf_filtered (stream, ")");
fprintf_filtered (stream, (is_vector ?
" __attribute__ ((vector_size(" : "["));
/* Bounds are not yet resolved, print a bounds placeholder instead. */
- if (TYPE_HIGH_BOUND_KIND (TYPE_INDEX_TYPE (type)) == PROP_LOCEXPR
- || TYPE_HIGH_BOUND_KIND (TYPE_INDEX_TYPE (type)) == PROP_LOCLIST)
+ if (type->bounds ()->high.kind () == PROP_LOCEXPR
+ || type->bounds ()->high.kind () == PROP_LOCLIST)
fprintf_filtered (stream, "variable length");
else if (get_array_bounds (type, &low_bound, &high_bound))
fprintf_filtered (stream, "%s",
case TYPE_CODE_COMPLEX:
case TYPE_CODE_NAMESPACE:
case TYPE_CODE_DECFLOAT:
+ case TYPE_CODE_FIXED_POINT:
/* These types do not need a suffix. They are listed so that
- gcc -Wall will report types that may not have been
- considered. */
+ gcc -Wall will report types that may not have been
+ considered. */
break;
default:
error (_("type not handled in c_type_print_varspec_suffix()"));
static bool
need_access_label_p (struct type *type)
{
- if (TYPE_DECLARED_CLASS (type))
+ if (type->is_declared_class ())
{
QUIT;
- for (int i = TYPE_N_BASECLASSES (type); i < TYPE_NFIELDS (type); i++)
+ for (int i = TYPE_N_BASECLASSES (type); i < type->num_fields (); i++)
if (!TYPE_FIELD_PRIVATE (type, i))
return true;
QUIT;
else
{
QUIT;
- for (int i = TYPE_N_BASECLASSES (type); i < TYPE_NFIELDS (type); i++)
+ for (int i = TYPE_N_BASECLASSES (type); i < type->num_fields (); i++)
if (TYPE_FIELD_PRIVATE (type, i) || TYPE_FIELD_PROTECTED (type, i))
return true;
QUIT;
c_type_print_modifier (type, stream, 0, 1, language);
if (type->code () == TYPE_CODE_UNION)
fprintf_filtered (stream, "union ");
- else if (TYPE_DECLARED_CLASS (type))
+ else if (type->is_declared_class ())
fprintf_filtered (stream, "class ");
else
fprintf_filtered (stream, "struct ");
fprintf_filtered (stream, "{\n");
- if (TYPE_NFIELDS (type) == 0 && TYPE_NFN_FIELDS (type) == 0
+ if (type->num_fields () == 0 && TYPE_NFN_FIELDS (type) == 0
&& TYPE_TYPEDEF_FIELD_COUNT (type) == 0)
{
- if (TYPE_STUB (type))
- fprintfi_filtered (level + 4, stream,
- _("%p[<incomplete type>%p]\n"),
- metadata_style.style ().ptr (), nullptr);
+ print_spaces_filtered_with_print_options (level + 4, stream, flags);
+ if (type->is_stub ())
+ fprintf_filtered (stream, _("%p[<incomplete type>%p]\n"),
+ metadata_style.style ().ptr (), nullptr);
else
- fprintfi_filtered (level + 4, stream,
- _("%p[<no data fields>%p]\n"),
- metadata_style.style ().ptr (), nullptr);
+ fprintf_filtered (stream, _("%p[<no data fields>%p]\n"),
+ metadata_style.style ().ptr (), nullptr);
}
/* Start off with no specific section type, so we can print
/* If there is a base class for this type,
do not print the field that it occupies. */
- int len = TYPE_NFIELDS (type);
+ int len = type->num_fields ();
vptr_fieldno = get_vptr_fieldno (type, &basetype);
- struct print_offset_data local_podata;
+ struct print_offset_data local_podata (flags);
for (int i = TYPE_N_BASECLASSES (type); i < len; i++)
{
TYPE_FIELD_PRIVATE (type, i), flags);
}
- bool is_static = field_is_static (&TYPE_FIELD (type, i));
+ bool is_static = field_is_static (&type->field (i));
if (flags->print_offsets)
podata->update (type, i, stream);
int newshow = show - 1;
if (!is_static && flags->print_offsets
- && (TYPE_FIELD_TYPE (type, i)->code () == TYPE_CODE_STRUCT
- || TYPE_FIELD_TYPE (type, i)->code () == TYPE_CODE_UNION))
+ && (type->field (i).type ()->code () == TYPE_CODE_STRUCT
+ || type->field (i).type ()->code () == TYPE_CODE_UNION))
{
/* If we're printing offsets and this field's type is
either a struct or an union, then we're interested in
the whole struct/union. */
local_podata.end_bitpos
= podata->end_bitpos
- - TYPE_LENGTH (TYPE_FIELD_TYPE (type, i)) * TARGET_CHAR_BIT;
+ - TYPE_LENGTH (type->field (i).type ()) * TARGET_CHAR_BIT;
}
- c_print_type_1 (TYPE_FIELD_TYPE (type, i),
+ c_print_type_1 (type->field (i).type (),
TYPE_FIELD_NAME (type, i),
stream, newshow, level + 4,
language, &local_flags, &local_podata);
if (semi_local_flags.print_nested_type_limit > 0)
--semi_local_flags.print_nested_type_limit;
- if (TYPE_NFIELDS (type) != 0 || TYPE_NFN_FIELDS (type) != 0)
+ if (type->num_fields () != 0 || TYPE_NFN_FIELDS (type) != 0)
fprintf_filtered (stream, "\n");
for (int i = 0; i < TYPE_NESTED_TYPES_COUNT (type); ++i)
if (TYPE_TYPEDEF_FIELD_COUNT (type) != 0 && flags->print_typedefs)
{
- if (TYPE_NFIELDS (type) != 0 || TYPE_NFN_FIELDS (type) != 0
+ if (type->num_fields () != 0 || TYPE_NFN_FIELDS (type) != 0
|| TYPE_NESTED_TYPES_COUNT (type) != 0)
fprintf_filtered (stream, "\n");
print_spaces_filtered (2, stream);
}
- fprintfi_filtered (level, stream, "}");
+ fprintf_filtered (stream, "%*s}", level, "");
}
}
fprintf_filtered (stream, "union ");
else if (type->code () == TYPE_CODE_STRUCT)
{
- if (TYPE_DECLARED_CLASS (type))
+ if (type->is_declared_class ())
fprintf_filtered (stream, "class ");
else
fprintf_filtered (stream, "struct ");
case TYPE_CODE_ENUM:
c_type_print_modifier (type, stream, 0, 1, language);
fprintf_filtered (stream, "enum ");
- if (TYPE_DECLARED_CLASS (type))
+ if (type->is_declared_class ())
fprintf_filtered (stream, "class ");
/* Print the tag name if it exists.
- The aCC compiler emits a spurious
- "{unnamed struct}"/"{unnamed union}"/"{unnamed enum}"
- tag for unnamed struct/union/enum's, which we don't
- want to print. */
+ The aCC compiler emits a spurious
+ "{unnamed struct}"/"{unnamed union}"/"{unnamed enum}"
+ tag for unnamed struct/union/enum's, which we don't
+ want to print. */
if (type->name () != NULL
&& !startswith (type->name (), "{unnamed"))
{
}
fprintf_filtered (stream, "{");
- len = TYPE_NFIELDS (type);
+ len = type->num_fields ();
for (i = 0; i < len; i++)
{
QUIT;
{
fputs_filtered (" ", stream);
fprintf_filtered (stream, "{\n");
- if (TYPE_NFIELDS (type) == 0)
+ if (type->num_fields () == 0)
{
- if (TYPE_STUB (type))
- fprintfi_filtered (level + 4, stream,
- _("%p[<incomplete type>%p]\n"),
- metadata_style.style ().ptr (), nullptr);
+ if (type->is_stub ())
+ fprintf_filtered (stream,
+ _("%*s%p[<incomplete type>%p]\n"),
+ level + 4, "",
+ metadata_style.style ().ptr (), nullptr);
else
- fprintfi_filtered (level + 4, stream,
- _("%p[<no data fields>%p]\n"),
- metadata_style.style ().ptr (), nullptr);
+ fprintf_filtered (stream,
+ _("%*s%p[<no data fields>%p]\n"),
+ level + 4, "",
+ metadata_style.style ().ptr (), nullptr);
}
- len = TYPE_NFIELDS (type);
+ len = type->num_fields ();
for (i = 0; i < len; i++)
{
QUIT;
print_spaces_filtered (level + 4, stream);
/* We pass "show" here and not "show - 1" to get enum types
printed. There's no other way to see them. */
- c_print_type_1 (TYPE_FIELD_TYPE (type, i),
+ c_print_type_1 (type->field (i).type (),
TYPE_FIELD_NAME (type, i),
stream, show, level + 4,
language, &local_flags, podata);
}
fprintf_filtered (stream, ";\n");
}
- fprintfi_filtered (level, stream, "}");
+ fprintf_filtered (stream, "%*s}", level, "");
}
}
break;
fprintf_styled (stream, metadata_style.style (), _("<range type>"));
break;
+ case TYPE_CODE_FIXED_POINT:
+ print_type_fixed_point (type, stream);
+ break;
+
case TYPE_CODE_NAMESPACE:
fputs_filtered ("namespace ", stream);
fputs_filtered (type->name (), stream);
default:
/* Handle types not explicitly handled by the other cases, such
- as fundamental types. For these, just print whatever the
- type name is, as recorded in the type itself. If there is no
- type name, then complain. */
+ as fundamental types. For these, just print whatever the
+ type name is, as recorded in the type itself. If there is no
+ type name, then complain. */
if (type->name () != NULL)
{
c_type_print_modifier (type, stream, 0, 1, language);
int show, int level,
const struct type_print_options *flags)
{
- struct print_offset_data podata;
+ struct print_offset_data podata (flags);
c_type_print_base_1 (type, stream, show, level,
current_language->la_language, flags, &podata);