* ui-out.c (ui_out_get_field_separator): Remove unused function.
[deliverable/binutils-gdb.git] / gdb / c-typeprint.c
index c70fa4beb3d2d123c88fd28f13440c311967e110..021223217eb3445b727ce25ae3f49767c0e9a8a4 100644 (file)
@@ -387,17 +387,16 @@ c_type_print_modifier (struct type *type, struct ui_file *stream,
 
 /* Print out the arguments of TYPE, which should have TYPE_CODE_METHOD
    or TYPE_CODE_FUNC, to STREAM.  Artificial arguments, such as "this"
-   in non-static methods, are displayed if SHOW_ARTIFICIAL is
-   non-zero.  If SHOW_ARTIFICIAL is zero and LANGUAGE is language_cplus
-   the topmost parameter types get removed their possible const and volatile
-   qualifiers to match demangled linkage name parameters part of such function
-   type.  LANGUAGE is the language in which TYPE was defined.  This is
-   a necessary evil since this code is used by the C, C++, and Java backends.
-   */
+   in non-static methods, are displayed if LINKAGE_NAME is zero.  If
+   LINKAGE_NAME is non-zero and LANGUAGE is language_cplus the topmost
+   parameter types get removed their possible const and volatile qualifiers to
+   match demangled linkage name parameters part of such function type.
+   LANGUAGE is the language in which TYPE was defined.  This is a necessary
+   evil since this code is used by the C, C++, and Java backends.  */
 
 void
 c_type_print_args (struct type *type, struct ui_file *stream,
-                  int show_artificial, enum language language)
+                  int linkage_name, enum language language)
 {
   int i, len;
   struct field *args;
@@ -411,7 +410,7 @@ c_type_print_args (struct type *type, struct ui_file *stream,
     {
       struct type *param_type;
 
-      if (TYPE_FIELD_ARTIFICIAL (type, i) && !show_artificial)
+      if (TYPE_FIELD_ARTIFICIAL (type, i) && linkage_name)
        continue;
 
       if (printed_any)
@@ -422,7 +421,7 @@ c_type_print_args (struct type *type, struct ui_file *stream,
 
       param_type = TYPE_FIELD_TYPE (type, i);
 
-      if (language == language_cplus && !show_artificial)
+      if (language == language_cplus && linkage_name)
        {
          /* C++ standard, 13.1 Overloadable declarations, point 3, item:
             - Parameter declarations that differ only in the presence or
@@ -658,8 +657,7 @@ c_type_print_varspec_suffix (struct type *type,
       if (passed_a_ptr)
        fprintf_filtered (stream, ")");
       if (!demangled_args)
-       c_type_print_args (type, stream, 1,
-                          current_language->la_language);
+       c_type_print_args (type, stream, 0, current_language->la_language);
       c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream,
                                   show, passed_a_ptr, 0);
       break;
@@ -721,9 +719,6 @@ c_type_print_base (struct type *type, struct ui_file *stream,
   int i;
   int len, real_len;
   int lastval;
-  char *mangled_name;
-  char *demangled_name;
-  char *demangled_no_static;
   enum
     {
       s_none, s_public, s_private, s_protected
@@ -1003,7 +998,10 @@ c_type_print_base (struct type *type, struct ui_file *stream,
 
              for (j = 0; j < len2; j++)
                {
-                 char *physname = TYPE_FN_FIELD_PHYSNAME (f, j);
+                 const char *mangled_name;
+                 char *demangled_name;
+                 struct cleanup *inner_cleanup;
+                 const char *physname = TYPE_FN_FIELD_PHYSNAME (f, j);
                  int is_full_physname_constructor =
                    is_constructor_name (physname) 
                    || is_destructor_name (physname)
@@ -1013,6 +1011,8 @@ c_type_print_base (struct type *type, struct ui_file *stream,
                  if (TYPE_FN_FIELD_ARTIFICIAL (f, j))
                    continue;
 
+                 inner_cleanup = make_cleanup (null_cleanup, NULL);
+
                  QUIT;
                  if (TYPE_FN_FIELD_PROTECTED (f, j))
                    {
@@ -1066,8 +1066,14 @@ c_type_print_base (struct type *type, struct ui_file *stream,
                      fputs_filtered (" ", stream);
                    }
                  if (TYPE_FN_FIELD_STUB (f, j))
-                   /* Build something we can demangle.  */
-                   mangled_name = gdb_mangle_name (type, i, j);
+                   {
+                     char *tem;
+
+                     /* Build something we can demangle.  */
+                     tem = gdb_mangle_name (type, i, j);
+                     make_cleanup (xfree, tem);
+                     mangled_name = tem;
+                   }
                  else
                    mangled_name = TYPE_FN_FIELD_PHYSNAME (f, j);
 
@@ -1109,6 +1115,7 @@ c_type_print_base (struct type *type, struct ui_file *stream,
                      if (p != NULL)
                        {
                          int length = p - demangled_no_class;
+                         char *demangled_no_static;
 
                          demangled_no_static
                            = (char *) xmalloc (length + 1);
@@ -1123,8 +1130,7 @@ c_type_print_base (struct type *type, struct ui_file *stream,
                      xfree (demangled_name);
                    }
 
-                 if (TYPE_FN_FIELD_STUB (f, j))
-                   xfree (mangled_name);
+                 do_cleanups (inner_cleanup);
 
                  fprintf_filtered (stream, ";\n");
                }
This page took 0.026561 seconds and 4 git commands to generate.