[binutils-gdb] [gdb] Minor refactoring of is_dynamic_type_internal
Tom de Vries
vries@sourceware.org
Tue Mar 10 20:44:06 GMT 2026
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=940f3a4a8a4e0c7711c6d02fec8cbdee25cf0f35
commit 940f3a4a8a4e0c7711c6d02fec8cbdee25cf0f35
Author: Tom de Vries <tdevries@suse.de>
Date: Tue Mar 10 21:44:01 2026 +0100
[gdb] Minor refactoring of is_dynamic_type_internal
Simplify is_dynamic_type_internal by:
- factoring out type->field (i) for the TYPE_CODE_STRUCT/UNION case.
- merging a loop iteration variable declaration into a for statement
Approved-By: Tom Tromey <tom@tromey.com>
Diff:
---
gdb/gdbtypes.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index d2e243abbe1..f3422fe5609 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -1982,21 +1982,21 @@ is_dynamic_type_internal (struct type *type, bool top_level)
case TYPE_CODE_STRUCT:
case TYPE_CODE_UNION:
{
- int i;
-
bool is_cplus = HAVE_CPLUS_STRUCT (type);
- for (i = 0; i < type->num_fields (); ++i)
+ for (int i = 0; i < type->num_fields (); ++i)
{
+ struct field &f = type->field (i);
+
/* Static fields can be ignored here. */
- if (type->field (i).is_static ())
+ if (f.is_static ())
continue;
/* If the field has dynamic type, then so does TYPE. */
- if (is_dynamic_type_internal (type->field (i).type (), false))
+ if (is_dynamic_type_internal (f.type (), false))
return true;
/* If the field is at a fixed offset, then it is not
dynamic. */
- if (!type->field (i).loc_is_dwarf_block ())
+ if (!f.loc_is_dwarf_block ())
continue;
/* Do not consider C++ virtual base types to be dynamic
due to the field's offset being dynamic; these are
More information about the Gdb-cvs
mailing list