Re: [gcc patch 1/3] cp-demangle.c: Make `options' a parameter

2011-06-13 Thread Jan Kratochvil
On Mon, 13 Jun 2011 20:06:21 +0200, Ian Lance Taylor wrote:
> The new options parameter should be the second parameter, not the last.

OK, I agree.


> This is OK with those changes.

Checked in.


Thanks,
Jan


http://gcc.gnu.org/viewcvs?view=revision&revision=174999

--- trunk/libiberty/ChangeLog   2011/06/13 19:05:04 174998
+++ trunk/libiberty/ChangeLog   2011/06/13 22:30:02 174999
@@ -1,3 +1,12 @@
+2011-06-13  Jan Kratochvil  
+
+   * cp-demangle.c (struct d_print_info): Remove field options.
+   (d_print_init): Remove parameter options.
+   (cplus_demangle_print_callback): Update all the callers.
+   (d_print_comp, d_print_mod_list, d_print_mod, d_print_function_type)
+   (d_print_array_type, d_print_expr_op, d_print_cast, d_print_subexpr):
+   Add parameter options, update all the callers.
+
 2011-04-20  Jim Meyering  
 
* cp-demint.c (cplus_demangle_v3_components): Remove useless
--- trunk/libiberty/cp-demangle.c   2011/06/13 19:05:04 174998
+++ trunk/libiberty/cp-demangle.c   2011/06/13 22:30:02 174999
@@ -278,8 +278,6 @@
 enum { D_PRINT_BUFFER_LENGTH = 256 };
 struct d_print_info
 {
-  /* The options passed to the demangler.  */
-  int options;
   /* Fixed-length allocated buffer for demangled data, flushed to the
  callback with a NUL termination once full.  */
   char buf[D_PRINT_BUFFER_LENGTH];
@@ -436,7 +434,7 @@
 d_growable_string_callback_adapter (const char *, size_t, void *);
 
 static void
-d_print_init (struct d_print_info *, int, demangle_callbackref, void *);
+d_print_init (struct d_print_info *, demangle_callbackref, void *);
 
 static inline void d_print_error (struct d_print_info *);
 
@@ -454,32 +452,32 @@
 static inline char d_last_char (struct d_print_info *);
 
 static void
-d_print_comp (struct d_print_info *, const struct demangle_component *);
+d_print_comp (struct d_print_info *, int, const struct demangle_component *);
 
 static void
 d_print_java_identifier (struct d_print_info *, const char *, int);
 
 static void
-d_print_mod_list (struct d_print_info *, struct d_print_mod *, int);
+d_print_mod_list (struct d_print_info *, int, struct d_print_mod *, int);
 
 static void
-d_print_mod (struct d_print_info *, const struct demangle_component *);
+d_print_mod (struct d_print_info *, int, const struct demangle_component *);
 
 static void
-d_print_function_type (struct d_print_info *,
+d_print_function_type (struct d_print_info *, int,
const struct demangle_component *,
struct d_print_mod *);
 
 static void
-d_print_array_type (struct d_print_info *,
+d_print_array_type (struct d_print_info *, int,
 const struct demangle_component *,
 struct d_print_mod *);
 
 static void
-d_print_expr_op (struct d_print_info *, const struct demangle_component *);
+d_print_expr_op (struct d_print_info *, int, const struct demangle_component 
*);
 
 static void
-d_print_cast (struct d_print_info *, const struct demangle_component *);
+d_print_cast (struct d_print_info *, int, const struct demangle_component *);
 
 static int d_demangle_callback (const char *, int,
 demangle_callbackref, void *);
@@ -3293,10 +3291,9 @@
 /* Initialize a print information structure.  */
 
 static void
-d_print_init (struct d_print_info *dpi, int options,
-  demangle_callbackref callback, void *opaque)
+d_print_init (struct d_print_info *dpi, demangle_callbackref callback,
+ void *opaque)
 {
-  dpi->options = options;
   dpi->len = 0;
   dpi->last_char = '\0';
   dpi->templates = NULL;
@@ -3392,9 +3389,9 @@
 {
   struct d_print_info dpi;
 
-  d_print_init (&dpi, options, callback, opaque);
+  d_print_init (&dpi, callback, opaque);
 
-  d_print_comp (&dpi, dc);
+  d_print_comp (&dpi, options, dc);
 
   d_print_flush (&dpi);
 
@@ -3537,7 +3534,7 @@
if needed.  */
 
 static void
-d_print_subexpr (struct d_print_info *dpi,
+d_print_subexpr (struct d_print_info *dpi, int options,
 const struct demangle_component *dc)
 {
   int simple = 0;
@@ -3546,7 +3543,7 @@
 simple = 1;
   if (!simple)
 d_append_char (dpi, '(');
-  d_print_comp (dpi, dc);
+  d_print_comp (dpi, options, dc);
   if (!simple)
 d_append_char (dpi, ')');
 }
@@ -3554,7 +3551,7 @@
 /* Subroutine to handle components.  */
 
 static void
-d_print_comp (struct d_print_info *dpi,
+d_print_comp (struct d_print_info *dpi, int options,
   const struct demangle_component *dc)
 {
   if (dc == NULL)
@@ -3568,7 +3565,7 @@
   switch (dc->type)
 {
 case DEMANGLE_COMPONENT_NAME:
-  if ((dpi->options & DMGL_JAVA) == 0)
+  if ((options & DMGL_JAVA) == 0)
d_append_buffer (dpi, dc->u.s_name.s, dc->u.s_name.len);
   else
d_print_java_identifier (dpi, dc->u.s_name.s, dc->u.s_name.len);
@@ -3576,12 +3573,12 @@
 
 case DEMANGLE_COMPONENT_QUAL_NAME:
 case DEMANGLE_COMPONENT_LOCAL_NAME:
-  

Re: [gcc patch 1/3] cp-demangle.c: Make `options' a parameter

