[binutils-gdb] gdb: convert TYPE_VOLATILE macro to type::is_volatile
Tankut Baris Aktemur via Gdb-cvs <[email protected]> Thu, 23 Jul 2026 10:13:20 +0000 (GMT)
| Newsgroups | gmane.comp.gdb.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D82dc5dcbce28= eabe9e71c3572ea3557506fbca4f commit 82dc5dcbce28eabe9e71c3572ea3557506fbca4f Author: Tankut Baris Aktemur <[email protected]> Date: Thu Jul 23 05:04:43 2026 -0500 gdb: convert TYPE_VOLATILE macro to type::is_volatile =20 Convert the TYPE_VOLATILE macro to a method of the type class. This is a refactoring. =20 Approved-By: Tom Tromey <[email protected]> Diff: --- gdb/c-typeprint.c | 4 ++-- gdb/compile/compile-c-types.c | 4 ++-- gdb/compile/compile-cplus-types.c | 6 +++--- gdb/ctfread.c | 4 ++-- gdb/dwarf2/read.c | 6 +++--- gdb/gdbtypes.c | 10 ++++------ gdb/gdbtypes.h | 7 ++++++- gdb/opencl-lang.c | 2 +- gdb/python/py-type.c | 4 ++-- gdb/type-stack.c | 2 +- gdb/valops.c | 6 +++--- 11 files changed, 29 insertions(+), 26 deletions(-) diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c index 97e547a92ef..fb8b228ea38 100644 --- a/gdb/c-typeprint.c +++ b/gdb/c-typeprint.c @@ -314,7 +314,7 @@ cp_type_print_method_args (struct type *mtype, if (domain->is_const ()) gdb_printf (stream, " const"); =20 - if (TYPE_VOLATILE (domain)) + if (domain->is_volatile ()) gdb_printf (stream, " volatile"); =20 if (TYPE_RESTRICT (domain)) @@ -457,7 +457,7 @@ c_type_print_modifier (struct type *type, struct ui_fil= e *stream, did_print_modifier =3D 1; } =20 - if (TYPE_VOLATILE (type)) + if (type->is_volatile ()) { if (did_print_modifier || need_pre_space) gdb_printf (stream, " "); diff --git a/gdb/compile/compile-c-types.c b/gdb/compile/compile-c-types.c index 2e5ca12a61b..2c115632a7c 100644 --- a/gdb/compile/compile-c-types.c +++ b/gdb/compile/compile-c-types.c @@ -249,7 +249,7 @@ convert_qualified (compile_c_instance *context, struct = type *type) =20 if (type->is_const ()) quals |=3D GCC_QUALIFIER_CONST; - if (TYPE_VOLATILE (type)) + if (type->is_volatile ()) quals |=3D GCC_QUALIFIER_VOLATILE; if (TYPE_RESTRICT (type)) quals |=3D GCC_QUALIFIER_RESTRICT; @@ -278,7 +278,7 @@ convert_type_basic (compile_c_instance *context, struct= type *type) { /* If we are converting a qualified type, first convert the unqualified type and then apply the qualifiers. */ - if (type->is_const () || TYPE_VOLATILE (type) || TYPE_RESTRICT (type)) + if (type->is_const () || type->is_volatile () || TYPE_RESTRICT (type)) return convert_qualified (context, type); =20 switch (type->code ()) diff --git a/gdb/compile/compile-cplus-types.c b/gdb/compile/compile-cplus-= types.c index 90ef1bda2cb..787ca321a5f 100644 --- a/gdb/compile/compile-cplus-types.c +++ b/gdb/compile/compile-cplus-types.c @@ -671,7 +671,7 @@ compile_cplus_convert_method (compile_cplus_instance *i= nstance, =20 if (method_type->is_const ()) quals |=3D GCC_CP_QUALIFIER_CONST; - if (TYPE_VOLATILE (method_type)) + if (method_type->is_volatile ()) quals |=3D GCC_CP_QUALIFIER_VOLATILE; if (TYPE_RESTRICT (method_type)) quals |=3D GCC_CP_QUALIFIER_RESTRICT; @@ -1068,7 +1068,7 @@ compile_cplus_convert_qualified (compile_cplus_instan= ce *instance, =20 if (type->is_const ()) quals |=3D GCC_CP_QUALIFIER_CONST; - if (TYPE_VOLATILE (type)) + if (type->is_volatile ()) quals |=3D GCC_CP_QUALIFIER_VOLATILE; if (TYPE_RESTRICT (type)) quals |=3D GCC_CP_QUALIFIER_RESTRICT; @@ -1126,7 +1126,7 @@ convert_type_cplus_basic (compile_cplus_instance *ins= tance, { /* If we are converting a qualified type, first convert the unqualified type and then apply the qualifiers. */ - if (type->is_const () || TYPE_VOLATILE (type) || TYPE_RESTRICT (type)) + if (type->is_const () || type->is_volatile () || TYPE_RESTRICT (type)) return compile_cplus_convert_qualified (instance, type); =20 switch (type->code ()) diff --git a/gdb/ctfread.c b/gdb/ctfread.c index b40d3de6763..ff34f42146a 100644 --- a/gdb/ctfread.c +++ b/gdb/ctfread.c @@ -758,7 +758,7 @@ add_array_cv_type (struct ctf_context *ccp, =20 el_type =3D inner_array->target_type (); cnst |=3D el_type->is_const (); - voltl |=3D TYPE_VOLATILE (el_type); + voltl |=3D el_type->is_volatile (); inner_array->set_target_type (make_cv_type (cnst, voltl, el_type)); =20 return set_tid_type (ccp, tid, base_type); @@ -830,7 +830,7 @@ read_const_type (struct ctf_context *ccp, ctf_id_t tid,= ctf_id_t btid) base_type =3D builtin_type (objfile)->builtin_error; } } - cv_type =3D make_cv_type (1, TYPE_VOLATILE (base_type), base_type); + cv_type =3D make_cv_type (1, base_type->is_volatile (), base_type); =20 return set_tid_type (ccp, tid, cv_type); } diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 067561b6e48..38c498b1901 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -12177,7 +12177,7 @@ add_array_cv_type (struct die_info *die, struct dwa= rf2_cu *cu, =20 el_type =3D inner_array->target_type (); cnst |=3D el_type->is_const (); - voltl |=3D TYPE_VOLATILE (el_type); + voltl |=3D el_type->is_volatile (); inner_array->set_target_type (make_cv_type (cnst, voltl, el_type)); =20 return set_die_type (die, base_type, cu); @@ -12200,7 +12200,7 @@ read_tag_const_type (struct die_info *die, struct d= warf2_cu *cu) if (base_type->code () =3D=3D TYPE_CODE_ARRAY) return add_array_cv_type (die, cu, base_type, 1, 0); =20 - cv_type =3D make_cv_type (1, TYPE_VOLATILE (base_type), base_type); + cv_type =3D make_cv_type (1, base_type->is_volatile (), base_type); return set_die_type (die, cv_type, cu); } =20 @@ -12545,7 +12545,7 @@ read_subroutine_type (struct die_info *die, struct = dwarf2_cu *cu) is_this =3D 1; =20 if (is_this) - arg_type =3D make_cv_type (1, TYPE_VOLATILE (arg_type), + arg_type =3D make_cv_type (1, arg_type->is_volatile (), arg_type); } =20 diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 74b043de9f9..1019f02e2e1 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -4316,7 +4316,7 @@ rank_one_type_parm_ptr (struct type *parm, struct typ= e *arg, struct value *value /* Make sure they are CV equal. */ if (t1->is_const () !=3D t2->is_const ()) rank.subrank |=3D CV_CONVERSION_CONST; - if (TYPE_VOLATILE (t1) !=3D TYPE_VOLATILE (t2)) + if (t1->is_volatile () !=3D t2->is_volatile ()) rank.subrank |=3D CV_CONVERSION_VOLATILE; if (rank.subrank !=3D 0) return sum_ranks (CV_CONVERSION_BADNESS, rank); @@ -4729,7 +4729,7 @@ rank_one_type (struct type *parm, struct type *arg, s= truct value *value) /* Make sure they are CV equal, too. */ if (t1->is_const () !=3D t2->is_const ()) rank.subrank |=3D CV_CONVERSION_CONST; - if (TYPE_VOLATILE (t1) !=3D TYPE_VOLATILE (t2)) + if (t1->is_volatile () !=3D t2->is_volatile ()) rank.subrank |=3D CV_CONVERSION_VOLATILE; if (rank.subrank !=3D 0) return sum_ranks (CV_CONVERSION_BADNESS, rank); @@ -5023,10 +5023,8 @@ recursive_dump_type (struct type *type, int spaces) gdb_printf ("%*sinstance_flags [", spaces, ""); if (type->is_const ()) gdb_puts (" TYPE_CONST"); - if (TYPE_VOLATILE (type)) - { - gdb_puts (" TYPE_VOLATILE"); - } + if (type->is_volatile ()) + gdb_puts (" TYPE_VOLATILE"); if (TYPE_CODE_SPACE (type)) { gdb_puts (" TYPE_CODE_SPACE"); diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index a4fcd4d07b4..6a8bc425d45 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -168,7 +168,6 @@ struct type_instance_flags bool is_atomic : 1; }; =20 -#define TYPE_VOLATILE(t) (((t)->instance_flags ()).is_volatile) #define TYPE_RESTRICT(t) (((t)->instance_flags ()).is_restrict) #define TYPE_ATOMIC(t) (((t)->instance_flags ()).is_atomic) =20 @@ -1211,6 +1210,12 @@ struct type return this->m_instance_flags.is_const; } =20 + /* Return if this type is volatile. */ + bool is_volatile () const + { + return this->m_instance_flags.is_volatile; + } + /* Get the bounds bounds of this type. The type must be a range type. = */ range_bounds *bounds () const { diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c index 96119785f92..895f7a41f01 100644 --- a/gdb/opencl-lang.c +++ b/gdb/opencl-lang.c @@ -292,7 +292,7 @@ create_value (struct gdbarch *gdbarch, struct value *va= l, enum noside noside, if (dst_type =3D=3D NULL) dst_type =3D init_vector_type (elm_type, n); =20 - make_cv_type (type->is_const (), TYPE_VOLATILE (type), dst_type); + make_cv_type (type->is_const (), type->is_volatile (), dst_type); =20 if (noside =3D=3D EVAL_AVOID_SIDE_EFFECTS) ret =3D value::allocate (dst_type); diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c index 5b98ec1fa7f..9dd0fe2ab37 100644 --- a/gdb/python/py-type.c +++ b/gdb/python/py-type.c @@ -715,7 +715,7 @@ typy_const (PyObject *self, PyObject *args) =20 try { - type =3D make_cv_type (1, TYPE_VOLATILE (type), type); + type =3D make_cv_type (1, type->is_volatile (), type); } catch (const gdb_exception &except) { @@ -891,7 +891,7 @@ typy_lookup_type (struct demangle_component *demangled, rtype =3D lookup_pointer_type (type); break; case DEMANGLE_COMPONENT_CONST: - rtype =3D make_cv_type (1, TYPE_VOLATILE (type), type); + rtype =3D make_cv_type (1, type->is_volatile (), type); break; case DEMANGLE_COMPONENT_VOLATILE: rtype =3D make_cv_type (type->is_const (), 1, type); diff --git a/gdb/type-stack.c b/gdb/type-stack.c index 05c5ee6e47f..01616ae4a14 100644 --- a/gdb/type-stack.c +++ b/gdb/type-stack.c @@ -156,7 +156,7 @@ type_stack::follow_types (struct type *follow_type) process_qualifiers: if (make_const) follow_type =3D make_cv_type (make_const, - TYPE_VOLATILE (follow_type), + follow_type->is_volatile (), follow_type); if (make_volatile) follow_type =3D make_cv_type (follow_type->is_const (), diff --git a/gdb/valops.c b/gdb/valops.c index ccb2ae21adc..d2dc3d9e869 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -3652,7 +3652,7 @@ value_struct_elt_for_reference (struct type *domain, = int offset, { if (intype->is_const () !=3D TYPE_FN_FIELD_CONST (f, j)) continue; - if (TYPE_VOLATILE (intype) !=3D TYPE_FN_FIELD_VOLATILE (f, j)) + if (intype->is_volatile () !=3D TYPE_FN_FIELD_VOLATILE (f, j)) continue; =20 if (compare_parameters (TYPE_FN_FIELD_TYPE (f, j), intype, 0) @@ -3874,7 +3874,7 @@ value_rtti_indirect_type (struct value *v, int *full, /* Copy qualifiers to the referenced object. */ target_type =3D target->type (); real_type =3D make_cv_type (target_type->is_const (), - TYPE_VOLATILE (target_type), real_type); + target_type->is_volatile (), real_type); if (TYPE_IS_REFERENCE (type)) real_type =3D lookup_reference_type (real_type, type->code ()); else if (type->code () =3D=3D TYPE_CODE_PTR) @@ -3883,7 +3883,7 @@ value_rtti_indirect_type (struct value *v, int *full, internal_error (_("Unexpected value type.")); =20 /* Copy qualifiers to the pointer/reference. */ - real_type =3D make_cv_type (type->is_const (), TYPE_VOLATILE (type), + real_type =3D make_cv_type (type->is_const (), type->is_volatile (), real_type); }