This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
FYI: remove count_struct_fields
- From: Tom Tromey <tromey at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Tue, 20 Nov 2012 11:18:06 -0700
- Subject: FYI: remove count_struct_fields
I'm checking this in. I think it is obvious.
count_struct_fields is no longer needed now that completion uses VEC.
It has a single caller that just discards the value it computes.
Regression tested on x86-64 Fedora 16.
Tom
2012-11-20 Tom Tromey <tromey@redhat.com>
* completer.c (count_struct_fields): Remove.
(expression_completer): Don't call count_struct_fields.
Index: completer.c
===================================================================
RCS file: /cvs/src/src/gdb/completer.c,v
retrieving revision 1.49
diff -u -r1.49 completer.c
--- completer.c 10 Aug 2012 05:03:11 -0000 1.49
+++ completer.c 20 Nov 2012 18:16:21 -0000
@@ -327,39 +327,6 @@
return list;
}
-/* Helper for expression_completer which recursively counts the number
- of named fields and methods in a structure or union type. */
-static int
-count_struct_fields (struct type *type)
-{
- int i, result = 0;
-
- CHECK_TYPEDEF (type);
- for (i = 0; i < TYPE_NFIELDS (type); ++i)
- {
- if (i < TYPE_N_BASECLASSES (type))
- result += count_struct_fields (TYPE_BASECLASS (type, i));
- else if (TYPE_FIELD_NAME (type, i))
- {
- if (TYPE_FIELD_NAME (type, i)[0] != '\0')
- ++result;
- else if (TYPE_CODE (TYPE_FIELD_TYPE (type, i)) == TYPE_CODE_UNION)
- {
- /* Recurse into anonymous unions. */
- result += count_struct_fields (TYPE_FIELD_TYPE (type, i));
- }
- }
- }
-
- for (i = TYPE_NFN_FIELDS (type) - 1; i >= 0; --i)
- {
- if (TYPE_FN_FIELDLIST_NAME (type, i))
- ++result;
- }
-
- return result;
-}
-
/* Helper for expression_completer which recursively adds field and
method names from TYPE, a struct or union type, to the array
OUTPUT. */
@@ -447,7 +414,6 @@
if (TYPE_CODE (type) == TYPE_CODE_UNION
|| TYPE_CODE (type) == TYPE_CODE_STRUCT)
{
- int alloc = count_struct_fields (type);
int flen = strlen (fieldname);
VEC (char_ptr) *result = NULL;