Mercurial > hg > CbC > CbC_gcc
comparison libiberty/cp-demangle.c @ 111:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | f6334be47118 |
children | 84e7813d76e9 |
comparison
equal
deleted
inserted
replaced
68:561a7518be6b | 111:04ced10e8804 |
---|---|
1 /* Demangler for g++ V3 ABI. | 1 /* Demangler for g++ V3 ABI. |
2 Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 | 2 Copyright (C) 2003-2017 Free Software Foundation, Inc. |
3 Free Software Foundation, Inc. | |
4 Written by Ian Lance Taylor <ian@wasabisystems.com>. | 3 Written by Ian Lance Taylor <ian@wasabisystems.com>. |
5 | 4 |
6 This file is part of the libiberty library, which is part of GCC. | 5 This file is part of the libiberty library, which is part of GCC. |
7 | 6 |
8 This file is free software; you can redistribute it and/or modify | 7 This file is free software; you can redistribute it and/or modify |
91 any arguments, or, if none, demangles stdin. | 90 any arguments, or, if none, demangles stdin. |
92 | 91 |
93 CP_DEMANGLE_DEBUG | 92 CP_DEMANGLE_DEBUG |
94 If defined, turns on debugging mode, which prints information on | 93 If defined, turns on debugging mode, which prints information on |
95 stdout about the mangled string. This is not generally useful. | 94 stdout about the mangled string. This is not generally useful. |
96 */ | 95 |
96 CHECK_DEMANGLER | |
97 If defined, additional sanity checks will be performed. It will | |
98 cause some slowdown, but will allow to catch out-of-bound access | |
99 errors earlier. This macro is intended for testing and debugging. */ | |
97 | 100 |
98 #if defined (_AIX) && !defined (__GNUC__) | 101 #if defined (_AIX) && !defined (__GNUC__) |
99 #pragma alloca | 102 #pragma alloca |
100 #endif | 103 #endif |
101 | 104 |
122 extern char *alloca (); | 125 extern char *alloca (); |
123 # endif /* __GNUC__ */ | 126 # endif /* __GNUC__ */ |
124 # endif /* alloca */ | 127 # endif /* alloca */ |
125 #endif /* HAVE_ALLOCA_H */ | 128 #endif /* HAVE_ALLOCA_H */ |
126 | 129 |
130 #ifdef HAVE_LIMITS_H | |
131 #include <limits.h> | |
132 #endif | |
133 #ifndef INT_MAX | |
134 # define INT_MAX (int)(((unsigned int) ~0) >> 1) /* 0x7FFFFFFF */ | |
135 #endif | |
136 | |
127 #include "ansidecl.h" | 137 #include "ansidecl.h" |
128 #include "libiberty.h" | 138 #include "libiberty.h" |
129 #include "demangle.h" | 139 #include "demangle.h" |
130 #include "cp-demangle.h" | 140 #include "cp-demangle.h" |
131 | 141 |
160 | 170 |
161 #define cplus_demangle_type d_type | 171 #define cplus_demangle_type d_type |
162 static struct demangle_component *d_type (struct d_info *); | 172 static struct demangle_component *d_type (struct d_info *); |
163 | 173 |
164 #define cplus_demangle_print d_print | 174 #define cplus_demangle_print d_print |
165 static char *d_print (int, const struct demangle_component *, int, size_t *); | 175 static char *d_print (int, struct demangle_component *, int, size_t *); |
166 | 176 |
167 #define cplus_demangle_print_callback d_print_callback | 177 #define cplus_demangle_print_callback d_print_callback |
168 static int d_print_callback (int, const struct demangle_component *, | 178 static int d_print_callback (int, struct demangle_component *, |
169 demangle_callbackref, void *); | 179 demangle_callbackref, void *); |
170 | 180 |
171 #define cplus_demangle_init_info d_init_info | 181 #define cplus_demangle_init_info d_init_info |
172 static void d_init_info (const char *, int, size_t, struct d_info *); | 182 static void d_init_info (const char *, int, size_t, struct d_info *); |
173 | 183 |
252 { | 262 { |
253 /* Next modifier on the list. These are in the reverse of the order | 263 /* Next modifier on the list. These are in the reverse of the order |
254 in which they appeared in the mangled string. */ | 264 in which they appeared in the mangled string. */ |
255 struct d_print_mod *next; | 265 struct d_print_mod *next; |
256 /* The modifier. */ | 266 /* The modifier. */ |
257 const struct demangle_component *mod; | 267 struct demangle_component *mod; |
258 /* Whether this modifier was printed. */ | 268 /* Whether this modifier was printed. */ |
259 int printed; | 269 int printed; |
260 /* The list of templates which applies to this modifier. */ | 270 /* The list of templates which applies to this modifier. */ |
261 struct d_print_template *templates; | 271 struct d_print_template *templates; |
262 }; | 272 }; |
273 size_t alc; | 283 size_t alc; |
274 /* Set to 1 if we had a memory allocation failure. */ | 284 /* Set to 1 if we had a memory allocation failure. */ |
275 int allocation_failure; | 285 int allocation_failure; |
276 }; | 286 }; |
277 | 287 |
288 /* Stack of components, innermost first, used to avoid loops. */ | |
289 | |
290 struct d_component_stack | |
291 { | |
292 /* This component. */ | |
293 const struct demangle_component *dc; | |
294 /* This component's parent. */ | |
295 const struct d_component_stack *parent; | |
296 }; | |
297 | |
298 /* A demangle component and some scope captured when it was first | |
299 traversed. */ | |
300 | |
301 struct d_saved_scope | |
302 { | |
303 /* The component whose scope this is. */ | |
304 const struct demangle_component *container; | |
305 /* The list of templates, if any, that was current when this | |
306 scope was captured. */ | |
307 struct d_print_template *templates; | |
308 }; | |
309 | |
310 /* Checkpoint structure to allow backtracking. This holds copies | |
311 of the fields of struct d_info that need to be restored | |
312 if a trial parse needs to be backtracked over. */ | |
313 | |
314 struct d_info_checkpoint | |
315 { | |
316 const char *n; | |
317 int next_comp; | |
318 int next_sub; | |
319 int expansion; | |
320 }; | |
321 | |
322 /* Maximum number of times d_print_comp may be called recursively. */ | |
323 #define MAX_RECURSION_COUNT 1024 | |
324 | |
278 enum { D_PRINT_BUFFER_LENGTH = 256 }; | 325 enum { D_PRINT_BUFFER_LENGTH = 256 }; |
279 struct d_print_info | 326 struct d_print_info |
280 { | 327 { |
281 /* The options passed to the demangler. */ | |
282 int options; | |
283 /* Fixed-length allocated buffer for demangled data, flushed to the | 328 /* Fixed-length allocated buffer for demangled data, flushed to the |
284 callback with a NUL termination once full. */ | 329 callback with a NUL termination once full. */ |
285 char buf[D_PRINT_BUFFER_LENGTH]; | 330 char buf[D_PRINT_BUFFER_LENGTH]; |
286 /* Current length of data in buffer. */ | 331 /* Current length of data in buffer. */ |
287 size_t len; | 332 size_t len; |
297 /* The current list of modifiers (e.g., pointer, reference, etc.), | 342 /* The current list of modifiers (e.g., pointer, reference, etc.), |
298 if any. */ | 343 if any. */ |
299 struct d_print_mod *modifiers; | 344 struct d_print_mod *modifiers; |
300 /* Set to 1 if we saw a demangling error. */ | 345 /* Set to 1 if we saw a demangling error. */ |
301 int demangle_failure; | 346 int demangle_failure; |
347 /* Number of times d_print_comp was recursively called. Should not | |
348 be bigger than MAX_RECURSION_COUNT. */ | |
349 int recursion; | |
350 /* Non-zero if we're printing a lambda argument. A template | |
351 parameter reference actually means 'auto'. */ | |
352 int is_lambda_arg; | |
302 /* The current index into any template argument packs we are using | 353 /* The current index into any template argument packs we are using |
303 for printing. */ | 354 for printing, or -1 to print the whole pack. */ |
304 int pack_index; | 355 int pack_index; |
305 /* Number of d_print_flush calls so far. */ | 356 /* Number of d_print_flush calls so far. */ |
306 unsigned long int flush_count; | 357 unsigned long int flush_count; |
358 /* Stack of components, innermost first, used to avoid loops. */ | |
359 const struct d_component_stack *component_stack; | |
360 /* Array of saved scopes for evaluating substitutions. */ | |
361 struct d_saved_scope *saved_scopes; | |
362 /* Index of the next unused saved scope in the above array. */ | |
363 int next_saved_scope; | |
364 /* Number of saved scopes in the above array. */ | |
365 int num_saved_scopes; | |
366 /* Array of templates for saving into scopes. */ | |
367 struct d_print_template *copy_templates; | |
368 /* Index of the next unused copy template in the above array. */ | |
369 int next_copy_template; | |
370 /* Number of copy templates in the above array. */ | |
371 int num_copy_templates; | |
372 /* The nearest enclosing template, if any. */ | |
373 const struct demangle_component *current_template; | |
307 }; | 374 }; |
308 | 375 |
309 #ifdef CP_DEMANGLE_DEBUG | 376 #ifdef CP_DEMANGLE_DEBUG |
310 static void d_dump (struct demangle_component *, int); | 377 static void d_dump (struct demangle_component *, int); |
311 #endif | 378 #endif |
343 static struct demangle_component * | 410 static struct demangle_component * |
344 d_make_dtor (struct d_info *, enum gnu_v3_dtor_kinds, | 411 d_make_dtor (struct d_info *, enum gnu_v3_dtor_kinds, |
345 struct demangle_component *); | 412 struct demangle_component *); |
346 | 413 |
347 static struct demangle_component * | 414 static struct demangle_component * |
348 d_make_template_param (struct d_info *, long); | 415 d_make_template_param (struct d_info *, int); |
349 | 416 |
350 static struct demangle_component * | 417 static struct demangle_component * |
351 d_make_sub (struct d_info *, const char *, int); | 418 d_make_sub (struct d_info *, const char *, int); |
352 | 419 |
353 static int | 420 static int |
366 | 433 |
367 static struct demangle_component *d_unqualified_name (struct d_info *); | 434 static struct demangle_component *d_unqualified_name (struct d_info *); |
368 | 435 |
369 static struct demangle_component *d_source_name (struct d_info *); | 436 static struct demangle_component *d_source_name (struct d_info *); |
370 | 437 |
371 static long d_number (struct d_info *); | 438 static int d_number (struct d_info *); |
372 | 439 |
373 static struct demangle_component *d_identifier (struct d_info *, int); | 440 static struct demangle_component *d_identifier (struct d_info *, int); |
374 | 441 |
375 static struct demangle_component *d_operator_name (struct d_info *); | 442 static struct demangle_component *d_operator_name (struct d_info *); |
376 | 443 |
377 static struct demangle_component *d_special_name (struct d_info *); | 444 static struct demangle_component *d_special_name (struct d_info *); |
445 | |
446 static struct demangle_component *d_parmlist (struct d_info *); | |
378 | 447 |
379 static int d_call_offset (struct d_info *, int); | 448 static int d_call_offset (struct d_info *, int); |
380 | 449 |
381 static struct demangle_component *d_ctor_dtor_name (struct d_info *); | 450 static struct demangle_component *d_ctor_dtor_name (struct d_info *); |
382 | 451 |
383 static struct demangle_component ** | 452 static struct demangle_component ** |
384 d_cv_qualifiers (struct d_info *, struct demangle_component **, int); | 453 d_cv_qualifiers (struct d_info *, struct demangle_component **, int); |
385 | 454 |
386 static struct demangle_component * | 455 static struct demangle_component * |
456 d_ref_qualifier (struct d_info *, struct demangle_component *); | |
457 | |
458 static struct demangle_component * | |
387 d_function_type (struct d_info *); | 459 d_function_type (struct d_info *); |
388 | 460 |
389 static struct demangle_component * | 461 static struct demangle_component * |
390 d_bare_function_type (struct d_info *, int); | 462 d_bare_function_type (struct d_info *, int); |
391 | 463 |
401 | 473 |
402 static struct demangle_component * | 474 static struct demangle_component * |
403 d_template_param (struct d_info *); | 475 d_template_param (struct d_info *); |
404 | 476 |
405 static struct demangle_component *d_template_args (struct d_info *); | 477 static struct demangle_component *d_template_args (struct d_info *); |
478 static struct demangle_component *d_template_args_1 (struct d_info *); | |
406 | 479 |
407 static struct demangle_component * | 480 static struct demangle_component * |
408 d_template_arg (struct d_info *); | 481 d_template_arg (struct d_info *); |
409 | 482 |
410 static struct demangle_component *d_expression (struct d_info *); | 483 static struct demangle_component *d_expression (struct d_info *); |
416 static int d_discriminator (struct d_info *); | 489 static int d_discriminator (struct d_info *); |
417 | 490 |
418 static struct demangle_component *d_lambda (struct d_info *); | 491 static struct demangle_component *d_lambda (struct d_info *); |
419 | 492 |
420 static struct demangle_component *d_unnamed_type (struct d_info *); | 493 static struct demangle_component *d_unnamed_type (struct d_info *); |
494 | |
495 static struct demangle_component * | |
496 d_clone_suffix (struct d_info *, struct demangle_component *); | |
421 | 497 |
422 static int | 498 static int |
423 d_add_substitution (struct d_info *, struct demangle_component *); | 499 d_add_substitution (struct d_info *, struct demangle_component *); |
424 | 500 |
425 static struct demangle_component *d_substitution (struct d_info *, int); | 501 static struct demangle_component *d_substitution (struct d_info *, int); |
502 | |
503 static void d_checkpoint (struct d_info *, struct d_info_checkpoint *); | |
504 | |
505 static void d_backtrack (struct d_info *, struct d_info_checkpoint *); | |
426 | 506 |
427 static void d_growable_string_init (struct d_growable_string *, size_t); | 507 static void d_growable_string_init (struct d_growable_string *, size_t); |
428 | 508 |
429 static inline void | 509 static inline void |
430 d_growable_string_resize (struct d_growable_string *, size_t); | 510 d_growable_string_resize (struct d_growable_string *, size_t); |
434 const char *, size_t); | 514 const char *, size_t); |
435 static void | 515 static void |
436 d_growable_string_callback_adapter (const char *, size_t, void *); | 516 d_growable_string_callback_adapter (const char *, size_t, void *); |
437 | 517 |
438 static void | 518 static void |
439 d_print_init (struct d_print_info *, int, demangle_callbackref, void *); | 519 d_print_init (struct d_print_info *, demangle_callbackref, void *, |
520 const struct demangle_component *); | |
440 | 521 |
441 static inline void d_print_error (struct d_print_info *); | 522 static inline void d_print_error (struct d_print_info *); |
442 | 523 |
443 static inline int d_print_saw_error (struct d_print_info *); | 524 static inline int d_print_saw_error (struct d_print_info *); |
444 | 525 |
452 static inline void d_append_string (struct d_print_info *, const char *); | 533 static inline void d_append_string (struct d_print_info *, const char *); |
453 | 534 |
454 static inline char d_last_char (struct d_print_info *); | 535 static inline char d_last_char (struct d_print_info *); |
455 | 536 |
456 static void | 537 static void |
457 d_print_comp (struct d_print_info *, const struct demangle_component *); | 538 d_print_comp (struct d_print_info *, int, struct demangle_component *); |
458 | 539 |
459 static void | 540 static void |
460 d_print_java_identifier (struct d_print_info *, const char *, int); | 541 d_print_java_identifier (struct d_print_info *, const char *, int); |
461 | 542 |
462 static void | 543 static void |
463 d_print_mod_list (struct d_print_info *, struct d_print_mod *, int); | 544 d_print_mod_list (struct d_print_info *, int, struct d_print_mod *, int); |
464 | 545 |
465 static void | 546 static void |
466 d_print_mod (struct d_print_info *, const struct demangle_component *); | 547 d_print_mod (struct d_print_info *, int, struct demangle_component *); |
467 | 548 |
468 static void | 549 static void |
469 d_print_function_type (struct d_print_info *, | 550 d_print_function_type (struct d_print_info *, int, |
470 const struct demangle_component *, | 551 struct demangle_component *, |
471 struct d_print_mod *); | 552 struct d_print_mod *); |
472 | 553 |
473 static void | 554 static void |
474 d_print_array_type (struct d_print_info *, | 555 d_print_array_type (struct d_print_info *, int, |
475 const struct demangle_component *, | 556 struct demangle_component *, |
476 struct d_print_mod *); | 557 struct d_print_mod *); |
477 | 558 |
478 static void | 559 static void |
479 d_print_expr_op (struct d_print_info *, const struct demangle_component *); | 560 d_print_expr_op (struct d_print_info *, int, struct demangle_component *); |
480 | 561 |
481 static void | 562 static void d_print_cast (struct d_print_info *, int, |
482 d_print_cast (struct d_print_info *, const struct demangle_component *); | 563 struct demangle_component *); |
564 static void d_print_conversion (struct d_print_info *, int, | |
565 struct demangle_component *); | |
483 | 566 |
484 static int d_demangle_callback (const char *, int, | 567 static int d_demangle_callback (const char *, int, |
485 demangle_callbackref, void *); | 568 demangle_callbackref, void *); |
486 static char *d_demangle (const char *, int, size_t *); | 569 static char *d_demangle (const char *, int, size_t *); |
487 | 570 |
571 #define FNQUAL_COMPONENT_CASE \ | |
572 case DEMANGLE_COMPONENT_RESTRICT_THIS: \ | |
573 case DEMANGLE_COMPONENT_VOLATILE_THIS: \ | |
574 case DEMANGLE_COMPONENT_CONST_THIS: \ | |
575 case DEMANGLE_COMPONENT_REFERENCE_THIS: \ | |
576 case DEMANGLE_COMPONENT_RVALUE_REFERENCE_THIS: \ | |
577 case DEMANGLE_COMPONENT_TRANSACTION_SAFE: \ | |
578 case DEMANGLE_COMPONENT_NOEXCEPT: \ | |
579 case DEMANGLE_COMPONENT_THROW_SPEC | |
580 | |
581 /* True iff TYPE is a demangling component representing a | |
582 function-type-qualifier. */ | |
583 | |
584 static int | |
585 is_fnqual_component_type (enum demangle_component_type type) | |
586 { | |
587 switch (type) | |
588 { | |
589 FNQUAL_COMPONENT_CASE: | |
590 return 1; | |
591 default: | |
592 break; | |
593 } | |
594 return 0; | |
595 } | |
596 | |
597 | |
488 #ifdef CP_DEMANGLE_DEBUG | 598 #ifdef CP_DEMANGLE_DEBUG |
489 | 599 |
490 static void | 600 static void |
491 d_dump (struct demangle_component *dc, int indent) | 601 d_dump (struct demangle_component *dc, int indent) |
492 { | 602 { |
505 switch (dc->type) | 615 switch (dc->type) |
506 { | 616 { |
507 case DEMANGLE_COMPONENT_NAME: | 617 case DEMANGLE_COMPONENT_NAME: |
508 printf ("name '%.*s'\n", dc->u.s_name.len, dc->u.s_name.s); | 618 printf ("name '%.*s'\n", dc->u.s_name.len, dc->u.s_name.s); |
509 return; | 619 return; |
620 case DEMANGLE_COMPONENT_TAGGED_NAME: | |
621 printf ("tagged name\n"); | |
622 d_dump (dc->u.s_binary.left, indent + 2); | |
623 d_dump (dc->u.s_binary.right, indent + 2); | |
624 return; | |
510 case DEMANGLE_COMPONENT_TEMPLATE_PARAM: | 625 case DEMANGLE_COMPONENT_TEMPLATE_PARAM: |
511 printf ("template parameter %ld\n", dc->u.s_number.number); | 626 printf ("template parameter %ld\n", dc->u.s_number.number); |
627 return; | |
628 case DEMANGLE_COMPONENT_FUNCTION_PARAM: | |
629 printf ("function parameter %ld\n", dc->u.s_number.number); | |
512 return; | 630 return; |
513 case DEMANGLE_COMPONENT_CTOR: | 631 case DEMANGLE_COMPONENT_CTOR: |
514 printf ("constructor %d\n", (int) dc->u.s_ctor.kind); | 632 printf ("constructor %d\n", (int) dc->u.s_ctor.kind); |
515 d_dump (dc->u.s_ctor.name, indent + 2); | 633 d_dump (dc->u.s_ctor.name, indent + 2); |
516 return; | 634 return; |
582 printf ("reference temporary\n"); | 700 printf ("reference temporary\n"); |
583 break; | 701 break; |
584 case DEMANGLE_COMPONENT_HIDDEN_ALIAS: | 702 case DEMANGLE_COMPONENT_HIDDEN_ALIAS: |
585 printf ("hidden alias\n"); | 703 printf ("hidden alias\n"); |
586 break; | 704 break; |
705 case DEMANGLE_COMPONENT_TRANSACTION_CLONE: | |
706 printf ("transaction clone\n"); | |
707 break; | |
708 case DEMANGLE_COMPONENT_NONTRANSACTION_CLONE: | |
709 printf ("non-transaction clone\n"); | |
710 break; | |
587 case DEMANGLE_COMPONENT_RESTRICT: | 711 case DEMANGLE_COMPONENT_RESTRICT: |
588 printf ("restrict\n"); | 712 printf ("restrict\n"); |
589 break; | 713 break; |
590 case DEMANGLE_COMPONENT_VOLATILE: | 714 case DEMANGLE_COMPONENT_VOLATILE: |
591 printf ("volatile\n"); | 715 printf ("volatile\n"); |
600 printf ("volatile this\n"); | 724 printf ("volatile this\n"); |
601 break; | 725 break; |
602 case DEMANGLE_COMPONENT_CONST_THIS: | 726 case DEMANGLE_COMPONENT_CONST_THIS: |
603 printf ("const this\n"); | 727 printf ("const this\n"); |
604 break; | 728 break; |
729 case DEMANGLE_COMPONENT_REFERENCE_THIS: | |
730 printf ("reference this\n"); | |
731 break; | |
732 case DEMANGLE_COMPONENT_RVALUE_REFERENCE_THIS: | |
733 printf ("rvalue reference this\n"); | |
734 break; | |
735 case DEMANGLE_COMPONENT_TRANSACTION_SAFE: | |
736 printf ("transaction_safe this\n"); | |
737 break; | |
605 case DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL: | 738 case DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL: |
606 printf ("vendor type qualifier\n"); | 739 printf ("vendor type qualifier\n"); |
607 break; | 740 break; |
608 case DEMANGLE_COMPONENT_POINTER: | 741 case DEMANGLE_COMPONENT_POINTER: |
609 printf ("pointer\n"); | 742 printf ("pointer\n"); |
631 break; | 764 break; |
632 case DEMANGLE_COMPONENT_PTRMEM_TYPE: | 765 case DEMANGLE_COMPONENT_PTRMEM_TYPE: |
633 printf ("pointer to member type\n"); | 766 printf ("pointer to member type\n"); |
634 break; | 767 break; |
635 case DEMANGLE_COMPONENT_FIXED_TYPE: | 768 case DEMANGLE_COMPONENT_FIXED_TYPE: |
636 printf ("fixed-point type\n"); | 769 printf ("fixed-point type, accum? %d, sat? %d\n", |
770 dc->u.s_fixed.accum, dc->u.s_fixed.sat); | |
771 d_dump (dc->u.s_fixed.length, indent + 2); | |
637 break; | 772 break; |
638 case DEMANGLE_COMPONENT_ARGLIST: | 773 case DEMANGLE_COMPONENT_ARGLIST: |
639 printf ("argument list\n"); | 774 printf ("argument list\n"); |
640 break; | 775 break; |
641 case DEMANGLE_COMPONENT_TEMPLATE_ARGLIST: | 776 case DEMANGLE_COMPONENT_TEMPLATE_ARGLIST: |
642 printf ("template argument list\n"); | 777 printf ("template argument list\n"); |
643 break; | 778 break; |
779 case DEMANGLE_COMPONENT_INITIALIZER_LIST: | |
780 printf ("initializer list\n"); | |
781 break; | |
644 case DEMANGLE_COMPONENT_CAST: | 782 case DEMANGLE_COMPONENT_CAST: |
645 printf ("cast\n"); | 783 printf ("cast\n"); |
646 break; | 784 break; |
785 case DEMANGLE_COMPONENT_CONVERSION: | |
786 printf ("conversion operator\n"); | |
787 break; | |
788 case DEMANGLE_COMPONENT_NULLARY: | |
789 printf ("nullary operator\n"); | |
790 break; | |
647 case DEMANGLE_COMPONENT_UNARY: | 791 case DEMANGLE_COMPONENT_UNARY: |
648 printf ("unary operator\n"); | 792 printf ("unary operator\n"); |
649 break; | 793 break; |
650 case DEMANGLE_COMPONENT_BINARY: | 794 case DEMANGLE_COMPONENT_BINARY: |
651 printf ("binary operator\n"); | 795 printf ("binary operator\n"); |
675 printf ("compound name\n"); | 819 printf ("compound name\n"); |
676 break; | 820 break; |
677 case DEMANGLE_COMPONENT_CHARACTER: | 821 case DEMANGLE_COMPONENT_CHARACTER: |
678 printf ("character '%c'\n", dc->u.s_character.character); | 822 printf ("character '%c'\n", dc->u.s_character.character); |
679 return; | 823 return; |
824 case DEMANGLE_COMPONENT_NUMBER: | |
825 printf ("number %ld\n", dc->u.s_number.number); | |
826 return; | |
680 case DEMANGLE_COMPONENT_DECLTYPE: | 827 case DEMANGLE_COMPONENT_DECLTYPE: |
681 printf ("decltype\n"); | 828 printf ("decltype\n"); |
682 break; | 829 break; |
683 case DEMANGLE_COMPONENT_PACK_EXPANSION: | 830 case DEMANGLE_COMPONENT_PACK_EXPANSION: |
684 printf ("pack expansion\n"); | 831 printf ("pack expansion\n"); |
685 break; | 832 break; |
833 case DEMANGLE_COMPONENT_TLS_INIT: | |
834 printf ("tls init function\n"); | |
835 break; | |
836 case DEMANGLE_COMPONENT_TLS_WRAPPER: | |
837 printf ("tls wrapper function\n"); | |
838 break; | |
839 case DEMANGLE_COMPONENT_DEFAULT_ARG: | |
840 printf ("default argument %d\n", dc->u.s_unary_num.num); | |
841 d_dump (dc->u.s_unary_num.sub, indent+2); | |
842 return; | |
843 case DEMANGLE_COMPONENT_LAMBDA: | |
844 printf ("lambda %d\n", dc->u.s_unary_num.num); | |
845 d_dump (dc->u.s_unary_num.sub, indent+2); | |
846 return; | |
686 } | 847 } |
687 | 848 |
688 d_dump (d_left (dc), indent + 2); | 849 d_dump (d_left (dc), indent + 2); |
689 d_dump (d_right (dc), indent + 2); | 850 d_dump (d_right (dc), indent + 2); |
690 } | 851 } |
697 int | 858 int |
698 cplus_demangle_fill_name (struct demangle_component *p, const char *s, int len) | 859 cplus_demangle_fill_name (struct demangle_component *p, const char *s, int len) |
699 { | 860 { |
700 if (p == NULL || s == NULL || len == 0) | 861 if (p == NULL || s == NULL || len == 0) |
701 return 0; | 862 return 0; |
863 p->d_printing = 0; | |
702 p->type = DEMANGLE_COMPONENT_NAME; | 864 p->type = DEMANGLE_COMPONENT_NAME; |
703 p->u.s_name.s = s; | 865 p->u.s_name.s = s; |
704 p->u.s_name.len = len; | 866 p->u.s_name.len = len; |
705 return 1; | 867 return 1; |
706 } | 868 } |
712 cplus_demangle_fill_extended_operator (struct demangle_component *p, int args, | 874 cplus_demangle_fill_extended_operator (struct demangle_component *p, int args, |
713 struct demangle_component *name) | 875 struct demangle_component *name) |
714 { | 876 { |
715 if (p == NULL || args < 0 || name == NULL) | 877 if (p == NULL || args < 0 || name == NULL) |
716 return 0; | 878 return 0; |
879 p->d_printing = 0; | |
717 p->type = DEMANGLE_COMPONENT_EXTENDED_OPERATOR; | 880 p->type = DEMANGLE_COMPONENT_EXTENDED_OPERATOR; |
718 p->u.s_extended_operator.args = args; | 881 p->u.s_extended_operator.args = args; |
719 p->u.s_extended_operator.name = name; | 882 p->u.s_extended_operator.name = name; |
720 return 1; | 883 return 1; |
721 } | 884 } |
729 struct demangle_component *name) | 892 struct demangle_component *name) |
730 { | 893 { |
731 if (p == NULL | 894 if (p == NULL |
732 || name == NULL | 895 || name == NULL |
733 || (int) kind < gnu_v3_complete_object_ctor | 896 || (int) kind < gnu_v3_complete_object_ctor |
734 || (int) kind > gnu_v3_complete_object_allocating_ctor) | 897 || (int) kind > gnu_v3_object_ctor_group) |
735 return 0; | 898 return 0; |
899 p->d_printing = 0; | |
736 p->type = DEMANGLE_COMPONENT_CTOR; | 900 p->type = DEMANGLE_COMPONENT_CTOR; |
737 p->u.s_ctor.kind = kind; | 901 p->u.s_ctor.kind = kind; |
738 p->u.s_ctor.name = name; | 902 p->u.s_ctor.name = name; |
739 return 1; | 903 return 1; |
740 } | 904 } |
748 struct demangle_component *name) | 912 struct demangle_component *name) |
749 { | 913 { |
750 if (p == NULL | 914 if (p == NULL |
751 || name == NULL | 915 || name == NULL |
752 || (int) kind < gnu_v3_deleting_dtor | 916 || (int) kind < gnu_v3_deleting_dtor |
753 || (int) kind > gnu_v3_base_object_dtor) | 917 || (int) kind > gnu_v3_object_dtor_group) |
754 return 0; | 918 return 0; |
919 p->d_printing = 0; | |
755 p->type = DEMANGLE_COMPONENT_DTOR; | 920 p->type = DEMANGLE_COMPONENT_DTOR; |
756 p->u.s_dtor.kind = kind; | 921 p->u.s_dtor.kind = kind; |
757 p->u.s_dtor.name = name; | 922 p->u.s_dtor.name = name; |
758 return 1; | 923 return 1; |
759 } | 924 } |
766 struct demangle_component *p; | 931 struct demangle_component *p; |
767 | 932 |
768 if (di->next_comp >= di->num_comps) | 933 if (di->next_comp >= di->num_comps) |
769 return NULL; | 934 return NULL; |
770 p = &di->comps[di->next_comp]; | 935 p = &di->comps[di->next_comp]; |
936 p->d_printing = 0; | |
771 ++di->next_comp; | 937 ++di->next_comp; |
772 return p; | 938 return p; |
773 } | 939 } |
774 | 940 |
775 /* Add a new generic component. */ | 941 /* Add a new generic component. */ |
788 { | 954 { |
789 /* These types require two parameters. */ | 955 /* These types require two parameters. */ |
790 case DEMANGLE_COMPONENT_QUAL_NAME: | 956 case DEMANGLE_COMPONENT_QUAL_NAME: |
791 case DEMANGLE_COMPONENT_LOCAL_NAME: | 957 case DEMANGLE_COMPONENT_LOCAL_NAME: |
792 case DEMANGLE_COMPONENT_TYPED_NAME: | 958 case DEMANGLE_COMPONENT_TYPED_NAME: |
959 case DEMANGLE_COMPONENT_TAGGED_NAME: | |
793 case DEMANGLE_COMPONENT_TEMPLATE: | 960 case DEMANGLE_COMPONENT_TEMPLATE: |
794 case DEMANGLE_COMPONENT_CONSTRUCTION_VTABLE: | 961 case DEMANGLE_COMPONENT_CONSTRUCTION_VTABLE: |
795 case DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL: | 962 case DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL: |
796 case DEMANGLE_COMPONENT_PTRMEM_TYPE: | 963 case DEMANGLE_COMPONENT_PTRMEM_TYPE: |
797 case DEMANGLE_COMPONENT_UNARY: | 964 case DEMANGLE_COMPONENT_UNARY: |
798 case DEMANGLE_COMPONENT_BINARY: | 965 case DEMANGLE_COMPONENT_BINARY: |
799 case DEMANGLE_COMPONENT_BINARY_ARGS: | 966 case DEMANGLE_COMPONENT_BINARY_ARGS: |
800 case DEMANGLE_COMPONENT_TRINARY: | 967 case DEMANGLE_COMPONENT_TRINARY: |
801 case DEMANGLE_COMPONENT_TRINARY_ARG1: | 968 case DEMANGLE_COMPONENT_TRINARY_ARG1: |
802 case DEMANGLE_COMPONENT_TRINARY_ARG2: | |
803 case DEMANGLE_COMPONENT_LITERAL: | 969 case DEMANGLE_COMPONENT_LITERAL: |
804 case DEMANGLE_COMPONENT_LITERAL_NEG: | 970 case DEMANGLE_COMPONENT_LITERAL_NEG: |
805 case DEMANGLE_COMPONENT_COMPOUND_NAME: | 971 case DEMANGLE_COMPONENT_COMPOUND_NAME: |
806 case DEMANGLE_COMPONENT_VECTOR_TYPE: | 972 case DEMANGLE_COMPONENT_VECTOR_TYPE: |
973 case DEMANGLE_COMPONENT_CLONE: | |
807 if (left == NULL || right == NULL) | 974 if (left == NULL || right == NULL) |
808 return NULL; | 975 return NULL; |
809 break; | 976 break; |
810 | 977 |
811 /* These types only require one parameter. */ | 978 /* These types only require one parameter. */ |
817 case DEMANGLE_COMPONENT_THUNK: | 984 case DEMANGLE_COMPONENT_THUNK: |
818 case DEMANGLE_COMPONENT_VIRTUAL_THUNK: | 985 case DEMANGLE_COMPONENT_VIRTUAL_THUNK: |
819 case DEMANGLE_COMPONENT_COVARIANT_THUNK: | 986 case DEMANGLE_COMPONENT_COVARIANT_THUNK: |
820 case DEMANGLE_COMPONENT_JAVA_CLASS: | 987 case DEMANGLE_COMPONENT_JAVA_CLASS: |
821 case DEMANGLE_COMPONENT_GUARD: | 988 case DEMANGLE_COMPONENT_GUARD: |
989 case DEMANGLE_COMPONENT_TLS_INIT: | |
990 case DEMANGLE_COMPONENT_TLS_WRAPPER: | |
822 case DEMANGLE_COMPONENT_REFTEMP: | 991 case DEMANGLE_COMPONENT_REFTEMP: |
823 case DEMANGLE_COMPONENT_HIDDEN_ALIAS: | 992 case DEMANGLE_COMPONENT_HIDDEN_ALIAS: |
993 case DEMANGLE_COMPONENT_TRANSACTION_CLONE: | |
994 case DEMANGLE_COMPONENT_NONTRANSACTION_CLONE: | |
824 case DEMANGLE_COMPONENT_POINTER: | 995 case DEMANGLE_COMPONENT_POINTER: |
825 case DEMANGLE_COMPONENT_REFERENCE: | 996 case DEMANGLE_COMPONENT_REFERENCE: |
826 case DEMANGLE_COMPONENT_RVALUE_REFERENCE: | 997 case DEMANGLE_COMPONENT_RVALUE_REFERENCE: |
827 case DEMANGLE_COMPONENT_COMPLEX: | 998 case DEMANGLE_COMPONENT_COMPLEX: |
828 case DEMANGLE_COMPONENT_IMAGINARY: | 999 case DEMANGLE_COMPONENT_IMAGINARY: |
829 case DEMANGLE_COMPONENT_VENDOR_TYPE: | 1000 case DEMANGLE_COMPONENT_VENDOR_TYPE: |
830 case DEMANGLE_COMPONENT_CAST: | 1001 case DEMANGLE_COMPONENT_CAST: |
1002 case DEMANGLE_COMPONENT_CONVERSION: | |
831 case DEMANGLE_COMPONENT_JAVA_RESOURCE: | 1003 case DEMANGLE_COMPONENT_JAVA_RESOURCE: |
832 case DEMANGLE_COMPONENT_DECLTYPE: | 1004 case DEMANGLE_COMPONENT_DECLTYPE: |
833 case DEMANGLE_COMPONENT_PACK_EXPANSION: | 1005 case DEMANGLE_COMPONENT_PACK_EXPANSION: |
834 case DEMANGLE_COMPONENT_GLOBAL_CONSTRUCTORS: | 1006 case DEMANGLE_COMPONENT_GLOBAL_CONSTRUCTORS: |
835 case DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS: | 1007 case DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS: |
1008 case DEMANGLE_COMPONENT_NULLARY: | |
1009 case DEMANGLE_COMPONENT_TRINARY_ARG2: | |
836 if (left == NULL) | 1010 if (left == NULL) |
837 return NULL; | 1011 return NULL; |
838 break; | 1012 break; |
839 | 1013 |
840 /* This needs a right parameter, but the left parameter can be | 1014 /* This needs a right parameter, but the left parameter can be |
841 empty. */ | 1015 empty. */ |
842 case DEMANGLE_COMPONENT_ARRAY_TYPE: | 1016 case DEMANGLE_COMPONENT_ARRAY_TYPE: |
1017 case DEMANGLE_COMPONENT_INITIALIZER_LIST: | |
843 if (right == NULL) | 1018 if (right == NULL) |
844 return NULL; | 1019 return NULL; |
845 break; | 1020 break; |
846 | 1021 |
847 /* These are allowed to have no parameters--in some cases they | 1022 /* These are allowed to have no parameters--in some cases they |
848 will be filled in later. */ | 1023 will be filled in later. */ |
849 case DEMANGLE_COMPONENT_FUNCTION_TYPE: | 1024 case DEMANGLE_COMPONENT_FUNCTION_TYPE: |
850 case DEMANGLE_COMPONENT_RESTRICT: | 1025 case DEMANGLE_COMPONENT_RESTRICT: |
851 case DEMANGLE_COMPONENT_VOLATILE: | 1026 case DEMANGLE_COMPONENT_VOLATILE: |
852 case DEMANGLE_COMPONENT_CONST: | 1027 case DEMANGLE_COMPONENT_CONST: |
853 case DEMANGLE_COMPONENT_RESTRICT_THIS: | |
854 case DEMANGLE_COMPONENT_VOLATILE_THIS: | |
855 case DEMANGLE_COMPONENT_CONST_THIS: | |
856 case DEMANGLE_COMPONENT_ARGLIST: | 1028 case DEMANGLE_COMPONENT_ARGLIST: |
857 case DEMANGLE_COMPONENT_TEMPLATE_ARGLIST: | 1029 case DEMANGLE_COMPONENT_TEMPLATE_ARGLIST: |
1030 FNQUAL_COMPONENT_CASE: | |
858 break; | 1031 break; |
859 | 1032 |
860 /* Other types should not be seen here. */ | 1033 /* Other types should not be seen here. */ |
861 default: | 1034 default: |
862 return NULL; | 1035 return NULL; |
988 } | 1161 } |
989 | 1162 |
990 /* Add a new template parameter. */ | 1163 /* Add a new template parameter. */ |
991 | 1164 |
992 static struct demangle_component * | 1165 static struct demangle_component * |
993 d_make_template_param (struct d_info *di, long i) | 1166 d_make_template_param (struct d_info *di, int i) |
994 { | 1167 { |
995 struct demangle_component *p; | 1168 struct demangle_component *p; |
996 | 1169 |
997 p = d_make_empty (di); | 1170 p = d_make_empty (di); |
998 if (p != NULL) | 1171 if (p != NULL) |
1004 } | 1177 } |
1005 | 1178 |
1006 /* Add a new function parameter. */ | 1179 /* Add a new function parameter. */ |
1007 | 1180 |
1008 static struct demangle_component * | 1181 static struct demangle_component * |
1009 d_make_function_param (struct d_info *di, long i) | 1182 d_make_function_param (struct d_info *di, int i) |
1010 { | 1183 { |
1011 struct demangle_component *p; | 1184 struct demangle_component *p; |
1012 | 1185 |
1013 p = d_make_empty (di); | 1186 p = d_make_empty (di); |
1014 if (p != NULL) | 1187 if (p != NULL) |
1034 p->u.s_string.len = len; | 1207 p->u.s_string.len = len; |
1035 } | 1208 } |
1036 return p; | 1209 return p; |
1037 } | 1210 } |
1038 | 1211 |
1039 /* <mangled-name> ::= _Z <encoding> | 1212 /* <mangled-name> ::= _Z <encoding> [<clone-suffix>]* |
1040 | 1213 |
1041 TOP_LEVEL is non-zero when called at the top level. */ | 1214 TOP_LEVEL is non-zero when called at the top level. */ |
1042 | 1215 |
1043 CP_STATIC_IF_GLIBCPP_V3 | 1216 CP_STATIC_IF_GLIBCPP_V3 |
1044 struct demangle_component * | 1217 struct demangle_component * |
1045 cplus_demangle_mangled_name (struct d_info *di, int top_level) | 1218 cplus_demangle_mangled_name (struct d_info *di, int top_level) |
1046 { | 1219 { |
1220 struct demangle_component *p; | |
1221 | |
1047 if (! d_check_char (di, '_') | 1222 if (! d_check_char (di, '_') |
1048 /* Allow missing _ if not at toplevel to work around a | 1223 /* Allow missing _ if not at toplevel to work around a |
1049 bug in G++ abi-version=2 mangling; see the comment in | 1224 bug in G++ abi-version=2 mangling; see the comment in |
1050 write_template_arg. */ | 1225 write_template_arg. */ |
1051 && top_level) | 1226 && top_level) |
1052 return NULL; | 1227 return NULL; |
1053 if (! d_check_char (di, 'Z')) | 1228 if (! d_check_char (di, 'Z')) |
1054 return NULL; | 1229 return NULL; |
1055 return d_encoding (di, top_level); | 1230 p = d_encoding (di, top_level); |
1231 | |
1232 /* If at top level and parsing parameters, check for a clone | |
1233 suffix. */ | |
1234 if (top_level && (di->options & DMGL_PARAMS) != 0) | |
1235 while (d_peek_char (di) == '.' | |
1236 && (IS_LOWER (d_peek_next_char (di)) | |
1237 || d_peek_next_char (di) == '_' | |
1238 || IS_DIGIT (d_peek_next_char (di)))) | |
1239 p = d_clone_suffix (di, p); | |
1240 | |
1241 return p; | |
1056 } | 1242 } |
1057 | 1243 |
1058 /* Return whether a function should have a return type. The argument | 1244 /* Return whether a function should have a return type. The argument |
1059 is the function name, which may be qualified in various ways. The | 1245 is the function name, which may be qualified in various ways. The |
1060 rules are that template functions have return types with some | 1246 rules are that template functions have return types with some |
1071 return 0; | 1257 return 0; |
1072 switch (dc->type) | 1258 switch (dc->type) |
1073 { | 1259 { |
1074 default: | 1260 default: |
1075 return 0; | 1261 return 0; |
1262 case DEMANGLE_COMPONENT_LOCAL_NAME: | |
1263 return has_return_type (d_right (dc)); | |
1076 case DEMANGLE_COMPONENT_TEMPLATE: | 1264 case DEMANGLE_COMPONENT_TEMPLATE: |
1077 return ! is_ctor_dtor_or_conversion (d_left (dc)); | 1265 return ! is_ctor_dtor_or_conversion (d_left (dc)); |
1078 case DEMANGLE_COMPONENT_RESTRICT_THIS: | 1266 FNQUAL_COMPONENT_CASE: |
1079 case DEMANGLE_COMPONENT_VOLATILE_THIS: | |
1080 case DEMANGLE_COMPONENT_CONST_THIS: | |
1081 return has_return_type (d_left (dc)); | 1267 return has_return_type (d_left (dc)); |
1082 } | 1268 } |
1083 } | 1269 } |
1084 | 1270 |
1085 /* Return whether a name is a constructor, a destructor, or a | 1271 /* Return whether a name is a constructor, a destructor, or a |
1097 case DEMANGLE_COMPONENT_QUAL_NAME: | 1283 case DEMANGLE_COMPONENT_QUAL_NAME: |
1098 case DEMANGLE_COMPONENT_LOCAL_NAME: | 1284 case DEMANGLE_COMPONENT_LOCAL_NAME: |
1099 return is_ctor_dtor_or_conversion (d_right (dc)); | 1285 return is_ctor_dtor_or_conversion (d_right (dc)); |
1100 case DEMANGLE_COMPONENT_CTOR: | 1286 case DEMANGLE_COMPONENT_CTOR: |
1101 case DEMANGLE_COMPONENT_DTOR: | 1287 case DEMANGLE_COMPONENT_DTOR: |
1102 case DEMANGLE_COMPONENT_CAST: | 1288 case DEMANGLE_COMPONENT_CONVERSION: |
1103 return 1; | 1289 return 1; |
1104 } | 1290 } |
1105 } | 1291 } |
1106 | 1292 |
1107 /* <encoding> ::= <(function) name> <bare-function-type> | 1293 /* <encoding> ::= <(function) name> <bare-function-type> |
1115 | 1301 |
1116 static struct demangle_component * | 1302 static struct demangle_component * |
1117 d_encoding (struct d_info *di, int top_level) | 1303 d_encoding (struct d_info *di, int top_level) |
1118 { | 1304 { |
1119 char peek = d_peek_char (di); | 1305 char peek = d_peek_char (di); |
1306 struct demangle_component *dc; | |
1120 | 1307 |
1121 if (peek == 'G' || peek == 'T') | 1308 if (peek == 'G' || peek == 'T') |
1122 return d_special_name (di); | 1309 dc = d_special_name (di); |
1123 else | 1310 else |
1124 { | 1311 { |
1125 struct demangle_component *dc; | |
1126 | |
1127 dc = d_name (di); | 1312 dc = d_name (di); |
1128 | 1313 |
1129 if (dc != NULL && top_level && (di->options & DMGL_PARAMS) == 0) | 1314 if (!dc) |
1315 /* Failed already. */; | |
1316 else if (top_level && (di->options & DMGL_PARAMS) == 0) | |
1130 { | 1317 { |
1131 /* Strip off any initial CV-qualifiers, as they really apply | 1318 /* Strip off any initial CV-qualifiers, as they really apply |
1132 to the `this' parameter, and they were not output by the | 1319 to the `this' parameter, and they were not output by the |
1133 v2 demangler without DMGL_PARAMS. */ | 1320 v2 demangler without DMGL_PARAMS. */ |
1134 while (dc->type == DEMANGLE_COMPONENT_RESTRICT_THIS | 1321 while (is_fnqual_component_type (dc->type)) |
1135 || dc->type == DEMANGLE_COMPONENT_VOLATILE_THIS | |
1136 || dc->type == DEMANGLE_COMPONENT_CONST_THIS) | |
1137 dc = d_left (dc); | 1322 dc = d_left (dc); |
1138 | 1323 |
1139 /* If the top level is a DEMANGLE_COMPONENT_LOCAL_NAME, then | 1324 /* If the top level is a DEMANGLE_COMPONENT_LOCAL_NAME, then |
1140 there may be CV-qualifiers on its right argument which | 1325 there may be function-qualifiers on its right argument which |
1141 really apply here; this happens when parsing a class | 1326 really apply here; this happens when parsing a class |
1142 which is local to a function. */ | 1327 which is local to a function. */ |
1143 if (dc->type == DEMANGLE_COMPONENT_LOCAL_NAME) | 1328 if (dc->type == DEMANGLE_COMPONENT_LOCAL_NAME) |
1329 while (is_fnqual_component_type (d_right (dc)->type)) | |
1330 d_right (dc) = d_left (d_right (dc)); | |
1331 } | |
1332 else | |
1333 { | |
1334 peek = d_peek_char (di); | |
1335 if (peek != '\0' && peek != 'E') | |
1144 { | 1336 { |
1145 struct demangle_component *dcr; | 1337 struct demangle_component *ftype; |
1146 | 1338 |
1147 dcr = d_right (dc); | 1339 ftype = d_bare_function_type (di, has_return_type (dc)); |
1148 while (dcr->type == DEMANGLE_COMPONENT_RESTRICT_THIS | 1340 if (ftype) |
1149 || dcr->type == DEMANGLE_COMPONENT_VOLATILE_THIS | 1341 { |
1150 || dcr->type == DEMANGLE_COMPONENT_CONST_THIS) | 1342 /* If this is a non-top-level local-name, clear the |
1151 dcr = d_left (dcr); | 1343 return type, so it doesn't confuse the user by |
1152 dc->u.s_binary.right = dcr; | 1344 being confused with the return type of whaever |
1345 this is nested within. */ | |
1346 if (!top_level && dc->type == DEMANGLE_COMPONENT_LOCAL_NAME | |
1347 && ftype->type == DEMANGLE_COMPONENT_FUNCTION_TYPE) | |
1348 d_left (ftype) = NULL; | |
1349 | |
1350 dc = d_make_comp (di, DEMANGLE_COMPONENT_TYPED_NAME, | |
1351 dc, ftype); | |
1352 } | |
1353 else | |
1354 dc = NULL; | |
1153 } | 1355 } |
1154 | |
1155 return dc; | |
1156 } | 1356 } |
1157 | 1357 } |
1158 peek = d_peek_char (di); | 1358 |
1159 if (dc == NULL || peek == '\0' || peek == 'E') | 1359 return dc; |
1160 return dc; | 1360 } |
1161 return d_make_comp (di, DEMANGLE_COMPONENT_TYPED_NAME, dc, | 1361 |
1162 d_bare_function_type (di, has_return_type (dc))); | 1362 /* <tagged-name> ::= <name> B <source-name> */ |
1163 } | 1363 |
1364 static struct demangle_component * | |
1365 d_abi_tags (struct d_info *di, struct demangle_component *dc) | |
1366 { | |
1367 struct demangle_component *hold_last_name; | |
1368 char peek; | |
1369 | |
1370 /* Preserve the last name, so the ABI tag doesn't clobber it. */ | |
1371 hold_last_name = di->last_name; | |
1372 | |
1373 while (peek = d_peek_char (di), | |
1374 peek == 'B') | |
1375 { | |
1376 struct demangle_component *tag; | |
1377 d_advance (di, 1); | |
1378 tag = d_source_name (di); | |
1379 dc = d_make_comp (di, DEMANGLE_COMPONENT_TAGGED_NAME, dc, tag); | |
1380 } | |
1381 | |
1382 di->last_name = hold_last_name; | |
1383 | |
1384 return dc; | |
1164 } | 1385 } |
1165 | 1386 |
1166 /* <name> ::= <nested-name> | 1387 /* <name> ::= <nested-name> |
1167 ::= <unscoped-name> | 1388 ::= <unscoped-name> |
1168 ::= <unscoped-template-name> <template-args> | 1389 ::= <unscoped-template-name> <template-args> |
1187 return d_nested_name (di); | 1408 return d_nested_name (di); |
1188 | 1409 |
1189 case 'Z': | 1410 case 'Z': |
1190 return d_local_name (di); | 1411 return d_local_name (di); |
1191 | 1412 |
1192 case 'L': | |
1193 case 'U': | 1413 case 'U': |
1194 return d_unqualified_name (di); | 1414 return d_unqualified_name (di); |
1195 | 1415 |
1196 case 'S': | 1416 case 'S': |
1197 { | 1417 { |
1234 } | 1454 } |
1235 | 1455 |
1236 return dc; | 1456 return dc; |
1237 } | 1457 } |
1238 | 1458 |
1459 case 'L': | |
1239 default: | 1460 default: |
1240 dc = d_unqualified_name (di); | 1461 dc = d_unqualified_name (di); |
1241 if (d_peek_char (di) == 'I') | 1462 if (d_peek_char (di) == 'I') |
1242 { | 1463 { |
1243 /* This is <template-args>, which means that we just saw | 1464 /* This is <template-args>, which means that we just saw |
1250 } | 1471 } |
1251 return dc; | 1472 return dc; |
1252 } | 1473 } |
1253 } | 1474 } |
1254 | 1475 |
1255 /* <nested-name> ::= N [<CV-qualifiers>] <prefix> <unqualified-name> E | 1476 /* <nested-name> ::= N [<CV-qualifiers>] [<ref-qualifier>] <prefix> <unqualified-name> E |
1256 ::= N [<CV-qualifiers>] <template-prefix> <template-args> E | 1477 ::= N [<CV-qualifiers>] [<ref-qualifier>] <template-prefix> <template-args> E |
1257 */ | 1478 */ |
1258 | 1479 |
1259 static struct demangle_component * | 1480 static struct demangle_component * |
1260 d_nested_name (struct d_info *di) | 1481 d_nested_name (struct d_info *di) |
1261 { | 1482 { |
1262 struct demangle_component *ret; | 1483 struct demangle_component *ret; |
1263 struct demangle_component **pret; | 1484 struct demangle_component **pret; |
1485 struct demangle_component *rqual; | |
1264 | 1486 |
1265 if (! d_check_char (di, 'N')) | 1487 if (! d_check_char (di, 'N')) |
1266 return NULL; | 1488 return NULL; |
1267 | 1489 |
1268 pret = d_cv_qualifiers (di, &ret, 1); | 1490 pret = d_cv_qualifiers (di, &ret, 1); |
1269 if (pret == NULL) | 1491 if (pret == NULL) |
1270 return NULL; | 1492 return NULL; |
1271 | 1493 |
1494 /* Parse the ref-qualifier now and then attach it | |
1495 once we have something to attach it to. */ | |
1496 rqual = d_ref_qualifier (di, NULL); | |
1497 | |
1272 *pret = d_prefix (di); | 1498 *pret = d_prefix (di); |
1273 if (*pret == NULL) | 1499 if (*pret == NULL) |
1274 return NULL; | 1500 return NULL; |
1275 | 1501 |
1502 if (rqual) | |
1503 { | |
1504 d_left (rqual) = ret; | |
1505 ret = rqual; | |
1506 } | |
1507 | |
1276 if (! d_check_char (di, 'E')) | 1508 if (! d_check_char (di, 'E')) |
1277 return NULL; | 1509 return NULL; |
1278 | 1510 |
1279 return ret; | 1511 return ret; |
1280 } | 1512 } |
1281 | 1513 |
1282 /* <prefix> ::= <prefix> <unqualified-name> | 1514 /* <prefix> ::= <prefix> <unqualified-name> |
1283 ::= <template-prefix> <template-args> | 1515 ::= <template-prefix> <template-args> |
1284 ::= <template-param> | 1516 ::= <template-param> |
1517 ::= <decltype> | |
1285 ::= | 1518 ::= |
1286 ::= <substitution> | 1519 ::= <substitution> |
1287 | 1520 |
1288 <template-prefix> ::= <prefix> <(template) unqualified-name> | 1521 <template-prefix> ::= <prefix> <(template) unqualified-name> |
1289 ::= <template-param> | 1522 ::= <template-param> |
1308 /* The older code accepts a <local-name> here, but I don't see | 1541 /* The older code accepts a <local-name> here, but I don't see |
1309 that in the grammar. The older code does not accept a | 1542 that in the grammar. The older code does not accept a |
1310 <template-param> here. */ | 1543 <template-param> here. */ |
1311 | 1544 |
1312 comb_type = DEMANGLE_COMPONENT_QUAL_NAME; | 1545 comb_type = DEMANGLE_COMPONENT_QUAL_NAME; |
1313 if (IS_DIGIT (peek) | 1546 if (peek == 'D') |
1547 { | |
1548 char peek2 = d_peek_next_char (di); | |
1549 if (peek2 == 'T' || peek2 == 't') | |
1550 /* Decltype. */ | |
1551 dc = cplus_demangle_type (di); | |
1552 else | |
1553 /* Destructor name. */ | |
1554 dc = d_unqualified_name (di); | |
1555 } | |
1556 else if (IS_DIGIT (peek) | |
1314 || IS_LOWER (peek) | 1557 || IS_LOWER (peek) |
1315 || peek == 'C' | 1558 || peek == 'C' |
1316 || peek == 'D' | |
1317 || peek == 'U' | 1559 || peek == 'U' |
1318 || peek == 'L') | 1560 || peek == 'L') |
1319 dc = d_unqualified_name (di); | 1561 dc = d_unqualified_name (di); |
1320 else if (peek == 'S') | 1562 else if (peek == 'S') |
1321 dc = d_substitution (di, 1); | 1563 dc = d_substitution (di, 1); |
1365 */ | 1607 */ |
1366 | 1608 |
1367 static struct demangle_component * | 1609 static struct demangle_component * |
1368 d_unqualified_name (struct d_info *di) | 1610 d_unqualified_name (struct d_info *di) |
1369 { | 1611 { |
1612 struct demangle_component *ret; | |
1370 char peek; | 1613 char peek; |
1371 | 1614 |
1372 peek = d_peek_char (di); | 1615 peek = d_peek_char (di); |
1373 if (IS_DIGIT (peek)) | 1616 if (IS_DIGIT (peek)) |
1374 return d_source_name (di); | 1617 ret = d_source_name (di); |
1375 else if (IS_LOWER (peek)) | 1618 else if (IS_LOWER (peek)) |
1376 { | 1619 { |
1377 struct demangle_component *ret; | 1620 if (peek == 'o' && d_peek_next_char (di) == 'n') |
1378 | 1621 d_advance (di, 2); |
1379 ret = d_operator_name (di); | 1622 ret = d_operator_name (di); |
1380 if (ret != NULL && ret->type == DEMANGLE_COMPONENT_OPERATOR) | 1623 if (ret != NULL && ret->type == DEMANGLE_COMPONENT_OPERATOR) |
1381 di->expansion += sizeof "operator" + ret->u.s_operator.op->len - 2; | 1624 { |
1382 return ret; | 1625 di->expansion += sizeof "operator" + ret->u.s_operator.op->len - 2; |
1626 if (!strcmp (ret->u.s_operator.op->code, "li")) | |
1627 ret = d_make_comp (di, DEMANGLE_COMPONENT_UNARY, ret, | |
1628 d_source_name (di)); | |
1629 } | |
1383 } | 1630 } |
1384 else if (peek == 'C' || peek == 'D') | 1631 else if (peek == 'C' || peek == 'D') |
1385 return d_ctor_dtor_name (di); | 1632 ret = d_ctor_dtor_name (di); |
1386 else if (peek == 'L') | 1633 else if (peek == 'L') |
1387 { | 1634 { |
1388 struct demangle_component * ret; | |
1389 | |
1390 d_advance (di, 1); | 1635 d_advance (di, 1); |
1391 | 1636 |
1392 ret = d_source_name (di); | 1637 ret = d_source_name (di); |
1393 if (ret == NULL) | 1638 if (ret == NULL) |
1394 return NULL; | 1639 return NULL; |
1395 if (! d_discriminator (di)) | 1640 if (! d_discriminator (di)) |
1396 return NULL; | 1641 return NULL; |
1397 return ret; | |
1398 } | 1642 } |
1399 else if (peek == 'U') | 1643 else if (peek == 'U') |
1400 { | 1644 { |
1401 switch (d_peek_next_char (di)) | 1645 switch (d_peek_next_char (di)) |
1402 { | 1646 { |
1403 case 'l': | 1647 case 'l': |
1404 return d_lambda (di); | 1648 ret = d_lambda (di); |
1649 break; | |
1405 case 't': | 1650 case 't': |
1406 return d_unnamed_type (di); | 1651 ret = d_unnamed_type (di); |
1652 break; | |
1407 default: | 1653 default: |
1408 return NULL; | 1654 return NULL; |
1409 } | 1655 } |
1410 } | 1656 } |
1411 else | 1657 else |
1412 return NULL; | 1658 return NULL; |
1659 | |
1660 if (d_peek_char (di) == 'B') | |
1661 ret = d_abi_tags (di, ret); | |
1662 return ret; | |
1413 } | 1663 } |
1414 | 1664 |
1415 /* <source-name> ::= <(positive length) number> <identifier> */ | 1665 /* <source-name> ::= <(positive length) number> <identifier> */ |
1416 | 1666 |
1417 static struct demangle_component * | 1667 static struct demangle_component * |
1418 d_source_name (struct d_info *di) | 1668 d_source_name (struct d_info *di) |
1419 { | 1669 { |
1420 long len; | 1670 int len; |
1421 struct demangle_component *ret; | 1671 struct demangle_component *ret; |
1422 | 1672 |
1423 len = d_number (di); | 1673 len = d_number (di); |
1424 if (len <= 0) | 1674 if (len <= 0) |
1425 return NULL; | 1675 return NULL; |
1428 return ret; | 1678 return ret; |
1429 } | 1679 } |
1430 | 1680 |
1431 /* number ::= [n] <(non-negative decimal integer)> */ | 1681 /* number ::= [n] <(non-negative decimal integer)> */ |
1432 | 1682 |
1433 static long | 1683 static int |
1434 d_number (struct d_info *di) | 1684 d_number (struct d_info *di) |
1435 { | 1685 { |
1436 int negative; | 1686 int negative; |
1437 char peek; | 1687 char peek; |
1438 long ret; | 1688 int ret; |
1439 | 1689 |
1440 negative = 0; | 1690 negative = 0; |
1441 peek = d_peek_char (di); | 1691 peek = d_peek_char (di); |
1442 if (peek == 'n') | 1692 if (peek == 'n') |
1443 { | 1693 { |
1453 { | 1703 { |
1454 if (negative) | 1704 if (negative) |
1455 ret = - ret; | 1705 ret = - ret; |
1456 return ret; | 1706 return ret; |
1457 } | 1707 } |
1708 if (ret > ((INT_MAX - (peek - '0')) / 10)) | |
1709 return -1; | |
1458 ret = ret * 10 + peek - '0'; | 1710 ret = ret * 10 + peek - '0'; |
1459 d_advance (di, 1); | 1711 d_advance (di, 1); |
1460 peek = d_peek_char (di); | 1712 peek = d_peek_char (di); |
1461 } | 1713 } |
1462 } | 1714 } |
1519 } | 1771 } |
1520 | 1772 |
1521 /* operator_name ::= many different two character encodings. | 1773 /* operator_name ::= many different two character encodings. |
1522 ::= cv <type> | 1774 ::= cv <type> |
1523 ::= v <digit> <source-name> | 1775 ::= v <digit> <source-name> |
1524 */ | 1776 |
1777 This list is sorted for binary search. */ | |
1525 | 1778 |
1526 #define NL(s) s, (sizeof s) - 1 | 1779 #define NL(s) s, (sizeof s) - 1 |
1527 | 1780 |
1528 CP_STATIC_IF_GLIBCPP_V3 | 1781 CP_STATIC_IF_GLIBCPP_V3 |
1529 const struct demangle_operator_info cplus_demangle_operators[] = | 1782 const struct demangle_operator_info cplus_demangle_operators[] = |
1531 { "aN", NL ("&="), 2 }, | 1784 { "aN", NL ("&="), 2 }, |
1532 { "aS", NL ("="), 2 }, | 1785 { "aS", NL ("="), 2 }, |
1533 { "aa", NL ("&&"), 2 }, | 1786 { "aa", NL ("&&"), 2 }, |
1534 { "ad", NL ("&"), 1 }, | 1787 { "ad", NL ("&"), 1 }, |
1535 { "an", NL ("&"), 2 }, | 1788 { "an", NL ("&"), 2 }, |
1789 { "at", NL ("alignof "), 1 }, | |
1790 { "az", NL ("alignof "), 1 }, | |
1791 { "cc", NL ("const_cast"), 2 }, | |
1536 { "cl", NL ("()"), 2 }, | 1792 { "cl", NL ("()"), 2 }, |
1537 { "cm", NL (","), 2 }, | 1793 { "cm", NL (","), 2 }, |
1538 { "co", NL ("~"), 1 }, | 1794 { "co", NL ("~"), 1 }, |
1539 { "dV", NL ("/="), 2 }, | 1795 { "dV", NL ("/="), 2 }, |
1540 { "da", NL ("delete[]"), 1 }, | 1796 { "da", NL ("delete[] "), 1 }, |
1797 { "dc", NL ("dynamic_cast"), 2 }, | |
1541 { "de", NL ("*"), 1 }, | 1798 { "de", NL ("*"), 1 }, |
1542 { "dl", NL ("delete"), 1 }, | 1799 { "dl", NL ("delete "), 1 }, |
1800 { "ds", NL (".*"), 2 }, | |
1543 { "dt", NL ("."), 2 }, | 1801 { "dt", NL ("."), 2 }, |
1544 { "dv", NL ("/"), 2 }, | 1802 { "dv", NL ("/"), 2 }, |
1545 { "eO", NL ("^="), 2 }, | 1803 { "eO", NL ("^="), 2 }, |
1546 { "eo", NL ("^"), 2 }, | 1804 { "eo", NL ("^"), 2 }, |
1547 { "eq", NL ("=="), 2 }, | 1805 { "eq", NL ("=="), 2 }, |
1806 { "fL", NL ("..."), 3 }, | |
1807 { "fR", NL ("..."), 3 }, | |
1808 { "fl", NL ("..."), 2 }, | |
1809 { "fr", NL ("..."), 2 }, | |
1548 { "ge", NL (">="), 2 }, | 1810 { "ge", NL (">="), 2 }, |
1811 { "gs", NL ("::"), 1 }, | |
1549 { "gt", NL (">"), 2 }, | 1812 { "gt", NL (">"), 2 }, |
1550 { "ix", NL ("[]"), 2 }, | 1813 { "ix", NL ("[]"), 2 }, |
1551 { "lS", NL ("<<="), 2 }, | 1814 { "lS", NL ("<<="), 2 }, |
1552 { "le", NL ("<="), 2 }, | 1815 { "le", NL ("<="), 2 }, |
1816 { "li", NL ("operator\"\" "), 1 }, | |
1553 { "ls", NL ("<<"), 2 }, | 1817 { "ls", NL ("<<"), 2 }, |
1554 { "lt", NL ("<"), 2 }, | 1818 { "lt", NL ("<"), 2 }, |
1555 { "mI", NL ("-="), 2 }, | 1819 { "mI", NL ("-="), 2 }, |
1556 { "mL", NL ("*="), 2 }, | 1820 { "mL", NL ("*="), 2 }, |
1557 { "mi", NL ("-"), 2 }, | 1821 { "mi", NL ("-"), 2 }, |
1558 { "ml", NL ("*"), 2 }, | 1822 { "ml", NL ("*"), 2 }, |
1559 { "mm", NL ("--"), 1 }, | 1823 { "mm", NL ("--"), 1 }, |
1560 { "na", NL ("new[]"), 1 }, | 1824 { "na", NL ("new[]"), 3 }, |
1561 { "ne", NL ("!="), 2 }, | 1825 { "ne", NL ("!="), 2 }, |
1562 { "ng", NL ("-"), 1 }, | 1826 { "ng", NL ("-"), 1 }, |
1563 { "nt", NL ("!"), 1 }, | 1827 { "nt", NL ("!"), 1 }, |
1564 { "nw", NL ("new"), 1 }, | 1828 { "nw", NL ("new"), 3 }, |
1565 { "oR", NL ("|="), 2 }, | 1829 { "oR", NL ("|="), 2 }, |
1566 { "oo", NL ("||"), 2 }, | 1830 { "oo", NL ("||"), 2 }, |
1567 { "or", NL ("|"), 2 }, | 1831 { "or", NL ("|"), 2 }, |
1568 { "pL", NL ("+="), 2 }, | 1832 { "pL", NL ("+="), 2 }, |
1569 { "pl", NL ("+"), 2 }, | 1833 { "pl", NL ("+"), 2 }, |
1572 { "ps", NL ("+"), 1 }, | 1836 { "ps", NL ("+"), 1 }, |
1573 { "pt", NL ("->"), 2 }, | 1837 { "pt", NL ("->"), 2 }, |
1574 { "qu", NL ("?"), 3 }, | 1838 { "qu", NL ("?"), 3 }, |
1575 { "rM", NL ("%="), 2 }, | 1839 { "rM", NL ("%="), 2 }, |
1576 { "rS", NL (">>="), 2 }, | 1840 { "rS", NL (">>="), 2 }, |
1841 { "rc", NL ("reinterpret_cast"), 2 }, | |
1577 { "rm", NL ("%"), 2 }, | 1842 { "rm", NL ("%"), 2 }, |
1578 { "rs", NL (">>"), 2 }, | 1843 { "rs", NL (">>"), 2 }, |
1844 { "sP", NL ("sizeof..."), 1 }, | |
1845 { "sZ", NL ("sizeof..."), 1 }, | |
1846 { "sc", NL ("static_cast"), 2 }, | |
1579 { "st", NL ("sizeof "), 1 }, | 1847 { "st", NL ("sizeof "), 1 }, |
1580 { "sz", NL ("sizeof "), 1 }, | 1848 { "sz", NL ("sizeof "), 1 }, |
1581 { "at", NL ("alignof "), 1 }, | 1849 { "tr", NL ("throw"), 0 }, |
1582 { "az", NL ("alignof "), 1 }, | 1850 { "tw", NL ("throw "), 1 }, |
1583 { NULL, NULL, 0, 0 } | 1851 { NULL, NULL, 0, 0 } |
1584 }; | 1852 }; |
1585 | 1853 |
1586 static struct demangle_component * | 1854 static struct demangle_component * |
1587 d_operator_name (struct d_info *di) | 1855 d_operator_name (struct d_info *di) |
1592 c1 = d_next_char (di); | 1860 c1 = d_next_char (di); |
1593 c2 = d_next_char (di); | 1861 c2 = d_next_char (di); |
1594 if (c1 == 'v' && IS_DIGIT (c2)) | 1862 if (c1 == 'v' && IS_DIGIT (c2)) |
1595 return d_make_extended_operator (di, c2 - '0', d_source_name (di)); | 1863 return d_make_extended_operator (di, c2 - '0', d_source_name (di)); |
1596 else if (c1 == 'c' && c2 == 'v') | 1864 else if (c1 == 'c' && c2 == 'v') |
1597 return d_make_comp (di, DEMANGLE_COMPONENT_CAST, | 1865 { |
1598 cplus_demangle_type (di), NULL); | 1866 struct demangle_component *type; |
1867 int was_conversion = di->is_conversion; | |
1868 struct demangle_component *res; | |
1869 | |
1870 di->is_conversion = ! di->is_expression; | |
1871 type = cplus_demangle_type (di); | |
1872 if (di->is_conversion) | |
1873 res = d_make_comp (di, DEMANGLE_COMPONENT_CONVERSION, type, NULL); | |
1874 else | |
1875 res = d_make_comp (di, DEMANGLE_COMPONENT_CAST, type, NULL); | |
1876 di->is_conversion = was_conversion; | |
1877 return res; | |
1878 } | |
1599 else | 1879 else |
1600 { | 1880 { |
1601 /* LOW is the inclusive lower bound. */ | 1881 /* LOW is the inclusive lower bound. */ |
1602 int low = 0; | 1882 int low = 0; |
1603 /* HIGH is the exclusive upper bound. We subtract one to ignore | 1883 /* HIGH is the exclusive upper bound. We subtract one to ignore |
1643 static struct demangle_component * | 1923 static struct demangle_component * |
1644 d_java_resource (struct d_info *di) | 1924 d_java_resource (struct d_info *di) |
1645 { | 1925 { |
1646 struct demangle_component *p = NULL; | 1926 struct demangle_component *p = NULL; |
1647 struct demangle_component *next = NULL; | 1927 struct demangle_component *next = NULL; |
1648 long len, i; | 1928 int len, i; |
1649 char c; | 1929 char c; |
1650 const char *str; | 1930 const char *str; |
1651 | 1931 |
1652 len = d_number (di); | 1932 len = d_number (di); |
1653 if (len <= 1) | 1933 if (len <= 1) |
1735 ::= TF <type> | 2015 ::= TF <type> |
1736 ::= TJ <type> | 2016 ::= TJ <type> |
1737 ::= GR <name> | 2017 ::= GR <name> |
1738 ::= GA <encoding> | 2018 ::= GA <encoding> |
1739 ::= Gr <resource name> | 2019 ::= Gr <resource name> |
2020 ::= GTt <encoding> | |
2021 ::= GTn <encoding> | |
1740 */ | 2022 */ |
1741 | 2023 |
1742 static struct demangle_component * | 2024 static struct demangle_component * |
1743 d_special_name (struct d_info *di) | 2025 d_special_name (struct d_info *di) |
1744 { | 2026 { |
1783 d_encoding (di, 0), NULL); | 2065 d_encoding (di, 0), NULL); |
1784 | 2066 |
1785 case 'C': | 2067 case 'C': |
1786 { | 2068 { |
1787 struct demangle_component *derived_type; | 2069 struct demangle_component *derived_type; |
1788 long offset; | 2070 int offset; |
1789 struct demangle_component *base_type; | 2071 struct demangle_component *base_type; |
1790 | 2072 |
1791 derived_type = cplus_demangle_type (di); | 2073 derived_type = cplus_demangle_type (di); |
1792 offset = d_number (di); | 2074 offset = d_number (di); |
1793 if (offset < 0) | 2075 if (offset < 0) |
1807 cplus_demangle_type (di), NULL); | 2089 cplus_demangle_type (di), NULL); |
1808 case 'J': | 2090 case 'J': |
1809 return d_make_comp (di, DEMANGLE_COMPONENT_JAVA_CLASS, | 2091 return d_make_comp (di, DEMANGLE_COMPONENT_JAVA_CLASS, |
1810 cplus_demangle_type (di), NULL); | 2092 cplus_demangle_type (di), NULL); |
1811 | 2093 |
2094 case 'H': | |
2095 return d_make_comp (di, DEMANGLE_COMPONENT_TLS_INIT, | |
2096 d_name (di), NULL); | |
2097 | |
2098 case 'W': | |
2099 return d_make_comp (di, DEMANGLE_COMPONENT_TLS_WRAPPER, | |
2100 d_name (di), NULL); | |
2101 | |
1812 default: | 2102 default: |
1813 return NULL; | 2103 return NULL; |
1814 } | 2104 } |
1815 } | 2105 } |
1816 else if (d_check_char (di, 'G')) | 2106 else if (d_check_char (di, 'G')) |
1817 { | 2107 { |
1818 switch (d_next_char (di)) | 2108 switch (d_next_char (di)) |
1819 { | 2109 { |
1820 case 'V': | 2110 case 'V': |
1821 return d_make_comp (di, DEMANGLE_COMPONENT_GUARD, d_name (di), NULL); | 2111 return d_make_comp (di, DEMANGLE_COMPONENT_GUARD, |
2112 d_name (di), NULL); | |
1822 | 2113 |
1823 case 'R': | 2114 case 'R': |
1824 return d_make_comp (di, DEMANGLE_COMPONENT_REFTEMP, d_name (di), | 2115 { |
1825 NULL); | 2116 struct demangle_component *name = d_name (di); |
2117 return d_make_comp (di, DEMANGLE_COMPONENT_REFTEMP, name, | |
2118 d_number_component (di)); | |
2119 } | |
1826 | 2120 |
1827 case 'A': | 2121 case 'A': |
1828 return d_make_comp (di, DEMANGLE_COMPONENT_HIDDEN_ALIAS, | 2122 return d_make_comp (di, DEMANGLE_COMPONENT_HIDDEN_ALIAS, |
1829 d_encoding (di, 0), NULL); | 2123 d_encoding (di, 0), NULL); |
2124 | |
2125 case 'T': | |
2126 switch (d_next_char (di)) | |
2127 { | |
2128 case 'n': | |
2129 return d_make_comp (di, DEMANGLE_COMPONENT_NONTRANSACTION_CLONE, | |
2130 d_encoding (di, 0), NULL); | |
2131 default: | |
2132 /* ??? The proposal is that other letters (such as 'h') stand | |
2133 for different variants of transaction cloning, such as | |
2134 compiling directly for hardware transaction support. But | |
2135 they still should all be transactional clones of some sort | |
2136 so go ahead and call them that. */ | |
2137 case 't': | |
2138 return d_make_comp (di, DEMANGLE_COMPONENT_TRANSACTION_CLONE, | |
2139 d_encoding (di, 0), NULL); | |
2140 } | |
1830 | 2141 |
1831 case 'r': | 2142 case 'r': |
1832 return d_java_resource (di); | 2143 return d_java_resource (di); |
1833 | 2144 |
1834 default: | 2145 default: |
1897 switch (d_peek_char (di)) | 2208 switch (d_peek_char (di)) |
1898 { | 2209 { |
1899 case 'C': | 2210 case 'C': |
1900 { | 2211 { |
1901 enum gnu_v3_ctor_kinds kind; | 2212 enum gnu_v3_ctor_kinds kind; |
2213 int inheriting = 0; | |
2214 | |
2215 if (d_peek_next_char (di) == 'I') | |
2216 { | |
2217 inheriting = 1; | |
2218 d_advance (di, 1); | |
2219 } | |
1902 | 2220 |
1903 switch (d_peek_next_char (di)) | 2221 switch (d_peek_next_char (di)) |
1904 { | 2222 { |
1905 case '1': | 2223 case '1': |
1906 kind = gnu_v3_complete_object_ctor; | 2224 kind = gnu_v3_complete_object_ctor; |
1909 kind = gnu_v3_base_object_ctor; | 2227 kind = gnu_v3_base_object_ctor; |
1910 break; | 2228 break; |
1911 case '3': | 2229 case '3': |
1912 kind = gnu_v3_complete_object_allocating_ctor; | 2230 kind = gnu_v3_complete_object_allocating_ctor; |
1913 break; | 2231 break; |
2232 case '4': | |
2233 kind = gnu_v3_unified_ctor; | |
2234 break; | |
2235 case '5': | |
2236 kind = gnu_v3_object_ctor_group; | |
2237 break; | |
1914 default: | 2238 default: |
1915 return NULL; | 2239 return NULL; |
1916 } | 2240 } |
2241 | |
1917 d_advance (di, 2); | 2242 d_advance (di, 2); |
2243 | |
2244 if (inheriting) | |
2245 cplus_demangle_type (di); | |
2246 | |
1918 return d_make_ctor (di, kind, di->last_name); | 2247 return d_make_ctor (di, kind, di->last_name); |
1919 } | 2248 } |
1920 | 2249 |
1921 case 'D': | 2250 case 'D': |
1922 { | 2251 { |
1931 kind = gnu_v3_complete_object_dtor; | 2260 kind = gnu_v3_complete_object_dtor; |
1932 break; | 2261 break; |
1933 case '2': | 2262 case '2': |
1934 kind = gnu_v3_base_object_dtor; | 2263 kind = gnu_v3_base_object_dtor; |
1935 break; | 2264 break; |
2265 /* digit '3' is not used */ | |
2266 case '4': | |
2267 kind = gnu_v3_unified_dtor; | |
2268 break; | |
2269 case '5': | |
2270 kind = gnu_v3_object_dtor_group; | |
2271 break; | |
1936 default: | 2272 default: |
1937 return NULL; | 2273 return NULL; |
1938 } | 2274 } |
1939 d_advance (di, 2); | 2275 d_advance (di, 2); |
1940 return d_make_dtor (di, kind, di->last_name); | 2276 return d_make_dtor (di, kind, di->last_name); |
1941 } | 2277 } |
1942 | 2278 |
1943 default: | 2279 default: |
1944 return NULL; | 2280 return NULL; |
1945 } | 2281 } |
2282 } | |
2283 | |
2284 /* True iff we're looking at an order-insensitive type-qualifier, including | |
2285 function-type-qualifiers. */ | |
2286 | |
2287 static int | |
2288 next_is_type_qual (struct d_info *di) | |
2289 { | |
2290 char peek = d_peek_char (di); | |
2291 if (peek == 'r' || peek == 'V' || peek == 'K') | |
2292 return 1; | |
2293 if (peek == 'D') | |
2294 { | |
2295 peek = d_peek_next_char (di); | |
2296 if (peek == 'x' || peek == 'o' || peek == 'O' || peek == 'w') | |
2297 return 1; | |
2298 } | |
2299 return 0; | |
1946 } | 2300 } |
1947 | 2301 |
1948 /* <type> ::= <builtin-type> | 2302 /* <type> ::= <builtin-type> |
1949 ::= <function-type> | 2303 ::= <function-type> |
1950 ::= <class-enum-type> | 2304 ::= <class-enum-type> |
2028 order-sensitive. So we just assume that they are all | 2382 order-sensitive. So we just assume that they are all |
2029 order-sensitive. g++ 3.4 supports only one vendor qualifier, | 2383 order-sensitive. g++ 3.4 supports only one vendor qualifier, |
2030 __vector, and it treats it as order-sensitive when mangling | 2384 __vector, and it treats it as order-sensitive when mangling |
2031 names. */ | 2385 names. */ |
2032 | 2386 |
2033 peek = d_peek_char (di); | 2387 if (next_is_type_qual (di)) |
2034 if (peek == 'r' || peek == 'V' || peek == 'K') | |
2035 { | 2388 { |
2036 struct demangle_component **pret; | 2389 struct demangle_component **pret; |
2037 | 2390 |
2038 pret = d_cv_qualifiers (di, &ret, 0); | 2391 pret = d_cv_qualifiers (di, &ret, 0); |
2039 if (pret == NULL) | 2392 if (pret == NULL) |
2040 return NULL; | 2393 return NULL; |
2041 *pret = cplus_demangle_type (di); | 2394 if (d_peek_char (di) == 'F') |
2042 if (! *pret || ! d_add_substitution (di, ret)) | 2395 { |
2396 /* cv-qualifiers before a function type apply to 'this', | |
2397 so avoid adding the unqualified function type to | |
2398 the substitution list. */ | |
2399 *pret = d_function_type (di); | |
2400 } | |
2401 else | |
2402 *pret = cplus_demangle_type (di); | |
2403 if (!*pret) | |
2404 return NULL; | |
2405 if ((*pret)->type == DEMANGLE_COMPONENT_RVALUE_REFERENCE_THIS | |
2406 || (*pret)->type == DEMANGLE_COMPONENT_REFERENCE_THIS) | |
2407 { | |
2408 /* Move the ref-qualifier outside the cv-qualifiers so that | |
2409 they are printed in the right order. */ | |
2410 struct demangle_component *fn = d_left (*pret); | |
2411 d_left (*pret) = ret; | |
2412 ret = *pret; | |
2413 *pret = fn; | |
2414 } | |
2415 if (! d_add_substitution (di, ret)) | |
2043 return NULL; | 2416 return NULL; |
2044 return ret; | 2417 return ret; |
2045 } | 2418 } |
2046 | 2419 |
2047 can_subst = 1; | 2420 can_subst = 1; |
2048 | 2421 |
2422 peek = d_peek_char (di); | |
2049 switch (peek) | 2423 switch (peek) |
2050 { | 2424 { |
2051 case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': | 2425 case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': |
2052 case 'h': case 'i': case 'j': case 'l': case 'm': case 'n': | 2426 case 'h': case 'i': case 'j': case 'l': case 'm': case 'n': |
2053 case 'o': case 's': case 't': | 2427 case 'o': case 's': case 't': |
2086 | 2460 |
2087 case 'T': | 2461 case 'T': |
2088 ret = d_template_param (di); | 2462 ret = d_template_param (di); |
2089 if (d_peek_char (di) == 'I') | 2463 if (d_peek_char (di) == 'I') |
2090 { | 2464 { |
2091 /* This is <template-template-param> <template-args>. The | 2465 /* This may be <template-template-param> <template-args>. |
2092 <template-template-param> part is a substitution | 2466 If this is the type for a conversion operator, we can |
2467 have a <template-template-param> here only by following | |
2468 a derivation like this: | |
2469 | |
2470 <nested-name> | |
2471 -> <template-prefix> <template-args> | |
2472 -> <prefix> <template-unqualified-name> <template-args> | |
2473 -> <unqualified-name> <template-unqualified-name> <template-args> | |
2474 -> <source-name> <template-unqualified-name> <template-args> | |
2475 -> <source-name> <operator-name> <template-args> | |
2476 -> <source-name> cv <type> <template-args> | |
2477 -> <source-name> cv <template-template-param> <template-args> <template-args> | |
2478 | |
2479 where the <template-args> is followed by another. | |
2480 Otherwise, we must have a derivation like this: | |
2481 | |
2482 <nested-name> | |
2483 -> <template-prefix> <template-args> | |
2484 -> <prefix> <template-unqualified-name> <template-args> | |
2485 -> <unqualified-name> <template-unqualified-name> <template-args> | |
2486 -> <source-name> <template-unqualified-name> <template-args> | |
2487 -> <source-name> <operator-name> <template-args> | |
2488 -> <source-name> cv <type> <template-args> | |
2489 -> <source-name> cv <template-param> <template-args> | |
2490 | |
2491 where we need to leave the <template-args> to be processed | |
2492 by d_prefix (following the <template-prefix>). | |
2493 | |
2494 The <template-template-param> part is a substitution | |
2093 candidate. */ | 2495 candidate. */ |
2094 if (! d_add_substitution (di, ret)) | 2496 if (! di->is_conversion) |
2095 return NULL; | 2497 { |
2096 ret = d_make_comp (di, DEMANGLE_COMPONENT_TEMPLATE, ret, | 2498 if (! d_add_substitution (di, ret)) |
2097 d_template_args (di)); | 2499 return NULL; |
2500 ret = d_make_comp (di, DEMANGLE_COMPONENT_TEMPLATE, ret, | |
2501 d_template_args (di)); | |
2502 } | |
2503 else | |
2504 { | |
2505 struct demangle_component *args; | |
2506 struct d_info_checkpoint checkpoint; | |
2507 | |
2508 d_checkpoint (di, &checkpoint); | |
2509 args = d_template_args (di); | |
2510 if (d_peek_char (di) == 'I') | |
2511 { | |
2512 if (! d_add_substitution (di, ret)) | |
2513 return NULL; | |
2514 ret = d_make_comp (di, DEMANGLE_COMPONENT_TEMPLATE, ret, | |
2515 args); | |
2516 } | |
2517 else | |
2518 d_backtrack (di, &checkpoint); | |
2519 } | |
2098 } | 2520 } |
2099 break; | 2521 break; |
2100 | 2522 |
2101 case 'S': | 2523 case 'S': |
2102 /* If this is a special substitution, then it is the start of | 2524 /* If this is a special substitution, then it is the start of |
2162 break; | 2584 break; |
2163 | 2585 |
2164 case 'U': | 2586 case 'U': |
2165 d_advance (di, 1); | 2587 d_advance (di, 1); |
2166 ret = d_source_name (di); | 2588 ret = d_source_name (di); |
2589 if (d_peek_char (di) == 'I') | |
2590 ret = d_make_comp (di, DEMANGLE_COMPONENT_TEMPLATE, ret, | |
2591 d_template_args (di)); | |
2167 ret = d_make_comp (di, DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL, | 2592 ret = d_make_comp (di, DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL, |
2168 cplus_demangle_type (di), ret); | 2593 cplus_demangle_type (di), ret); |
2169 break; | 2594 break; |
2170 | 2595 |
2171 case 'D': | 2596 case 'D': |
2179 /* decltype (expression) */ | 2604 /* decltype (expression) */ |
2180 ret = d_make_comp (di, DEMANGLE_COMPONENT_DECLTYPE, | 2605 ret = d_make_comp (di, DEMANGLE_COMPONENT_DECLTYPE, |
2181 d_expression (di), NULL); | 2606 d_expression (di), NULL); |
2182 if (ret && d_next_char (di) != 'E') | 2607 if (ret && d_next_char (di) != 'E') |
2183 ret = NULL; | 2608 ret = NULL; |
2609 can_subst = 1; | |
2184 break; | 2610 break; |
2185 | 2611 |
2186 case 'p': | 2612 case 'p': |
2187 /* Pack expansion. */ | 2613 /* Pack expansion. */ |
2188 ret = d_make_comp (di, DEMANGLE_COMPONENT_PACK_EXPANSION, | 2614 ret = d_make_comp (di, DEMANGLE_COMPONENT_PACK_EXPANSION, |
2189 cplus_demangle_type (di), NULL); | 2615 cplus_demangle_type (di), NULL); |
2616 can_subst = 1; | |
2190 break; | 2617 break; |
2191 | 2618 |
2619 case 'a': | |
2620 /* auto */ | |
2621 ret = d_make_name (di, "auto", 4); | |
2622 break; | |
2623 case 'c': | |
2624 /* decltype(auto) */ | |
2625 ret = d_make_name (di, "decltype(auto)", 14); | |
2626 break; | |
2627 | |
2192 case 'f': | 2628 case 'f': |
2193 /* 32-bit decimal floating point */ | 2629 /* 32-bit decimal floating point */ |
2194 ret = d_make_builtin_type (di, &cplus_demangle_builtin_types[26]); | 2630 ret = d_make_builtin_type (di, &cplus_demangle_builtin_types[26]); |
2195 di->expansion += ret->u.s_builtin.type->len; | 2631 di->expansion += ret->u.s_builtin.type->len; |
2196 break; | 2632 break; |
2235 ret->u.s_fixed.sat = (peek == 's'); | 2671 ret->u.s_fixed.sat = (peek == 's'); |
2236 break; | 2672 break; |
2237 | 2673 |
2238 case 'v': | 2674 case 'v': |
2239 ret = d_vector_type (di); | 2675 ret = d_vector_type (di); |
2676 can_subst = 1; | |
2240 break; | 2677 break; |
2241 | 2678 |
2242 case 'n': | 2679 case 'n': |
2243 /* decltype(nullptr) */ | 2680 /* decltype(nullptr) */ |
2244 ret = d_make_builtin_type (di, &cplus_demangle_builtin_types[32]); | 2681 ret = d_make_builtin_type (di, &cplus_demangle_builtin_types[32]); |
2261 } | 2698 } |
2262 | 2699 |
2263 return ret; | 2700 return ret; |
2264 } | 2701 } |
2265 | 2702 |
2266 /* <CV-qualifiers> ::= [r] [V] [K] */ | 2703 /* <CV-qualifiers> ::= [r] [V] [K] [Dx] */ |
2267 | 2704 |
2268 static struct demangle_component ** | 2705 static struct demangle_component ** |
2269 d_cv_qualifiers (struct d_info *di, | 2706 d_cv_qualifiers (struct d_info *di, |
2270 struct demangle_component **pret, int member_fn) | 2707 struct demangle_component **pret, int member_fn) |
2271 { | 2708 { |
2709 struct demangle_component **pstart; | |
2272 char peek; | 2710 char peek; |
2273 | 2711 |
2712 pstart = pret; | |
2274 peek = d_peek_char (di); | 2713 peek = d_peek_char (di); |
2275 while (peek == 'r' || peek == 'V' || peek == 'K') | 2714 while (next_is_type_qual (di)) |
2276 { | 2715 { |
2277 enum demangle_component_type t; | 2716 enum demangle_component_type t; |
2717 struct demangle_component *right = NULL; | |
2278 | 2718 |
2279 d_advance (di, 1); | 2719 d_advance (di, 1); |
2280 if (peek == 'r') | 2720 if (peek == 'r') |
2281 { | 2721 { |
2282 t = (member_fn | 2722 t = (member_fn |
2289 t = (member_fn | 2729 t = (member_fn |
2290 ? DEMANGLE_COMPONENT_VOLATILE_THIS | 2730 ? DEMANGLE_COMPONENT_VOLATILE_THIS |
2291 : DEMANGLE_COMPONENT_VOLATILE); | 2731 : DEMANGLE_COMPONENT_VOLATILE); |
2292 di->expansion += sizeof "volatile"; | 2732 di->expansion += sizeof "volatile"; |
2293 } | 2733 } |
2294 else | 2734 else if (peek == 'K') |
2295 { | 2735 { |
2296 t = (member_fn | 2736 t = (member_fn |
2297 ? DEMANGLE_COMPONENT_CONST_THIS | 2737 ? DEMANGLE_COMPONENT_CONST_THIS |
2298 : DEMANGLE_COMPONENT_CONST); | 2738 : DEMANGLE_COMPONENT_CONST); |
2299 di->expansion += sizeof "const"; | 2739 di->expansion += sizeof "const"; |
2300 } | 2740 } |
2301 | 2741 else |
2302 *pret = d_make_comp (di, t, NULL, NULL); | 2742 { |
2743 peek = d_next_char (di); | |
2744 if (peek == 'x') | |
2745 { | |
2746 t = DEMANGLE_COMPONENT_TRANSACTION_SAFE; | |
2747 di->expansion += sizeof "transaction_safe"; | |
2748 } | |
2749 else if (peek == 'o' | |
2750 || peek == 'O') | |
2751 { | |
2752 t = DEMANGLE_COMPONENT_NOEXCEPT; | |
2753 di->expansion += sizeof "noexcept"; | |
2754 if (peek == 'O') | |
2755 { | |
2756 right = d_expression (di); | |
2757 if (right == NULL) | |
2758 return NULL; | |
2759 if (! d_check_char (di, 'E')) | |
2760 return NULL; | |
2761 } | |
2762 } | |
2763 else if (peek == 'w') | |
2764 { | |
2765 t = DEMANGLE_COMPONENT_THROW_SPEC; | |
2766 di->expansion += sizeof "throw"; | |
2767 right = d_parmlist (di); | |
2768 if (right == NULL) | |
2769 return NULL; | |
2770 if (! d_check_char (di, 'E')) | |
2771 return NULL; | |
2772 } | |
2773 else | |
2774 return NULL; | |
2775 } | |
2776 | |
2777 *pret = d_make_comp (di, t, NULL, right); | |
2303 if (*pret == NULL) | 2778 if (*pret == NULL) |
2304 return NULL; | 2779 return NULL; |
2305 pret = &d_left (*pret); | 2780 pret = &d_left (*pret); |
2306 | 2781 |
2307 peek = d_peek_char (di); | 2782 peek = d_peek_char (di); |
2308 } | 2783 } |
2309 | 2784 |
2785 if (!member_fn && peek == 'F') | |
2786 { | |
2787 while (pstart != pret) | |
2788 { | |
2789 switch ((*pstart)->type) | |
2790 { | |
2791 case DEMANGLE_COMPONENT_RESTRICT: | |
2792 (*pstart)->type = DEMANGLE_COMPONENT_RESTRICT_THIS; | |
2793 break; | |
2794 case DEMANGLE_COMPONENT_VOLATILE: | |
2795 (*pstart)->type = DEMANGLE_COMPONENT_VOLATILE_THIS; | |
2796 break; | |
2797 case DEMANGLE_COMPONENT_CONST: | |
2798 (*pstart)->type = DEMANGLE_COMPONENT_CONST_THIS; | |
2799 break; | |
2800 default: | |
2801 break; | |
2802 } | |
2803 pstart = &d_left (*pstart); | |
2804 } | |
2805 } | |
2806 | |
2310 return pret; | 2807 return pret; |
2311 } | 2808 } |
2312 | 2809 |
2313 /* <function-type> ::= F [Y] <bare-function-type> E */ | 2810 /* <ref-qualifier> ::= R |
2811 ::= O */ | |
2812 | |
2813 static struct demangle_component * | |
2814 d_ref_qualifier (struct d_info *di, struct demangle_component *sub) | |
2815 { | |
2816 struct demangle_component *ret = sub; | |
2817 char peek; | |
2818 | |
2819 peek = d_peek_char (di); | |
2820 if (peek == 'R' || peek == 'O') | |
2821 { | |
2822 enum demangle_component_type t; | |
2823 if (peek == 'R') | |
2824 { | |
2825 t = DEMANGLE_COMPONENT_REFERENCE_THIS; | |
2826 di->expansion += sizeof "&"; | |
2827 } | |
2828 else | |
2829 { | |
2830 t = DEMANGLE_COMPONENT_RVALUE_REFERENCE_THIS; | |
2831 di->expansion += sizeof "&&"; | |
2832 } | |
2833 d_advance (di, 1); | |
2834 | |
2835 ret = d_make_comp (di, t, ret, NULL); | |
2836 } | |
2837 | |
2838 return ret; | |
2839 } | |
2840 | |
2841 /* <function-type> ::= F [Y] <bare-function-type> [<ref-qualifier>] [T] E */ | |
2314 | 2842 |
2315 static struct demangle_component * | 2843 static struct demangle_component * |
2316 d_function_type (struct d_info *di) | 2844 d_function_type (struct d_info *di) |
2317 { | 2845 { |
2318 struct demangle_component *ret; | 2846 struct demangle_component *ret; |
2324 /* Function has C linkage. We don't print this information. | 2852 /* Function has C linkage. We don't print this information. |
2325 FIXME: We should print it in verbose mode. */ | 2853 FIXME: We should print it in verbose mode. */ |
2326 d_advance (di, 1); | 2854 d_advance (di, 1); |
2327 } | 2855 } |
2328 ret = d_bare_function_type (di, 1); | 2856 ret = d_bare_function_type (di, 1); |
2857 ret = d_ref_qualifier (di, ret); | |
2858 | |
2329 if (! d_check_char (di, 'E')) | 2859 if (! d_check_char (di, 'E')) |
2330 return NULL; | 2860 return NULL; |
2331 return ret; | 2861 return ret; |
2332 } | 2862 } |
2333 | 2863 |
2344 while (1) | 2874 while (1) |
2345 { | 2875 { |
2346 struct demangle_component *type; | 2876 struct demangle_component *type; |
2347 | 2877 |
2348 char peek = d_peek_char (di); | 2878 char peek = d_peek_char (di); |
2349 if (peek == '\0' || peek == 'E') | 2879 if (peek == '\0' || peek == 'E' || peek == '.') |
2880 break; | |
2881 if ((peek == 'R' || peek == 'O') | |
2882 && d_peek_next_char (di) == 'E') | |
2883 /* Function ref-qualifier, not a ref prefix for a parameter type. */ | |
2350 break; | 2884 break; |
2351 type = cplus_demangle_type (di); | 2885 type = cplus_demangle_type (di); |
2352 if (type == NULL) | 2886 if (type == NULL) |
2353 return NULL; | 2887 return NULL; |
2354 *ptl = d_make_comp (di, DEMANGLE_COMPONENT_ARGLIST, type, NULL); | 2888 *ptl = d_make_comp (di, DEMANGLE_COMPONENT_ARGLIST, type, NULL); |
2496 static struct demangle_component * | 3030 static struct demangle_component * |
2497 d_pointer_to_member_type (struct d_info *di) | 3031 d_pointer_to_member_type (struct d_info *di) |
2498 { | 3032 { |
2499 struct demangle_component *cl; | 3033 struct demangle_component *cl; |
2500 struct demangle_component *mem; | 3034 struct demangle_component *mem; |
2501 struct demangle_component **pmem; | |
2502 | 3035 |
2503 if (! d_check_char (di, 'M')) | 3036 if (! d_check_char (di, 'M')) |
2504 return NULL; | 3037 return NULL; |
2505 | 3038 |
2506 cl = cplus_demangle_type (di); | 3039 cl = cplus_demangle_type (di); |
2507 | 3040 if (cl == NULL) |
2508 /* The ABI specifies that any type can be a substitution source, and | |
2509 that M is followed by two types, and that when a CV-qualified | |
2510 type is seen both the base type and the CV-qualified types are | |
2511 substitution sources. The ABI also specifies that for a pointer | |
2512 to a CV-qualified member function, the qualifiers are attached to | |
2513 the second type. Given the grammar, a plain reading of the ABI | |
2514 suggests that both the CV-qualified member function and the | |
2515 non-qualified member function are substitution sources. However, | |
2516 g++ does not work that way. g++ treats only the CV-qualified | |
2517 member function as a substitution source. FIXME. So to work | |
2518 with g++, we need to pull off the CV-qualifiers here, in order to | |
2519 avoid calling add_substitution() in cplus_demangle_type(). But | |
2520 for a CV-qualified member which is not a function, g++ does | |
2521 follow the ABI, so we need to handle that case here by calling | |
2522 d_add_substitution ourselves. */ | |
2523 | |
2524 pmem = d_cv_qualifiers (di, &mem, 1); | |
2525 if (pmem == NULL) | |
2526 return NULL; | 3041 return NULL; |
2527 *pmem = cplus_demangle_type (di); | 3042 |
2528 if (*pmem == NULL) | 3043 /* The ABI says, "The type of a non-static member function is considered |
3044 to be different, for the purposes of substitution, from the type of a | |
3045 namespace-scope or static member function whose type appears | |
3046 similar. The types of two non-static member functions are considered | |
3047 to be different, for the purposes of substitution, if the functions | |
3048 are members of different classes. In other words, for the purposes of | |
3049 substitution, the class of which the function is a member is | |
3050 considered part of the type of function." | |
3051 | |
3052 For a pointer to member function, this call to cplus_demangle_type | |
3053 will end up adding a (possibly qualified) non-member function type to | |
3054 the substitution table, which is not correct; however, the member | |
3055 function type will never be used in a substitution, so putting the | |
3056 wrong type in the substitution table is harmless. */ | |
3057 | |
3058 mem = cplus_demangle_type (di); | |
3059 if (mem == NULL) | |
2529 return NULL; | 3060 return NULL; |
2530 | 3061 |
2531 if (pmem != &mem && (*pmem)->type != DEMANGLE_COMPONENT_FUNCTION_TYPE) | |
2532 { | |
2533 if (! d_add_substitution (di, mem)) | |
2534 return NULL; | |
2535 } | |
2536 | |
2537 return d_make_comp (di, DEMANGLE_COMPONENT_PTRMEM_TYPE, cl, mem); | 3062 return d_make_comp (di, DEMANGLE_COMPONENT_PTRMEM_TYPE, cl, mem); |
2538 } | 3063 } |
2539 | 3064 |
2540 /* <non-negative number> _ */ | 3065 /* <non-negative number> _ */ |
2541 | 3066 |
2542 static long | 3067 static int |
2543 d_compact_number (struct d_info *di) | 3068 d_compact_number (struct d_info *di) |
2544 { | 3069 { |
2545 long num; | 3070 int num; |
2546 if (d_peek_char (di) == '_') | 3071 if (d_peek_char (di) == '_') |
2547 num = 0; | 3072 num = 0; |
2548 else if (d_peek_char (di) == 'n') | 3073 else if (d_peek_char (di) == 'n') |
2549 return -1; | 3074 return -1; |
2550 else | 3075 else |
2551 num = d_number (di) + 1; | 3076 num = d_number (di) + 1; |
2552 | 3077 |
2553 if (! d_check_char (di, '_')) | 3078 if (num < 0 || ! d_check_char (di, '_')) |
2554 return -1; | 3079 return -1; |
2555 return num; | 3080 return num; |
2556 } | 3081 } |
2557 | 3082 |
2558 /* <template-param> ::= T_ | 3083 /* <template-param> ::= T_ |
2560 */ | 3085 */ |
2561 | 3086 |
2562 static struct demangle_component * | 3087 static struct demangle_component * |
2563 d_template_param (struct d_info *di) | 3088 d_template_param (struct d_info *di) |
2564 { | 3089 { |
2565 long param; | 3090 int param; |
2566 | 3091 |
2567 if (! d_check_char (di, 'T')) | 3092 if (! d_check_char (di, 'T')) |
2568 return NULL; | 3093 return NULL; |
2569 | 3094 |
2570 param = d_compact_number (di); | 3095 param = d_compact_number (di); |
2571 if (param < 0) | 3096 if (param < 0) |
2572 return NULL; | 3097 return NULL; |
2573 | 3098 |
2574 ++di->did_subs; | |
2575 | |
2576 return d_make_template_param (di, param); | 3099 return d_make_template_param (di, param); |
2577 } | 3100 } |
2578 | 3101 |
2579 /* <template-args> ::= I <template-arg>+ E */ | 3102 /* <template-args> ::= I <template-arg>+ E */ |
2580 | 3103 |
2581 static struct demangle_component * | 3104 static struct demangle_component * |
2582 d_template_args (struct d_info *di) | 3105 d_template_args (struct d_info *di) |
3106 { | |
3107 if (d_peek_char (di) != 'I' | |
3108 && d_peek_char (di) != 'J') | |
3109 return NULL; | |
3110 d_advance (di, 1); | |
3111 | |
3112 return d_template_args_1 (di); | |
3113 } | |
3114 | |
3115 /* <template-arg>* E */ | |
3116 | |
3117 static struct demangle_component * | |
3118 d_template_args_1 (struct d_info *di) | |
2583 { | 3119 { |
2584 struct demangle_component *hold_last_name; | 3120 struct demangle_component *hold_last_name; |
2585 struct demangle_component *al; | 3121 struct demangle_component *al; |
2586 struct demangle_component **pal; | 3122 struct demangle_component **pal; |
2587 | 3123 |
2588 /* Preserve the last name we saw--don't let the template arguments | 3124 /* Preserve the last name we saw--don't let the template arguments |
2589 clobber it, as that would give us the wrong name for a subsequent | 3125 clobber it, as that would give us the wrong name for a subsequent |
2590 constructor or destructor. */ | 3126 constructor or destructor. */ |
2591 hold_last_name = di->last_name; | 3127 hold_last_name = di->last_name; |
2592 | |
2593 if (! d_check_char (di, 'I')) | |
2594 return NULL; | |
2595 | 3128 |
2596 if (d_peek_char (di) == 'E') | 3129 if (d_peek_char (di) == 'E') |
2597 { | 3130 { |
2598 /* An argument pack can be empty. */ | 3131 /* An argument pack can be empty. */ |
2599 d_advance (di, 1); | 3132 d_advance (di, 1); |
2648 | 3181 |
2649 case 'L': | 3182 case 'L': |
2650 return d_expr_primary (di); | 3183 return d_expr_primary (di); |
2651 | 3184 |
2652 case 'I': | 3185 case 'I': |
3186 case 'J': | |
2653 /* An argument pack. */ | 3187 /* An argument pack. */ |
2654 return d_template_args (di); | 3188 return d_template_args (di); |
2655 | 3189 |
2656 default: | 3190 default: |
2657 return cplus_demangle_type (di); | 3191 return cplus_demangle_type (di); |
2658 } | 3192 } |
2659 } | 3193 } |
2660 | 3194 |
2661 /* Subroutine of <expression> ::= cl <expression>+ E */ | 3195 /* Parse a sequence of expressions until we hit the terminator |
2662 | 3196 character. */ |
2663 static struct demangle_component * | 3197 |
2664 d_exprlist (struct d_info *di) | 3198 static struct demangle_component * |
3199 d_exprlist (struct d_info *di, char terminator) | |
2665 { | 3200 { |
2666 struct demangle_component *list = NULL; | 3201 struct demangle_component *list = NULL; |
2667 struct demangle_component **p = &list; | 3202 struct demangle_component **p = &list; |
2668 | 3203 |
2669 if (d_peek_char (di) == 'E') | 3204 if (d_peek_char (di) == terminator) |
2670 { | 3205 { |
2671 d_advance (di, 1); | 3206 d_advance (di, 1); |
2672 return d_make_comp (di, DEMANGLE_COMPONENT_ARGLIST, NULL, NULL); | 3207 return d_make_comp (di, DEMANGLE_COMPONENT_ARGLIST, NULL, NULL); |
2673 } | 3208 } |
2674 | 3209 |
2681 *p = d_make_comp (di, DEMANGLE_COMPONENT_ARGLIST, arg, NULL); | 3216 *p = d_make_comp (di, DEMANGLE_COMPONENT_ARGLIST, arg, NULL); |
2682 if (*p == NULL) | 3217 if (*p == NULL) |
2683 return NULL; | 3218 return NULL; |
2684 p = &d_right (*p); | 3219 p = &d_right (*p); |
2685 | 3220 |
2686 if (d_peek_char (di) == 'E') | 3221 if (d_peek_char (di) == terminator) |
2687 { | 3222 { |
2688 d_advance (di, 1); | 3223 d_advance (di, 1); |
2689 break; | 3224 break; |
2690 } | 3225 } |
2691 } | 3226 } |
2692 | 3227 |
2693 return list; | 3228 return list; |
3229 } | |
3230 | |
3231 /* Returns nonzero iff OP is an operator for a C++ cast: const_cast, | |
3232 dynamic_cast, static_cast or reinterpret_cast. */ | |
3233 | |
3234 static int | |
3235 op_is_new_cast (struct demangle_component *op) | |
3236 { | |
3237 const char *code = op->u.s_operator.op->code; | |
3238 return (code[1] == 'c' | |
3239 && (code[0] == 's' || code[0] == 'd' | |
3240 || code[0] == 'c' || code[0] == 'r')); | |
2694 } | 3241 } |
2695 | 3242 |
2696 /* <expression> ::= <(unary) operator-name> <expression> | 3243 /* <expression> ::= <(unary) operator-name> <expression> |
2697 ::= <(binary) operator-name> <expression> <expression> | 3244 ::= <(binary) operator-name> <expression> <expression> |
2698 ::= <(trinary) operator-name> <expression> <expression> <expression> | 3245 ::= <(trinary) operator-name> <expression> <expression> <expression> |
2702 ::= sr <type> <unqualified-name> | 3249 ::= sr <type> <unqualified-name> |
2703 ::= sr <type> <unqualified-name> <template-args> | 3250 ::= sr <type> <unqualified-name> <template-args> |
2704 ::= <expr-primary> | 3251 ::= <expr-primary> |
2705 */ | 3252 */ |
2706 | 3253 |
2707 static struct demangle_component * | 3254 static inline struct demangle_component * |
2708 d_expression (struct d_info *di) | 3255 d_expression_1 (struct d_info *di) |
2709 { | 3256 { |
2710 char peek; | 3257 char peek; |
2711 | 3258 |
2712 peek = d_peek_char (di); | 3259 peek = d_peek_char (di); |
2713 if (peek == 'L') | 3260 if (peek == 'L') |
2731 } | 3278 } |
2732 else if (peek == 's' && d_peek_next_char (di) == 'p') | 3279 else if (peek == 's' && d_peek_next_char (di) == 'p') |
2733 { | 3280 { |
2734 d_advance (di, 2); | 3281 d_advance (di, 2); |
2735 return d_make_comp (di, DEMANGLE_COMPONENT_PACK_EXPANSION, | 3282 return d_make_comp (di, DEMANGLE_COMPONENT_PACK_EXPANSION, |
2736 d_expression (di), NULL); | 3283 d_expression_1 (di), NULL); |
2737 } | 3284 } |
2738 else if (peek == 'f' && d_peek_next_char (di) == 'p') | 3285 else if (peek == 'f' && d_peek_next_char (di) == 'p') |
2739 { | 3286 { |
2740 /* Function parameter used in a late-specified return type. */ | 3287 /* Function parameter used in a late-specified return type. */ |
2741 int index; | 3288 int index; |
2742 d_advance (di, 2); | 3289 d_advance (di, 2); |
2743 index = d_compact_number (di); | 3290 if (d_peek_char (di) == 'T') |
2744 if (index < 0) | 3291 { |
2745 return NULL; | 3292 /* 'this' parameter. */ |
2746 | 3293 d_advance (di, 1); |
3294 index = 0; | |
3295 } | |
3296 else | |
3297 { | |
3298 index = d_compact_number (di); | |
3299 if (index == INT_MAX || index == -1) | |
3300 return NULL; | |
3301 index++; | |
3302 } | |
2747 return d_make_function_param (di, index); | 3303 return d_make_function_param (di, index); |
2748 } | 3304 } |
2749 else if (IS_DIGIT (peek) | 3305 else if (IS_DIGIT (peek) |
2750 || (peek == 'o' && d_peek_next_char (di) == 'n')) | 3306 || (peek == 'o' && d_peek_next_char (di) == 'n')) |
2751 { | 3307 { |
2764 return d_make_comp (di, DEMANGLE_COMPONENT_TEMPLATE, name, | 3320 return d_make_comp (di, DEMANGLE_COMPONENT_TEMPLATE, name, |
2765 d_template_args (di)); | 3321 d_template_args (di)); |
2766 else | 3322 else |
2767 return name; | 3323 return name; |
2768 } | 3324 } |
3325 else if ((peek == 'i' || peek == 't') | |
3326 && d_peek_next_char (di) == 'l') | |
3327 { | |
3328 /* Brace-enclosed initializer list, untyped or typed. */ | |
3329 struct demangle_component *type = NULL; | |
3330 if (peek == 't') | |
3331 type = cplus_demangle_type (di); | |
3332 if (!d_peek_next_char (di)) | |
3333 return NULL; | |
3334 d_advance (di, 2); | |
3335 return d_make_comp (di, DEMANGLE_COMPONENT_INITIALIZER_LIST, | |
3336 type, d_exprlist (di, 'E')); | |
3337 } | |
2769 else | 3338 else |
2770 { | 3339 { |
2771 struct demangle_component *op; | 3340 struct demangle_component *op; |
3341 const char *code = NULL; | |
2772 int args; | 3342 int args; |
2773 | 3343 |
2774 op = d_operator_name (di); | 3344 op = d_operator_name (di); |
2775 if (op == NULL) | 3345 if (op == NULL) |
2776 return NULL; | 3346 return NULL; |
2777 | 3347 |
2778 if (op->type == DEMANGLE_COMPONENT_OPERATOR) | 3348 if (op->type == DEMANGLE_COMPONENT_OPERATOR) |
2779 di->expansion += op->u.s_operator.op->len - 2; | 3349 { |
2780 | 3350 code = op->u.s_operator.op->code; |
2781 if (op->type == DEMANGLE_COMPONENT_OPERATOR | 3351 di->expansion += op->u.s_operator.op->len - 2; |
2782 && strcmp (op->u.s_operator.op->code, "st") == 0) | 3352 if (strcmp (code, "st") == 0) |
2783 return d_make_comp (di, DEMANGLE_COMPONENT_UNARY, op, | 3353 return d_make_comp (di, DEMANGLE_COMPONENT_UNARY, op, |
2784 cplus_demangle_type (di)); | 3354 cplus_demangle_type (di)); |
3355 } | |
2785 | 3356 |
2786 switch (op->type) | 3357 switch (op->type) |
2787 { | 3358 { |
2788 default: | 3359 default: |
2789 return NULL; | 3360 return NULL; |
2798 break; | 3369 break; |
2799 } | 3370 } |
2800 | 3371 |
2801 switch (args) | 3372 switch (args) |
2802 { | 3373 { |
3374 case 0: | |
3375 return d_make_comp (di, DEMANGLE_COMPONENT_NULLARY, op, NULL); | |
3376 | |
2803 case 1: | 3377 case 1: |
2804 { | 3378 { |
2805 struct demangle_component *operand; | 3379 struct demangle_component *operand; |
3380 int suffix = 0; | |
3381 | |
3382 if (code && (code[0] == 'p' || code[0] == 'm') | |
3383 && code[1] == code[0]) | |
3384 /* pp_ and mm_ are the prefix variants. */ | |
3385 suffix = !d_check_char (di, '_'); | |
3386 | |
2806 if (op->type == DEMANGLE_COMPONENT_CAST | 3387 if (op->type == DEMANGLE_COMPONENT_CAST |
2807 && d_check_char (di, '_')) | 3388 && d_check_char (di, '_')) |
2808 operand = d_exprlist (di); | 3389 operand = d_exprlist (di, 'E'); |
3390 else if (code && !strcmp (code, "sP")) | |
3391 operand = d_template_args_1 (di); | |
2809 else | 3392 else |
2810 operand = d_expression (di); | 3393 operand = d_expression_1 (di); |
2811 return d_make_comp (di, DEMANGLE_COMPONENT_UNARY, op, | 3394 |
2812 operand); | 3395 if (suffix) |
3396 /* Indicate the suffix variant for d_print_comp. */ | |
3397 operand = d_make_comp (di, DEMANGLE_COMPONENT_BINARY_ARGS, | |
3398 operand, operand); | |
3399 | |
3400 return d_make_comp (di, DEMANGLE_COMPONENT_UNARY, op, operand); | |
2813 } | 3401 } |
2814 case 2: | 3402 case 2: |
2815 { | 3403 { |
2816 struct demangle_component *left; | 3404 struct demangle_component *left; |
2817 struct demangle_component *right; | 3405 struct demangle_component *right; |
2818 const char *code = op->u.s_operator.op->code; | 3406 |
2819 | 3407 if (code == NULL) |
2820 left = d_expression (di); | 3408 return NULL; |
3409 if (op_is_new_cast (op)) | |
3410 left = cplus_demangle_type (di); | |
3411 else if (code[0] == 'f') | |
3412 /* fold-expression. */ | |
3413 left = d_operator_name (di); | |
3414 else | |
3415 left = d_expression_1 (di); | |
2821 if (!strcmp (code, "cl")) | 3416 if (!strcmp (code, "cl")) |
2822 right = d_exprlist (di); | 3417 right = d_exprlist (di, 'E'); |
2823 else if (!strcmp (code, "dt") || !strcmp (code, "pt")) | 3418 else if (!strcmp (code, "dt") || !strcmp (code, "pt")) |
2824 { | 3419 { |
2825 right = d_unqualified_name (di); | 3420 right = d_unqualified_name (di); |
2826 if (d_peek_char (di) == 'I') | 3421 if (d_peek_char (di) == 'I') |
2827 right = d_make_comp (di, DEMANGLE_COMPONENT_TEMPLATE, | 3422 right = d_make_comp (di, DEMANGLE_COMPONENT_TEMPLATE, |
2828 right, d_template_args (di)); | 3423 right, d_template_args (di)); |
2829 } | 3424 } |
2830 else | 3425 else |
2831 right = d_expression (di); | 3426 right = d_expression_1 (di); |
2832 | 3427 |
2833 return d_make_comp (di, DEMANGLE_COMPONENT_BINARY, op, | 3428 return d_make_comp (di, DEMANGLE_COMPONENT_BINARY, op, |
2834 d_make_comp (di, | 3429 d_make_comp (di, |
2835 DEMANGLE_COMPONENT_BINARY_ARGS, | 3430 DEMANGLE_COMPONENT_BINARY_ARGS, |
2836 left, right)); | 3431 left, right)); |
2837 } | 3432 } |
2838 case 3: | 3433 case 3: |
2839 { | 3434 { |
2840 struct demangle_component *first; | 3435 struct demangle_component *first; |
2841 struct demangle_component *second; | 3436 struct demangle_component *second; |
2842 | 3437 struct demangle_component *third; |
2843 first = d_expression (di); | 3438 |
2844 second = d_expression (di); | 3439 if (code == NULL) |
3440 return NULL; | |
3441 else if (!strcmp (code, "qu")) | |
3442 { | |
3443 /* ?: expression. */ | |
3444 first = d_expression_1 (di); | |
3445 second = d_expression_1 (di); | |
3446 third = d_expression_1 (di); | |
3447 if (third == NULL) | |
3448 return NULL; | |
3449 } | |
3450 else if (code[0] == 'f') | |
3451 { | |
3452 /* fold-expression. */ | |
3453 first = d_operator_name (di); | |
3454 second = d_expression_1 (di); | |
3455 third = d_expression_1 (di); | |
3456 if (third == NULL) | |
3457 return NULL; | |
3458 } | |
3459 else if (code[0] == 'n') | |
3460 { | |
3461 /* new-expression. */ | |
3462 if (code[1] != 'w' && code[1] != 'a') | |
3463 return NULL; | |
3464 first = d_exprlist (di, '_'); | |
3465 second = cplus_demangle_type (di); | |
3466 if (d_peek_char (di) == 'E') | |
3467 { | |
3468 d_advance (di, 1); | |
3469 third = NULL; | |
3470 } | |
3471 else if (d_peek_char (di) == 'p' | |
3472 && d_peek_next_char (di) == 'i') | |
3473 { | |
3474 /* Parenthesized initializer. */ | |
3475 d_advance (di, 2); | |
3476 third = d_exprlist (di, 'E'); | |
3477 } | |
3478 else if (d_peek_char (di) == 'i' | |
3479 && d_peek_next_char (di) == 'l') | |
3480 /* initializer-list. */ | |
3481 third = d_expression_1 (di); | |
3482 else | |
3483 return NULL; | |
3484 } | |
3485 else | |
3486 return NULL; | |
2845 return d_make_comp (di, DEMANGLE_COMPONENT_TRINARY, op, | 3487 return d_make_comp (di, DEMANGLE_COMPONENT_TRINARY, op, |
2846 d_make_comp (di, | 3488 d_make_comp (di, |
2847 DEMANGLE_COMPONENT_TRINARY_ARG1, | 3489 DEMANGLE_COMPONENT_TRINARY_ARG1, |
2848 first, | 3490 first, |
2849 d_make_comp (di, | 3491 d_make_comp (di, |
2850 DEMANGLE_COMPONENT_TRINARY_ARG2, | 3492 DEMANGLE_COMPONENT_TRINARY_ARG2, |
2851 second, | 3493 second, third))); |
2852 d_expression (di)))); | |
2853 } | 3494 } |
2854 default: | 3495 default: |
2855 return NULL; | 3496 return NULL; |
2856 } | 3497 } |
2857 } | 3498 } |
3499 } | |
3500 | |
3501 static struct demangle_component * | |
3502 d_expression (struct d_info *di) | |
3503 { | |
3504 struct demangle_component *ret; | |
3505 int was_expression = di->is_expression; | |
3506 | |
3507 di->is_expression = 1; | |
3508 ret = d_expression_1 (di); | |
3509 di->is_expression = was_expression; | |
3510 return ret; | |
2858 } | 3511 } |
2859 | 3512 |
2860 /* <expr-primary> ::= L <type> <(value) number> E | 3513 /* <expr-primary> ::= L <type> <(value) number> E |
2861 ::= L <type> <(value) float> E | 3514 ::= L <type> <(value) float> E |
2862 ::= L <mangled-name> E | 3515 ::= L <mangled-name> E |
2920 return ret; | 3573 return ret; |
2921 } | 3574 } |
2922 | 3575 |
2923 /* <local-name> ::= Z <(function) encoding> E <(entity) name> [<discriminator>] | 3576 /* <local-name> ::= Z <(function) encoding> E <(entity) name> [<discriminator>] |
2924 ::= Z <(function) encoding> E s [<discriminator>] | 3577 ::= Z <(function) encoding> E s [<discriminator>] |
3578 ::= Z <(function) encoding> E d [<parameter> number>] _ <entity name> | |
2925 */ | 3579 */ |
2926 | 3580 |
2927 static struct demangle_component * | 3581 static struct demangle_component * |
2928 d_local_name (struct d_info *di) | 3582 d_local_name (struct d_info *di) |
2929 { | 3583 { |
2930 struct demangle_component *function; | 3584 struct demangle_component *function; |
3585 struct demangle_component *name; | |
2931 | 3586 |
2932 if (! d_check_char (di, 'Z')) | 3587 if (! d_check_char (di, 'Z')) |
2933 return NULL; | 3588 return NULL; |
2934 | 3589 |
2935 function = d_encoding (di, 0); | 3590 function = d_encoding (di, 0); |
3591 if (!function) | |
3592 return NULL; | |
2936 | 3593 |
2937 if (! d_check_char (di, 'E')) | 3594 if (! d_check_char (di, 'E')) |
2938 return NULL; | 3595 return NULL; |
2939 | 3596 |
2940 if (d_peek_char (di) == 's') | 3597 if (d_peek_char (di) == 's') |
2941 { | 3598 { |
2942 d_advance (di, 1); | 3599 d_advance (di, 1); |
2943 if (! d_discriminator (di)) | 3600 if (! d_discriminator (di)) |
2944 return NULL; | 3601 return NULL; |
2945 return d_make_comp (di, DEMANGLE_COMPONENT_LOCAL_NAME, function, | 3602 name = d_make_name (di, "string literal", sizeof "string literal" - 1); |
2946 d_make_name (di, "string literal", | |
2947 sizeof "string literal" - 1)); | |
2948 } | 3603 } |
2949 else | 3604 else |
2950 { | 3605 { |
2951 struct demangle_component *name; | |
2952 int num = -1; | 3606 int num = -1; |
2953 | 3607 |
2954 if (d_peek_char (di) == 'd') | 3608 if (d_peek_char (di) == 'd') |
2955 { | 3609 { |
2956 /* Default argument scope: d <number> _. */ | 3610 /* Default argument scope: d <number> _. */ |
2959 if (num < 0) | 3613 if (num < 0) |
2960 return NULL; | 3614 return NULL; |
2961 } | 3615 } |
2962 | 3616 |
2963 name = d_name (di); | 3617 name = d_name (di); |
2964 if (name) | 3618 |
2965 switch (name->type) | 3619 if (name |
2966 { | 3620 /* Lambdas and unnamed types have internal discriminators |
2967 /* Lambdas and unnamed types have internal discriminators. */ | 3621 and are not functions. */ |
2968 case DEMANGLE_COMPONENT_LAMBDA: | 3622 && name->type != DEMANGLE_COMPONENT_LAMBDA |
2969 case DEMANGLE_COMPONENT_UNNAMED_TYPE: | 3623 && name->type != DEMANGLE_COMPONENT_UNNAMED_TYPE) |
2970 break; | 3624 { |
2971 default: | 3625 /* Read and ignore an optional discriminator. */ |
2972 if (! d_discriminator (di)) | 3626 if (! d_discriminator (di)) |
2973 return NULL; | 3627 return NULL; |
2974 } | 3628 } |
3629 | |
2975 if (num >= 0) | 3630 if (num >= 0) |
2976 name = d_make_default_arg (di, num, name); | 3631 name = d_make_default_arg (di, num, name); |
2977 return d_make_comp (di, DEMANGLE_COMPONENT_LOCAL_NAME, function, name); | 3632 } |
2978 } | 3633 |
2979 } | 3634 /* Elide the return type of the containing function so as to not |
2980 | 3635 confuse the user thinking it is the return type of whatever local |
2981 /* <discriminator> ::= _ <(non-negative) number> | 3636 function we might be containing. */ |
3637 if (function->type == DEMANGLE_COMPONENT_TYPED_NAME | |
3638 && d_right (function)->type == DEMANGLE_COMPONENT_FUNCTION_TYPE) | |
3639 d_left (d_right (function)) = NULL; | |
3640 | |
3641 return d_make_comp (di, DEMANGLE_COMPONENT_LOCAL_NAME, function, name); | |
3642 } | |
3643 | |
3644 /* <discriminator> ::= _ <number> # when number < 10 | |
3645 ::= __ <number> _ # when number >= 10 | |
3646 | |
3647 <discriminator> ::= _ <number> # when number >=10 | |
3648 is also accepted to support gcc versions that wrongly mangled that way. | |
2982 | 3649 |
2983 We demangle the discriminator, but we don't print it out. FIXME: | 3650 We demangle the discriminator, but we don't print it out. FIXME: |
2984 We should print it out in verbose mode. */ | 3651 We should print it out in verbose mode. */ |
2985 | 3652 |
2986 static int | 3653 static int |
2987 d_discriminator (struct d_info *di) | 3654 d_discriminator (struct d_info *di) |
2988 { | 3655 { |
2989 long discrim; | 3656 int discrim, num_underscores = 1; |
2990 | 3657 |
2991 if (d_peek_char (di) != '_') | 3658 if (d_peek_char (di) != '_') |
2992 return 1; | 3659 return 1; |
2993 d_advance (di, 1); | 3660 d_advance (di, 1); |
3661 if (d_peek_char (di) == '_') | |
3662 { | |
3663 ++num_underscores; | |
3664 d_advance (di, 1); | |
3665 } | |
3666 | |
2994 discrim = d_number (di); | 3667 discrim = d_number (di); |
2995 if (discrim < 0) | 3668 if (discrim < 0) |
2996 return 0; | 3669 return 0; |
3670 if (num_underscores > 1 && discrim >= 10) | |
3671 { | |
3672 if (d_peek_char (di) == '_') | |
3673 d_advance (di, 1); | |
3674 else | |
3675 return 0; | |
3676 } | |
3677 | |
2997 return 1; | 3678 return 1; |
2998 } | 3679 } |
2999 | 3680 |
3000 /* <closure-type-name> ::= Ul <lambda-sig> E [ <nonnegative number> ] _ */ | 3681 /* <closure-type-name> ::= Ul <lambda-sig> E [ <nonnegative number> ] _ */ |
3001 | 3682 |
3040 | 3721 |
3041 static struct demangle_component * | 3722 static struct demangle_component * |
3042 d_unnamed_type (struct d_info *di) | 3723 d_unnamed_type (struct d_info *di) |
3043 { | 3724 { |
3044 struct demangle_component *ret; | 3725 struct demangle_component *ret; |
3045 long num; | 3726 int num; |
3046 | 3727 |
3047 if (! d_check_char (di, 'U')) | 3728 if (! d_check_char (di, 'U')) |
3048 return NULL; | 3729 return NULL; |
3049 if (! d_check_char (di, 't')) | 3730 if (! d_check_char (di, 't')) |
3050 return NULL; | 3731 return NULL; |
3062 | 3743 |
3063 if (! d_add_substitution (di, ret)) | 3744 if (! d_add_substitution (di, ret)) |
3064 return NULL; | 3745 return NULL; |
3065 | 3746 |
3066 return ret; | 3747 return ret; |
3748 } | |
3749 | |
3750 /* <clone-suffix> ::= [ . <clone-type-identifier> ] [ . <nonnegative number> ]* | |
3751 */ | |
3752 | |
3753 static struct demangle_component * | |
3754 d_clone_suffix (struct d_info *di, struct demangle_component *encoding) | |
3755 { | |
3756 const char *suffix = d_str (di); | |
3757 const char *pend = suffix; | |
3758 struct demangle_component *n; | |
3759 | |
3760 if (*pend == '.' && (IS_LOWER (pend[1]) || pend[1] == '_')) | |
3761 { | |
3762 pend += 2; | |
3763 while (IS_LOWER (*pend) || *pend == '_') | |
3764 ++pend; | |
3765 } | |
3766 while (*pend == '.' && IS_DIGIT (pend[1])) | |
3767 { | |
3768 pend += 2; | |
3769 while (IS_DIGIT (*pend)) | |
3770 ++pend; | |
3771 } | |
3772 d_advance (di, pend - suffix); | |
3773 n = d_make_name (di, suffix, pend - suffix); | |
3774 return d_make_comp (di, DEMANGLE_COMPONENT_CLONE, encoding, n); | |
3067 } | 3775 } |
3068 | 3776 |
3069 /* Add a new substitution. */ | 3777 /* Add a new substitution. */ |
3070 | 3778 |
3071 static int | 3779 static int |
3161 } | 3869 } |
3162 | 3870 |
3163 if (id >= (unsigned int) di->next_sub) | 3871 if (id >= (unsigned int) di->next_sub) |
3164 return NULL; | 3872 return NULL; |
3165 | 3873 |
3166 ++di->did_subs; | |
3167 | |
3168 return di->subs[id]; | 3874 return di->subs[id]; |
3169 } | 3875 } |
3170 else | 3876 else |
3171 { | 3877 { |
3172 int verbose; | 3878 int verbose; |
3189 { | 3895 { |
3190 if (c == p->code) | 3896 if (c == p->code) |
3191 { | 3897 { |
3192 const char *s; | 3898 const char *s; |
3193 int len; | 3899 int len; |
3900 struct demangle_component *dc; | |
3194 | 3901 |
3195 if (p->set_last_name != NULL) | 3902 if (p->set_last_name != NULL) |
3196 di->last_name = d_make_sub (di, p->set_last_name, | 3903 di->last_name = d_make_sub (di, p->set_last_name, |
3197 p->set_last_name_len); | 3904 p->set_last_name_len); |
3198 if (verbose) | 3905 if (verbose) |
3204 { | 3911 { |
3205 s = p->simple_expansion; | 3912 s = p->simple_expansion; |
3206 len = p->simple_len; | 3913 len = p->simple_len; |
3207 } | 3914 } |
3208 di->expansion += len; | 3915 di->expansion += len; |
3209 return d_make_sub (di, s, len); | 3916 dc = d_make_sub (di, s, len); |
3917 if (d_peek_char (di) == 'B') | |
3918 { | |
3919 /* If there are ABI tags on the abbreviation, it becomes | |
3920 a substitution candidate. */ | |
3921 dc = d_abi_tags (di, dc); | |
3922 if (! d_add_substitution (di, dc)) | |
3923 return NULL; | |
3924 } | |
3925 return dc; | |
3210 } | 3926 } |
3211 } | 3927 } |
3212 | 3928 |
3213 return NULL; | 3929 return NULL; |
3214 } | 3930 } |
3931 } | |
3932 | |
3933 static void | |
3934 d_checkpoint (struct d_info *di, struct d_info_checkpoint *checkpoint) | |
3935 { | |
3936 checkpoint->n = di->n; | |
3937 checkpoint->next_comp = di->next_comp; | |
3938 checkpoint->next_sub = di->next_sub; | |
3939 checkpoint->expansion = di->expansion; | |
3940 } | |
3941 | |
3942 static void | |
3943 d_backtrack (struct d_info *di, struct d_info_checkpoint *checkpoint) | |
3944 { | |
3945 di->n = checkpoint->n; | |
3946 di->next_comp = checkpoint->next_comp; | |
3947 di->next_sub = checkpoint->next_sub; | |
3948 di->expansion = checkpoint->expansion; | |
3215 } | 3949 } |
3216 | 3950 |
3217 /* Initialize a growable string. */ | 3951 /* Initialize a growable string. */ |
3218 | 3952 |
3219 static void | 3953 static void |
3288 struct d_growable_string *dgs = (struct d_growable_string*) opaque; | 4022 struct d_growable_string *dgs = (struct d_growable_string*) opaque; |
3289 | 4023 |
3290 d_growable_string_append_buffer (dgs, s, l); | 4024 d_growable_string_append_buffer (dgs, s, l); |
3291 } | 4025 } |
3292 | 4026 |
4027 /* Walk the tree, counting the number of templates encountered, and | |
4028 the number of times a scope might be saved. These counts will be | |
4029 used to allocate data structures for d_print_comp, so the logic | |
4030 here must mirror the logic d_print_comp will use. It is not | |
4031 important that the resulting numbers are exact, so long as they | |
4032 are larger than the actual numbers encountered. */ | |
4033 | |
4034 static void | |
4035 d_count_templates_scopes (int *num_templates, int *num_scopes, | |
4036 const struct demangle_component *dc) | |
4037 { | |
4038 if (dc == NULL) | |
4039 return; | |
4040 | |
4041 switch (dc->type) | |
4042 { | |
4043 case DEMANGLE_COMPONENT_NAME: | |
4044 case DEMANGLE_COMPONENT_TEMPLATE_PARAM: | |
4045 case DEMANGLE_COMPONENT_FUNCTION_PARAM: | |
4046 case DEMANGLE_COMPONENT_SUB_STD: | |
4047 case DEMANGLE_COMPONENT_BUILTIN_TYPE: | |
4048 case DEMANGLE_COMPONENT_OPERATOR: | |
4049 case DEMANGLE_COMPONENT_CHARACTER: | |
4050 case DEMANGLE_COMPONENT_NUMBER: | |
4051 case DEMANGLE_COMPONENT_UNNAMED_TYPE: | |
4052 break; | |
4053 | |
4054 case DEMANGLE_COMPONENT_TEMPLATE: | |
4055 (*num_templates)++; | |
4056 goto recurse_left_right; | |
4057 | |
4058 case DEMANGLE_COMPONENT_REFERENCE: | |
4059 case DEMANGLE_COMPONENT_RVALUE_REFERENCE: | |
4060 if (d_left (dc)->type == DEMANGLE_COMPONENT_TEMPLATE_PARAM) | |
4061 (*num_scopes)++; | |
4062 goto recurse_left_right; | |
4063 | |
4064 case DEMANGLE_COMPONENT_QUAL_NAME: | |
4065 case DEMANGLE_COMPONENT_LOCAL_NAME: | |
4066 case DEMANGLE_COMPONENT_TYPED_NAME: | |
4067 case DEMANGLE_COMPONENT_VTABLE: | |
4068 case DEMANGLE_COMPONENT_VTT: | |
4069 case DEMANGLE_COMPONENT_CONSTRUCTION_VTABLE: | |
4070 case DEMANGLE_COMPONENT_TYPEINFO: | |
4071 case DEMANGLE_COMPONENT_TYPEINFO_NAME: | |
4072 case DEMANGLE_COMPONENT_TYPEINFO_FN: | |
4073 case DEMANGLE_COMPONENT_THUNK: | |
4074 case DEMANGLE_COMPONENT_VIRTUAL_THUNK: | |
4075 case DEMANGLE_COMPONENT_COVARIANT_THUNK: | |
4076 case DEMANGLE_COMPONENT_JAVA_CLASS: | |
4077 case DEMANGLE_COMPONENT_GUARD: | |
4078 case DEMANGLE_COMPONENT_TLS_INIT: | |
4079 case DEMANGLE_COMPONENT_TLS_WRAPPER: | |
4080 case DEMANGLE_COMPONENT_REFTEMP: | |
4081 case DEMANGLE_COMPONENT_HIDDEN_ALIAS: | |
4082 case DEMANGLE_COMPONENT_RESTRICT: | |
4083 case DEMANGLE_COMPONENT_VOLATILE: | |
4084 case DEMANGLE_COMPONENT_CONST: | |
4085 case DEMANGLE_COMPONENT_RESTRICT_THIS: | |
4086 case DEMANGLE_COMPONENT_VOLATILE_THIS: | |
4087 case DEMANGLE_COMPONENT_CONST_THIS: | |
4088 case DEMANGLE_COMPONENT_REFERENCE_THIS: | |
4089 case DEMANGLE_COMPONENT_RVALUE_REFERENCE_THIS: | |
4090 case DEMANGLE_COMPONENT_TRANSACTION_SAFE: | |
4091 case DEMANGLE_COMPONENT_NOEXCEPT: | |
4092 case DEMANGLE_COMPONENT_THROW_SPEC: | |
4093 case DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL: | |
4094 case DEMANGLE_COMPONENT_POINTER: | |
4095 case DEMANGLE_COMPONENT_COMPLEX: | |
4096 case DEMANGLE_COMPONENT_IMAGINARY: | |
4097 case DEMANGLE_COMPONENT_VENDOR_TYPE: | |
4098 case DEMANGLE_COMPONENT_FUNCTION_TYPE: | |
4099 case DEMANGLE_COMPONENT_ARRAY_TYPE: | |
4100 case DEMANGLE_COMPONENT_PTRMEM_TYPE: | |
4101 case DEMANGLE_COMPONENT_VECTOR_TYPE: | |
4102 case DEMANGLE_COMPONENT_ARGLIST: | |
4103 case DEMANGLE_COMPONENT_TEMPLATE_ARGLIST: | |
4104 case DEMANGLE_COMPONENT_INITIALIZER_LIST: | |
4105 case DEMANGLE_COMPONENT_CAST: | |
4106 case DEMANGLE_COMPONENT_CONVERSION: | |
4107 case DEMANGLE_COMPONENT_NULLARY: | |
4108 case DEMANGLE_COMPONENT_UNARY: | |
4109 case DEMANGLE_COMPONENT_BINARY: | |
4110 case DEMANGLE_COMPONENT_BINARY_ARGS: | |
4111 case DEMANGLE_COMPONENT_TRINARY: | |
4112 case DEMANGLE_COMPONENT_TRINARY_ARG1: | |
4113 case DEMANGLE_COMPONENT_TRINARY_ARG2: | |
4114 case DEMANGLE_COMPONENT_LITERAL: | |
4115 case DEMANGLE_COMPONENT_LITERAL_NEG: | |
4116 case DEMANGLE_COMPONENT_JAVA_RESOURCE: | |
4117 case DEMANGLE_COMPONENT_COMPOUND_NAME: | |
4118 case DEMANGLE_COMPONENT_DECLTYPE: | |
4119 case DEMANGLE_COMPONENT_TRANSACTION_CLONE: | |
4120 case DEMANGLE_COMPONENT_NONTRANSACTION_CLONE: | |
4121 case DEMANGLE_COMPONENT_PACK_EXPANSION: | |
4122 case DEMANGLE_COMPONENT_TAGGED_NAME: | |
4123 case DEMANGLE_COMPONENT_CLONE: | |
4124 recurse_left_right: | |
4125 d_count_templates_scopes (num_templates, num_scopes, | |
4126 d_left (dc)); | |
4127 d_count_templates_scopes (num_templates, num_scopes, | |
4128 d_right (dc)); | |
4129 break; | |
4130 | |
4131 case DEMANGLE_COMPONENT_CTOR: | |
4132 d_count_templates_scopes (num_templates, num_scopes, | |
4133 dc->u.s_ctor.name); | |
4134 break; | |
4135 | |
4136 case DEMANGLE_COMPONENT_DTOR: | |
4137 d_count_templates_scopes (num_templates, num_scopes, | |
4138 dc->u.s_dtor.name); | |
4139 break; | |
4140 | |
4141 case DEMANGLE_COMPONENT_EXTENDED_OPERATOR: | |
4142 d_count_templates_scopes (num_templates, num_scopes, | |
4143 dc->u.s_extended_operator.name); | |
4144 break; | |
4145 | |
4146 case DEMANGLE_COMPONENT_FIXED_TYPE: | |
4147 d_count_templates_scopes (num_templates, num_scopes, | |
4148 dc->u.s_fixed.length); | |
4149 break; | |
4150 | |
4151 case DEMANGLE_COMPONENT_GLOBAL_CONSTRUCTORS: | |
4152 case DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS: | |
4153 d_count_templates_scopes (num_templates, num_scopes, | |
4154 d_left (dc)); | |
4155 break; | |
4156 | |
4157 case DEMANGLE_COMPONENT_LAMBDA: | |
4158 case DEMANGLE_COMPONENT_DEFAULT_ARG: | |
4159 d_count_templates_scopes (num_templates, num_scopes, | |
4160 dc->u.s_unary_num.sub); | |
4161 break; | |
4162 } | |
4163 } | |
4164 | |
3293 /* Initialize a print information structure. */ | 4165 /* Initialize a print information structure. */ |
3294 | 4166 |
3295 static void | 4167 static void |
3296 d_print_init (struct d_print_info *dpi, int options, | 4168 d_print_init (struct d_print_info *dpi, demangle_callbackref callback, |
3297 demangle_callbackref callback, void *opaque) | 4169 void *opaque, const struct demangle_component *dc) |
3298 { | 4170 { |
3299 dpi->options = options; | |
3300 dpi->len = 0; | 4171 dpi->len = 0; |
3301 dpi->last_char = '\0'; | 4172 dpi->last_char = '\0'; |
3302 dpi->templates = NULL; | 4173 dpi->templates = NULL; |
3303 dpi->modifiers = NULL; | 4174 dpi->modifiers = NULL; |
4175 dpi->pack_index = 0; | |
3304 dpi->flush_count = 0; | 4176 dpi->flush_count = 0; |
3305 | 4177 |
3306 dpi->callback = callback; | 4178 dpi->callback = callback; |
3307 dpi->opaque = opaque; | 4179 dpi->opaque = opaque; |
3308 | 4180 |
3309 dpi->demangle_failure = 0; | 4181 dpi->demangle_failure = 0; |
4182 dpi->recursion = 0; | |
4183 dpi->is_lambda_arg = 0; | |
4184 | |
4185 dpi->component_stack = NULL; | |
4186 | |
4187 dpi->saved_scopes = NULL; | |
4188 dpi->next_saved_scope = 0; | |
4189 dpi->num_saved_scopes = 0; | |
4190 | |
4191 dpi->copy_templates = NULL; | |
4192 dpi->next_copy_template = 0; | |
4193 dpi->num_copy_templates = 0; | |
4194 | |
4195 d_count_templates_scopes (&dpi->num_copy_templates, | |
4196 &dpi->num_saved_scopes, dc); | |
4197 dpi->num_copy_templates *= dpi->num_saved_scopes; | |
4198 | |
4199 dpi->current_template = NULL; | |
3310 } | 4200 } |
3311 | 4201 |
3312 /* Indicate that an error occurred during printing, and test for error. */ | 4202 /* Indicate that an error occurred during printing, and test for error. */ |
3313 | 4203 |
3314 static inline void | 4204 static inline void |
3360 { | 4250 { |
3361 d_append_buffer (dpi, s, strlen (s)); | 4251 d_append_buffer (dpi, s, strlen (s)); |
3362 } | 4252 } |
3363 | 4253 |
3364 static inline void | 4254 static inline void |
3365 d_append_num (struct d_print_info *dpi, long l) | 4255 d_append_num (struct d_print_info *dpi, int l) |
3366 { | 4256 { |
3367 char buf[25]; | 4257 char buf[25]; |
3368 sprintf (buf,"%ld", l); | 4258 sprintf (buf,"%d", l); |
3369 d_append_string (dpi, buf); | 4259 d_append_string (dpi, buf); |
3370 } | 4260 } |
3371 | 4261 |
3372 static inline char | 4262 static inline char |
3373 d_last_char (struct d_print_info *dpi) | 4263 d_last_char (struct d_print_info *dpi) |
3385 allocation failure. */ | 4275 allocation failure. */ |
3386 | 4276 |
3387 CP_STATIC_IF_GLIBCPP_V3 | 4277 CP_STATIC_IF_GLIBCPP_V3 |
3388 int | 4278 int |
3389 cplus_demangle_print_callback (int options, | 4279 cplus_demangle_print_callback (int options, |
3390 const struct demangle_component *dc, | 4280 struct demangle_component *dc, |
3391 demangle_callbackref callback, void *opaque) | 4281 demangle_callbackref callback, void *opaque) |
3392 { | 4282 { |
3393 struct d_print_info dpi; | 4283 struct d_print_info dpi; |
3394 | 4284 |
3395 d_print_init (&dpi, options, callback, opaque); | 4285 d_print_init (&dpi, callback, opaque, dc); |
3396 | 4286 |
3397 d_print_comp (&dpi, dc); | 4287 { |
4288 #ifdef CP_DYNAMIC_ARRAYS | |
4289 /* Avoid zero-length VLAs, which are prohibited by the C99 standard | |
4290 and flagged as errors by Address Sanitizer. */ | |
4291 __extension__ struct d_saved_scope scopes[(dpi.num_saved_scopes > 0) | |
4292 ? dpi.num_saved_scopes : 1]; | |
4293 __extension__ struct d_print_template temps[(dpi.num_copy_templates > 0) | |
4294 ? dpi.num_copy_templates : 1]; | |
4295 | |
4296 dpi.saved_scopes = scopes; | |
4297 dpi.copy_templates = temps; | |
4298 #else | |
4299 dpi.saved_scopes = alloca (dpi.num_saved_scopes | |
4300 * sizeof (*dpi.saved_scopes)); | |
4301 dpi.copy_templates = alloca (dpi.num_copy_templates | |
4302 * sizeof (*dpi.copy_templates)); | |
4303 #endif | |
4304 | |
4305 d_print_comp (&dpi, options, dc); | |
4306 } | |
3398 | 4307 |
3399 d_print_flush (&dpi); | 4308 d_print_flush (&dpi); |
3400 | 4309 |
3401 return ! d_print_saw_error (&dpi); | 4310 return ! d_print_saw_error (&dpi); |
3402 } | 4311 } |
3409 sets *PALC to 0 for a bad parse, or to 1 for a memory allocation | 4318 sets *PALC to 0 for a bad parse, or to 1 for a memory allocation |
3410 failure. */ | 4319 failure. */ |
3411 | 4320 |
3412 CP_STATIC_IF_GLIBCPP_V3 | 4321 CP_STATIC_IF_GLIBCPP_V3 |
3413 char * | 4322 char * |
3414 cplus_demangle_print (int options, const struct demangle_component *dc, | 4323 cplus_demangle_print (int options, struct demangle_component *dc, |
3415 int estimate, size_t *palc) | 4324 int estimate, size_t *palc) |
3416 { | 4325 { |
3417 struct d_growable_string dgs; | 4326 struct d_growable_string dgs; |
3418 | 4327 |
3419 d_growable_string_init (&dgs, estimate); | 4328 d_growable_string_init (&dgs, estimate); |
3430 *palc = dgs.allocation_failure ? 1 : dgs.alc; | 4339 *palc = dgs.allocation_failure ? 1 : dgs.alc; |
3431 return dgs.buf; | 4340 return dgs.buf; |
3432 } | 4341 } |
3433 | 4342 |
3434 /* Returns the I'th element of the template arglist ARGS, or NULL on | 4343 /* Returns the I'th element of the template arglist ARGS, or NULL on |
3435 failure. */ | 4344 failure. If I is negative, return the entire arglist. */ |
3436 | 4345 |
3437 static struct demangle_component * | 4346 static struct demangle_component * |
3438 d_index_template_argument (struct demangle_component *args, int i) | 4347 d_index_template_argument (struct demangle_component *args, int i) |
3439 { | 4348 { |
3440 struct demangle_component *a; | 4349 struct demangle_component *a; |
4350 | |
4351 if (i < 0) | |
4352 /* Print the whole argument pack. */ | |
4353 return args; | |
3441 | 4354 |
3442 for (a = args; | 4355 for (a = args; |
3443 a != NULL; | 4356 a != NULL; |
3444 a = d_right (a)) | 4357 a = d_right (a)) |
3445 { | 4358 { |
3494 case DEMANGLE_COMPONENT_PACK_EXPANSION: | 4407 case DEMANGLE_COMPONENT_PACK_EXPANSION: |
3495 return NULL; | 4408 return NULL; |
3496 | 4409 |
3497 case DEMANGLE_COMPONENT_LAMBDA: | 4410 case DEMANGLE_COMPONENT_LAMBDA: |
3498 case DEMANGLE_COMPONENT_NAME: | 4411 case DEMANGLE_COMPONENT_NAME: |
4412 case DEMANGLE_COMPONENT_TAGGED_NAME: | |
3499 case DEMANGLE_COMPONENT_OPERATOR: | 4413 case DEMANGLE_COMPONENT_OPERATOR: |
3500 case DEMANGLE_COMPONENT_BUILTIN_TYPE: | 4414 case DEMANGLE_COMPONENT_BUILTIN_TYPE: |
3501 case DEMANGLE_COMPONENT_SUB_STD: | 4415 case DEMANGLE_COMPONENT_SUB_STD: |
3502 case DEMANGLE_COMPONENT_CHARACTER: | 4416 case DEMANGLE_COMPONENT_CHARACTER: |
3503 case DEMANGLE_COMPONENT_FUNCTION_PARAM: | 4417 case DEMANGLE_COMPONENT_FUNCTION_PARAM: |
4418 case DEMANGLE_COMPONENT_UNNAMED_TYPE: | |
4419 case DEMANGLE_COMPONENT_FIXED_TYPE: | |
4420 case DEMANGLE_COMPONENT_DEFAULT_ARG: | |
4421 case DEMANGLE_COMPONENT_NUMBER: | |
3504 return NULL; | 4422 return NULL; |
3505 | 4423 |
3506 case DEMANGLE_COMPONENT_EXTENDED_OPERATOR: | 4424 case DEMANGLE_COMPONENT_EXTENDED_OPERATOR: |
3507 return d_find_pack (dpi, dc->u.s_extended_operator.name); | 4425 return d_find_pack (dpi, dc->u.s_extended_operator.name); |
3508 case DEMANGLE_COMPONENT_CTOR: | 4426 case DEMANGLE_COMPONENT_CTOR: |
3531 dc = d_right (dc); | 4449 dc = d_right (dc); |
3532 } | 4450 } |
3533 return count; | 4451 return count; |
3534 } | 4452 } |
3535 | 4453 |
4454 /* Returns the number of template args in DC, expanding any pack expansions | |
4455 found there. */ | |
4456 | |
4457 static int | |
4458 d_args_length (struct d_print_info *dpi, const struct demangle_component *dc) | |
4459 { | |
4460 int count = 0; | |
4461 for (; dc && dc->type == DEMANGLE_COMPONENT_TEMPLATE_ARGLIST; | |
4462 dc = d_right (dc)) | |
4463 { | |
4464 struct demangle_component *elt = d_left (dc); | |
4465 if (elt == NULL) | |
4466 break; | |
4467 if (elt->type == DEMANGLE_COMPONENT_PACK_EXPANSION) | |
4468 { | |
4469 struct demangle_component *a = d_find_pack (dpi, d_left (elt)); | |
4470 count += d_pack_length (a); | |
4471 } | |
4472 else | |
4473 ++count; | |
4474 } | |
4475 return count; | |
4476 } | |
4477 | |
3536 /* DC is a component of a mangled expression. Print it, wrapped in parens | 4478 /* DC is a component of a mangled expression. Print it, wrapped in parens |
3537 if needed. */ | 4479 if needed. */ |
3538 | 4480 |
3539 static void | 4481 static void |
3540 d_print_subexpr (struct d_print_info *dpi, | 4482 d_print_subexpr (struct d_print_info *dpi, int options, |
3541 const struct demangle_component *dc) | 4483 struct demangle_component *dc) |
3542 { | 4484 { |
3543 int simple = 0; | 4485 int simple = 0; |
3544 if (dc->type == DEMANGLE_COMPONENT_NAME | 4486 if (dc->type == DEMANGLE_COMPONENT_NAME |
4487 || dc->type == DEMANGLE_COMPONENT_QUAL_NAME | |
4488 || dc->type == DEMANGLE_COMPONENT_INITIALIZER_LIST | |
3545 || dc->type == DEMANGLE_COMPONENT_FUNCTION_PARAM) | 4489 || dc->type == DEMANGLE_COMPONENT_FUNCTION_PARAM) |
3546 simple = 1; | 4490 simple = 1; |
3547 if (!simple) | 4491 if (!simple) |
3548 d_append_char (dpi, '('); | 4492 d_append_char (dpi, '('); |
3549 d_print_comp (dpi, dc); | 4493 d_print_comp (dpi, options, dc); |
3550 if (!simple) | 4494 if (!simple) |
3551 d_append_char (dpi, ')'); | 4495 d_append_char (dpi, ')'); |
3552 } | 4496 } |
3553 | 4497 |
4498 /* Save the current scope. */ | |
4499 | |
4500 static void | |
4501 d_save_scope (struct d_print_info *dpi, | |
4502 const struct demangle_component *container) | |
4503 { | |
4504 struct d_saved_scope *scope; | |
4505 struct d_print_template *src, **link; | |
4506 | |
4507 if (dpi->next_saved_scope >= dpi->num_saved_scopes) | |
4508 { | |
4509 d_print_error (dpi); | |
4510 return; | |
4511 } | |
4512 scope = &dpi->saved_scopes[dpi->next_saved_scope]; | |
4513 dpi->next_saved_scope++; | |
4514 | |
4515 scope->container = container; | |
4516 link = &scope->templates; | |
4517 | |
4518 for (src = dpi->templates; src != NULL; src = src->next) | |
4519 { | |
4520 struct d_print_template *dst; | |
4521 | |
4522 if (dpi->next_copy_template >= dpi->num_copy_templates) | |
4523 { | |
4524 d_print_error (dpi); | |
4525 return; | |
4526 } | |
4527 dst = &dpi->copy_templates[dpi->next_copy_template]; | |
4528 dpi->next_copy_template++; | |
4529 | |
4530 dst->template_decl = src->template_decl; | |
4531 *link = dst; | |
4532 link = &dst->next; | |
4533 } | |
4534 | |
4535 *link = NULL; | |
4536 } | |
4537 | |
4538 /* Attempt to locate a previously saved scope. Returns NULL if no | |
4539 corresponding saved scope was found. */ | |
4540 | |
4541 static struct d_saved_scope * | |
4542 d_get_saved_scope (struct d_print_info *dpi, | |
4543 const struct demangle_component *container) | |
4544 { | |
4545 int i; | |
4546 | |
4547 for (i = 0; i < dpi->next_saved_scope; i++) | |
4548 if (dpi->saved_scopes[i].container == container) | |
4549 return &dpi->saved_scopes[i]; | |
4550 | |
4551 return NULL; | |
4552 } | |
4553 | |
4554 /* If DC is a C++17 fold-expression, print it and return true; otherwise | |
4555 return false. */ | |
4556 | |
4557 static int | |
4558 d_maybe_print_fold_expression (struct d_print_info *dpi, int options, | |
4559 struct demangle_component *dc) | |
4560 { | |
4561 struct demangle_component *ops, *operator_, *op1, *op2; | |
4562 int save_idx; | |
4563 | |
4564 const char *fold_code = d_left (dc)->u.s_operator.op->code; | |
4565 if (fold_code[0] != 'f') | |
4566 return 0; | |
4567 | |
4568 ops = d_right (dc); | |
4569 operator_ = d_left (ops); | |
4570 op1 = d_right (ops); | |
4571 op2 = 0; | |
4572 if (op1->type == DEMANGLE_COMPONENT_TRINARY_ARG2) | |
4573 { | |
4574 op2 = d_right (op1); | |
4575 op1 = d_left (op1); | |
4576 } | |
4577 | |
4578 /* Print the whole pack. */ | |
4579 save_idx = dpi->pack_index; | |
4580 dpi->pack_index = -1; | |
4581 | |
4582 switch (fold_code[1]) | |
4583 { | |
4584 /* Unary left fold, (... + X). */ | |
4585 case 'l': | |
4586 d_append_string (dpi, "(..."); | |
4587 d_print_expr_op (dpi, options, operator_); | |
4588 d_print_subexpr (dpi, options, op1); | |
4589 d_append_char (dpi, ')'); | |
4590 break; | |
4591 | |
4592 /* Unary right fold, (X + ...). */ | |
4593 case 'r': | |
4594 d_append_char (dpi, '('); | |
4595 d_print_subexpr (dpi, options, op1); | |
4596 d_print_expr_op (dpi, options, operator_); | |
4597 d_append_string (dpi, "...)"); | |
4598 break; | |
4599 | |
4600 /* Binary left fold, (42 + ... + X). */ | |
4601 case 'L': | |
4602 /* Binary right fold, (X + ... + 42). */ | |
4603 case 'R': | |
4604 d_append_char (dpi, '('); | |
4605 d_print_subexpr (dpi, options, op1); | |
4606 d_print_expr_op (dpi, options, operator_); | |
4607 d_append_string (dpi, "..."); | |
4608 d_print_expr_op (dpi, options, operator_); | |
4609 d_print_subexpr (dpi, options, op2); | |
4610 d_append_char (dpi, ')'); | |
4611 break; | |
4612 } | |
4613 | |
4614 dpi->pack_index = save_idx; | |
4615 return 1; | |
4616 } | |
4617 | |
3554 /* Subroutine to handle components. */ | 4618 /* Subroutine to handle components. */ |
3555 | 4619 |
3556 static void | 4620 static void |
3557 d_print_comp (struct d_print_info *dpi, | 4621 d_print_comp_inner (struct d_print_info *dpi, int options, |
3558 const struct demangle_component *dc) | 4622 struct demangle_component *dc) |
3559 { | 4623 { |
4624 /* Magic variable to let reference smashing skip over the next modifier | |
4625 without needing to modify *dc. */ | |
4626 struct demangle_component *mod_inner = NULL; | |
4627 | |
4628 /* Variable used to store the current templates while a previously | |
4629 captured scope is used. */ | |
4630 struct d_print_template *saved_templates; | |
4631 | |
4632 /* Nonzero if templates have been stored in the above variable. */ | |
4633 int need_template_restore = 0; | |
4634 | |
3560 if (dc == NULL) | 4635 if (dc == NULL) |
3561 { | 4636 { |
3562 d_print_error (dpi); | 4637 d_print_error (dpi); |
3563 return; | 4638 return; |
3564 } | 4639 } |
3566 return; | 4641 return; |
3567 | 4642 |
3568 switch (dc->type) | 4643 switch (dc->type) |
3569 { | 4644 { |
3570 case DEMANGLE_COMPONENT_NAME: | 4645 case DEMANGLE_COMPONENT_NAME: |
3571 if ((dpi->options & DMGL_JAVA) == 0) | 4646 if ((options & DMGL_JAVA) == 0) |
3572 d_append_buffer (dpi, dc->u.s_name.s, dc->u.s_name.len); | 4647 d_append_buffer (dpi, dc->u.s_name.s, dc->u.s_name.len); |
3573 else | 4648 else |
3574 d_print_java_identifier (dpi, dc->u.s_name.s, dc->u.s_name.len); | 4649 d_print_java_identifier (dpi, dc->u.s_name.s, dc->u.s_name.len); |
3575 return; | 4650 return; |
3576 | 4651 |
4652 case DEMANGLE_COMPONENT_TAGGED_NAME: | |
4653 d_print_comp (dpi, options, d_left (dc)); | |
4654 d_append_string (dpi, "[abi:"); | |
4655 d_print_comp (dpi, options, d_right (dc)); | |
4656 d_append_char (dpi, ']'); | |
4657 return; | |
4658 | |
3577 case DEMANGLE_COMPONENT_QUAL_NAME: | 4659 case DEMANGLE_COMPONENT_QUAL_NAME: |
3578 case DEMANGLE_COMPONENT_LOCAL_NAME: | 4660 case DEMANGLE_COMPONENT_LOCAL_NAME: |
3579 d_print_comp (dpi, d_left (dc)); | 4661 d_print_comp (dpi, options, d_left (dc)); |
3580 if ((dpi->options & DMGL_JAVA) == 0) | 4662 if ((options & DMGL_JAVA) == 0) |
3581 d_append_string (dpi, "::"); | 4663 d_append_string (dpi, "::"); |
3582 else | 4664 else |
3583 d_append_char (dpi, '.'); | 4665 d_append_char (dpi, '.'); |
3584 d_print_comp (dpi, d_right (dc)); | 4666 { |
4667 struct demangle_component *local_name = d_right (dc); | |
4668 if (local_name->type == DEMANGLE_COMPONENT_DEFAULT_ARG) | |
4669 { | |
4670 d_append_string (dpi, "{default arg#"); | |
4671 d_append_num (dpi, local_name->u.s_unary_num.num + 1); | |
4672 d_append_string (dpi, "}::"); | |
4673 local_name = local_name->u.s_unary_num.sub; | |
4674 } | |
4675 d_print_comp (dpi, options, local_name); | |
4676 } | |
3585 return; | 4677 return; |
3586 | 4678 |
3587 case DEMANGLE_COMPONENT_TYPED_NAME: | 4679 case DEMANGLE_COMPONENT_TYPED_NAME: |
3588 { | 4680 { |
3589 struct d_print_mod *hold_modifiers; | 4681 struct d_print_mod *hold_modifiers; |
3612 adpm[i].mod = typed_name; | 4704 adpm[i].mod = typed_name; |
3613 adpm[i].printed = 0; | 4705 adpm[i].printed = 0; |
3614 adpm[i].templates = dpi->templates; | 4706 adpm[i].templates = dpi->templates; |
3615 ++i; | 4707 ++i; |
3616 | 4708 |
3617 if (typed_name->type != DEMANGLE_COMPONENT_RESTRICT_THIS | 4709 if (!is_fnqual_component_type (typed_name->type)) |
3618 && typed_name->type != DEMANGLE_COMPONENT_VOLATILE_THIS | |
3619 && typed_name->type != DEMANGLE_COMPONENT_CONST_THIS) | |
3620 break; | 4710 break; |
3621 | 4711 |
3622 typed_name = d_left (typed_name); | 4712 typed_name = d_left (typed_name); |
3623 } | 4713 } |
3624 | 4714 |
3625 if (typed_name == NULL) | 4715 if (typed_name == NULL) |
3626 { | 4716 { |
3627 d_print_error (dpi); | 4717 d_print_error (dpi); |
3628 return; | 4718 return; |
4719 } | |
4720 | |
4721 /* If typed_name is a DEMANGLE_COMPONENT_LOCAL_NAME, then | |
4722 there may be CV-qualifiers on its right argument which | |
4723 really apply here; this happens when parsing a class that | |
4724 is local to a function. */ | |
4725 if (typed_name->type == DEMANGLE_COMPONENT_LOCAL_NAME) | |
4726 { | |
4727 typed_name = d_right (typed_name); | |
4728 if (typed_name->type == DEMANGLE_COMPONENT_DEFAULT_ARG) | |
4729 typed_name = typed_name->u.s_unary_num.sub; | |
4730 if (typed_name == NULL) | |
4731 { | |
4732 d_print_error (dpi); | |
4733 return; | |
4734 } | |
4735 while (is_fnqual_component_type (typed_name->type)) | |
4736 { | |
4737 if (i >= sizeof adpm / sizeof adpm[0]) | |
4738 { | |
4739 d_print_error (dpi); | |
4740 return; | |
4741 } | |
4742 | |
4743 adpm[i] = adpm[i - 1]; | |
4744 adpm[i].next = &adpm[i - 1]; | |
4745 dpi->modifiers = &adpm[i]; | |
4746 | |
4747 adpm[i - 1].mod = typed_name; | |
4748 adpm[i - 1].printed = 0; | |
4749 adpm[i - 1].templates = dpi->templates; | |
4750 ++i; | |
4751 | |
4752 typed_name = d_left (typed_name); | |
4753 } | |
3629 } | 4754 } |
3630 | 4755 |
3631 /* If typed_name is a template, then it applies to the | 4756 /* If typed_name is a template, then it applies to the |
3632 function type as well. */ | 4757 function type as well. */ |
3633 if (typed_name->type == DEMANGLE_COMPONENT_TEMPLATE) | 4758 if (typed_name->type == DEMANGLE_COMPONENT_TEMPLATE) |
3635 dpt.next = dpi->templates; | 4760 dpt.next = dpi->templates; |
3636 dpi->templates = &dpt; | 4761 dpi->templates = &dpt; |
3637 dpt.template_decl = typed_name; | 4762 dpt.template_decl = typed_name; |
3638 } | 4763 } |
3639 | 4764 |
3640 /* If typed_name is a DEMANGLE_COMPONENT_LOCAL_NAME, then | 4765 d_print_comp (dpi, options, d_right (dc)); |
3641 there may be CV-qualifiers on its right argument which | |
3642 really apply here; this happens when parsing a class which | |
3643 is local to a function. */ | |
3644 if (typed_name->type == DEMANGLE_COMPONENT_LOCAL_NAME) | |
3645 { | |
3646 struct demangle_component *local_name; | |
3647 | |
3648 local_name = d_right (typed_name); | |
3649 if (local_name->type == DEMANGLE_COMPONENT_DEFAULT_ARG) | |
3650 local_name = local_name->u.s_unary_num.sub; | |
3651 while (local_name->type == DEMANGLE_COMPONENT_RESTRICT_THIS | |
3652 || local_name->type == DEMANGLE_COMPONENT_VOLATILE_THIS | |
3653 || local_name->type == DEMANGLE_COMPONENT_CONST_THIS) | |
3654 { | |
3655 if (i >= sizeof adpm / sizeof adpm[0]) | |
3656 { | |
3657 d_print_error (dpi); | |
3658 return; | |
3659 } | |
3660 | |
3661 adpm[i] = adpm[i - 1]; | |
3662 adpm[i].next = &adpm[i - 1]; | |
3663 dpi->modifiers = &adpm[i]; | |
3664 | |
3665 adpm[i - 1].mod = local_name; | |
3666 adpm[i - 1].printed = 0; | |
3667 adpm[i - 1].templates = dpi->templates; | |
3668 ++i; | |
3669 | |
3670 local_name = d_left (local_name); | |
3671 } | |
3672 } | |
3673 | |
3674 d_print_comp (dpi, d_right (dc)); | |
3675 | 4766 |
3676 if (typed_name->type == DEMANGLE_COMPONENT_TEMPLATE) | 4767 if (typed_name->type == DEMANGLE_COMPONENT_TEMPLATE) |
3677 dpi->templates = dpt.next; | 4768 dpi->templates = dpt.next; |
3678 | 4769 |
3679 /* If the modifiers didn't get printed by the type, print them | 4770 /* If the modifiers didn't get printed by the type, print them |
3682 { | 4773 { |
3683 --i; | 4774 --i; |
3684 if (! adpm[i].printed) | 4775 if (! adpm[i].printed) |
3685 { | 4776 { |
3686 d_append_char (dpi, ' '); | 4777 d_append_char (dpi, ' '); |
3687 d_print_mod (dpi, adpm[i].mod); | 4778 d_print_mod (dpi, options, adpm[i].mod); |
3688 } | 4779 } |
3689 } | 4780 } |
3690 | 4781 |
3691 dpi->modifiers = hold_modifiers; | 4782 dpi->modifiers = hold_modifiers; |
3692 | 4783 |
3695 | 4786 |
3696 case DEMANGLE_COMPONENT_TEMPLATE: | 4787 case DEMANGLE_COMPONENT_TEMPLATE: |
3697 { | 4788 { |
3698 struct d_print_mod *hold_dpm; | 4789 struct d_print_mod *hold_dpm; |
3699 struct demangle_component *dcl; | 4790 struct demangle_component *dcl; |
4791 const struct demangle_component *hold_current; | |
4792 | |
4793 /* This template may need to be referenced by a cast operator | |
4794 contained in its subtree. */ | |
4795 hold_current = dpi->current_template; | |
4796 dpi->current_template = dc; | |
3700 | 4797 |
3701 /* Don't push modifiers into a template definition. Doing so | 4798 /* Don't push modifiers into a template definition. Doing so |
3702 could give the wrong definition for a template argument. | 4799 could give the wrong definition for a template argument. |
3703 Instead, treat the template essentially as a name. */ | 4800 Instead, treat the template essentially as a name. */ |
3704 | 4801 |
3705 hold_dpm = dpi->modifiers; | 4802 hold_dpm = dpi->modifiers; |
3706 dpi->modifiers = NULL; | 4803 dpi->modifiers = NULL; |
3707 | 4804 |
3708 dcl = d_left (dc); | 4805 dcl = d_left (dc); |
3709 | 4806 |
3710 if ((dpi->options & DMGL_JAVA) != 0 | 4807 if ((options & DMGL_JAVA) != 0 |
3711 && dcl->type == DEMANGLE_COMPONENT_NAME | 4808 && dcl->type == DEMANGLE_COMPONENT_NAME |
3712 && dcl->u.s_name.len == 6 | 4809 && dcl->u.s_name.len == 6 |
3713 && strncmp (dcl->u.s_name.s, "JArray", 6) == 0) | 4810 && strncmp (dcl->u.s_name.s, "JArray", 6) == 0) |
3714 { | 4811 { |
3715 /* Special-case Java arrays, so that JArray<TYPE> appears | 4812 /* Special-case Java arrays, so that JArray<TYPE> appears |
3716 instead as TYPE[]. */ | 4813 instead as TYPE[]. */ |
3717 | 4814 |
3718 d_print_comp (dpi, d_right (dc)); | 4815 d_print_comp (dpi, options, d_right (dc)); |
3719 d_append_string (dpi, "[]"); | 4816 d_append_string (dpi, "[]"); |
3720 } | 4817 } |
3721 else | 4818 else |
3722 { | 4819 { |
3723 d_print_comp (dpi, dcl); | 4820 d_print_comp (dpi, options, dcl); |
3724 if (d_last_char (dpi) == '<') | 4821 if (d_last_char (dpi) == '<') |
3725 d_append_char (dpi, ' '); | 4822 d_append_char (dpi, ' '); |
3726 d_append_char (dpi, '<'); | 4823 d_append_char (dpi, '<'); |
3727 d_print_comp (dpi, d_right (dc)); | 4824 d_print_comp (dpi, options, d_right (dc)); |
3728 /* Avoid generating two consecutive '>' characters, to avoid | 4825 /* Avoid generating two consecutive '>' characters, to avoid |
3729 the C++ syntactic ambiguity. */ | 4826 the C++ syntactic ambiguity. */ |
3730 if (d_last_char (dpi) == '>') | 4827 if (d_last_char (dpi) == '>') |
3731 d_append_char (dpi, ' '); | 4828 d_append_char (dpi, ' '); |
3732 d_append_char (dpi, '>'); | 4829 d_append_char (dpi, '>'); |
3733 } | 4830 } |
3734 | 4831 |
3735 dpi->modifiers = hold_dpm; | 4832 dpi->modifiers = hold_dpm; |
4833 dpi->current_template = hold_current; | |
3736 | 4834 |
3737 return; | 4835 return; |
3738 } | 4836 } |
3739 | 4837 |
3740 case DEMANGLE_COMPONENT_TEMPLATE_PARAM: | 4838 case DEMANGLE_COMPONENT_TEMPLATE_PARAM: |
3741 { | 4839 if (dpi->is_lambda_arg) |
3742 struct d_print_template *hold_dpt; | 4840 { |
3743 struct demangle_component *a = d_lookup_template_argument (dpi, dc); | 4841 /* Show the template parm index, as that's how g++ displays |
3744 | 4842 these, and future proofs us against potential |
3745 if (a && a->type == DEMANGLE_COMPONENT_TEMPLATE_ARGLIST) | 4843 '[]<typename T> (T *a, T *b) {...}'. */ |
3746 a = d_index_template_argument (a, dpi->pack_index); | 4844 d_append_buffer (dpi, "auto:", 5); |
3747 | 4845 d_append_num (dpi, dc->u.s_number.number + 1); |
3748 if (a == NULL) | 4846 } |
3749 { | 4847 else |
3750 d_print_error (dpi); | 4848 { |
3751 return; | 4849 struct d_print_template *hold_dpt; |
3752 } | 4850 struct demangle_component *a = d_lookup_template_argument (dpi, dc); |
3753 | 4851 |
3754 /* While processing this parameter, we need to pop the list of | 4852 if (a && a->type == DEMANGLE_COMPONENT_TEMPLATE_ARGLIST) |
3755 templates. This is because the template parameter may | 4853 a = d_index_template_argument (a, dpi->pack_index); |
3756 itself be a reference to a parameter of an outer | 4854 |
3757 template. */ | 4855 if (a == NULL) |
3758 | 4856 { |
3759 hold_dpt = dpi->templates; | 4857 d_print_error (dpi); |
3760 dpi->templates = hold_dpt->next; | 4858 return; |
3761 | 4859 } |
3762 d_print_comp (dpi, a); | 4860 |
3763 | 4861 /* While processing this parameter, we need to pop the list |
3764 dpi->templates = hold_dpt; | 4862 of templates. This is because the template parameter may |
3765 | 4863 itself be a reference to a parameter of an outer |
3766 return; | 4864 template. */ |
3767 } | 4865 |
4866 hold_dpt = dpi->templates; | |
4867 dpi->templates = hold_dpt->next; | |
4868 | |
4869 d_print_comp (dpi, options, a); | |
4870 | |
4871 dpi->templates = hold_dpt; | |
4872 } | |
4873 return; | |
3768 | 4874 |
3769 case DEMANGLE_COMPONENT_CTOR: | 4875 case DEMANGLE_COMPONENT_CTOR: |
3770 d_print_comp (dpi, dc->u.s_ctor.name); | 4876 d_print_comp (dpi, options, dc->u.s_ctor.name); |
3771 return; | 4877 return; |
3772 | 4878 |
3773 case DEMANGLE_COMPONENT_DTOR: | 4879 case DEMANGLE_COMPONENT_DTOR: |
3774 d_append_char (dpi, '~'); | 4880 d_append_char (dpi, '~'); |
3775 d_print_comp (dpi, dc->u.s_dtor.name); | 4881 d_print_comp (dpi, options, dc->u.s_dtor.name); |
3776 return; | 4882 return; |
3777 | 4883 |
3778 case DEMANGLE_COMPONENT_VTABLE: | 4884 case DEMANGLE_COMPONENT_VTABLE: |
3779 d_append_string (dpi, "vtable for "); | 4885 d_append_string (dpi, "vtable for "); |
3780 d_print_comp (dpi, d_left (dc)); | 4886 d_print_comp (dpi, options, d_left (dc)); |
3781 return; | 4887 return; |
3782 | 4888 |
3783 case DEMANGLE_COMPONENT_VTT: | 4889 case DEMANGLE_COMPONENT_VTT: |
3784 d_append_string (dpi, "VTT for "); | 4890 d_append_string (dpi, "VTT for "); |
3785 d_print_comp (dpi, d_left (dc)); | 4891 d_print_comp (dpi, options, d_left (dc)); |
3786 return; | 4892 return; |
3787 | 4893 |
3788 case DEMANGLE_COMPONENT_CONSTRUCTION_VTABLE: | 4894 case DEMANGLE_COMPONENT_CONSTRUCTION_VTABLE: |
3789 d_append_string (dpi, "construction vtable for "); | 4895 d_append_string (dpi, "construction vtable for "); |
3790 d_print_comp (dpi, d_left (dc)); | 4896 d_print_comp (dpi, options, d_left (dc)); |
3791 d_append_string (dpi, "-in-"); | 4897 d_append_string (dpi, "-in-"); |
3792 d_print_comp (dpi, d_right (dc)); | 4898 d_print_comp (dpi, options, d_right (dc)); |
3793 return; | 4899 return; |
3794 | 4900 |
3795 case DEMANGLE_COMPONENT_TYPEINFO: | 4901 case DEMANGLE_COMPONENT_TYPEINFO: |
3796 d_append_string (dpi, "typeinfo for "); | 4902 d_append_string (dpi, "typeinfo for "); |
3797 d_print_comp (dpi, d_left (dc)); | 4903 d_print_comp (dpi, options, d_left (dc)); |
3798 return; | 4904 return; |
3799 | 4905 |
3800 case DEMANGLE_COMPONENT_TYPEINFO_NAME: | 4906 case DEMANGLE_COMPONENT_TYPEINFO_NAME: |
3801 d_append_string (dpi, "typeinfo name for "); | 4907 d_append_string (dpi, "typeinfo name for "); |
3802 d_print_comp (dpi, d_left (dc)); | 4908 d_print_comp (dpi, options, d_left (dc)); |
3803 return; | 4909 return; |
3804 | 4910 |
3805 case DEMANGLE_COMPONENT_TYPEINFO_FN: | 4911 case DEMANGLE_COMPONENT_TYPEINFO_FN: |
3806 d_append_string (dpi, "typeinfo fn for "); | 4912 d_append_string (dpi, "typeinfo fn for "); |
3807 d_print_comp (dpi, d_left (dc)); | 4913 d_print_comp (dpi, options, d_left (dc)); |
3808 return; | 4914 return; |
3809 | 4915 |
3810 case DEMANGLE_COMPONENT_THUNK: | 4916 case DEMANGLE_COMPONENT_THUNK: |
3811 d_append_string (dpi, "non-virtual thunk to "); | 4917 d_append_string (dpi, "non-virtual thunk to "); |
3812 d_print_comp (dpi, d_left (dc)); | 4918 d_print_comp (dpi, options, d_left (dc)); |
3813 return; | 4919 return; |
3814 | 4920 |
3815 case DEMANGLE_COMPONENT_VIRTUAL_THUNK: | 4921 case DEMANGLE_COMPONENT_VIRTUAL_THUNK: |
3816 d_append_string (dpi, "virtual thunk to "); | 4922 d_append_string (dpi, "virtual thunk to "); |
3817 d_print_comp (dpi, d_left (dc)); | 4923 d_print_comp (dpi, options, d_left (dc)); |
3818 return; | 4924 return; |
3819 | 4925 |
3820 case DEMANGLE_COMPONENT_COVARIANT_THUNK: | 4926 case DEMANGLE_COMPONENT_COVARIANT_THUNK: |
3821 d_append_string (dpi, "covariant return thunk to "); | 4927 d_append_string (dpi, "covariant return thunk to "); |
3822 d_print_comp (dpi, d_left (dc)); | 4928 d_print_comp (dpi, options, d_left (dc)); |
3823 return; | 4929 return; |
3824 | 4930 |
3825 case DEMANGLE_COMPONENT_JAVA_CLASS: | 4931 case DEMANGLE_COMPONENT_JAVA_CLASS: |
3826 d_append_string (dpi, "java Class for "); | 4932 d_append_string (dpi, "java Class for "); |
3827 d_print_comp (dpi, d_left (dc)); | 4933 d_print_comp (dpi, options, d_left (dc)); |
3828 return; | 4934 return; |
3829 | 4935 |
3830 case DEMANGLE_COMPONENT_GUARD: | 4936 case DEMANGLE_COMPONENT_GUARD: |
3831 d_append_string (dpi, "guard variable for "); | 4937 d_append_string (dpi, "guard variable for "); |
3832 d_print_comp (dpi, d_left (dc)); | 4938 d_print_comp (dpi, options, d_left (dc)); |
4939 return; | |
4940 | |
4941 case DEMANGLE_COMPONENT_TLS_INIT: | |
4942 d_append_string (dpi, "TLS init function for "); | |
4943 d_print_comp (dpi, options, d_left (dc)); | |
4944 return; | |
4945 | |
4946 case DEMANGLE_COMPONENT_TLS_WRAPPER: | |
4947 d_append_string (dpi, "TLS wrapper function for "); | |
4948 d_print_comp (dpi, options, d_left (dc)); | |
3833 return; | 4949 return; |
3834 | 4950 |
3835 case DEMANGLE_COMPONENT_REFTEMP: | 4951 case DEMANGLE_COMPONENT_REFTEMP: |
3836 d_append_string (dpi, "reference temporary for "); | 4952 d_append_string (dpi, "reference temporary #"); |
3837 d_print_comp (dpi, d_left (dc)); | 4953 d_print_comp (dpi, options, d_right (dc)); |
4954 d_append_string (dpi, " for "); | |
4955 d_print_comp (dpi, options, d_left (dc)); | |
3838 return; | 4956 return; |
3839 | 4957 |
3840 case DEMANGLE_COMPONENT_HIDDEN_ALIAS: | 4958 case DEMANGLE_COMPONENT_HIDDEN_ALIAS: |
3841 d_append_string (dpi, "hidden alias for "); | 4959 d_append_string (dpi, "hidden alias for "); |
3842 d_print_comp (dpi, d_left (dc)); | 4960 d_print_comp (dpi, options, d_left (dc)); |
4961 return; | |
4962 | |
4963 case DEMANGLE_COMPONENT_TRANSACTION_CLONE: | |
4964 d_append_string (dpi, "transaction clone for "); | |
4965 d_print_comp (dpi, options, d_left (dc)); | |
4966 return; | |
4967 | |
4968 case DEMANGLE_COMPONENT_NONTRANSACTION_CLONE: | |
4969 d_append_string (dpi, "non-transaction clone for "); | |
4970 d_print_comp (dpi, options, d_left (dc)); | |
3843 return; | 4971 return; |
3844 | 4972 |
3845 case DEMANGLE_COMPONENT_SUB_STD: | 4973 case DEMANGLE_COMPONENT_SUB_STD: |
3846 d_append_buffer (dpi, dc->u.s_string.string, dc->u.s_string.len); | 4974 d_append_buffer (dpi, dc->u.s_string.string, dc->u.s_string.len); |
3847 return; | 4975 return; |
3864 && pdpm->mod->type != DEMANGLE_COMPONENT_VOLATILE | 4992 && pdpm->mod->type != DEMANGLE_COMPONENT_VOLATILE |
3865 && pdpm->mod->type != DEMANGLE_COMPONENT_CONST) | 4993 && pdpm->mod->type != DEMANGLE_COMPONENT_CONST) |
3866 break; | 4994 break; |
3867 if (pdpm->mod->type == dc->type) | 4995 if (pdpm->mod->type == dc->type) |
3868 { | 4996 { |
3869 d_print_comp (dpi, d_left (dc)); | 4997 d_print_comp (dpi, options, d_left (dc)); |
3870 return; | 4998 return; |
3871 } | 4999 } |
3872 } | 5000 } |
3873 } | 5001 } |
3874 } | 5002 } |
5003 goto modifier; | |
5004 | |
5005 case DEMANGLE_COMPONENT_REFERENCE: | |
5006 case DEMANGLE_COMPONENT_RVALUE_REFERENCE: | |
5007 { | |
5008 /* Handle reference smashing: & + && = &. */ | |
5009 struct demangle_component *sub = d_left (dc); | |
5010 if (!dpi->is_lambda_arg | |
5011 && sub->type == DEMANGLE_COMPONENT_TEMPLATE_PARAM) | |
5012 { | |
5013 struct d_saved_scope *scope = d_get_saved_scope (dpi, sub); | |
5014 struct demangle_component *a; | |
5015 | |
5016 if (scope == NULL) | |
5017 { | |
5018 /* This is the first time SUB has been traversed. | |
5019 We need to capture the current templates so | |
5020 they can be restored if SUB is reentered as a | |
5021 substitution. */ | |
5022 d_save_scope (dpi, sub); | |
5023 if (d_print_saw_error (dpi)) | |
5024 return; | |
5025 } | |
5026 else | |
5027 { | |
5028 const struct d_component_stack *dcse; | |
5029 int found_self_or_parent = 0; | |
5030 | |
5031 /* This traversal is reentering SUB as a substition. | |
5032 If we are not beneath SUB or DC in the tree then we | |
5033 need to restore SUB's template stack temporarily. */ | |
5034 for (dcse = dpi->component_stack; dcse != NULL; | |
5035 dcse = dcse->parent) | |
5036 { | |
5037 if (dcse->dc == sub | |
5038 || (dcse->dc == dc | |
5039 && dcse != dpi->component_stack)) | |
5040 { | |
5041 found_self_or_parent = 1; | |
5042 break; | |
5043 } | |
5044 } | |
5045 | |
5046 if (!found_self_or_parent) | |
5047 { | |
5048 saved_templates = dpi->templates; | |
5049 dpi->templates = scope->templates; | |
5050 need_template_restore = 1; | |
5051 } | |
5052 } | |
5053 | |
5054 a = d_lookup_template_argument (dpi, sub); | |
5055 if (a && a->type == DEMANGLE_COMPONENT_TEMPLATE_ARGLIST) | |
5056 a = d_index_template_argument (a, dpi->pack_index); | |
5057 | |
5058 if (a == NULL) | |
5059 { | |
5060 if (need_template_restore) | |
5061 dpi->templates = saved_templates; | |
5062 | |
5063 d_print_error (dpi); | |
5064 return; | |
5065 } | |
5066 | |
5067 sub = a; | |
5068 } | |
5069 | |
5070 if (sub->type == DEMANGLE_COMPONENT_REFERENCE | |
5071 || sub->type == dc->type) | |
5072 dc = sub; | |
5073 else if (sub->type == DEMANGLE_COMPONENT_RVALUE_REFERENCE) | |
5074 mod_inner = d_left (sub); | |
5075 } | |
3875 /* Fall through. */ | 5076 /* Fall through. */ |
3876 case DEMANGLE_COMPONENT_RESTRICT_THIS: | 5077 |
3877 case DEMANGLE_COMPONENT_VOLATILE_THIS: | |
3878 case DEMANGLE_COMPONENT_CONST_THIS: | |
3879 case DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL: | 5078 case DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL: |
3880 case DEMANGLE_COMPONENT_POINTER: | 5079 case DEMANGLE_COMPONENT_POINTER: |
3881 case DEMANGLE_COMPONENT_REFERENCE: | |
3882 case DEMANGLE_COMPONENT_RVALUE_REFERENCE: | |
3883 case DEMANGLE_COMPONENT_COMPLEX: | 5080 case DEMANGLE_COMPONENT_COMPLEX: |
3884 case DEMANGLE_COMPONENT_IMAGINARY: | 5081 case DEMANGLE_COMPONENT_IMAGINARY: |
5082 FNQUAL_COMPONENT_CASE: | |
5083 modifier: | |
3885 { | 5084 { |
3886 /* We keep a list of modifiers on the stack. */ | 5085 /* We keep a list of modifiers on the stack. */ |
3887 struct d_print_mod dpm; | 5086 struct d_print_mod dpm; |
3888 | 5087 |
3889 dpm.next = dpi->modifiers; | 5088 dpm.next = dpi->modifiers; |
3890 dpi->modifiers = &dpm; | 5089 dpi->modifiers = &dpm; |
3891 dpm.mod = dc; | 5090 dpm.mod = dc; |
3892 dpm.printed = 0; | 5091 dpm.printed = 0; |
3893 dpm.templates = dpi->templates; | 5092 dpm.templates = dpi->templates; |
3894 | 5093 |
3895 d_print_comp (dpi, d_left (dc)); | 5094 if (!mod_inner) |
5095 mod_inner = d_left (dc); | |
5096 | |
5097 d_print_comp (dpi, options, mod_inner); | |
3896 | 5098 |
3897 /* If the modifier didn't get printed by the type, print it | 5099 /* If the modifier didn't get printed by the type, print it |
3898 now. */ | 5100 now. */ |
3899 if (! dpm.printed) | 5101 if (! dpm.printed) |
3900 d_print_mod (dpi, dc); | 5102 d_print_mod (dpi, options, dc); |
3901 | 5103 |
3902 dpi->modifiers = dpm.next; | 5104 dpi->modifiers = dpm.next; |
5105 | |
5106 if (need_template_restore) | |
5107 dpi->templates = saved_templates; | |
3903 | 5108 |
3904 return; | 5109 return; |
3905 } | 5110 } |
3906 | 5111 |
3907 case DEMANGLE_COMPONENT_BUILTIN_TYPE: | 5112 case DEMANGLE_COMPONENT_BUILTIN_TYPE: |
3908 if ((dpi->options & DMGL_JAVA) == 0) | 5113 if ((options & DMGL_JAVA) == 0) |
3909 d_append_buffer (dpi, dc->u.s_builtin.type->name, | 5114 d_append_buffer (dpi, dc->u.s_builtin.type->name, |
3910 dc->u.s_builtin.type->len); | 5115 dc->u.s_builtin.type->len); |
3911 else | 5116 else |
3912 d_append_buffer (dpi, dc->u.s_builtin.type->java_name, | 5117 d_append_buffer (dpi, dc->u.s_builtin.type->java_name, |
3913 dc->u.s_builtin.type->java_len); | 5118 dc->u.s_builtin.type->java_len); |
3914 return; | 5119 return; |
3915 | 5120 |
3916 case DEMANGLE_COMPONENT_VENDOR_TYPE: | 5121 case DEMANGLE_COMPONENT_VENDOR_TYPE: |
3917 d_print_comp (dpi, d_left (dc)); | 5122 d_print_comp (dpi, options, d_left (dc)); |
3918 return; | 5123 return; |
3919 | 5124 |
3920 case DEMANGLE_COMPONENT_FUNCTION_TYPE: | 5125 case DEMANGLE_COMPONENT_FUNCTION_TYPE: |
3921 { | 5126 { |
3922 if ((dpi->options & DMGL_RET_POSTFIX) != 0) | 5127 if ((options & DMGL_RET_POSTFIX) != 0) |
3923 d_print_function_type (dpi, dc, dpi->modifiers); | 5128 d_print_function_type (dpi, |
5129 options & ~(DMGL_RET_POSTFIX | DMGL_RET_DROP), | |
5130 dc, dpi->modifiers); | |
3924 | 5131 |
3925 /* Print return type if present */ | 5132 /* Print return type if present */ |
3926 if (d_left (dc) != NULL) | 5133 if (d_left (dc) != NULL && (options & DMGL_RET_POSTFIX) != 0) |
5134 d_print_comp (dpi, options & ~(DMGL_RET_POSTFIX | DMGL_RET_DROP), | |
5135 d_left (dc)); | |
5136 else if (d_left (dc) != NULL && (options & DMGL_RET_DROP) == 0) | |
3927 { | 5137 { |
3928 struct d_print_mod dpm; | 5138 struct d_print_mod dpm; |
3929 | 5139 |
3930 /* We must pass this type down as a modifier in order to | 5140 /* We must pass this type down as a modifier in order to |
3931 print it in the right location. */ | 5141 print it in the right location. */ |
3933 dpi->modifiers = &dpm; | 5143 dpi->modifiers = &dpm; |
3934 dpm.mod = dc; | 5144 dpm.mod = dc; |
3935 dpm.printed = 0; | 5145 dpm.printed = 0; |
3936 dpm.templates = dpi->templates; | 5146 dpm.templates = dpi->templates; |
3937 | 5147 |
3938 d_print_comp (dpi, d_left (dc)); | 5148 d_print_comp (dpi, options & ~(DMGL_RET_POSTFIX | DMGL_RET_DROP), |
5149 d_left (dc)); | |
3939 | 5150 |
3940 dpi->modifiers = dpm.next; | 5151 dpi->modifiers = dpm.next; |
3941 | 5152 |
3942 if (dpm.printed) | 5153 if (dpm.printed) |
3943 return; | 5154 return; |
3944 | 5155 |
3945 /* In standard prefix notation, there is a space between the | 5156 /* In standard prefix notation, there is a space between the |
3946 return type and the function signature. */ | 5157 return type and the function signature. */ |
3947 if ((dpi->options & DMGL_RET_POSTFIX) == 0) | 5158 if ((options & DMGL_RET_POSTFIX) == 0) |
3948 d_append_char (dpi, ' '); | 5159 d_append_char (dpi, ' '); |
3949 } | 5160 } |
3950 | 5161 |
3951 if ((dpi->options & DMGL_RET_POSTFIX) == 0) | 5162 if ((options & DMGL_RET_POSTFIX) == 0) |
3952 d_print_function_type (dpi, dc, dpi->modifiers); | 5163 d_print_function_type (dpi, |
5164 options & ~(DMGL_RET_POSTFIX | DMGL_RET_DROP), | |
5165 dc, dpi->modifiers); | |
3953 | 5166 |
3954 return; | 5167 return; |
3955 } | 5168 } |
3956 | 5169 |
3957 case DEMANGLE_COMPONENT_ARRAY_TYPE: | 5170 case DEMANGLE_COMPONENT_ARRAY_TYPE: |
4000 } | 5213 } |
4001 | 5214 |
4002 pdpm = pdpm->next; | 5215 pdpm = pdpm->next; |
4003 } | 5216 } |
4004 | 5217 |
4005 d_print_comp (dpi, d_right (dc)); | 5218 d_print_comp (dpi, options, d_right (dc)); |
4006 | 5219 |
4007 dpi->modifiers = hold_modifiers; | 5220 dpi->modifiers = hold_modifiers; |
4008 | 5221 |
4009 if (adpm[0].printed) | 5222 if (adpm[0].printed) |
4010 return; | 5223 return; |
4011 | 5224 |
4012 while (i > 1) | 5225 while (i > 1) |
4013 { | 5226 { |
4014 --i; | 5227 --i; |
4015 d_print_mod (dpi, adpm[i].mod); | 5228 d_print_mod (dpi, options, adpm[i].mod); |
4016 } | 5229 } |
4017 | 5230 |
4018 d_print_array_type (dpi, dc, dpi->modifiers); | 5231 d_print_array_type (dpi, options, dc, dpi->modifiers); |
4019 | 5232 |
4020 return; | 5233 return; |
4021 } | 5234 } |
4022 | 5235 |
4023 case DEMANGLE_COMPONENT_PTRMEM_TYPE: | 5236 case DEMANGLE_COMPONENT_PTRMEM_TYPE: |
4029 dpi->modifiers = &dpm; | 5242 dpi->modifiers = &dpm; |
4030 dpm.mod = dc; | 5243 dpm.mod = dc; |
4031 dpm.printed = 0; | 5244 dpm.printed = 0; |
4032 dpm.templates = dpi->templates; | 5245 dpm.templates = dpi->templates; |
4033 | 5246 |
4034 d_print_comp (dpi, d_right (dc)); | 5247 d_print_comp (dpi, options, d_right (dc)); |
4035 | 5248 |
4036 /* If the modifier didn't get printed by the type, print it | 5249 /* If the modifier didn't get printed by the type, print it |
4037 now. */ | 5250 now. */ |
4038 if (! dpm.printed) | 5251 if (! dpm.printed) |
4039 d_print_mod (dpi, dc); | 5252 d_print_mod (dpi, options, dc); |
4040 | 5253 |
4041 dpi->modifiers = dpm.next; | 5254 dpi->modifiers = dpm.next; |
4042 | 5255 |
4043 return; | 5256 return; |
4044 } | 5257 } |
4048 d_append_string (dpi, "_Sat "); | 5261 d_append_string (dpi, "_Sat "); |
4049 /* Don't print "int _Accum". */ | 5262 /* Don't print "int _Accum". */ |
4050 if (dc->u.s_fixed.length->u.s_builtin.type | 5263 if (dc->u.s_fixed.length->u.s_builtin.type |
4051 != &cplus_demangle_builtin_types['i'-'a']) | 5264 != &cplus_demangle_builtin_types['i'-'a']) |
4052 { | 5265 { |
4053 d_print_comp (dpi, dc->u.s_fixed.length); | 5266 d_print_comp (dpi, options, dc->u.s_fixed.length); |
4054 d_append_char (dpi, ' '); | 5267 d_append_char (dpi, ' '); |
4055 } | 5268 } |
4056 if (dc->u.s_fixed.accum) | 5269 if (dc->u.s_fixed.accum) |
4057 d_append_string (dpi, "_Accum"); | 5270 d_append_string (dpi, "_Accum"); |
4058 else | 5271 else |
4060 return; | 5273 return; |
4061 | 5274 |
4062 case DEMANGLE_COMPONENT_ARGLIST: | 5275 case DEMANGLE_COMPONENT_ARGLIST: |
4063 case DEMANGLE_COMPONENT_TEMPLATE_ARGLIST: | 5276 case DEMANGLE_COMPONENT_TEMPLATE_ARGLIST: |
4064 if (d_left (dc) != NULL) | 5277 if (d_left (dc) != NULL) |
4065 d_print_comp (dpi, d_left (dc)); | 5278 d_print_comp (dpi, options, d_left (dc)); |
4066 if (d_right (dc) != NULL) | 5279 if (d_right (dc) != NULL) |
4067 { | 5280 { |
4068 size_t len; | 5281 size_t len; |
4069 unsigned long int flush_count; | 5282 unsigned long int flush_count; |
4070 /* Make sure ", " isn't flushed by d_append_string, otherwise | 5283 /* Make sure ", " isn't flushed by d_append_string, otherwise |
4072 if (dpi->len >= sizeof (dpi->buf) - 2) | 5285 if (dpi->len >= sizeof (dpi->buf) - 2) |
4073 d_print_flush (dpi); | 5286 d_print_flush (dpi); |
4074 d_append_string (dpi, ", "); | 5287 d_append_string (dpi, ", "); |
4075 len = dpi->len; | 5288 len = dpi->len; |
4076 flush_count = dpi->flush_count; | 5289 flush_count = dpi->flush_count; |
4077 d_print_comp (dpi, d_right (dc)); | 5290 d_print_comp (dpi, options, d_right (dc)); |
4078 /* If that didn't print anything (which can happen with empty | 5291 /* If that didn't print anything (which can happen with empty |
4079 template argument packs), remove the comma and space. */ | 5292 template argument packs), remove the comma and space. */ |
4080 if (dpi->flush_count == flush_count && dpi->len == len) | 5293 if (dpi->flush_count == flush_count && dpi->len == len) |
4081 dpi->len -= 2; | 5294 dpi->len -= 2; |
4082 } | 5295 } |
4083 return; | 5296 return; |
4084 | 5297 |
5298 case DEMANGLE_COMPONENT_INITIALIZER_LIST: | |
5299 { | |
5300 struct demangle_component *type = d_left (dc); | |
5301 struct demangle_component *list = d_right (dc); | |
5302 | |
5303 if (type) | |
5304 d_print_comp (dpi, options, type); | |
5305 d_append_char (dpi, '{'); | |
5306 d_print_comp (dpi, options, list); | |
5307 d_append_char (dpi, '}'); | |
5308 } | |
5309 return; | |
5310 | |
4085 case DEMANGLE_COMPONENT_OPERATOR: | 5311 case DEMANGLE_COMPONENT_OPERATOR: |
4086 { | 5312 { |
4087 char c; | 5313 const struct demangle_operator_info *op = dc->u.s_operator.op; |
5314 int len = op->len; | |
4088 | 5315 |
4089 d_append_string (dpi, "operator"); | 5316 d_append_string (dpi, "operator"); |
4090 c = dc->u.s_operator.op->name[0]; | 5317 /* Add a space before new/delete. */ |
4091 if (IS_LOWER (c)) | 5318 if (IS_LOWER (op->name[0])) |
4092 d_append_char (dpi, ' '); | 5319 d_append_char (dpi, ' '); |
4093 d_append_buffer (dpi, dc->u.s_operator.op->name, | 5320 /* Omit a trailing space. */ |
4094 dc->u.s_operator.op->len); | 5321 if (op->name[len-1] == ' ') |
5322 --len; | |
5323 d_append_buffer (dpi, op->name, len); | |
4095 return; | 5324 return; |
4096 } | 5325 } |
4097 | 5326 |
4098 case DEMANGLE_COMPONENT_EXTENDED_OPERATOR: | 5327 case DEMANGLE_COMPONENT_EXTENDED_OPERATOR: |
4099 d_append_string (dpi, "operator "); | 5328 d_append_string (dpi, "operator "); |
4100 d_print_comp (dpi, dc->u.s_extended_operator.name); | 5329 d_print_comp (dpi, options, dc->u.s_extended_operator.name); |
4101 return; | 5330 return; |
4102 | 5331 |
4103 case DEMANGLE_COMPONENT_CAST: | 5332 case DEMANGLE_COMPONENT_CONVERSION: |
4104 d_append_string (dpi, "operator "); | 5333 d_append_string (dpi, "operator "); |
4105 d_print_cast (dpi, dc); | 5334 d_print_conversion (dpi, options, dc); |
5335 return; | |
5336 | |
5337 case DEMANGLE_COMPONENT_NULLARY: | |
5338 d_print_expr_op (dpi, options, d_left (dc)); | |
4106 return; | 5339 return; |
4107 | 5340 |
4108 case DEMANGLE_COMPONENT_UNARY: | 5341 case DEMANGLE_COMPONENT_UNARY: |
4109 if (d_left (dc)->type != DEMANGLE_COMPONENT_CAST) | 5342 { |
4110 d_print_expr_op (dpi, d_left (dc)); | 5343 struct demangle_component *op = d_left (dc); |
4111 else | 5344 struct demangle_component *operand = d_right (dc); |
4112 { | 5345 const char *code = NULL; |
4113 d_append_char (dpi, '('); | 5346 |
4114 d_print_cast (dpi, d_left (dc)); | 5347 if (op->type == DEMANGLE_COMPONENT_OPERATOR) |
4115 d_append_char (dpi, ')'); | 5348 { |
4116 } | 5349 code = op->u.s_operator.op->code; |
4117 d_print_subexpr (dpi, d_right (dc)); | 5350 if (!strcmp (code, "ad")) |
5351 { | |
5352 /* Don't print the argument list for the address of a | |
5353 function. */ | |
5354 if (operand->type == DEMANGLE_COMPONENT_TYPED_NAME | |
5355 && d_left (operand)->type == DEMANGLE_COMPONENT_QUAL_NAME | |
5356 && d_right (operand)->type == DEMANGLE_COMPONENT_FUNCTION_TYPE) | |
5357 operand = d_left (operand); | |
5358 } | |
5359 if (operand->type == DEMANGLE_COMPONENT_BINARY_ARGS) | |
5360 { | |
5361 /* This indicates a suffix operator. */ | |
5362 operand = d_left (operand); | |
5363 d_print_subexpr (dpi, options, operand); | |
5364 d_print_expr_op (dpi, options, op); | |
5365 return; | |
5366 } | |
5367 } | |
5368 | |
5369 /* For sizeof..., just print the pack length. */ | |
5370 if (code && !strcmp (code, "sZ")) | |
5371 { | |
5372 struct demangle_component *a = d_find_pack (dpi, operand); | |
5373 int len = d_pack_length (a); | |
5374 d_append_num (dpi, len); | |
5375 return; | |
5376 } | |
5377 else if (code && !strcmp (code, "sP")) | |
5378 { | |
5379 int len = d_args_length (dpi, operand); | |
5380 d_append_num (dpi, len); | |
5381 return; | |
5382 } | |
5383 | |
5384 if (op->type != DEMANGLE_COMPONENT_CAST) | |
5385 d_print_expr_op (dpi, options, op); | |
5386 else | |
5387 { | |
5388 d_append_char (dpi, '('); | |
5389 d_print_cast (dpi, options, op); | |
5390 d_append_char (dpi, ')'); | |
5391 } | |
5392 if (code && !strcmp (code, "gs")) | |
5393 /* Avoid parens after '::'. */ | |
5394 d_print_comp (dpi, options, operand); | |
5395 else if (code && !strcmp (code, "st")) | |
5396 /* Always print parens for sizeof (type). */ | |
5397 { | |
5398 d_append_char (dpi, '('); | |
5399 d_print_comp (dpi, options, operand); | |
5400 d_append_char (dpi, ')'); | |
5401 } | |
5402 else | |
5403 d_print_subexpr (dpi, options, operand); | |
5404 } | |
4118 return; | 5405 return; |
4119 | 5406 |
4120 case DEMANGLE_COMPONENT_BINARY: | 5407 case DEMANGLE_COMPONENT_BINARY: |
4121 if (d_right (dc)->type != DEMANGLE_COMPONENT_BINARY_ARGS) | 5408 if (d_right (dc)->type != DEMANGLE_COMPONENT_BINARY_ARGS) |
4122 { | 5409 { |
4123 d_print_error (dpi); | 5410 d_print_error (dpi); |
4124 return; | 5411 return; |
4125 } | 5412 } |
5413 | |
5414 if (op_is_new_cast (d_left (dc))) | |
5415 { | |
5416 d_print_expr_op (dpi, options, d_left (dc)); | |
5417 d_append_char (dpi, '<'); | |
5418 d_print_comp (dpi, options, d_left (d_right (dc))); | |
5419 d_append_string (dpi, ">("); | |
5420 d_print_comp (dpi, options, d_right (d_right (dc))); | |
5421 d_append_char (dpi, ')'); | |
5422 return; | |
5423 } | |
5424 | |
5425 if (d_maybe_print_fold_expression (dpi, options, dc)) | |
5426 return; | |
4126 | 5427 |
4127 /* We wrap an expression which uses the greater-than operator in | 5428 /* We wrap an expression which uses the greater-than operator in |
4128 an extra layer of parens so that it does not get confused | 5429 an extra layer of parens so that it does not get confused |
4129 with the '>' which ends the template parameters. */ | 5430 with the '>' which ends the template parameters. */ |
4130 if (d_left (dc)->type == DEMANGLE_COMPONENT_OPERATOR | 5431 if (d_left (dc)->type == DEMANGLE_COMPONENT_OPERATOR |
4131 && d_left (dc)->u.s_operator.op->len == 1 | 5432 && d_left (dc)->u.s_operator.op->len == 1 |
4132 && d_left (dc)->u.s_operator.op->name[0] == '>') | 5433 && d_left (dc)->u.s_operator.op->name[0] == '>') |
4133 d_append_char (dpi, '('); | 5434 d_append_char (dpi, '('); |
4134 | 5435 |
4135 d_print_subexpr (dpi, d_left (d_right (dc))); | 5436 if (strcmp (d_left (dc)->u.s_operator.op->code, "cl") == 0 |
5437 && d_left (d_right (dc))->type == DEMANGLE_COMPONENT_TYPED_NAME) | |
5438 { | |
5439 /* Function call used in an expression should not have printed types | |
5440 of the function arguments. Values of the function arguments still | |
5441 get printed below. */ | |
5442 | |
5443 const struct demangle_component *func = d_left (d_right (dc)); | |
5444 | |
5445 if (d_right (func)->type != DEMANGLE_COMPONENT_FUNCTION_TYPE) | |
5446 d_print_error (dpi); | |
5447 d_print_subexpr (dpi, options, d_left (func)); | |
5448 } | |
5449 else | |
5450 d_print_subexpr (dpi, options, d_left (d_right (dc))); | |
4136 if (strcmp (d_left (dc)->u.s_operator.op->code, "ix") == 0) | 5451 if (strcmp (d_left (dc)->u.s_operator.op->code, "ix") == 0) |
4137 { | 5452 { |
4138 d_append_char (dpi, '['); | 5453 d_append_char (dpi, '['); |
4139 d_print_comp (dpi, d_right (d_right (dc))); | 5454 d_print_comp (dpi, options, d_right (d_right (dc))); |
4140 d_append_char (dpi, ']'); | 5455 d_append_char (dpi, ']'); |
4141 } | 5456 } |
4142 else | 5457 else |
4143 { | 5458 { |
4144 if (strcmp (d_left (dc)->u.s_operator.op->code, "cl") != 0) | 5459 if (strcmp (d_left (dc)->u.s_operator.op->code, "cl") != 0) |
4145 d_print_expr_op (dpi, d_left (dc)); | 5460 d_print_expr_op (dpi, options, d_left (dc)); |
4146 d_print_subexpr (dpi, d_right (d_right (dc))); | 5461 d_print_subexpr (dpi, options, d_right (d_right (dc))); |
4147 } | 5462 } |
4148 | 5463 |
4149 if (d_left (dc)->type == DEMANGLE_COMPONENT_OPERATOR | 5464 if (d_left (dc)->type == DEMANGLE_COMPONENT_OPERATOR |
4150 && d_left (dc)->u.s_operator.op->len == 1 | 5465 && d_left (dc)->u.s_operator.op->len == 1 |
4151 && d_left (dc)->u.s_operator.op->name[0] == '>') | 5466 && d_left (dc)->u.s_operator.op->name[0] == '>') |
4163 || d_right (d_right (dc))->type != DEMANGLE_COMPONENT_TRINARY_ARG2) | 5478 || d_right (d_right (dc))->type != DEMANGLE_COMPONENT_TRINARY_ARG2) |
4164 { | 5479 { |
4165 d_print_error (dpi); | 5480 d_print_error (dpi); |
4166 return; | 5481 return; |
4167 } | 5482 } |
4168 d_print_subexpr (dpi, d_left (d_right (dc))); | 5483 if (d_maybe_print_fold_expression (dpi, options, dc)) |
4169 d_print_expr_op (dpi, d_left (dc)); | 5484 return; |
4170 d_print_subexpr (dpi, d_left (d_right (d_right (dc)))); | 5485 { |
4171 d_append_string (dpi, " : "); | 5486 struct demangle_component *op = d_left (dc); |
4172 d_print_subexpr (dpi, d_right (d_right (d_right (dc)))); | 5487 struct demangle_component *first = d_left (d_right (dc)); |
5488 struct demangle_component *second = d_left (d_right (d_right (dc))); | |
5489 struct demangle_component *third = d_right (d_right (d_right (dc))); | |
5490 | |
5491 if (!strcmp (op->u.s_operator.op->code, "qu")) | |
5492 { | |
5493 d_print_subexpr (dpi, options, first); | |
5494 d_print_expr_op (dpi, options, op); | |
5495 d_print_subexpr (dpi, options, second); | |
5496 d_append_string (dpi, " : "); | |
5497 d_print_subexpr (dpi, options, third); | |
5498 } | |
5499 else | |
5500 { | |
5501 d_append_string (dpi, "new "); | |
5502 if (d_left (first) != NULL) | |
5503 { | |
5504 d_print_subexpr (dpi, options, first); | |
5505 d_append_char (dpi, ' '); | |
5506 } | |
5507 d_print_comp (dpi, options, second); | |
5508 if (third) | |
5509 d_print_subexpr (dpi, options, third); | |
5510 } | |
5511 } | |
4173 return; | 5512 return; |
4174 | 5513 |
4175 case DEMANGLE_COMPONENT_TRINARY_ARG1: | 5514 case DEMANGLE_COMPONENT_TRINARY_ARG1: |
4176 case DEMANGLE_COMPONENT_TRINARY_ARG2: | 5515 case DEMANGLE_COMPONENT_TRINARY_ARG2: |
4177 /* We should only see these are part of DEMANGLE_COMPONENT_TRINARY. */ | 5516 /* We should only see these are part of DEMANGLE_COMPONENT_TRINARY. */ |
4198 case D_PRINT_UNSIGNED_LONG_LONG: | 5537 case D_PRINT_UNSIGNED_LONG_LONG: |
4199 if (d_right (dc)->type == DEMANGLE_COMPONENT_NAME) | 5538 if (d_right (dc)->type == DEMANGLE_COMPONENT_NAME) |
4200 { | 5539 { |
4201 if (dc->type == DEMANGLE_COMPONENT_LITERAL_NEG) | 5540 if (dc->type == DEMANGLE_COMPONENT_LITERAL_NEG) |
4202 d_append_char (dpi, '-'); | 5541 d_append_char (dpi, '-'); |
4203 d_print_comp (dpi, d_right (dc)); | 5542 d_print_comp (dpi, options, d_right (dc)); |
4204 switch (tp) | 5543 switch (tp) |
4205 { | 5544 { |
4206 default: | 5545 default: |
4207 break; | 5546 break; |
4208 case D_PRINT_UNSIGNED: | 5547 case D_PRINT_UNSIGNED: |
4248 break; | 5587 break; |
4249 } | 5588 } |
4250 } | 5589 } |
4251 | 5590 |
4252 d_append_char (dpi, '('); | 5591 d_append_char (dpi, '('); |
4253 d_print_comp (dpi, d_left (dc)); | 5592 d_print_comp (dpi, options, d_left (dc)); |
4254 d_append_char (dpi, ')'); | 5593 d_append_char (dpi, ')'); |
4255 if (dc->type == DEMANGLE_COMPONENT_LITERAL_NEG) | 5594 if (dc->type == DEMANGLE_COMPONENT_LITERAL_NEG) |
4256 d_append_char (dpi, '-'); | 5595 d_append_char (dpi, '-'); |
4257 if (tp == D_PRINT_FLOAT) | 5596 if (tp == D_PRINT_FLOAT) |
4258 d_append_char (dpi, '['); | 5597 d_append_char (dpi, '['); |
4259 d_print_comp (dpi, d_right (dc)); | 5598 d_print_comp (dpi, options, d_right (dc)); |
4260 if (tp == D_PRINT_FLOAT) | 5599 if (tp == D_PRINT_FLOAT) |
4261 d_append_char (dpi, ']'); | 5600 d_append_char (dpi, ']'); |
4262 } | 5601 } |
4263 return; | 5602 return; |
4264 | 5603 |
4266 d_append_num (dpi, dc->u.s_number.number); | 5605 d_append_num (dpi, dc->u.s_number.number); |
4267 return; | 5606 return; |
4268 | 5607 |
4269 case DEMANGLE_COMPONENT_JAVA_RESOURCE: | 5608 case DEMANGLE_COMPONENT_JAVA_RESOURCE: |
4270 d_append_string (dpi, "java resource "); | 5609 d_append_string (dpi, "java resource "); |
4271 d_print_comp (dpi, d_left (dc)); | 5610 d_print_comp (dpi, options, d_left (dc)); |
4272 return; | 5611 return; |
4273 | 5612 |
4274 case DEMANGLE_COMPONENT_COMPOUND_NAME: | 5613 case DEMANGLE_COMPONENT_COMPOUND_NAME: |
4275 d_print_comp (dpi, d_left (dc)); | 5614 d_print_comp (dpi, options, d_left (dc)); |
4276 d_print_comp (dpi, d_right (dc)); | 5615 d_print_comp (dpi, options, d_right (dc)); |
4277 return; | 5616 return; |
4278 | 5617 |
4279 case DEMANGLE_COMPONENT_CHARACTER: | 5618 case DEMANGLE_COMPONENT_CHARACTER: |
4280 d_append_char (dpi, dc->u.s_character.character); | 5619 d_append_char (dpi, dc->u.s_character.character); |
4281 return; | 5620 return; |
4282 | 5621 |
4283 case DEMANGLE_COMPONENT_DECLTYPE: | 5622 case DEMANGLE_COMPONENT_DECLTYPE: |
4284 d_append_string (dpi, "decltype ("); | 5623 d_append_string (dpi, "decltype ("); |
4285 d_print_comp (dpi, d_left (dc)); | 5624 d_print_comp (dpi, options, d_left (dc)); |
4286 d_append_char (dpi, ')'); | 5625 d_append_char (dpi, ')'); |
4287 return; | 5626 return; |
4288 | 5627 |
4289 case DEMANGLE_COMPONENT_PACK_EXPANSION: | 5628 case DEMANGLE_COMPONENT_PACK_EXPANSION: |
4290 { | 5629 { |
4294 if (a == NULL) | 5633 if (a == NULL) |
4295 { | 5634 { |
4296 /* d_find_pack won't find anything if the only packs involved | 5635 /* d_find_pack won't find anything if the only packs involved |
4297 in this expansion are function parameter packs; in that | 5636 in this expansion are function parameter packs; in that |
4298 case, just print the pattern and "...". */ | 5637 case, just print the pattern and "...". */ |
4299 d_print_subexpr (dpi, d_left (dc)); | 5638 d_print_subexpr (dpi, options, d_left (dc)); |
4300 d_append_string (dpi, "..."); | 5639 d_append_string (dpi, "..."); |
4301 return; | 5640 return; |
4302 } | 5641 } |
4303 | 5642 |
4304 len = d_pack_length (a); | 5643 len = d_pack_length (a); |
4305 dc = d_left (dc); | 5644 dc = d_left (dc); |
4306 for (i = 0; i < len; ++i) | 5645 for (i = 0; i < len; ++i) |
4307 { | 5646 { |
4308 dpi->pack_index = i; | 5647 dpi->pack_index = i; |
4309 d_print_comp (dpi, dc); | 5648 d_print_comp (dpi, options, dc); |
4310 if (i < len-1) | 5649 if (i < len-1) |
4311 d_append_string (dpi, ", "); | 5650 d_append_string (dpi, ", "); |
4312 } | 5651 } |
4313 } | 5652 } |
4314 return; | 5653 return; |
4315 | 5654 |
4316 case DEMANGLE_COMPONENT_FUNCTION_PARAM: | 5655 case DEMANGLE_COMPONENT_FUNCTION_PARAM: |
4317 d_append_string (dpi, "{parm#"); | 5656 { |
4318 d_append_num (dpi, dc->u.s_number.number + 1); | 5657 long num = dc->u.s_number.number; |
4319 d_append_char (dpi, '}'); | 5658 if (num == 0) |
5659 d_append_string (dpi, "this"); | |
5660 else | |
5661 { | |
5662 d_append_string (dpi, "{parm#"); | |
5663 d_append_num (dpi, num); | |
5664 d_append_char (dpi, '}'); | |
5665 } | |
5666 } | |
4320 return; | 5667 return; |
4321 | 5668 |
4322 case DEMANGLE_COMPONENT_GLOBAL_CONSTRUCTORS: | 5669 case DEMANGLE_COMPONENT_GLOBAL_CONSTRUCTORS: |
4323 d_append_string (dpi, "global constructors keyed to "); | 5670 d_append_string (dpi, "global constructors keyed to "); |
4324 d_print_comp (dpi, dc->u.s_binary.left); | 5671 d_print_comp (dpi, options, dc->u.s_binary.left); |
4325 return; | 5672 return; |
4326 | 5673 |
4327 case DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS: | 5674 case DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS: |
4328 d_append_string (dpi, "global destructors keyed to "); | 5675 d_append_string (dpi, "global destructors keyed to "); |
4329 d_print_comp (dpi, dc->u.s_binary.left); | 5676 d_print_comp (dpi, options, dc->u.s_binary.left); |
4330 return; | 5677 return; |
4331 | 5678 |
4332 case DEMANGLE_COMPONENT_LAMBDA: | 5679 case DEMANGLE_COMPONENT_LAMBDA: |
4333 d_append_string (dpi, "{lambda("); | 5680 d_append_string (dpi, "{lambda("); |
4334 d_print_comp (dpi, dc->u.s_unary_num.sub); | 5681 /* Generic lambda auto parms are mangled as the template type |
5682 parm they are. */ | |
5683 dpi->is_lambda_arg++; | |
5684 d_print_comp (dpi, options, dc->u.s_unary_num.sub); | |
5685 dpi->is_lambda_arg--; | |
4335 d_append_string (dpi, ")#"); | 5686 d_append_string (dpi, ")#"); |
4336 d_append_num (dpi, dc->u.s_unary_num.num + 1); | 5687 d_append_num (dpi, dc->u.s_unary_num.num + 1); |
4337 d_append_char (dpi, '}'); | 5688 d_append_char (dpi, '}'); |
4338 return; | 5689 return; |
4339 | 5690 |
4341 d_append_string (dpi, "{unnamed type#"); | 5692 d_append_string (dpi, "{unnamed type#"); |
4342 d_append_num (dpi, dc->u.s_number.number + 1); | 5693 d_append_num (dpi, dc->u.s_number.number + 1); |
4343 d_append_char (dpi, '}'); | 5694 d_append_char (dpi, '}'); |
4344 return; | 5695 return; |
4345 | 5696 |
5697 case DEMANGLE_COMPONENT_CLONE: | |
5698 d_print_comp (dpi, options, d_left (dc)); | |
5699 d_append_string (dpi, " [clone "); | |
5700 d_print_comp (dpi, options, d_right (dc)); | |
5701 d_append_char (dpi, ']'); | |
5702 return; | |
5703 | |
4346 default: | 5704 default: |
4347 d_print_error (dpi); | 5705 d_print_error (dpi); |
4348 return; | 5706 return; |
4349 } | 5707 } |
5708 } | |
5709 | |
5710 static void | |
5711 d_print_comp (struct d_print_info *dpi, int options, | |
5712 struct demangle_component *dc) | |
5713 { | |
5714 struct d_component_stack self; | |
5715 if (dc == NULL || dc->d_printing > 1 || dpi->recursion > MAX_RECURSION_COUNT) | |
5716 { | |
5717 d_print_error (dpi); | |
5718 return; | |
5719 } | |
5720 | |
5721 dc->d_printing++; | |
5722 dpi->recursion++; | |
5723 | |
5724 self.dc = dc; | |
5725 self.parent = dpi->component_stack; | |
5726 dpi->component_stack = &self; | |
5727 | |
5728 d_print_comp_inner (dpi, options, dc); | |
5729 | |
5730 dpi->component_stack = self.parent; | |
5731 dc->d_printing--; | |
5732 dpi->recursion--; | |
4350 } | 5733 } |
4351 | 5734 |
4352 /* Print a Java dentifier. For Java we try to handle encoded extended | 5735 /* Print a Java dentifier. For Java we try to handle encoded extended |
4353 Unicode characters. The C++ ABI doesn't mention Unicode encoding, | 5736 Unicode characters. The C++ ABI doesn't mention Unicode encoding, |
4354 so we don't it for C++. Characters are encoded as | 5737 so we don't it for C++. Characters are encoded as |
4403 | 5786 |
4404 /* Print a list of modifiers. SUFFIX is 1 if we are printing | 5787 /* Print a list of modifiers. SUFFIX is 1 if we are printing |
4405 qualifiers on this after printing a function. */ | 5788 qualifiers on this after printing a function. */ |
4406 | 5789 |
4407 static void | 5790 static void |
4408 d_print_mod_list (struct d_print_info *dpi, | 5791 d_print_mod_list (struct d_print_info *dpi, int options, |
4409 struct d_print_mod *mods, int suffix) | 5792 struct d_print_mod *mods, int suffix) |
4410 { | 5793 { |
4411 struct d_print_template *hold_dpt; | 5794 struct d_print_template *hold_dpt; |
4412 | 5795 |
4413 if (mods == NULL || d_print_saw_error (dpi)) | 5796 if (mods == NULL || d_print_saw_error (dpi)) |
4414 return; | 5797 return; |
4415 | 5798 |
4416 if (mods->printed | 5799 if (mods->printed |
4417 || (! suffix | 5800 || (! suffix |
4418 && (mods->mod->type == DEMANGLE_COMPONENT_RESTRICT_THIS | 5801 && (is_fnqual_component_type (mods->mod->type)))) |
4419 || mods->mod->type == DEMANGLE_COMPONENT_VOLATILE_THIS | 5802 { |
4420 || mods->mod->type == DEMANGLE_COMPONENT_CONST_THIS))) | 5803 d_print_mod_list (dpi, options, mods->next, suffix); |
4421 { | |
4422 d_print_mod_list (dpi, mods->next, suffix); | |
4423 return; | 5804 return; |
4424 } | 5805 } |
4425 | 5806 |
4426 mods->printed = 1; | 5807 mods->printed = 1; |
4427 | 5808 |
4428 hold_dpt = dpi->templates; | 5809 hold_dpt = dpi->templates; |
4429 dpi->templates = mods->templates; | 5810 dpi->templates = mods->templates; |
4430 | 5811 |
4431 if (mods->mod->type == DEMANGLE_COMPONENT_FUNCTION_TYPE) | 5812 if (mods->mod->type == DEMANGLE_COMPONENT_FUNCTION_TYPE) |
4432 { | 5813 { |
4433 d_print_function_type (dpi, mods->mod, mods->next); | 5814 d_print_function_type (dpi, options, mods->mod, mods->next); |
4434 dpi->templates = hold_dpt; | 5815 dpi->templates = hold_dpt; |
4435 return; | 5816 return; |
4436 } | 5817 } |
4437 else if (mods->mod->type == DEMANGLE_COMPONENT_ARRAY_TYPE) | 5818 else if (mods->mod->type == DEMANGLE_COMPONENT_ARRAY_TYPE) |
4438 { | 5819 { |
4439 d_print_array_type (dpi, mods->mod, mods->next); | 5820 d_print_array_type (dpi, options, mods->mod, mods->next); |
4440 dpi->templates = hold_dpt; | 5821 dpi->templates = hold_dpt; |
4441 return; | 5822 return; |
4442 } | 5823 } |
4443 else if (mods->mod->type == DEMANGLE_COMPONENT_LOCAL_NAME) | 5824 else if (mods->mod->type == DEMANGLE_COMPONENT_LOCAL_NAME) |
4444 { | 5825 { |
4450 print it as usual, but don't let the left argument see any | 5831 print it as usual, but don't let the left argument see any |
4451 modifiers. */ | 5832 modifiers. */ |
4452 | 5833 |
4453 hold_modifiers = dpi->modifiers; | 5834 hold_modifiers = dpi->modifiers; |
4454 dpi->modifiers = NULL; | 5835 dpi->modifiers = NULL; |
4455 d_print_comp (dpi, d_left (mods->mod)); | 5836 d_print_comp (dpi, options, d_left (mods->mod)); |
4456 dpi->modifiers = hold_modifiers; | 5837 dpi->modifiers = hold_modifiers; |
4457 | 5838 |
4458 if ((dpi->options & DMGL_JAVA) == 0) | 5839 if ((options & DMGL_JAVA) == 0) |
4459 d_append_string (dpi, "::"); | 5840 d_append_string (dpi, "::"); |
4460 else | 5841 else |
4461 d_append_char (dpi, '.'); | 5842 d_append_char (dpi, '.'); |
4462 | 5843 |
4463 dc = d_right (mods->mod); | 5844 dc = d_right (mods->mod); |
4468 d_append_num (dpi, dc->u.s_unary_num.num + 1); | 5849 d_append_num (dpi, dc->u.s_unary_num.num + 1); |
4469 d_append_string (dpi, "}::"); | 5850 d_append_string (dpi, "}::"); |
4470 dc = dc->u.s_unary_num.sub; | 5851 dc = dc->u.s_unary_num.sub; |
4471 } | 5852 } |
4472 | 5853 |
4473 while (dc->type == DEMANGLE_COMPONENT_RESTRICT_THIS | 5854 while (is_fnqual_component_type (dc->type)) |
4474 || dc->type == DEMANGLE_COMPONENT_VOLATILE_THIS | |
4475 || dc->type == DEMANGLE_COMPONENT_CONST_THIS) | |
4476 dc = d_left (dc); | 5855 dc = d_left (dc); |
4477 | 5856 |
4478 d_print_comp (dpi, dc); | 5857 d_print_comp (dpi, options, dc); |
4479 | 5858 |
4480 dpi->templates = hold_dpt; | 5859 dpi->templates = hold_dpt; |
4481 return; | 5860 return; |
4482 } | 5861 } |
4483 | 5862 |
4484 d_print_mod (dpi, mods->mod); | 5863 d_print_mod (dpi, options, mods->mod); |
4485 | 5864 |
4486 dpi->templates = hold_dpt; | 5865 dpi->templates = hold_dpt; |
4487 | 5866 |
4488 d_print_mod_list (dpi, mods->next, suffix); | 5867 d_print_mod_list (dpi, options, mods->next, suffix); |
4489 } | 5868 } |
4490 | 5869 |
4491 /* Print a modifier. */ | 5870 /* Print a modifier. */ |
4492 | 5871 |
4493 static void | 5872 static void |
4494 d_print_mod (struct d_print_info *dpi, | 5873 d_print_mod (struct d_print_info *dpi, int options, |
4495 const struct demangle_component *mod) | 5874 struct demangle_component *mod) |
4496 { | 5875 { |
4497 switch (mod->type) | 5876 switch (mod->type) |
4498 { | 5877 { |
4499 case DEMANGLE_COMPONENT_RESTRICT: | 5878 case DEMANGLE_COMPONENT_RESTRICT: |
4500 case DEMANGLE_COMPONENT_RESTRICT_THIS: | 5879 case DEMANGLE_COMPONENT_RESTRICT_THIS: |
4506 return; | 5885 return; |
4507 case DEMANGLE_COMPONENT_CONST: | 5886 case DEMANGLE_COMPONENT_CONST: |
4508 case DEMANGLE_COMPONENT_CONST_THIS: | 5887 case DEMANGLE_COMPONENT_CONST_THIS: |
4509 d_append_string (dpi, " const"); | 5888 d_append_string (dpi, " const"); |
4510 return; | 5889 return; |
5890 case DEMANGLE_COMPONENT_TRANSACTION_SAFE: | |
5891 d_append_string (dpi, " transaction_safe"); | |
5892 return; | |
5893 case DEMANGLE_COMPONENT_NOEXCEPT: | |
5894 d_append_string (dpi, " noexcept"); | |
5895 if (d_right (mod)) | |
5896 { | |
5897 d_append_char (dpi, '('); | |
5898 d_print_comp (dpi, options, d_right (mod)); | |
5899 d_append_char (dpi, ')'); | |
5900 } | |
5901 return; | |
5902 case DEMANGLE_COMPONENT_THROW_SPEC: | |
5903 d_append_string (dpi, " throw"); | |
5904 if (d_right (mod)) | |
5905 { | |
5906 d_append_char (dpi, '('); | |
5907 d_print_comp (dpi, options, d_right (mod)); | |
5908 d_append_char (dpi, ')'); | |
5909 } | |
5910 return; | |
4511 case DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL: | 5911 case DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL: |
4512 d_append_char (dpi, ' '); | 5912 d_append_char (dpi, ' '); |
4513 d_print_comp (dpi, d_right (mod)); | 5913 d_print_comp (dpi, options, d_right (mod)); |
4514 return; | 5914 return; |
4515 case DEMANGLE_COMPONENT_POINTER: | 5915 case DEMANGLE_COMPONENT_POINTER: |
4516 /* There is no pointer symbol in Java. */ | 5916 /* There is no pointer symbol in Java. */ |
4517 if ((dpi->options & DMGL_JAVA) == 0) | 5917 if ((options & DMGL_JAVA) == 0) |
4518 d_append_char (dpi, '*'); | 5918 d_append_char (dpi, '*'); |
4519 return; | 5919 return; |
5920 case DEMANGLE_COMPONENT_REFERENCE_THIS: | |
5921 /* For the ref-qualifier, put a space before the &. */ | |
5922 d_append_char (dpi, ' '); | |
5923 /* FALLTHRU */ | |
4520 case DEMANGLE_COMPONENT_REFERENCE: | 5924 case DEMANGLE_COMPONENT_REFERENCE: |
4521 d_append_char (dpi, '&'); | 5925 d_append_char (dpi, '&'); |
4522 return; | 5926 return; |
5927 case DEMANGLE_COMPONENT_RVALUE_REFERENCE_THIS: | |
5928 d_append_char (dpi, ' '); | |
5929 /* FALLTHRU */ | |
4523 case DEMANGLE_COMPONENT_RVALUE_REFERENCE: | 5930 case DEMANGLE_COMPONENT_RVALUE_REFERENCE: |
4524 d_append_string (dpi, "&&"); | 5931 d_append_string (dpi, "&&"); |
4525 return; | 5932 return; |
4526 case DEMANGLE_COMPONENT_COMPLEX: | 5933 case DEMANGLE_COMPONENT_COMPLEX: |
4527 d_append_string (dpi, "complex "); | 5934 d_append_string (dpi, "complex "); |
4530 d_append_string (dpi, "imaginary "); | 5937 d_append_string (dpi, "imaginary "); |
4531 return; | 5938 return; |
4532 case DEMANGLE_COMPONENT_PTRMEM_TYPE: | 5939 case DEMANGLE_COMPONENT_PTRMEM_TYPE: |
4533 if (d_last_char (dpi) != '(') | 5940 if (d_last_char (dpi) != '(') |
4534 d_append_char (dpi, ' '); | 5941 d_append_char (dpi, ' '); |
4535 d_print_comp (dpi, d_left (mod)); | 5942 d_print_comp (dpi, options, d_left (mod)); |
4536 d_append_string (dpi, "::*"); | 5943 d_append_string (dpi, "::*"); |
4537 return; | 5944 return; |
4538 case DEMANGLE_COMPONENT_TYPED_NAME: | 5945 case DEMANGLE_COMPONENT_TYPED_NAME: |
4539 d_print_comp (dpi, d_left (mod)); | 5946 d_print_comp (dpi, options, d_left (mod)); |
4540 return; | 5947 return; |
4541 case DEMANGLE_COMPONENT_VECTOR_TYPE: | 5948 case DEMANGLE_COMPONENT_VECTOR_TYPE: |
4542 d_append_string (dpi, " __vector("); | 5949 d_append_string (dpi, " __vector("); |
4543 d_print_comp (dpi, d_left (mod)); | 5950 d_print_comp (dpi, options, d_left (mod)); |
4544 d_append_char (dpi, ')'); | 5951 d_append_char (dpi, ')'); |
4545 return; | 5952 return; |
4546 | 5953 |
4547 default: | 5954 default: |
4548 /* Otherwise, we have something that won't go back on the | 5955 /* Otherwise, we have something that won't go back on the |
4549 modifier stack, so we can just print it. */ | 5956 modifier stack, so we can just print it. */ |
4550 d_print_comp (dpi, mod); | 5957 d_print_comp (dpi, options, mod); |
4551 return; | 5958 return; |
4552 } | 5959 } |
4553 } | 5960 } |
4554 | 5961 |
4555 /* Print a function type, except for the return type. */ | 5962 /* Print a function type, except for the return type. */ |
4556 | 5963 |
4557 static void | 5964 static void |
4558 d_print_function_type (struct d_print_info *dpi, | 5965 d_print_function_type (struct d_print_info *dpi, int options, |
4559 const struct demangle_component *dc, | 5966 struct demangle_component *dc, |
4560 struct d_print_mod *mods) | 5967 struct d_print_mod *mods) |
4561 { | 5968 { |
4562 int need_paren; | 5969 int need_paren; |
4563 int need_space; | 5970 int need_space; |
4564 struct d_print_mod *p; | 5971 struct d_print_mod *p; |
4586 case DEMANGLE_COMPONENT_IMAGINARY: | 5993 case DEMANGLE_COMPONENT_IMAGINARY: |
4587 case DEMANGLE_COMPONENT_PTRMEM_TYPE: | 5994 case DEMANGLE_COMPONENT_PTRMEM_TYPE: |
4588 need_space = 1; | 5995 need_space = 1; |
4589 need_paren = 1; | 5996 need_paren = 1; |
4590 break; | 5997 break; |
4591 case DEMANGLE_COMPONENT_RESTRICT_THIS: | 5998 FNQUAL_COMPONENT_CASE: |
4592 case DEMANGLE_COMPONENT_VOLATILE_THIS: | |
4593 case DEMANGLE_COMPONENT_CONST_THIS: | |
4594 break; | 5999 break; |
4595 default: | 6000 default: |
4596 break; | 6001 break; |
4597 } | 6002 } |
4598 if (need_paren) | 6003 if (need_paren) |
4613 } | 6018 } |
4614 | 6019 |
4615 hold_modifiers = dpi->modifiers; | 6020 hold_modifiers = dpi->modifiers; |
4616 dpi->modifiers = NULL; | 6021 dpi->modifiers = NULL; |
4617 | 6022 |
4618 d_print_mod_list (dpi, mods, 0); | 6023 d_print_mod_list (dpi, options, mods, 0); |
4619 | 6024 |
4620 if (need_paren) | 6025 if (need_paren) |
4621 d_append_char (dpi, ')'); | 6026 d_append_char (dpi, ')'); |
4622 | 6027 |
4623 d_append_char (dpi, '('); | 6028 d_append_char (dpi, '('); |
4624 | 6029 |
4625 if (d_right (dc) != NULL) | 6030 if (d_right (dc) != NULL) |
4626 d_print_comp (dpi, d_right (dc)); | 6031 d_print_comp (dpi, options, d_right (dc)); |
4627 | 6032 |
4628 d_append_char (dpi, ')'); | 6033 d_append_char (dpi, ')'); |
4629 | 6034 |
4630 d_print_mod_list (dpi, mods, 1); | 6035 d_print_mod_list (dpi, options, mods, 1); |
4631 | 6036 |
4632 dpi->modifiers = hold_modifiers; | 6037 dpi->modifiers = hold_modifiers; |
4633 } | 6038 } |
4634 | 6039 |
4635 /* Print an array type, except for the element type. */ | 6040 /* Print an array type, except for the element type. */ |
4636 | 6041 |
4637 static void | 6042 static void |
4638 d_print_array_type (struct d_print_info *dpi, | 6043 d_print_array_type (struct d_print_info *dpi, int options, |
4639 const struct demangle_component *dc, | 6044 struct demangle_component *dc, |
4640 struct d_print_mod *mods) | 6045 struct d_print_mod *mods) |
4641 { | 6046 { |
4642 int need_space; | 6047 int need_space; |
4643 | 6048 |
4644 need_space = 1; | 6049 need_space = 1; |
4667 } | 6072 } |
4668 | 6073 |
4669 if (need_paren) | 6074 if (need_paren) |
4670 d_append_string (dpi, " ("); | 6075 d_append_string (dpi, " ("); |
4671 | 6076 |
4672 d_print_mod_list (dpi, mods, 0); | 6077 d_print_mod_list (dpi, options, mods, 0); |
4673 | 6078 |
4674 if (need_paren) | 6079 if (need_paren) |
4675 d_append_char (dpi, ')'); | 6080 d_append_char (dpi, ')'); |
4676 } | 6081 } |
4677 | 6082 |
4679 d_append_char (dpi, ' '); | 6084 d_append_char (dpi, ' '); |
4680 | 6085 |
4681 d_append_char (dpi, '['); | 6086 d_append_char (dpi, '['); |
4682 | 6087 |
4683 if (d_left (dc) != NULL) | 6088 if (d_left (dc) != NULL) |
4684 d_print_comp (dpi, d_left (dc)); | 6089 d_print_comp (dpi, options, d_left (dc)); |
4685 | 6090 |
4686 d_append_char (dpi, ']'); | 6091 d_append_char (dpi, ']'); |
4687 } | 6092 } |
4688 | 6093 |
4689 /* Print an operator in an expression. */ | 6094 /* Print an operator in an expression. */ |
4690 | 6095 |
4691 static void | 6096 static void |
4692 d_print_expr_op (struct d_print_info *dpi, | 6097 d_print_expr_op (struct d_print_info *dpi, int options, |
4693 const struct demangle_component *dc) | 6098 struct demangle_component *dc) |
4694 { | 6099 { |
4695 if (dc->type == DEMANGLE_COMPONENT_OPERATOR) | 6100 if (dc->type == DEMANGLE_COMPONENT_OPERATOR) |
4696 d_append_buffer (dpi, dc->u.s_operator.op->name, | 6101 d_append_buffer (dpi, dc->u.s_operator.op->name, |
4697 dc->u.s_operator.op->len); | 6102 dc->u.s_operator.op->len); |
4698 else | 6103 else |
4699 d_print_comp (dpi, dc); | 6104 d_print_comp (dpi, options, dc); |
4700 } | 6105 } |
4701 | 6106 |
4702 /* Print a cast. */ | 6107 /* Print a cast. */ |
4703 | 6108 |
4704 static void | 6109 static void |
4705 d_print_cast (struct d_print_info *dpi, | 6110 d_print_cast (struct d_print_info *dpi, int options, |
4706 const struct demangle_component *dc) | 6111 struct demangle_component *dc) |
4707 { | 6112 { |
4708 if (d_left (dc)->type != DEMANGLE_COMPONENT_TEMPLATE) | 6113 d_print_comp (dpi, options, d_left (dc)); |
4709 d_print_comp (dpi, d_left (dc)); | 6114 } |
4710 else | 6115 |
4711 { | 6116 /* Print a conversion operator. */ |
4712 struct d_print_mod *hold_dpm; | 6117 |
4713 struct d_print_template dpt; | 6118 static void |
4714 | 6119 d_print_conversion (struct d_print_info *dpi, int options, |
4715 /* It appears that for a templated cast operator, we need to put | 6120 struct demangle_component *dc) |
4716 the template parameters in scope for the operator name, but | 6121 { |
4717 not for the parameters. The effect is that we need to handle | 6122 struct d_print_template dpt; |
4718 the template printing here. */ | 6123 |
4719 | 6124 /* For a conversion operator, we need the template parameters from |
4720 hold_dpm = dpi->modifiers; | 6125 the enclosing template in scope for processing the type. */ |
4721 dpi->modifiers = NULL; | 6126 if (dpi->current_template != NULL) |
4722 | 6127 { |
4723 dpt.next = dpi->templates; | 6128 dpt.next = dpi->templates; |
4724 dpi->templates = &dpt; | 6129 dpi->templates = &dpt; |
4725 dpt.template_decl = d_left (dc); | 6130 dpt.template_decl = dpi->current_template; |
4726 | 6131 } |
4727 d_print_comp (dpi, d_left (d_left (dc))); | 6132 |
4728 | 6133 if (d_left (dc)->type != DEMANGLE_COMPONENT_TEMPLATE) |
4729 dpi->templates = dpt.next; | 6134 { |
6135 d_print_comp (dpi, options, d_left (dc)); | |
6136 if (dpi->current_template != NULL) | |
6137 dpi->templates = dpt.next; | |
6138 } | |
6139 else | |
6140 { | |
6141 d_print_comp (dpi, options, d_left (d_left (dc))); | |
6142 | |
6143 /* For a templated cast operator, we need to remove the template | |
6144 parameters from scope after printing the operator name, | |
6145 so we need to handle the template printing here. */ | |
6146 if (dpi->current_template != NULL) | |
6147 dpi->templates = dpt.next; | |
4730 | 6148 |
4731 if (d_last_char (dpi) == '<') | 6149 if (d_last_char (dpi) == '<') |
4732 d_append_char (dpi, ' '); | 6150 d_append_char (dpi, ' '); |
4733 d_append_char (dpi, '<'); | 6151 d_append_char (dpi, '<'); |
4734 d_print_comp (dpi, d_right (d_left (dc))); | 6152 d_print_comp (dpi, options, d_right (d_left (dc))); |
4735 /* Avoid generating two consecutive '>' characters, to avoid | 6153 /* Avoid generating two consecutive '>' characters, to avoid |
4736 the C++ syntactic ambiguity. */ | 6154 the C++ syntactic ambiguity. */ |
4737 if (d_last_char (dpi) == '>') | 6155 if (d_last_char (dpi) == '>') |
4738 d_append_char (dpi, ' '); | 6156 d_append_char (dpi, ' '); |
4739 d_append_char (dpi, '>'); | 6157 d_append_char (dpi, '>'); |
4740 | |
4741 dpi->modifiers = hold_dpm; | |
4742 } | 6158 } |
4743 } | 6159 } |
4744 | 6160 |
4745 /* Initialize the information structure we use to pass around | 6161 /* Initialize the information structure we use to pass around |
4746 information. */ | 6162 information. */ |
4764 | 6180 |
4765 /* Similarly, we can not need more substitutions than there are | 6181 /* Similarly, we can not need more substitutions than there are |
4766 chars in the mangled string. */ | 6182 chars in the mangled string. */ |
4767 di->num_subs = len; | 6183 di->num_subs = len; |
4768 di->next_sub = 0; | 6184 di->next_sub = 0; |
4769 di->did_subs = 0; | |
4770 | 6185 |
4771 di->last_name = NULL; | 6186 di->last_name = NULL; |
4772 | 6187 |
4773 di->expansion = 0; | 6188 di->expansion = 0; |
6189 di->is_expression = 0; | |
6190 di->is_conversion = 0; | |
4774 } | 6191 } |
4775 | 6192 |
4776 /* Internal implementation for the demangler. If MANGLED is a g++ v3 ABI | 6193 /* Internal implementation for the demangler. If MANGLED is a g++ v3 ABI |
4777 mangled name, return strings in repeated callback giving the demangled | 6194 mangled name, return strings in repeated callback giving the demangled |
4778 name. OPTIONS is the usual libiberty demangler options. On success, | 6195 name. OPTIONS is the usual libiberty demangler options. On success, |
4839 : DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS), | 6256 : DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS), |
4840 d_make_demangle_mangled_name (&di, d_str (&di)), | 6257 d_make_demangle_mangled_name (&di, d_str (&di)), |
4841 NULL); | 6258 NULL); |
4842 d_advance (&di, strlen (d_str (&di))); | 6259 d_advance (&di, strlen (d_str (&di))); |
4843 break; | 6260 break; |
6261 default: | |
6262 abort (); /* We have listed all the cases. */ | |
4844 } | 6263 } |
4845 | 6264 |
4846 /* If DMGL_PARAMS is set, then if we didn't consume the entire | 6265 /* If DMGL_PARAMS is set, then if we didn't consume the entire |
4847 mangled string, then we didn't successfully demangle it. If | 6266 mangled string, then we didn't successfully demangle it. If |
4848 DMGL_PARAMS is not set, we didn't look at the trailing | 6267 DMGL_PARAMS is not set, we didn't look at the trailing |
5109 ret = 0; | 6528 ret = 0; |
5110 while (dc != NULL) | 6529 while (dc != NULL) |
5111 { | 6530 { |
5112 switch (dc->type) | 6531 switch (dc->type) |
5113 { | 6532 { |
6533 /* These cannot appear on a constructor or destructor. */ | |
6534 case DEMANGLE_COMPONENT_RESTRICT_THIS: | |
6535 case DEMANGLE_COMPONENT_VOLATILE_THIS: | |
6536 case DEMANGLE_COMPONENT_CONST_THIS: | |
6537 case DEMANGLE_COMPONENT_REFERENCE_THIS: | |
6538 case DEMANGLE_COMPONENT_RVALUE_REFERENCE_THIS: | |
5114 default: | 6539 default: |
5115 dc = NULL; | 6540 dc = NULL; |
5116 break; | 6541 break; |
5117 case DEMANGLE_COMPONENT_TYPED_NAME: | 6542 case DEMANGLE_COMPONENT_TYPED_NAME: |
5118 case DEMANGLE_COMPONENT_TEMPLATE: | 6543 case DEMANGLE_COMPONENT_TEMPLATE: |
5119 case DEMANGLE_COMPONENT_RESTRICT_THIS: | |
5120 case DEMANGLE_COMPONENT_VOLATILE_THIS: | |
5121 case DEMANGLE_COMPONENT_CONST_THIS: | |
5122 dc = d_left (dc); | 6544 dc = d_left (dc); |
5123 break; | 6545 break; |
5124 case DEMANGLE_COMPONENT_QUAL_NAME: | 6546 case DEMANGLE_COMPONENT_QUAL_NAME: |
5125 case DEMANGLE_COMPONENT_LOCAL_NAME: | 6547 case DEMANGLE_COMPONENT_LOCAL_NAME: |
5126 dc = d_right (dc); | 6548 dc = d_right (dc); |