-/* Helper for expression_completer which recursively adds field and
- method names from TYPE, a struct or union type, to the OUTPUT
- list. */
-
-static void
-add_struct_fields (struct type *type, completion_list &output,
- const char *fieldname, int namelen)
-{
- int i;
- int computed_type_name = 0;
- const char *type_name = NULL;
-
- type = check_typedef (type);
- for (i = 0; i < TYPE_NFIELDS (type); ++i)
- {
- if (i < TYPE_N_BASECLASSES (type))
- add_struct_fields (TYPE_BASECLASS (type, i),
- output, fieldname, namelen);
- else if (TYPE_FIELD_NAME (type, i))
- {
- if (TYPE_FIELD_NAME (type, i)[0] != '\0')
- {
- if (! strncmp (TYPE_FIELD_NAME (type, i),
- fieldname, namelen))
- output.emplace_back (xstrdup (TYPE_FIELD_NAME (type, i)));
- }
- else if (TYPE_FIELD_TYPE (type, i)->code () == TYPE_CODE_UNION)
- {
- /* Recurse into anonymous unions. */
- add_struct_fields (TYPE_FIELD_TYPE (type, i),
- output, fieldname, namelen);
- }
- }
- }
-
- for (i = TYPE_NFN_FIELDS (type) - 1; i >= 0; --i)
- {
- const char *name = TYPE_FN_FIELDLIST_NAME (type, i);
-
- if (name && ! strncmp (name, fieldname, namelen))
- {
- if (!computed_type_name)
- {
- type_name = type->name ();
- computed_type_name = 1;
- }
- /* Omit constructors from the completion list. */
- if (!type_name || strcmp (type_name, name))
- output.emplace_back (xstrdup (name));
- }
- }
-}
-