[1/2] gdb, dwarf: update code style in read_tag_pointer_type

Message ID 20260728170746.1037942-1-tankutbaris.aktemur@amd.com
State New
Headers
Series [1/2] gdb, dwarf: update code style in read_tag_pointer_type |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm fail Patch failed to apply
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 fail Patch failed to apply

Commit Message

Aktemur, Baris July 28, 2026, 5:07 p.m. UTC
  Update the code style in read_tag_pointer_type to match current
practices.

The declared type of `byte_size` is changed to ULONGEST because we are
reading an unsigned constant.
---
 gdb/dwarf2/read.c | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)
  

Comments

Tom Tromey July 30, 2026, 4:26 p.m. UTC | #1
>>>>> Tankut Baris Aktemur <tankutbaris.aktemur@amd.com> writes:

> Update the code style in read_tag_pointer_type to match current
> practices.

> The declared type of `byte_size` is changed to ULONGEST because we are
> reading an unsigned constant.

Thanks, this is ok.
Approved-By: Tom Tromey <tom@tromey.com>

Tom
  

Patch

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 38c498b1901..7db76140319 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -12001,10 +12001,6 @@  read_tag_pointer_type (struct die_info *die, struct dwarf2_cu *cu)
 {
   struct gdbarch *gdbarch = cu->per_objfile->objfile->arch ();
   unit_head *cu_header = &cu->header;
-  struct type *type;
-  struct attribute *attr_byte_size;
-  struct attribute *attr_address_class;
-  int byte_size;
   struct type *target_type;
 
   /* In Ada, it's possible to create a self-referential pointer type.
@@ -12020,23 +12016,24 @@  read_tag_pointer_type (struct die_info *die, struct dwarf2_cu *cu)
     target_type = die_type (die, cu);
 
   /* The die_type call above may have already set the type for this DIE.  */
-  type = get_die_type (die, cu);
-  if (type)
+  type *type = get_die_type (die, cu);
+  if (type != nullptr)
     return type;
 
   type = lookup_pointer_type (target_type);
 
-  attr_byte_size = dwarf2_attr (die, DW_AT_byte_size, cu);
-  if (attr_byte_size)
+  ULONGEST byte_size;
+  if (attribute *attr_byte_size = dwarf2_attr (die, DW_AT_byte_size, cu);
+      attr_byte_size != nullptr)
     byte_size = (attr_byte_size->unsigned_constant ()
 		 .value_or (cu_header->addr_size));
   else
     byte_size = cu_header->addr_size;
 
-  attr_address_class = dwarf2_attr (die, DW_AT_address_class, cu);
   ULONGEST addr_class;
-  if (attr_address_class)
-    addr_class = (attr_address_class->unsigned_constant ()
+  if (attribute *attr_aclass = dwarf2_attr (die, DW_AT_address_class, cu);
+      attr_aclass != nullptr)
+    addr_class = (attr_aclass->unsigned_constant ()
 		  .value_or (DW_ADDR_none));
   else
     addr_class = DW_ADDR_none;
@@ -12060,7 +12057,7 @@  read_tag_pointer_type (struct die_info *die, struct dwarf2_cu *cu)
 	}
       else if (type->length () != byte_size)
 	{
-	  complaint (_("invalid pointer size %d"), byte_size);
+	  complaint (_("invalid pointer size %s"), pulongest (byte_size));
 	}
       else if (TYPE_RAW_ALIGN (type) != alignment)
 	{