2011-06-13 Thread Ian Lance Taylor
On Thu, Jun 2, 2011 at 7:15 AM, Jan Kratochvil
 wrote:
>
> libiberty/
> 2011-05-24  Jan Kratochvil  
>
>        * cp-demangle.c (struct d_print_info): Remove field options.
>        (d_print_init): Remove parameter options.
>        (cplus_demangle_print_callback): Update all the callers.
>        (d_print_comp, d_print_mod_list, d_print_mod, d_print_function_type)
>        (d_print_array_type, d_print_expr_op, d_print_cast, d_print_subexpr):
>        Add parameter options, update all the callers.

>  static void
> -d_print_comp (struct d_print_info *, const struct demangle_component *);
> +d_print_comp (struct d_print_info *, const struct demangle_component *, int);

The new options parameter should be the second parameter, not the last.

>  static void
> -d_print_mod_list (struct d_print_info *, struct d_print_mod *, int);
> +d_print_mod_list (struct d_print_info *, struct d_print_mod *, int, int);

Likewise.

>  static void
> -d_print_mod (struct d_print_info *, const struct demangle_component *);
> +d_print_mod (struct d_print_info *, const struct demangle_component *, int);

Likewise.

>  static void
>  d_print_function_type (struct d_print_info *,
>                        const struct demangle_component *,
> -                       struct d_print_mod *);
> +                       struct d_print_mod *, int);

Likewise.

>  static void
>  d_print_array_type (struct d_print_info *,
>                     const struct demangle_component *,
> -                    struct d_print_mod *);
> +                    struct d_print_mod *, int);

Likewise.

>  static void
> -d_print_expr_op (struct d_print_info *, const struct demangle_component *);
> +d_print_expr_op (struct d_print_info *, const struct demangle_component *, 
> int);

Likewise.

>  static void
> -d_print_cast (struct d_print_info *, const struct demangle_component *);
> +d_print_cast (struct d_print_info *, const struct demangle_component *, int);

Likewise.

You will have to change the function definitions and calls accordingly.

This is OK with those changes.

Thanks.

Ian


