Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tankut Baris Aktemur <tankutbaris.aktemur@amd.com>
To: <gdb-patches@sourceware.org>
Subject: [PATCH 13/16] gdb: convert TYPE_RESTRICT macro to type::is_restrict
Date: Mon, 13 Jul 2026 09:00:12 -0500	[thread overview]
Message-ID: <20260713-users-aktemur-type-instance-flags-v1-13-779cad0c85ec@amd.com> (raw)
In-Reply-To: <20260713-users-aktemur-type-instance-flags-v1-0-779cad0c85ec@amd.com>

Convert the TYPE_RESTRICT macro to a method of the type class.  This
is a refactoring.
---
 gdb/c-typeprint.c                 | 4 ++--
 gdb/compile/compile-c-types.c     | 4 ++--
 gdb/compile/compile-cplus-types.c | 6 +++---
 gdb/gdbtypes.c                    | 6 ++----
 gdb/gdbtypes.h                    | 7 ++++++-
 5 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c
index d45f5f6ab6d..d924e76a3db 100644
--- a/gdb/c-typeprint.c
+++ b/gdb/c-typeprint.c
@@ -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, " ");
diff --git a/gdb/compile/compile-c-types.c b/gdb/compile/compile-c-types.c
index 2c115632a7c..818cdecd50d 100644
--- a/gdb/compile/compile-c-types.c
+++ b/gdb/compile/compile-c-types.c
@@ -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 ())
diff --git a/gdb/compile/compile-cplus-types.c b/gdb/compile/compile-cplus-types.c
index 787ca321a5f..8352c9324f4 100644
--- a/gdb/compile/compile-cplus-types.c
+++ b/gdb/compile/compile-cplus-types.c
@@ -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 ())
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index bdac30204d0..33f0a57285b 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -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");
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index a12acb72967..599a45d9969 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -165,7 +165,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.  */
@@ -1219,6 +1218,12 @@ struct type
     return this->m_instance_flags.harvard_aspace == HARVARD_ASPACE_DATA;
   }
 
+  /* Return if this type is restrict.  */
+  bool is_restrict ()
+  {
+    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
   {

-- 
2.34.1


  parent reply	other threads:[~2026-07-13 14:01 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-13 13:59 [PATCH 00/16] Rewrite type instance flags as a struct with bitfields Tankut Baris Aktemur
2026-07-13 14:00 ` [PATCH 01/16] gdb: use type instance macros to query const, volatile, restrict Tankut Baris Aktemur
2026-07-21 17:52   ` Tom Tromey
2026-07-13 14:00 ` [PATCH 02/16] gdb: convert address_class_type_flags_to_name to address_class_id_to_name Tankut Baris Aktemur
2026-07-21 18:03   ` Tom Tromey
2026-07-13 14:00 ` [PATCH 03/16] gdb: convert address_class_name_to_type_flags to address_class_name_to_id Tankut Baris Aktemur
2026-07-21 18:10   ` Tom Tromey
2026-07-13 14:00 ` [PATCH 04/16] gdb: convert address_class_type_flags to address_class_dwarf_to_id Tankut Baris Aktemur
2026-07-21 18:19   ` Tom Tromey
2026-07-13 14:00 ` [PATCH 05/16] gdb: inline address_space_{name, type_instance_flags}_to_{type_instance_flags, name} Tankut Baris Aktemur
2026-07-21 18:29   ` Tom Tromey
2026-07-22 10:29     ` Aktemur, Baris
2026-07-22 13:38       ` Tom Tromey
2026-07-13 14:00 ` [PATCH 06/16] gdb: split make_type_with_address_space Tankut Baris Aktemur
2026-07-21 18:49   ` Tom Tromey
2026-07-13 14:00 ` [PATCH 07/16] gdb: convert type instance flags to bitfields Tankut Baris Aktemur
2026-07-21 19:13   ` Tom Tromey
2026-07-22 10:29     ` Aktemur, Baris
2026-07-13 14:00 ` [PATCH 08/16] gdb: convert TYPE_NOTTEXT macro to type::is_nottext Tankut Baris Aktemur
2026-07-21 18:39   ` Tom Tromey
2026-07-13 14:00 ` [PATCH 09/16] gdb: convert TYPE_CONST macro to type::is_const Tankut Baris Aktemur
2026-07-21 18:40   ` Tom Tromey
2026-07-13 14:00 ` [PATCH 10/16] gdb: convert TYPE_VOLATILE macro to type::is_volatile Tankut Baris Aktemur
2026-07-13 14:00 ` [PATCH 11/16] gdb: convert TYPE_CODE_SPACE macro to type::is_code_space Tankut Baris Aktemur
2026-07-13 14:00 ` [PATCH 12/16] gdb: convert TYPE_DATA_SPACE macro to type::is_data_space Tankut Baris Aktemur
2026-07-13 14:00 ` Tankut Baris Aktemur [this message]
2026-07-13 14:00 ` [PATCH 14/16] gdb: convert TYPE_ATOMIC macro to type::is_atomic Tankut Baris Aktemur
2026-07-13 14:00 ` [PATCH 15/16] gdb: convert TYPE_ADDRESS_CLASS macro to type::address_class Tankut Baris Aktemur
2026-07-13 14:00 ` [PATCH 16/16] gdb: remove unnecessary braces in recursive_dump_type Tankut Baris Aktemur
2026-07-21 18:45   ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260713-users-aktemur-type-instance-flags-v1-13-779cad0c85ec@amd.com \
    --to=tankutbaris.aktemur@amd.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox