View | Details | Return to bug 70909 | Differences between
and this patch

Collapse All | Expand All

(-)a/include/demangle.h (-2 / +7 lines)
Lines 494-499 struct demangle_component Link Here
494
  /* The type of this component.  */
494
  /* The type of this component.  */
495
  enum demangle_component_type type;
495
  enum demangle_component_type type;
496
496
497
  /* Guard against recursive component printing.
498
     Initialize to zero.  Private to d_print_comp.
499
     All other fields are final after initialization.  */
500
  int d_printing;
501
497
  union
502
  union
498
  {
503
  {
499
    /* For DEMANGLE_COMPONENT_NAME.  */
504
    /* For DEMANGLE_COMPONENT_NAME.  */
Lines 688-694 cplus_demangle_v3_components (const char *mangled, int options, void **mem); Link Here
688
693
689
extern char *
694
extern char *
690
cplus_demangle_print (int options,
695
cplus_demangle_print (int options,
691
                      const struct demangle_component *tree,
696
                      struct demangle_component *tree,
692
                      int estimated_length,
697
                      int estimated_length,
693
                      size_t *p_allocated_size);
698
                      size_t *p_allocated_size);
694
699
Lines 708-714 cplus_demangle_print (int options, Link Here
708
713
709
extern int
714
extern int
710
cplus_demangle_print_callback (int options,
715
cplus_demangle_print_callback (int options,
711
                               const struct demangle_component *tree,
716
                               struct demangle_component *tree,
712
                               demangle_callbackref callback, void *opaque);
717
                               demangle_callbackref callback, void *opaque);
713
718
714
#ifdef __cplusplus
719
#ifdef __cplusplus
(-)a/libiberty/cp-demangle.c (-25 / +38 lines)
Lines 173-182 static struct demangle_component *d_mangled_name (struct d_info *, int); Link Here
173
static struct demangle_component *d_type (struct d_info *);
173
static struct demangle_component *d_type (struct d_info *);
174
174
175
#define cplus_demangle_print d_print
175
#define cplus_demangle_print d_print
176
static char *d_print (int, const struct demangle_component *, int, size_t *);
176
static char *d_print (int, struct demangle_component *, int, size_t *);
177
177
178
#define cplus_demangle_print_callback d_print_callback
178
#define cplus_demangle_print_callback d_print_callback
179
static int d_print_callback (int, const struct demangle_component *,
179
static int d_print_callback (int, struct demangle_component *,
180
                             demangle_callbackref, void *);
180
                             demangle_callbackref, void *);
181
181
182
#define cplus_demangle_init_info d_init_info
182
#define cplus_demangle_init_info d_init_info
Lines 265-271 struct d_print_mod Link Here
265
     in which they appeared in the mangled string.  */
265
     in which they appeared in the mangled string.  */
266
  struct d_print_mod *next;
266
  struct d_print_mod *next;
267
  /* The modifier.  */
267
  /* The modifier.  */
268
  const struct demangle_component *mod;
268
  struct demangle_component *mod;
269
  /* Whether this modifier was printed.  */
269
  /* Whether this modifier was printed.  */
270
  int printed;
270
  int printed;
271
  /* The list of templates which applies to this modifier.  */
271
  /* The list of templates which applies to this modifier.  */
Lines 533-539 static inline void d_append_string (struct d_print_info *, const char *); Link Here
533
static inline char d_last_char (struct d_print_info *);
533
static inline char d_last_char (struct d_print_info *);
534
534
535
static void
535
static void
536
d_print_comp (struct d_print_info *, int, const struct demangle_component *);
536
d_print_comp (struct d_print_info *, int, struct demangle_component *);
537
537
538
static void
538
static void
539
d_print_java_identifier (struct d_print_info *, const char *, int);
539
d_print_java_identifier (struct d_print_info *, const char *, int);
Lines 542-566 static void Link Here
542
d_print_mod_list (struct d_print_info *, int, struct d_print_mod *, int);
542
d_print_mod_list (struct d_print_info *, int, struct d_print_mod *, int);
543
543
544
static void
544
static void
545
d_print_mod (struct d_print_info *, int, const struct demangle_component *);
545
d_print_mod (struct d_print_info *, int, struct demangle_component *);
546
546
547
static void
547
static void
548
d_print_function_type (struct d_print_info *, int,
548
d_print_function_type (struct d_print_info *, int,
549
                       const struct demangle_component *,
549
                       struct demangle_component *,
550
                       struct d_print_mod *);
550
                       struct d_print_mod *);
551
551
552
static void
552
static void
553
d_print_array_type (struct d_print_info *, int,
553
d_print_array_type (struct d_print_info *, int,
554
                    const struct demangle_component *,
554
                    struct demangle_component *,
555
                    struct d_print_mod *);
555
                    struct d_print_mod *);
556
556
557
static void
557
static void
558
d_print_expr_op (struct d_print_info *, int, const struct demangle_component *);
558
d_print_expr_op (struct d_print_info *, int, struct demangle_component *);
559
559
560
static void d_print_cast (struct d_print_info *, int,
560
static void d_print_cast (struct d_print_info *, int,
561
			  const struct demangle_component *);
561
			  struct demangle_component *);
562
static void d_print_conversion (struct d_print_info *, int,
562
static void d_print_conversion (struct d_print_info *, int,
563
				const struct demangle_component *);
563
				struct demangle_component *);
564
564
565
static int d_demangle_callback (const char *, int,
565
static int d_demangle_callback (const char *, int,
566
                                demangle_callbackref, void *);
566
                                demangle_callbackref, void *);
Lines 926-931 d_make_empty (struct d_info *di) Link Here
926
  if (di->next_comp >= di->num_comps)
926
  if (di->next_comp >= di->num_comps)
927
    return NULL;
927
    return NULL;
928
  p = &di->comps[di->next_comp];
928
  p = &di->comps[di->next_comp];
929
  p->d_printing = 0;
929
  ++di->next_comp;
930
  ++di->next_comp;
930
  return p;
931
  return p;
931
}
932
}
Lines 4222-4228 d_last_char (struct d_print_info *dpi) Link Here
4222
CP_STATIC_IF_GLIBCPP_V3
4223
CP_STATIC_IF_GLIBCPP_V3
4223
int
4224
int
4224
cplus_demangle_print_callback (int options,
4225
cplus_demangle_print_callback (int options,
4225
                               const struct demangle_component *dc,
4226
                               struct demangle_component *dc,
4226
                               demangle_callbackref callback, void *opaque)
4227
                               demangle_callbackref callback, void *opaque)
4227
{
4228
{
4228
  struct d_print_info dpi;
4229
  struct d_print_info dpi;
Lines 4265-4271 cplus_demangle_print_callback (int options, Link Here
4265
4266
4266
CP_STATIC_IF_GLIBCPP_V3
4267
CP_STATIC_IF_GLIBCPP_V3
4267
char *
4268
char *
4268
cplus_demangle_print (int options, const struct demangle_component *dc,
4269
cplus_demangle_print (int options, struct demangle_component *dc,
4269
                      int estimate, size_t *palc)
4270
                      int estimate, size_t *palc)
4270
{
4271
{
4271
  struct d_growable_string dgs;
4272
  struct d_growable_string dgs;
Lines 4425-4431 d_args_length (struct d_print_info *dpi, const struct demangle_component *dc) Link Here
4425
4426
4426
static void
4427
static void
4427
d_print_subexpr (struct d_print_info *dpi, int options,
4428
d_print_subexpr (struct d_print_info *dpi, int options,
4428
		 const struct demangle_component *dc)
4429
		 struct demangle_component *dc)
4429
{
4430
{
4430
  int simple = 0;
4431
  int simple = 0;
4431
  if (dc->type == DEMANGLE_COMPONENT_NAME
4432
  if (dc->type == DEMANGLE_COMPONENT_NAME
Lines 4501-4509 d_get_saved_scope (struct d_print_info *dpi, Link Here
4501
4502
4502
static int
4503
static int
4503
d_maybe_print_fold_expression (struct d_print_info *dpi, int options,
4504
d_maybe_print_fold_expression (struct d_print_info *dpi, int options,
4504
			       const struct demangle_component *dc)
4505
			       struct demangle_component *dc)
4505
{
4506
{
4506
  const struct demangle_component *ops, *operator_, *op1, *op2;
4507
  struct demangle_component *ops, *operator_, *op1, *op2;
4507
  int save_idx;
4508
  int save_idx;
4508
4509
4509
  const char *fold_code = d_left (dc)->u.s_operator.op->code;
4510
  const char *fold_code = d_left (dc)->u.s_operator.op->code;
Lines 4564-4574 d_maybe_print_fold_expression (struct d_print_info *dpi, int options, Link Here
4564
4565
4565
static void
4566
static void
4566
d_print_comp_inner (struct d_print_info *dpi, int options,
4567
d_print_comp_inner (struct d_print_info *dpi, int options,
4567
		    const struct demangle_component *dc)
4568
		    struct demangle_component *dc)
4568
{
4569
{
4569
  /* Magic variable to let reference smashing skip over the next modifier
4570
  /* Magic variable to let reference smashing skip over the next modifier
4570
     without needing to modify *dc.  */
4571
     without needing to modify *dc.  */
4571
  const struct demangle_component *mod_inner = NULL;
4572
  struct demangle_component *mod_inner = NULL;
4572
4573
4573
  /* Variable used to store the current templates while a previously
4574
  /* Variable used to store the current templates while a previously
4574
     captured scope is used.  */
4575
     captured scope is used.  */
Lines 4947-4953 d_print_comp_inner (struct d_print_info *dpi, int options, Link Here
4947
    case DEMANGLE_COMPONENT_RVALUE_REFERENCE:
4948
    case DEMANGLE_COMPONENT_RVALUE_REFERENCE:
4948
      {
4949
      {
4949
	/* Handle reference smashing: & + && = &.  */
4950
	/* Handle reference smashing: & + && = &.  */
4950
	const struct demangle_component *sub = d_left (dc);
4951
	struct demangle_component *sub = d_left (dc);
4951
	if (!dpi->is_lambda_arg
4952
	if (!dpi->is_lambda_arg
4952
	    && sub->type == DEMANGLE_COMPONENT_TEMPLATE_PARAM)
4953
	    && sub->type == DEMANGLE_COMPONENT_TEMPLATE_PARAM)
4953
	  {
4954
	  {
Lines 5653-5661 d_print_comp_inner (struct d_print_info *dpi, int options, Link Here
5653
5654
5654
static void
5655
static void
5655
d_print_comp (struct d_print_info *dpi, int options,
5656
d_print_comp (struct d_print_info *dpi, int options,
5656
	      const struct demangle_component *dc)
5657
	      struct demangle_component *dc)
5657
{
5658
{
5658
  struct d_component_stack self;
5659
  struct d_component_stack self;
5660
  /* We need to allow one level of recursion for function types,
5661
     which are printed twice with different options depending on
5662
     whether or not the return type needs to be printed.
5663
     XXX We need to allow another level of recursion because... ???  */
5664
  if (dc == NULL || dc->d_printing > 2)
5665
    {
5666
      d_print_error (dpi);
5667
      return;
5668
    }
5669
  else
5670
    dc->d_printing++;
5659
5671
5660
  self.dc = dc;
5672
  self.dc = dc;
5661
  self.parent = dpi->component_stack;
5673
  self.parent = dpi->component_stack;
Lines 5664-5669 d_print_comp (struct d_print_info *dpi, int options, Link Here
5664
  d_print_comp_inner (dpi, options, dc);
5676
  d_print_comp_inner (dpi, options, dc);
5665
5677
5666
  dpi->component_stack = self.parent;
5678
  dpi->component_stack = self.parent;
5679
  dc->d_printing--;
5667
}
5680
}
5668
5681
5669
/* Print a Java dentifier.  For Java we try to handle encoded extended
5682
/* Print a Java dentifier.  For Java we try to handle encoded extended
Lines 5805-5811 d_print_mod_list (struct d_print_info *dpi, int options, Link Here
5805
5818
5806
static void
5819
static void
5807
d_print_mod (struct d_print_info *dpi, int options,
5820
d_print_mod (struct d_print_info *dpi, int options,
5808
             const struct demangle_component *mod)
5821
             struct demangle_component *mod)
5809
{
5822
{
5810
  switch (mod->type)
5823
  switch (mod->type)
5811
    {
5824
    {
Lines 5897-5903 d_print_mod (struct d_print_info *dpi, int options, Link Here
5897
5910
5898
static void
5911
static void
5899
d_print_function_type (struct d_print_info *dpi, int options,
5912
d_print_function_type (struct d_print_info *dpi, int options,
5900
                       const struct demangle_component *dc,
5913
                       struct demangle_component *dc,
5901
                       struct d_print_mod *mods)
5914
                       struct d_print_mod *mods)
5902
{
5915
{
5903
  int need_paren;
5916
  int need_paren;
Lines 5975-5981 d_print_function_type (struct d_print_info *dpi, int options, Link Here
5975
5988
5976
static void
5989
static void
5977
d_print_array_type (struct d_print_info *dpi, int options,
5990
d_print_array_type (struct d_print_info *dpi, int options,
5978
                    const struct demangle_component *dc,
5991
                    struct demangle_component *dc,
5979
                    struct d_print_mod *mods)
5992
                    struct d_print_mod *mods)
5980
{
5993
{
5981
  int need_space;
5994
  int need_space;
Lines 6029-6035 d_print_array_type (struct d_print_info *dpi, int options, Link Here
6029
6042
6030
static void
6043
static void
6031
d_print_expr_op (struct d_print_info *dpi, int options,
6044
d_print_expr_op (struct d_print_info *dpi, int options,
6032
                 const struct demangle_component *dc)
6045
                 struct demangle_component *dc)
6033
{
6046
{
6034
  if (dc->type == DEMANGLE_COMPONENT_OPERATOR)
6047
  if (dc->type == DEMANGLE_COMPONENT_OPERATOR)
6035
    d_append_buffer (dpi, dc->u.s_operator.op->name,
6048
    d_append_buffer (dpi, dc->u.s_operator.op->name,
Lines 6042-6048 d_print_expr_op (struct d_print_info *dpi, int options, Link Here
6042
6055
6043
static void
6056
static void
6044
d_print_cast (struct d_print_info *dpi, int options,
6057
d_print_cast (struct d_print_info *dpi, int options,
6045
		    const struct demangle_component *dc)
6058
	      struct demangle_component *dc)
6046
{
6059
{
6047
  d_print_comp (dpi, options, d_left (dc));
6060
  d_print_comp (dpi, options, d_left (dc));
6048
}
6061
}
Lines 6051-6057 d_print_cast (struct d_print_info *dpi, int options, Link Here
6051
6064
6052
static void
6065
static void
6053
d_print_conversion (struct d_print_info *dpi, int options,
6066
d_print_conversion (struct d_print_info *dpi, int options,
6054
		    const struct demangle_component *dc)
6067
		    struct demangle_component *dc)
6055
{
6068
{
6056
  struct d_print_template dpt;
6069
  struct d_print_template dpt;
6057
6070
(-)a/libiberty/cp-demint.c (+3 lines)
Lines 123-128 cplus_demangle_fill_component (struct demangle_component *p, Link Here
123
  p->type = type;
123
  p->type = type;
124
  p->u.s_binary.left = left;
124
  p->u.s_binary.left = left;
125
  p->u.s_binary.right = right;
125
  p->u.s_binary.right = right;
126
  p->d_printing = 0;
126
127
127
  return 1;
128
  return 1;
128
}
129
}
Lines 146-151 cplus_demangle_fill_builtin_type (struct demangle_component *p, Link Here
146
	{
147
	{
147
	  p->type = DEMANGLE_COMPONENT_BUILTIN_TYPE;
148
	  p->type = DEMANGLE_COMPONENT_BUILTIN_TYPE;
148
	  p->u.s_builtin.type = &cplus_demangle_builtin_types[i];
149
	  p->u.s_builtin.type = &cplus_demangle_builtin_types[i];
150
	  p->d_printing = 0;
149
	  return 1;
151
	  return 1;
150
	}
152
	}
151
    }
153
    }
Lines 172-177 cplus_demangle_fill_operator (struct demangle_component *p, Link Here
172
	{
174
	{
173
	  p->type = DEMANGLE_COMPONENT_OPERATOR;
175
	  p->type = DEMANGLE_COMPONENT_OPERATOR;
174
	  p->u.s_operator.op = &cplus_demangle_operators[i];
176
	  p->u.s_operator.op = &cplus_demangle_operators[i];
177
	  p->d_printing = 0;
175
	  return 1;
178
	  return 1;
176
	}
179
	}
177
    }
180
    }
(-)a/libiberty/testsuite/demangle-expected (-1 / +30 lines)
Lines 4657-4660 void eat<Foo()::{lambda(auto&, X<int>&)#2}>(Foo()::{lambda(auto&, X<int>&)#2}&) Link Here
4657
4657
4658
_Z3eatIZ3FoovEUlPA5_T_E1_EvRS0_
4658
_Z3eatIZ3FoovEUlPA5_T_E1_EvRS0_
4659
void eat<Foo()::{lambda(auto (*) [5])#3}>(Foo()::{lambda(auto (*&) [5])#3})
4659
void eat<Foo()::{lambda(auto (*) [5])#3}>(Foo()::{lambda(auto (*&) [5])#3})
4660
#
4661
# Test recursion PR67264
4662
4663
_Z1KIStcvT_E
4664
_Z1KIStcvT_E
4665
4666
_ZcvT_IIS0_EE
4667
_ZcvT_IIS0_EE
4668
4669
_ZcvT_IZcvT_E1fE
4670
_ZcvT_IZcvT_E1fE
4671
4672
_Z1gINcvT_EE
4673
_Z1gINcvT_EE
4674
4675
_ZcvT_ILZcvDTT_EEE
4676
_ZcvT_ILZcvDTT_EEE
4677
4678
_Z1gIJOOT_EEOT_c
4679
_Z1gIJOOT_EEOT_c
4680
4681
_Z1KMMMMMMMMMMMMMMMA_xooooooooooooooo
4682
_Z1KMMMMMMMMMMMMMMMA_xooooooooooooooo
4683
4684
_ZdvMMMMMMMMMMMMMrrrrA_DTdvfp_fp_Eededilfdfdfdfd
4685
_ZdvMMMMMMMMMMMMMrrrrA_DTdvfp_fp_Eededilfdfdfdfd
4686
#
4687
# Test for Infinite Recursion PR70909
4660
4688
4661
- 
4689
_Z1MA_aMMMMA_MMA_MMMMMMMMSt1MS_o11T0000000000t2M0oooozoooo
4690
_Z1MA_aMMMMA_MMA_MMMMMMMMSt1MS_o11T0000000000t2M0oooozoooo

Return to bug 70909