[gcc patch 1/3] cp-demangle.c: Make `options' a parameter

2011-06-02 Thread Jan Kratochvil
Hi,

this patch makes no functionality change, it only reshuffles the code.

After printing the toplevel function type we want to disable DMGL_RET_POSTFIX
for any inner types.  Without such DMGL_RET_POSTFIX disabling for inner types
the new testcase would:

FAIL at line 3973, options --format=gnu-v3 --ret-postfix:
in:  _Z5outerIsEcPFilE
out: outer((*)(long)int)char
exp: outer(int (*)(long))char

At least I believe the "exp" form is what a user expects.

As so far DMGL_RET_POSTFIX was used (at least in GDB) only with DMGL_JAVA and
Java does not support pointers to methods it just was not needed so far.


Thanks,
Jan


libiberty/
2011-05-24  Jan Kratochvil  

* cp-demangle.c (struct d_print_info): Remove field options.
(d_print_init): Remove parameter options.
(cplus_demangle_print_callback): Update all the callers.
(d_print_comp, d_print_mod_list, d_print_mod, d_print_function_type)
(d_print_array_type, d_print_expr_op, d_print_cast, d_print_subexpr):
Add parameter options, update all the callers.

--- a/libiberty/cp-demangle.c
+++ b/libiberty/cp-demangle.c
@@ -278,8 +278,6 @@ struct d_growable_string
 enum { D_PRINT_BUFFER_LENGTH = 256 };
 struct d_print_info
 {
-  /* The options passed to the demangler.  */
-  int options;
   /* Fixed-length allocated buffer for demangled data, flushed to the
  callback with a NUL termination once full.  */
   char buf[D_PRINT_BUFFER_LENGTH];
@@ -436,7 +434,7 @@ static void
 d_growable_string_callback_adapter (const char *, size_t, void *);
 
 static void
-d_print_init (struct d_print_info *, int, demangle_callbackref, void *);
+d_print_init (struct d_print_info *, demangle_callbackref, void *);
 
 static inline void d_print_error (struct d_print_info *);
 
@@ -454,32 +452,32 @@ static inline void d_append_string (struct d_print_info 
*, const char *);
 static inline char d_last_char (struct d_print_info *);
 
 static void
-d_print_comp (struct d_print_info *, const struct demangle_component *);
+d_print_comp (struct d_print_info *, const struct demangle_component *, int);
 
 static void
 d_print_java_identifier (struct d_print_info *, const char *, int);
 
 static void
-d_print_mod_list (struct d_print_info *, struct d_print_mod *, int);
+d_print_mod_list (struct d_print_info *, struct d_print_mod *, int, int);
 
 static void
-d_print_mod (struct d_print_info *, const struct demangle_component *);
+d_print_mod (struct d_print_info *, const struct demangle_component *, int);
 
 static void
 d_print_function_type (struct d_print_info *,
const struct demangle_component *,
-   struct d_print_mod *);
+   struct d_print_mod *, int);
 
 static void
 d_print_array_type (struct d_print_info *,
 const struct demangle_component *,
-struct d_print_mod *);
+struct d_print_mod *, int);
 
 static void
-d_print_expr_op (struct d_print_info *, const struct demangle_component *);
+d_print_expr_op (struct d_print_info *, const struct demangle_component *, 
int);
 
 static void
-d_print_cast (struct d_print_info *, const struct demangle_component *);
+d_print_cast (struct d_print_info *, const struct demangle_component *, int);
 
 static int d_demangle_callback (const char *, int,
 demangle_callbackref, void *);
@@ -3293,10 +3291,9 @@ d_growable_string_callback_adapter (const char *s, 
size_t l, void *opaque)
 /* Initialize a print information structure.  */
 
 static void
-d_print_init (struct d_print_info *dpi, int options,
-  demangle_callbackref callback, void *opaque)
+d_print_init (struct d_print_info *dpi, demangle_callbackref callback,
+ void *opaque)
 {
-  dpi->options = options;
   dpi->len = 0;
   dpi->last_char = '\0';
   dpi->templates = NULL;
@@ -3392,9 +3389,9 @@ cplus_demangle_print_callback (int options,
 {
   struct d_print_info dpi;
 
-  d_print_init (&dpi, options, callback, opaque);
+  d_print_init (&dpi, callback, opaque);
 
-  d_print_comp (&dpi, dc);
+  d_print_comp (&dpi, dc, options);
 
   d_print_flush (&dpi);
 
@@ -3537,8 +3534,8 @@ d_pack_length (const struct demangle_component *dc)
if needed.  */
 
 static void
-d_print_subexpr (struct d_print_info *dpi,
-const struct demangle_component *dc)
+d_print_subexpr (struct d_print_info *dpi, const struct demangle_component *dc,
+int options)
 {
   int simple = 0;
   if (dc->type == DEMANGLE_COMPONENT_NAME
@@ -3546,7 +3543,7 @@ d_print_subexpr (struct d_print_info *dpi,
 simple = 1;
   if (!simple)
 d_append_char (dpi, '(');
-  d_print_comp (dpi, dc);
+  d_print_comp (dpi, dc, options);
   if (!simple)
 d_append_char (dpi, ')');
 }
@@ -3554,8 +3551,8 @@ d_print_subexpr (struct d_print_info *dpi,
 /* Subroutine to handle components.  */
 
 static void
-d_print_comp (struct d_print_info *dpi,
-  const struct demangle_component *dc)
+d