This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[drow-cplus-branch] More type printer updates
- From: Daniel Jacobowitz <drow at mvista dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Fri, 1 Nov 2002 11:45:46 -0500
- Subject: [drow-cplus-branch] More type printer updates
This patch:
- removes a completely redundant function
- Honors artificial arguments; meant to do this ages ago and got
sidetracked.
- Correctly considers T5 to be a constructor name for T5<int>.
Committed on the branch.
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
2002-11-01 Daniel Jacobowitz <drow@mvista.com>
* c-typeprint.c (c_type_print_args): Remove.
(cp_type_print_method_args): Remove unused PREFIX argument.
Simplify logic. Skip FIELD_ARTIFICIAL arguments.
(c_type_print_varspec_suffix): Call cp_type_print_method_args.
(c_type_print_base): Handle template classes when looking for
constructor field names. Update call to cp_type_print_method_args.
Index: c-typeprint.c
===================================================================
RCS file: /cvs/src/src/gdb/c-typeprint.c,v
retrieving revision 1.22.10.4
diff -u -p -r1.22.10.4 c-typeprint.c
--- c-typeprint.c 30 Oct 2002 23:11:47 -0000 1.22.10.4
+++ c-typeprint.c 31 Oct 2002 23:04:34 -0000
@@ -41,12 +41,10 @@
/* Flag indicating target was compiled by HP compiler */
extern int hp_som_som_object_present;
-static void cp_type_print_method_args (struct type *mtype, char *prefix,
+static void cp_type_print_method_args (struct type *mtype,
char *varstring, int staticp,
struct ui_file *stream);
-static void c_type_print_args (struct type *, struct ui_file *);
-
static void cp_type_print_derivation_info (struct ui_file *, struct type *);
static void c_type_print_varspec_prefix (struct type *, struct ui_file *, int,
@@ -153,36 +151,41 @@ cp_type_print_derivation_info (struct ui
/* Print the C++ method arguments ARGS to the file STREAM. */
static void
-cp_type_print_method_args (struct type *mtype, char *prefix, char *varstring,
+cp_type_print_method_args (struct type *mtype, char *varstring,
int staticp, struct ui_file *stream)
{
struct field *args = TYPE_FIELDS (mtype);
int nargs = TYPE_NFIELDS (mtype);
int varargs = TYPE_VARARGS (mtype);
- int i;
+ int i, printed_arg;
- fprintf_symbol_filtered (stream, prefix, language_cplus, DMGL_ANSI);
fprintf_symbol_filtered (stream, varstring, language_cplus, DMGL_ANSI);
fputs_filtered ("(", stream);
- /* Skip the class variable. */
+ /* Always skip the class variable. */
i = staticp ? 0 : 1;
- if (nargs > i)
+ printed_arg = 0;
+ while (i < nargs)
{
- while (i < nargs)
+ /* Don't print artificial arguments. */
+ if (FIELD_ARTIFICIAL (args[i]))
{
- /* Don't recursively expand classes in method arguments. */
- type_print (args[i++].type, "", stream, -1);
-
- if (i == nargs && varargs)
- fprintf_filtered (stream, ", ...");
- else if (i < nargs)
- fprintf_filtered (stream, ", ");
+ i++;
+ continue;
}
+
+ /* Don't recursively expand classes in method arguments. */
+ type_print (args[i++].type, "", stream, -1);
+ printed_arg = 1;
+
+ if (i < nargs || varargs)
+ fprintf_filtered (stream, ", ");
}
- else if (varargs)
+
+ if (varargs)
fprintf_filtered (stream, "...");
- else if (current_language->la_language == language_cplus)
+ else if (printed_arg == 0
+ && current_language->la_language == language_cplus)
fprintf_filtered (stream, "void");
fprintf_filtered (stream, ")");
@@ -350,45 +353,6 @@ c_type_print_modifier_after (struct type
c_type_print_modifier (type, stream, 1, 0);
}
-static void
-c_type_print_args (struct type *type, struct ui_file *stream)
-{
- int i;
- struct field *args;
-
- fprintf_filtered (stream, "(");
- args = TYPE_FIELDS (type);
- if (args != NULL)
- {
- int i;
-
- /* FIXME drow/2002-05-31: Always skips the first argument,
- should we be checking for static members? */
-
- for (i = 1; i < TYPE_NFIELDS (type); i++)
- {
- c_print_type (args[i].type, "", stream, -1, 0);
- if (i != TYPE_NFIELDS (type))
- {
- fprintf_filtered (stream, ",");
- wrap_here (" ");
- }
- }
- if (TYPE_VARARGS (type))
- fprintf_filtered (stream, "...");
- else if (i == 1
- && (current_language->la_language == language_cplus))
- fprintf_filtered (stream, "void");
- }
- else if (current_language->la_language == language_cplus)
- {
- fprintf_filtered (stream, "void");
- }
-
- fprintf_filtered (stream, ")");
-}
-
-
/* Return true iff the j'th overloading of the i'th method of TYPE
is a type conversion operator, like `operator int () { ... }'.
When listing a class's methods, we don't print the return type of
@@ -569,9 +533,7 @@ c_type_print_varspec_suffix (struct type
fprintf_filtered (stream, ")");
c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 0, 0);
if (passed_a_ptr)
- {
- c_type_print_args (type, stream);
- }
+ cp_type_print_method_args (type, "", 0, stream);
break;
case TYPE_CODE_PTR:
@@ -945,12 +907,17 @@ c_type_print_base (struct type *type, st
int j, len2 = TYPE_FN_FIELDLIST_LENGTH (type, i);
char *method_name;
char *name = type_name_no_tag (type);
- int is_constructor, is_destructor;
+ int is_constructor, is_destructor, name_len;
check_stub_method_group (type, i);
+
method_name = TYPE_FN_FIELDLIST_NAME (type, i);
- is_constructor = name && STREQ (method_name, name);
+ name_len = strlen (method_name);
+ is_constructor = name
+ && !strncmp (method_name, name, name_len)
+ && (name[name_len] == 0 || name[name_len] == '<');
is_destructor = method_name[0] == '~';
+
for (j = 0; j < len2; j++)
{
/* Do not print out artificial methods. */
@@ -1009,7 +976,6 @@ c_type_print_base (struct type *type, st
}
cp_type_print_method_args (TYPE_FN_FIELD_TYPE (f, j),
- "",
method_name,
TYPE_FN_FIELD_STATIC_P (f, j),
stream);