diff options
author | Tom Tromey <tromey@redhat.com> | 2009-02-03 01:00:40 +0000 |
---|---|---|
committer | Tom Tromey <tromey@redhat.com> | 2009-02-03 01:00:40 +0000 |
commit | 1c71341a8f5470b0873e57fb7bb7641a8e1d436d (patch) | |
tree | ecef2c44bb26c88b8b37e9dc408167ad277f5000 /gdb/completer.c | |
parent | b6b5e91cdd590a5e17772be993fb097dd012d173 (diff) | |
download | gdb-1c71341a8f5470b0873e57fb7bb7641a8e1d436d.zip gdb-1c71341a8f5470b0873e57fb7bb7641a8e1d436d.tar.gz gdb-1c71341a8f5470b0873e57fb7bb7641a8e1d436d.tar.bz2 |
gdb
PR gdb/2489:
* completer.c (count_struct_fields): Count method names.
(add_struct_fields): Add matching method names.
gdb/testsuite
* gdb.cp/Makefile.in (EXECUTABLES): Add pr2489.
* gdb.cp/pr2489.cc: New file.
* gdb.cp/cpcompletion.exp: New file.
Diffstat (limited to 'gdb/completer.c')
-rw-r--r-- | gdb/completer.c | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/gdb/completer.c b/gdb/completer.c index b1b0cf3..5d7225f 100644 --- a/gdb/completer.c +++ b/gdb/completer.c @@ -339,7 +339,7 @@ location_completer (char *text, char *word) } /* Helper for expression_completer which recursively counts the number - of named fields in a structure or union type. */ + of named fields and methods in a structure or union type. */ static int count_struct_fields (struct type *type) { @@ -353,17 +353,25 @@ count_struct_fields (struct type *type) else if (TYPE_FIELD_NAME (type, i)) ++result; } + + 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 names - from TYPE, a struct or union type, to the array OUTPUT. This - function assumes that OUTPUT is correctly-sized. */ +/* Helper for expression_completer which recursively adds field and + method names from TYPE, a struct or union type, to the array + OUTPUT. This function assumes that OUTPUT is correctly-sized. */ static void add_struct_fields (struct type *type, int *nextp, char **output, char *fieldname, int namelen) { int i; + char *type_name = NULL; CHECK_TYPEDEF (type); for (i = 0; i < TYPE_NFIELDS (type); ++i) @@ -378,6 +386,22 @@ add_struct_fields (struct type *type, int *nextp, char **output, ++*nextp; } } + + for (i = TYPE_NFN_FIELDS (type) - 1; i >= 0; --i) + { + char *name = TYPE_FN_FIELDLIST_NAME (type, i); + if (name && ! strncmp (name, fieldname, namelen)) + { + if (!type_name) + type_name = type_name_no_tag (type); + /* Omit constructors from the completion list. */ + if (strcmp (type_name, name)) + { + output[*nextp] = xstrdup (name); + ++*nextp; + } + } + } } /* Complete on expressions. Often this means completing on symbol |