[binutils-gdb] gdb: remove dead code in make_pointer_type and make_reference_type
Tankut Baris Aktemur via Gdb-cvs <[email protected]> Mon, 3 Aug 2026 15:32:46 +0000 (GMT)
| Newsgroups | gmane.comp.gdb.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D4374c16fbac0= bbc261e3fd510548bbb65c3fc398 commit 4374c16fbac0bbc261e3fd510548bbb65c3fc398 Author: Tankut Baris Aktemur <[email protected]> Date: Mon Aug 3 15:38:34 2026 +0200 gdb: remove dead code in make_pointer_type and make_reference_type =20 At the end of `make_pointer_type` and `make_reference_type`, GDB updates the length of every type in the chain. This is practically dead code, because if we reach this point, we must have allocated a new type. After a new allocation, the chain contains only the newly-created type itself. See in `type_allocator::new_type ()`: =20 type->chain =3D type; /* Chain back to itself. */ =20 That is, we always have `ntype =3D=3D ntype->chain`. Therefore, the lo= op can never be entered. Remove it. =20 In `make_reference_type`, we also remove `*reftype =3D ntype;`, because a few lines above the assignment was already made. This is repeated code. =20 Approved-By: Simon Marchi <[email protected]> Diff: --- gdb/gdbtypes.c | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 9098727959e..2dda175237c 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -367,8 +367,6 @@ type * make_pointer_type (type *type) { struct type *ntype; /* New type */ - struct type *chain; - ntype =3D type->pointer_type; =20 if (ntype) @@ -388,14 +386,6 @@ make_pointer_type (type *type) gdbarch_address_to_pointer. */ ntype->set_is_unsigned (true); =20 - /* Update the length of all the other variants of this type. */ - chain =3D ntype->chain; - while (chain !=3D ntype) - { - chain->set_length (ntype->length ()); - chain =3D chain->chain; - } - return ntype; } =20 @@ -415,7 +405,6 @@ make_reference_type (type *type, type_code refcode) { struct type *ntype; /* New type */ struct type **reftype; - struct type *chain; =20 gdb_assert (refcode =3D=3D TYPE_CODE_REF || refcode =3D=3D TYPE_CODE_RVA= LUE_REF); =20 @@ -439,16 +428,6 @@ make_reference_type (type *type, type_code refcode) ntype->set_length (gdbarch_ptr_bit (type->arch ()) / TARGET_CHAR_BIT); ntype->set_code (refcode); =20 - *reftype =3D ntype; - - /* Update the length of all the other variants of this type. */ - chain =3D ntype->chain; - while (chain !=3D ntype) - { - chain->set_length (ntype->length ()); - chain =3D chain->chain; - } - return ntype; }