if (lang == language_cplus && strchr (name, '<') == NULL)
{
struct attribute *attr;
- struct die_info *child;
int first = 1;
die->building_fullname = 1;
- for (child = die->child; child != NULL; child = child->next)
+ for (die_info *child : die->children ())
{
struct type *type;
LONGEST value;
{
struct objfile *objfile = cu->per_objfile->objfile;
struct attribute *import_attr;
- struct die_info *imported_die, *child_die;
+ struct die_info *imported_die;
struct dwarf2_cu *imported_cu;
const char *imported_name;
const char *imported_name_prefix;
else
canonical_name = imported_name;
- if (die->tag == DW_TAG_imported_module
- && cu->lang () == language_fortran)
- for (child_die = die->child; child_die && child_die->tag;
- child_die = child_die->next)
+ if (die->tag == DW_TAG_imported_module && cu->lang () == language_fortran)
+ for (die_info *child_die : die->children ())
{
/* DWARF-4: A Fortran use statement with a “rename list” may be
represented by an imported module entry with an import attribute
struct objfile *objfile = per_objfile->objfile;
CORE_ADDR lowpc;
struct attribute *attr;
- struct die_info *child_die;
unrelocated_addr unrel_low, unrel_high;
get_scope_pc_bounds (die, &unrel_low, &unrel_high, cu);
handle_DW_AT_stmt_list (die, cu, fnd, unrel_low, unrel_low != unrel_high);
/* Process all dies in compilation unit. */
- if (die->child != NULL)
- {
- child_die = die->child;
- while (child_die && child_die->tag)
- {
- process_die (child_die, cu);
- child_die = child_die->next;
- }
- }
+ for (die_info *child_die : die->children ())
+ process_die (child_die, cu);
+
per_objfile->sym_cu = nullptr;
/* Decode macro information, if present. Dwarf 2 macro information
static void
read_type_unit_scope (struct die_info *die, struct dwarf2_cu *cu)
{
- struct die_info *child_die;
-
/* Initialize (or reinitialize) the machinery for building symtabs.
We do this before processing child DIEs, so that the line header table
is available for DW_AT_decl_file. */
cu->setup_type_unit_groups (die);
- if (die->child != NULL)
- {
- child_die = die->child;
- while (child_die && child_die->tag)
- {
- process_die (child_die, cu);
- child_die = child_die->next;
- }
- }
+ for (die_info *child_die : die->children ())
+ process_die (child_die, cu);
}
\f
/* DWO/DWP files.
std::vector<sect_offset> offsets;
- for (die_info *child_die = die->child;
- child_die && child_die->tag;
- child_die = child_die->next)
+ for (die_info *child_die : die->children ())
{
/* We are trying to process concrete instance entries:
DW_TAG_call_site DIEs indeed have a DW_AT_abstract_origin tag, but
}
auto offsets_it = offsets.begin ();
- die_info *origin_child_die = origin_die->child;
- while (origin_child_die != nullptr && origin_child_die->tag != 0)
+ for (die_info *origin_child_die : origin_die->children ())
{
/* Is ORIGIN_CHILD_DIE referenced by any of the DIE children? */
while (offsets_it < offsets.end ()
if (!origin_child_die->in_process)
process_die (origin_child_die, origin_cu);
}
-
- origin_child_die = origin_child_die->next;
}
origin_cu->list_in_scope = origin_previous_list_in_scope;
struct context_stack *newobj;
CORE_ADDR lowpc;
CORE_ADDR highpc;
- struct die_info *child_die;
struct attribute *attr, *call_line, *call_file;
const char *name;
struct block *block;
/* If we have any template arguments, then we must allocate a
different sort of symbol. */
- for (child_die = die->child; child_die; child_die = child_die->next)
+ for (die_info *child_die : die->children ())
{
if (child_die->tag == DW_TAG_template_type_param
|| child_die->tag == DW_TAG_template_value_param)
cu->list_in_scope = cu->get_builder ()->get_local_symbols ();
- if (die->child != NULL)
+ for (die_info *child_die : die->children ())
{
- child_die = die->child;
- while (child_die && child_die->tag)
+ if (child_die->tag == DW_TAG_template_type_param
+ || child_die->tag == DW_TAG_template_value_param)
{
- if (child_die->tag == DW_TAG_template_type_param
- || child_die->tag == DW_TAG_template_value_param)
- {
- struct symbol *arg = new_symbol (child_die, NULL, cu);
+ struct symbol *arg = new_symbol (child_die, NULL, cu);
- if (arg != NULL)
- template_args.push_back (arg);
- }
- else
- process_die (child_die, cu);
- child_die = child_die->next;
+ if (arg != NULL)
+ template_args.push_back (arg);
}
+ else
+ process_die (child_die, cu);
}
inherit_abstract_dies (die, cu);
while (spec_die)
{
- child_die = spec_die->child;
- while (child_die && child_die->tag)
- {
- if (child_die->tag == DW_TAG_imported_module)
- process_die (child_die, spec_cu);
- child_die = child_die->next;
- }
+ for (die_info *child_die : spec_die->children ())
+ if (child_die->tag == DW_TAG_imported_module)
+ process_die (child_die, spec_cu);
/* In some cases, GCC generates specification DIEs that
themselves contain DW_AT_specification attributes. */
{
dwarf2_per_objfile *per_objfile = cu->per_objfile;
CORE_ADDR lowpc, highpc;
- struct die_info *child_die;
/* Ignore blocks with missing or invalid low and high pc attributes. */
/* ??? Perhaps consider discontiguous blocks defined by DW_AT_ranges
/* DW_TAG_lexical_block has no attributes, process its children as if
there was no wrapping by that DW_TAG_lexical_block.
GCC does no longer produces such DWARF since GCC r224161. */
- for (child_die = die->child;
- child_die != NULL && child_die->tag;
- child_die = child_die->next)
+ for (die_info *child_die : die->children ())
{
/* We might already be processing this DIE. This can happen
in an unusual circumstance -- where a subroutine A
highpc = per_objfile->relocate (unrel_high);
cu->get_builder ()->push_context (0, lowpc);
- if (die->child != NULL)
- {
- child_die = die->child;
- while (child_die && child_die->tag)
- {
- process_die (child_die, cu);
- child_die = child_die->next;
- }
- }
+ for (die_info *child_die : die->children ())
+ process_die (child_die, cu);
+
inherit_abstract_dies (die, cu);
struct context_stack cstk = cu->get_builder ()->pop_context ();
struct gdbarch *gdbarch = objfile->arch ();
struct attribute *attr;
int nparams;
- struct die_info *child_die;
attr = dwarf2_attr (die, DW_AT_call_return_pc, cu);
if (attr == NULL)
/* Count parameters at the caller. */
nparams = 0;
- for (child_die = die->child; child_die && child_die->tag;
- child_die = child_die->next)
+ for (die_info *child_die : die->children ())
{
if (child_die->tag != DW_TAG_call_site_parameter
&& child_die->tag != DW_TAG_GNU_call_site_parameter)
"block nor reference, for DIE %s [in module %s]"),
sect_offset_str (die->sect_off), objfile_name (objfile));
- for (child_die = die->child;
- child_die && child_die->tag;
- child_die = child_die->next)
+ for (die_info *child_die : die->children ())
{
struct call_site_parameter *parameter;
struct attribute *loc, *origin;
struct dwarf2_cu *cu)
{
unrelocated_addr low, high;
- struct die_info *child = die->child;
if (dwarf2_get_pc_bounds (die, &low, &high, cu, nullptr, nullptr)
>= PC_BOUNDS_RANGES)
subprograms, then check their pc bounds. Likewise, we need to
check lexical blocks as well, as they may also contain subprogram
definitions. */
- while (child && child->tag)
+ for (die_info *child : die->children ())
{
if (child->tag == DW_TAG_subprogram
|| child->tag == DW_TAG_lexical_block)
dwarf2_get_subprogram_pc_bounds (child, lowpc, highpc, cu);
- child = child->next;
}
}
}
else
{
- struct die_info *child = die->child;
-
- while (child && child->tag)
+ for (die_info *child : die->children ())
{
switch (child->tag) {
case DW_TAG_subprogram:
/* Ignore. */
break;
}
-
- child = child->next;
}
}
objfile_name (cu->per_objfile->objfile));
}
- for (die_info *child_die = die->child;
- child_die != NULL;
- child_die = child_die->next)
+ for (die_info *child_die : die->children ())
handle_struct_member_die (child_die, type, fi, template_args, cu);
}
else
variant.discriminant_value = discr->constant_value (0);
- for (die_info *variant_child = die->child;
- variant_child != NULL;
- variant_child = variant_child->next)
+ for (die_info *variant_child : die->children ())
handle_struct_member_die (variant_child, type, fi, template_args, cu);
variant.last_field = fi->fields.size ();
process_structure_scope (struct die_info *die, struct dwarf2_cu *cu)
{
struct objfile *objfile = cu->per_objfile->objfile;
- struct die_info *child_die;
struct type *type;
type = get_die_type (die, cu);
struct field_info fi;
std::vector<struct symbol *> template_args;
- child_die = die->child;
-
- while (child_die && child_die->tag)
- {
- handle_struct_member_die (child_die, type, &fi, &template_args, cu);
- child_die = child_die->next;
- }
+ for (die_info *child_die : die->children ())
+ handle_struct_member_die (child_die, type, &fi, &template_args, cu);
/* Attach template arguments to type. */
if (!template_args.empty ())
current die is a declaration. Normally, of course, a declaration
won't have any children at all. */
- child_die = die->child;
-
- while (child_die != NULL && child_die->tag)
+ for (die_info *child_die : die->children ())
{
if (child_die->tag == DW_TAG_member
|| child_die->tag == DW_TAG_variable
}
else
process_die (child_die, cu);
-
- child_die = child_die->next;
}
/* Do not consider external references. According to the DWARF standard,
struct type *type,
struct dwarf2_cu *cu)
{
- struct die_info *child_die;
int unsigned_enum = 1;
int flag_enum = 1;
auto_obstack obstack;
std::vector<struct field> fields;
- for (child_die = die->child;
- child_die != NULL && child_die->tag;
- child_die = child_die->next)
+ for (die_info *child_die : die->children ())
{
struct attribute *attr;
LONGEST value;
if (die->child != NULL)
{
- struct die_info *child_die;
-
- child_die = die->child;
- while (child_die && child_die->tag)
+ for (die_info *child_die : die->children ())
{
if (child_die->tag != DW_TAG_enumerator)
{
}
else
new_symbol (child_die, this_type, cu);
-
- child_die = child_die->next;
}
}
int bounds_offset = -1;
int max_align = -1;
std::vector<struct field> range_fields;
- for (struct die_info *child_die = die->child;
- child_die;
- child_die = child_die->next)
+ for (die_info *child_die : die->children ())
{
if (child_die->tag == DW_TAG_subrange_type)
{
read_array_type (struct die_info *die, struct dwarf2_cu *cu)
{
struct objfile *objfile = cu->per_objfile->objfile;
- struct die_info *child_die;
struct type *type;
struct type *element_type, *range_type, *index_type;
struct attribute *attr;
}
std::vector<struct type *> range_types;
- child_die = die->child;
- while (child_die && child_die->tag)
+ for (die_info *child_die : die->children ())
{
if (child_die->tag == DW_TAG_subrange_type
|| child_die->tag == DW_TAG_generic_subrange)
range_types.push_back (child_type);
}
}
- child_die = child_die->next;
}
if (range_types.empty ())
if (die->child != NULL)
{
struct objfile *objfile = cu->per_objfile->objfile;
- struct die_info *child_die;
- size_t n_entries = 0, size;
+ size_t size;
struct common_block *common_block;
struct symbol *sym;
- for (child_die = die->child;
- child_die && child_die->tag;
- child_die = child_die->next)
- ++n_entries;
+ auto range = die->children ();
+ size_t n_entries = std::distance (range.begin (), range.end ());
size = (sizeof (struct common_block)
+ (n_entries - 1) * sizeof (struct symbol *));
memset (common_block->contents, 0, n_entries * sizeof (struct symbol *));
common_block->n_entries = 0;
- for (child_die = die->child;
- child_die && child_die->tag;
- child_die = child_die->next)
+ for (die_info *child_die : die->children ())
{
/* Create the symbol in the DW_TAG_common_block block in the current
symbol scope. */
if (die->child != NULL)
{
- struct die_info *child_die = die->child;
-
- while (child_die && child_die->tag)
- {
- process_die (child_die, cu);
- child_die = child_die->next;
- }
+ for (die_info *child_die : die->children ())
+ process_die (child_die, cu);
}
}
static void
read_module (struct die_info *die, struct dwarf2_cu *cu)
{
- struct die_info *child_die = die->child;
struct type *type;
type = read_type_die (die, cu);
new_symbol (die, type, cu);
- while (child_die && child_die->tag)
- {
- process_die (child_die, cu);
- child_die = child_die->next;
- }
+ for (die_info *child_die : die->children ())
+ process_die (child_die, cu);
}
/* Return the name of the namespace represented by DIE. Set
if (die->child != NULL)
{
struct type *void_type = builtin_type (objfile)->builtin_void;
- struct die_info *child_die;
int nparams, iparams;
/* Count the number of parameters.
FIXME: GDB currently ignores vararg functions, but knows about
vararg member functions. */
nparams = 0;
- child_die = die->child;
- while (child_die && child_die->tag)
+ for (die_info *child_die : die->children ())
{
if (child_die->tag == DW_TAG_formal_parameter)
nparams++;
else if (child_die->tag == DW_TAG_unspecified_parameters)
ftype->set_has_varargs (true);
-
- child_die = child_die->next;
}
/* Allocate storage for parameters and fill them in. */
ftype->field (iparams).set_type (void_type);
iparams = 0;
- child_die = die->child;
- while (child_die && child_die->tag)
+ for (die_info *child_die : die->children ())
{
if (child_die->tag == DW_TAG_formal_parameter)
{
ftype->field (iparams).set_type (arg_type);
iparams++;
}
- child_die = child_die->next;
}
}
{
struct die_info *spec_die;
struct dwarf2_cu *spec_cu;
- struct die_info *child;
struct objfile *objfile = cu->per_objfile->objfile;
spec_cu = cu;
cu = spec_cu;
}
- for (child = die->child;
- child != NULL;
- child = child->next)
+ for (die_info *child : die->children ())
{
if (child->tag == DW_TAG_subprogram)
{
arrive at our entry. */
size_t nth_unnamed = 0;
- die_info *child = die->parent->child;
- while (child != die)
- {
- gdb_assert (child != nullptr);
- if (child->tag == DW_TAG_template_type_param
- || child->tag == DW_TAG_template_value_param)
- {
- if (dwarf2_attr (child, DW_AT_name, cu) == nullptr)
- ++nth_unnamed;
- }
- child = child->next;
- }
+ for (die_info *child : die->parent->children ())
+ {
+ if (child == die)
+ break;
+
+ gdb_assert (child != nullptr);
+ if (child->tag == DW_TAG_template_type_param
+ || child->tag == DW_TAG_template_value_param)
+ {
+ if (dwarf2_attr (child, DW_AT_name, cu) == nullptr)
+ ++nth_unnamed;
+ }
+ }
const std::string name_str = "<unnamed" + std::to_string (nth_unnamed) + ">";
return cu->per_objfile->objfile->intern (name_str.c_str ());