]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: convert TYPE_RESTRICT macro to type::is_restrict
authorTankut Baris Aktemur <tankutbaris.aktemur@amd.com>
Thu, 23 Jul 2026 10:04:43 +0000 (05:04 -0500)
committerTankut Baris Aktemur <tankutbaris.aktemur@amd.com>
Thu, 23 Jul 2026 10:10:06 +0000 (05:10 -0500)
Convert the TYPE_RESTRICT macro to a method of the type class.  This
is a refactoring.

Approved-By: Tom Tromey <tom@tromey.com>
gdb/c-typeprint.c
gdb/compile/compile-c-types.c
gdb/compile/compile-cplus-types.c
gdb/gdbtypes.c
gdb/gdbtypes.h

index d26640e10e6bd83559effceb1dbe6da00fe01e1a..1c3b0fba04d6b251d327ea873c1d43b74918262c 100644 (file)
@@ -317,7 +317,7 @@ cp_type_print_method_args (struct type *mtype,
       if (domain->is_volatile ())
        gdb_printf (stream, " volatile");
 
-      if (TYPE_RESTRICT (domain))
+      if (domain->is_restrict ())
        gdb_printf (stream, (language == language_cplus
                             ? " __restrict__"
                             : " restrict"));
@@ -465,7 +465,7 @@ c_type_print_modifier (struct type *type, struct ui_file *stream,
       did_print_modifier = 1;
     }
 
-  if (TYPE_RESTRICT (type))
+  if (type->is_restrict ())
     {
       if (did_print_modifier || need_pre_space)
        gdb_printf (stream, " ");
index 2c115632a7c2e35c06ef9e078697f8a8a5981c8a..818cdecd50d95e473c0b28cab86de4e77a63ac71 100644 (file)
@@ -251,7 +251,7 @@ convert_qualified (compile_c_instance *context, struct type *type)
     quals |= GCC_QUALIFIER_CONST;
   if (type->is_volatile ())
     quals |= GCC_QUALIFIER_VOLATILE;
-  if (TYPE_RESTRICT (type))
+  if (type->is_restrict ())
     quals |= GCC_QUALIFIER_RESTRICT;
 
   return context->plugin ().build_qualified_type (unqual_converted,
@@ -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->is_volatile () || TYPE_RESTRICT (type))
+  if (type->is_const () || type->is_volatile () || type->is_restrict ())
     return convert_qualified (context, type);
 
   switch (type->code ())
index 787ca321a5fcfbd314aed1380d892825e726f6b1..8352c9324f4b46df9f5a6543114986623b1a105f 100644 (file)
@@ -673,7 +673,7 @@ compile_cplus_convert_method (compile_cplus_instance *instance,
     quals |= GCC_CP_QUALIFIER_CONST;
   if (method_type->is_volatile ())
     quals |= GCC_CP_QUALIFIER_VOLATILE;
-  if (TYPE_RESTRICT (method_type))
+  if (method_type->is_restrict ())
     quals |= GCC_CP_QUALIFIER_RESTRICT;
 
   /* Not yet implemented.  */
@@ -1070,7 +1070,7 @@ compile_cplus_convert_qualified (compile_cplus_instance *instance,
     quals |= GCC_CP_QUALIFIER_CONST;
   if (type->is_volatile ())
     quals |= GCC_CP_QUALIFIER_VOLATILE;
-  if (TYPE_RESTRICT (type))
+  if (type->is_restrict ())
     quals |= GCC_CP_QUALIFIER_RESTRICT;
 
   return instance->convert_qualified_base (unqual_converted, quals);
@@ -1126,7 +1126,7 @@ convert_type_cplus_basic (compile_cplus_instance *instance,
 {
   /* If we are converting a qualified type, first convert the
      unqualified type and then apply the qualifiers.  */
-  if (type->is_const () || type->is_volatile () || TYPE_RESTRICT (type))
+  if (type->is_const () || type->is_volatile () || type->is_restrict ())
     return compile_cplus_convert_qualified (instance, type);
 
   switch (type->code ())
index 731c7436dc6aa94a97e1768aae9b34a9d9eb9dcd..a682d52513445ec31fc6b1622857a0d319d83ff4 100644 (file)
@@ -5033,10 +5033,8 @@ recursive_dump_type (struct type *type, int spaces)
     {
       gdb_printf (" TYPE_ADDRESS_CLASS(%u)", TYPE_ADDRESS_CLASS (type));
     }
-  if (TYPE_RESTRICT (type))
-    {
-      gdb_puts (" TYPE_RESTRICT");
-    }
+  if (type->is_restrict ())
+    gdb_puts (" TYPE_RESTRICT");
   if (TYPE_ATOMIC (type))
     {
       gdb_puts (" TYPE_ATOMIC");
index b6c3b2194191cca0ecf1063f336742dd5da054f8..0acfda0d74b608ee400362d79a9a9c2b849b20e5 100644 (file)
@@ -168,7 +168,6 @@ struct type_instance_flags
   bool is_atomic : 1;
 };
 
-#define TYPE_RESTRICT(t) (((t)->instance_flags ()).is_restrict)
 #define TYPE_ATOMIC(t) (((t)->instance_flags ()).is_atomic)
 
 /* True if this type represents either an lvalue or lvalue reference type.  */
@@ -1222,6 +1221,12 @@ struct type
     return this->m_instance_flags.harvard_aspace == HARVARD_ASPACE_DATA;
   }
 
+  /* Return if this type is restrict.  */
+  bool is_restrict () const
+  {
+    return this->m_instance_flags.is_restrict;
+  }
+
   /* Get the bounds bounds of this type.  The type must be a range type.  */
   range_bounds *bounds () const
   {