OLD | NEW |
1 /* Demangler for g++ V3 ABI. | 1 /* Demangler for g++ V3 ABI. |
2 Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 | 2 Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 |
3 Free Software Foundation, Inc. | 3 Free Software Foundation, Inc. |
4 Written by Ian Lance Taylor <ian@wasabisystems.com>. | 4 Written by Ian Lance Taylor <ian@wasabisystems.com>. |
5 | 5 |
6 This file is part of the libiberty library, which is part of GCC. | 6 This file is part of the libiberty library, which is part of GCC. |
7 | 7 |
8 This file is free software; you can redistribute it and/or modify | 8 This file is free software; you can redistribute it and/or modify |
9 it under the terms of the GNU General Public License as published by | 9 it under the terms of the GNU General Public License as published by |
10 the Free Software Foundation; either version 2 of the License, or | 10 the Free Software Foundation; either version 2 of the License, or |
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 break; | 641 break; |
642 case DEMANGLE_COMPONENT_FIXED_TYPE: | 642 case DEMANGLE_COMPONENT_FIXED_TYPE: |
643 printf ("fixed-point type\n"); | 643 printf ("fixed-point type\n"); |
644 break; | 644 break; |
645 case DEMANGLE_COMPONENT_ARGLIST: | 645 case DEMANGLE_COMPONENT_ARGLIST: |
646 printf ("argument list\n"); | 646 printf ("argument list\n"); |
647 break; | 647 break; |
648 case DEMANGLE_COMPONENT_TEMPLATE_ARGLIST: | 648 case DEMANGLE_COMPONENT_TEMPLATE_ARGLIST: |
649 printf ("template argument list\n"); | 649 printf ("template argument list\n"); |
650 break; | 650 break; |
| 651 case DEMANGLE_COMPONENT_INITIALIZER_LIST: |
| 652 printf ("initializer list\n"); |
| 653 break; |
651 case DEMANGLE_COMPONENT_CAST: | 654 case DEMANGLE_COMPONENT_CAST: |
652 printf ("cast\n"); | 655 printf ("cast\n"); |
653 break; | 656 break; |
| 657 case DEMANGLE_COMPONENT_NULLARY: |
| 658 printf ("nullary operator\n"); |
| 659 break; |
654 case DEMANGLE_COMPONENT_UNARY: | 660 case DEMANGLE_COMPONENT_UNARY: |
655 printf ("unary operator\n"); | 661 printf ("unary operator\n"); |
656 break; | 662 break; |
657 case DEMANGLE_COMPONENT_BINARY: | 663 case DEMANGLE_COMPONENT_BINARY: |
658 printf ("binary operator\n"); | 664 printf ("binary operator\n"); |
659 break; | 665 break; |
660 case DEMANGLE_COMPONENT_BINARY_ARGS: | 666 case DEMANGLE_COMPONENT_BINARY_ARGS: |
661 printf ("binary operator arguments\n"); | 667 printf ("binary operator arguments\n"); |
662 break; | 668 break; |
663 case DEMANGLE_COMPONENT_TRINARY: | 669 case DEMANGLE_COMPONENT_TRINARY: |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
799 case DEMANGLE_COMPONENT_TYPED_NAME: | 805 case DEMANGLE_COMPONENT_TYPED_NAME: |
800 case DEMANGLE_COMPONENT_TEMPLATE: | 806 case DEMANGLE_COMPONENT_TEMPLATE: |
801 case DEMANGLE_COMPONENT_CONSTRUCTION_VTABLE: | 807 case DEMANGLE_COMPONENT_CONSTRUCTION_VTABLE: |
802 case DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL: | 808 case DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL: |
803 case DEMANGLE_COMPONENT_PTRMEM_TYPE: | 809 case DEMANGLE_COMPONENT_PTRMEM_TYPE: |
804 case DEMANGLE_COMPONENT_UNARY: | 810 case DEMANGLE_COMPONENT_UNARY: |
805 case DEMANGLE_COMPONENT_BINARY: | 811 case DEMANGLE_COMPONENT_BINARY: |
806 case DEMANGLE_COMPONENT_BINARY_ARGS: | 812 case DEMANGLE_COMPONENT_BINARY_ARGS: |
807 case DEMANGLE_COMPONENT_TRINARY: | 813 case DEMANGLE_COMPONENT_TRINARY: |
808 case DEMANGLE_COMPONENT_TRINARY_ARG1: | 814 case DEMANGLE_COMPONENT_TRINARY_ARG1: |
809 case DEMANGLE_COMPONENT_TRINARY_ARG2: | |
810 case DEMANGLE_COMPONENT_LITERAL: | 815 case DEMANGLE_COMPONENT_LITERAL: |
811 case DEMANGLE_COMPONENT_LITERAL_NEG: | 816 case DEMANGLE_COMPONENT_LITERAL_NEG: |
812 case DEMANGLE_COMPONENT_COMPOUND_NAME: | 817 case DEMANGLE_COMPONENT_COMPOUND_NAME: |
813 case DEMANGLE_COMPONENT_VECTOR_TYPE: | 818 case DEMANGLE_COMPONENT_VECTOR_TYPE: |
814 case DEMANGLE_COMPONENT_CLONE: | 819 case DEMANGLE_COMPONENT_CLONE: |
815 if (left == NULL || right == NULL) | 820 if (left == NULL || right == NULL) |
816 return NULL; | 821 return NULL; |
817 break; | 822 break; |
818 | 823 |
819 /* These types only require one parameter. */ | 824 /* These types only require one parameter. */ |
(...skipping 16 matching lines...) Expand all Loading... |
836 case DEMANGLE_COMPONENT_RVALUE_REFERENCE: | 841 case DEMANGLE_COMPONENT_RVALUE_REFERENCE: |
837 case DEMANGLE_COMPONENT_COMPLEX: | 842 case DEMANGLE_COMPONENT_COMPLEX: |
838 case DEMANGLE_COMPONENT_IMAGINARY: | 843 case DEMANGLE_COMPONENT_IMAGINARY: |
839 case DEMANGLE_COMPONENT_VENDOR_TYPE: | 844 case DEMANGLE_COMPONENT_VENDOR_TYPE: |
840 case DEMANGLE_COMPONENT_CAST: | 845 case DEMANGLE_COMPONENT_CAST: |
841 case DEMANGLE_COMPONENT_JAVA_RESOURCE: | 846 case DEMANGLE_COMPONENT_JAVA_RESOURCE: |
842 case DEMANGLE_COMPONENT_DECLTYPE: | 847 case DEMANGLE_COMPONENT_DECLTYPE: |
843 case DEMANGLE_COMPONENT_PACK_EXPANSION: | 848 case DEMANGLE_COMPONENT_PACK_EXPANSION: |
844 case DEMANGLE_COMPONENT_GLOBAL_CONSTRUCTORS: | 849 case DEMANGLE_COMPONENT_GLOBAL_CONSTRUCTORS: |
845 case DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS: | 850 case DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS: |
| 851 case DEMANGLE_COMPONENT_NULLARY: |
| 852 case DEMANGLE_COMPONENT_TRINARY_ARG2: |
846 if (left == NULL) | 853 if (left == NULL) |
847 return NULL; | 854 return NULL; |
848 break; | 855 break; |
849 | 856 |
850 /* This needs a right parameter, but the left parameter can be | 857 /* This needs a right parameter, but the left parameter can be |
851 empty. */ | 858 empty. */ |
852 case DEMANGLE_COMPONENT_ARRAY_TYPE: | 859 case DEMANGLE_COMPONENT_ARRAY_TYPE: |
| 860 case DEMANGLE_COMPONENT_INITIALIZER_LIST: |
853 if (right == NULL) | 861 if (right == NULL) |
854 return NULL; | 862 return NULL; |
855 break; | 863 break; |
856 | 864 |
857 /* These are allowed to have no parameters--in some cases they | 865 /* These are allowed to have no parameters--in some cases they |
858 will be filled in later. */ | 866 will be filled in later. */ |
859 case DEMANGLE_COMPONENT_FUNCTION_TYPE: | 867 case DEMANGLE_COMPONENT_FUNCTION_TYPE: |
860 case DEMANGLE_COMPONENT_RESTRICT: | 868 case DEMANGLE_COMPONENT_RESTRICT: |
861 case DEMANGLE_COMPONENT_VOLATILE: | 869 case DEMANGLE_COMPONENT_VOLATILE: |
862 case DEMANGLE_COMPONENT_CONST: | 870 case DEMANGLE_COMPONENT_CONST: |
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1404 | 1412 |
1405 peek = d_peek_char (di); | 1413 peek = d_peek_char (di); |
1406 if (IS_DIGIT (peek)) | 1414 if (IS_DIGIT (peek)) |
1407 return d_source_name (di); | 1415 return d_source_name (di); |
1408 else if (IS_LOWER (peek)) | 1416 else if (IS_LOWER (peek)) |
1409 { | 1417 { |
1410 struct demangle_component *ret; | 1418 struct demangle_component *ret; |
1411 | 1419 |
1412 ret = d_operator_name (di); | 1420 ret = d_operator_name (di); |
1413 if (ret != NULL && ret->type == DEMANGLE_COMPONENT_OPERATOR) | 1421 if (ret != NULL && ret->type == DEMANGLE_COMPONENT_OPERATOR) |
1414 » di->expansion += sizeof "operator" + ret->u.s_operator.op->len - 2; | 1422 » { |
| 1423 » di->expansion += sizeof "operator" + ret->u.s_operator.op->len - 2; |
| 1424 » if (!strcmp (ret->u.s_operator.op->code, "li")) |
| 1425 » ret = d_make_comp (di, DEMANGLE_COMPONENT_UNARY, ret, |
| 1426 » » » d_source_name (di)); |
| 1427 » } |
1415 return ret; | 1428 return ret; |
1416 } | 1429 } |
1417 else if (peek == 'C' || peek == 'D') | 1430 else if (peek == 'C' || peek == 'D') |
1418 return d_ctor_dtor_name (di); | 1431 return d_ctor_dtor_name (di); |
1419 else if (peek == 'L') | 1432 else if (peek == 'L') |
1420 { | 1433 { |
1421 struct demangle_component * ret; | 1434 struct demangle_component * ret; |
1422 | 1435 |
1423 d_advance (di, 1); | 1436 d_advance (di, 1); |
1424 | 1437 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1547 sizeof "(anonymous namespace)" - 1); | 1560 sizeof "(anonymous namespace)" - 1); |
1548 } | 1561 } |
1549 } | 1562 } |
1550 | 1563 |
1551 return d_make_name (di, name, len); | 1564 return d_make_name (di, name, len); |
1552 } | 1565 } |
1553 | 1566 |
1554 /* operator_name ::= many different two character encodings. | 1567 /* operator_name ::= many different two character encodings. |
1555 ::= cv <type> | 1568 ::= cv <type> |
1556 ::= v <digit> <source-name> | 1569 ::= v <digit> <source-name> |
1557 */ | 1570 |
| 1571 This list is sorted for binary search. */ |
1558 | 1572 |
1559 #define NL(s) s, (sizeof s) - 1 | 1573 #define NL(s) s, (sizeof s) - 1 |
1560 | 1574 |
1561 CP_STATIC_IF_GLIBCPP_V3 | 1575 CP_STATIC_IF_GLIBCPP_V3 |
1562 const struct demangle_operator_info cplus_demangle_operators[] = | 1576 const struct demangle_operator_info cplus_demangle_operators[] = |
1563 { | 1577 { |
1564 { "aN", NL ("&="), 2 }, | 1578 { "aN", NL ("&="), 2 }, |
1565 { "aS", NL ("="), 2 }, | 1579 { "aS", NL ("="), 2 }, |
1566 { "aa", NL ("&&"), 2 }, | 1580 { "aa", NL ("&&"), 2 }, |
1567 { "ad", NL ("&"), 1 }, | 1581 { "ad", NL ("&"), 1 }, |
1568 { "an", NL ("&"), 2 }, | 1582 { "an", NL ("&"), 2 }, |
| 1583 { "at", NL ("alignof "), 1 }, |
| 1584 { "az", NL ("alignof "), 1 }, |
1569 { "cl", NL ("()"), 2 }, | 1585 { "cl", NL ("()"), 2 }, |
1570 { "cm", NL (","), 2 }, | 1586 { "cm", NL (","), 2 }, |
1571 { "co", NL ("~"), 1 }, | 1587 { "co", NL ("~"), 1 }, |
1572 { "dV", NL ("/="), 2 }, | 1588 { "dV", NL ("/="), 2 }, |
1573 { "da", NL ("delete[]"), 1 }, | 1589 { "da", NL ("delete[] "), 1 }, |
1574 { "de", NL ("*"), 1 }, | 1590 { "de", NL ("*"), 1 }, |
1575 { "dl", NL ("delete"), 1 }, | 1591 { "dl", NL ("delete "), 1 }, |
| 1592 { "ds", NL (".*"), 2 }, |
1576 { "dt", NL ("."), 2 }, | 1593 { "dt", NL ("."), 2 }, |
1577 { "dv", NL ("/"), 2 }, | 1594 { "dv", NL ("/"), 2 }, |
1578 { "eO", NL ("^="), 2 }, | 1595 { "eO", NL ("^="), 2 }, |
1579 { "eo", NL ("^"), 2 }, | 1596 { "eo", NL ("^"), 2 }, |
1580 { "eq", NL ("=="), 2 }, | 1597 { "eq", NL ("=="), 2 }, |
1581 { "ge", NL (">="), 2 }, | 1598 { "ge", NL (">="), 2 }, |
| 1599 { "gs", NL ("::"), 1 }, |
1582 { "gt", NL (">"), 2 }, | 1600 { "gt", NL (">"), 2 }, |
1583 { "ix", NL ("[]"), 2 }, | 1601 { "ix", NL ("[]"), 2 }, |
1584 { "lS", NL ("<<="), 2 }, | 1602 { "lS", NL ("<<="), 2 }, |
1585 { "le", NL ("<="), 2 }, | 1603 { "le", NL ("<="), 2 }, |
| 1604 { "li", NL ("operator\"\" "), 1 }, |
1586 { "ls", NL ("<<"), 2 }, | 1605 { "ls", NL ("<<"), 2 }, |
1587 { "lt", NL ("<"), 2 }, | 1606 { "lt", NL ("<"), 2 }, |
1588 { "mI", NL ("-="), 2 }, | 1607 { "mI", NL ("-="), 2 }, |
1589 { "mL", NL ("*="), 2 }, | 1608 { "mL", NL ("*="), 2 }, |
1590 { "mi", NL ("-"), 2 }, | 1609 { "mi", NL ("-"), 2 }, |
1591 { "ml", NL ("*"), 2 }, | 1610 { "ml", NL ("*"), 2 }, |
1592 { "mm", NL ("--"), 1 }, | 1611 { "mm", NL ("--"), 1 }, |
1593 { "na", NL ("new[]"), 1 }, | 1612 { "na", NL ("new[]"), 3 }, |
1594 { "ne", NL ("!="), 2 }, | 1613 { "ne", NL ("!="), 2 }, |
1595 { "ng", NL ("-"), 1 }, | 1614 { "ng", NL ("-"), 1 }, |
1596 { "nt", NL ("!"), 1 }, | 1615 { "nt", NL ("!"), 1 }, |
1597 { "nw", NL ("new"), 1 }, | 1616 { "nw", NL ("new"), 3 }, |
1598 { "oR", NL ("|="), 2 }, | 1617 { "oR", NL ("|="), 2 }, |
1599 { "oo", NL ("||"), 2 }, | 1618 { "oo", NL ("||"), 2 }, |
1600 { "or", NL ("|"), 2 }, | 1619 { "or", NL ("|"), 2 }, |
1601 { "pL", NL ("+="), 2 }, | 1620 { "pL", NL ("+="), 2 }, |
1602 { "pl", NL ("+"), 2 }, | 1621 { "pl", NL ("+"), 2 }, |
1603 { "pm", NL ("->*"), 2 }, | 1622 { "pm", NL ("->*"), 2 }, |
1604 { "pp", NL ("++"), 1 }, | 1623 { "pp", NL ("++"), 1 }, |
1605 { "ps", NL ("+"), 1 }, | 1624 { "ps", NL ("+"), 1 }, |
1606 { "pt", NL ("->"), 2 }, | 1625 { "pt", NL ("->"), 2 }, |
1607 { "qu", NL ("?"), 3 }, | 1626 { "qu", NL ("?"), 3 }, |
1608 { "rM", NL ("%="), 2 }, | 1627 { "rM", NL ("%="), 2 }, |
1609 { "rS", NL (">>="), 2 }, | 1628 { "rS", NL (">>="), 2 }, |
1610 { "rm", NL ("%"), 2 }, | 1629 { "rm", NL ("%"), 2 }, |
1611 { "rs", NL (">>"), 2 }, | 1630 { "rs", NL (">>"), 2 }, |
1612 { "st", NL ("sizeof "), 1 }, | 1631 { "st", NL ("sizeof "), 1 }, |
1613 { "sz", NL ("sizeof "), 1 }, | 1632 { "sz", NL ("sizeof "), 1 }, |
1614 { "at", NL ("alignof "), 1 }, | 1633 { "tr", NL ("throw"), 0 }, |
1615 { "az", NL ("alignof "), 1 }, | 1634 { "tw", NL ("throw "), 1 }, |
1616 { NULL, NULL, 0, 0 } | 1635 { NULL, NULL, 0, 0 } |
1617 }; | 1636 }; |
1618 | 1637 |
1619 static struct demangle_component * | 1638 static struct demangle_component * |
1620 d_operator_name (struct d_info *di) | 1639 d_operator_name (struct d_info *di) |
1621 { | 1640 { |
1622 char c1; | 1641 char c1; |
1623 char c2; | 1642 char c2; |
1624 | 1643 |
1625 c1 = d_next_char (di); | 1644 c1 = d_next_char (di); |
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2235 peek = d_next_char (di); | 2254 peek = d_next_char (di); |
2236 switch (peek) | 2255 switch (peek) |
2237 { | 2256 { |
2238 case 'T': | 2257 case 'T': |
2239 case 't': | 2258 case 't': |
2240 /* decltype (expression) */ | 2259 /* decltype (expression) */ |
2241 ret = d_make_comp (di, DEMANGLE_COMPONENT_DECLTYPE, | 2260 ret = d_make_comp (di, DEMANGLE_COMPONENT_DECLTYPE, |
2242 d_expression (di), NULL); | 2261 d_expression (di), NULL); |
2243 if (ret && d_next_char (di) != 'E') | 2262 if (ret && d_next_char (di) != 'E') |
2244 ret = NULL; | 2263 ret = NULL; |
| 2264 can_subst = 1; |
2245 break; | 2265 break; |
2246 | 2266 |
2247 case 'p': | 2267 case 'p': |
2248 /* Pack expansion. */ | 2268 /* Pack expansion. */ |
2249 ret = d_make_comp (di, DEMANGLE_COMPONENT_PACK_EXPANSION, | 2269 ret = d_make_comp (di, DEMANGLE_COMPONENT_PACK_EXPANSION, |
2250 cplus_demangle_type (di), NULL); | 2270 cplus_demangle_type (di), NULL); |
| 2271 can_subst = 1; |
| 2272 break; |
| 2273 |
| 2274 case 'a': |
| 2275 /* auto */ |
| 2276 ret = d_make_name (di, "auto", 4); |
2251 break; | 2277 break; |
2252 | 2278 |
2253 case 'f': | 2279 case 'f': |
2254 /* 32-bit decimal floating point */ | 2280 /* 32-bit decimal floating point */ |
2255 ret = d_make_builtin_type (di, &cplus_demangle_builtin_types[26]); | 2281 ret = d_make_builtin_type (di, &cplus_demangle_builtin_types[26]); |
2256 di->expansion += ret->u.s_builtin.type->len; | 2282 di->expansion += ret->u.s_builtin.type->len; |
2257 break; | 2283 break; |
2258 case 'd': | 2284 case 'd': |
2259 /* 64-bit DFP */ | 2285 /* 64-bit DFP */ |
2260 ret = d_make_builtin_type (di, &cplus_demangle_builtin_types[27]); | 2286 ret = d_make_builtin_type (di, &cplus_demangle_builtin_types[27]); |
(...skipping 30 matching lines...) Expand all Loading... |
2291 ret->u.s_fixed.length = cplus_demangle_type (di); | 2317 ret->u.s_fixed.length = cplus_demangle_type (di); |
2292 if (ret->u.s_fixed.length == NULL) | 2318 if (ret->u.s_fixed.length == NULL) |
2293 return NULL; | 2319 return NULL; |
2294 d_number (di); | 2320 d_number (di); |
2295 peek = d_next_char (di); | 2321 peek = d_next_char (di); |
2296 ret->u.s_fixed.sat = (peek == 's'); | 2322 ret->u.s_fixed.sat = (peek == 's'); |
2297 break; | 2323 break; |
2298 | 2324 |
2299 case 'v': | 2325 case 'v': |
2300 ret = d_vector_type (di); | 2326 ret = d_vector_type (di); |
| 2327 can_subst = 1; |
2301 break; | 2328 break; |
2302 | 2329 |
2303 case 'n': | 2330 case 'n': |
2304 /* decltype(nullptr) */ | 2331 /* decltype(nullptr) */ |
2305 ret = d_make_builtin_type (di, &cplus_demangle_builtin_types[32]); | 2332 ret = d_make_builtin_type (di, &cplus_demangle_builtin_types[32]); |
2306 di->expansion += ret->u.s_builtin.type->len; | 2333 di->expansion += ret->u.s_builtin.type->len; |
2307 break; | 2334 break; |
2308 | 2335 |
2309 default: | 2336 default: |
2310 return NULL; | 2337 return NULL; |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2668 { | 2695 { |
2669 struct demangle_component *hold_last_name; | 2696 struct demangle_component *hold_last_name; |
2670 struct demangle_component *al; | 2697 struct demangle_component *al; |
2671 struct demangle_component **pal; | 2698 struct demangle_component **pal; |
2672 | 2699 |
2673 /* Preserve the last name we saw--don't let the template arguments | 2700 /* Preserve the last name we saw--don't let the template arguments |
2674 clobber it, as that would give us the wrong name for a subsequent | 2701 clobber it, as that would give us the wrong name for a subsequent |
2675 constructor or destructor. */ | 2702 constructor or destructor. */ |
2676 hold_last_name = di->last_name; | 2703 hold_last_name = di->last_name; |
2677 | 2704 |
2678 if (! d_check_char (di, 'I')) | 2705 if (d_peek_char (di) != 'I' |
| 2706 && d_peek_char (di) != 'J') |
2679 return NULL; | 2707 return NULL; |
| 2708 d_advance (di, 1); |
2680 | 2709 |
2681 if (d_peek_char (di) == 'E') | 2710 if (d_peek_char (di) == 'E') |
2682 { | 2711 { |
2683 /* An argument pack can be empty. */ | 2712 /* An argument pack can be empty. */ |
2684 d_advance (di, 1); | 2713 d_advance (di, 1); |
2685 return d_make_comp (di, DEMANGLE_COMPONENT_TEMPLATE_ARGLIST, NULL, NULL); | 2714 return d_make_comp (di, DEMANGLE_COMPONENT_TEMPLATE_ARGLIST, NULL, NULL); |
2686 } | 2715 } |
2687 | 2716 |
2688 al = NULL; | 2717 al = NULL; |
2689 pal = &al; | 2718 pal = &al; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2728 d_advance (di, 1); | 2757 d_advance (di, 1); |
2729 ret = d_expression (di); | 2758 ret = d_expression (di); |
2730 if (! d_check_char (di, 'E')) | 2759 if (! d_check_char (di, 'E')) |
2731 return NULL; | 2760 return NULL; |
2732 return ret; | 2761 return ret; |
2733 | 2762 |
2734 case 'L': | 2763 case 'L': |
2735 return d_expr_primary (di); | 2764 return d_expr_primary (di); |
2736 | 2765 |
2737 case 'I': | 2766 case 'I': |
| 2767 case 'J': |
2738 /* An argument pack. */ | 2768 /* An argument pack. */ |
2739 return d_template_args (di); | 2769 return d_template_args (di); |
2740 | 2770 |
2741 default: | 2771 default: |
2742 return cplus_demangle_type (di); | 2772 return cplus_demangle_type (di); |
2743 } | 2773 } |
2744 } | 2774 } |
2745 | 2775 |
2746 /* Subroutine of <expression> ::= cl <expression>+ E */ | 2776 /* Parse a sequence of expressions until we hit the terminator |
| 2777 character. */ |
2747 | 2778 |
2748 static struct demangle_component * | 2779 static struct demangle_component * |
2749 d_exprlist (struct d_info *di) | 2780 d_exprlist (struct d_info *di, char terminator) |
2750 { | 2781 { |
2751 struct demangle_component *list = NULL; | 2782 struct demangle_component *list = NULL; |
2752 struct demangle_component **p = &list; | 2783 struct demangle_component **p = &list; |
2753 | 2784 |
2754 if (d_peek_char (di) == 'E') | 2785 if (d_peek_char (di) == terminator) |
2755 { | 2786 { |
2756 d_advance (di, 1); | 2787 d_advance (di, 1); |
2757 return d_make_comp (di, DEMANGLE_COMPONENT_ARGLIST, NULL, NULL); | 2788 return d_make_comp (di, DEMANGLE_COMPONENT_ARGLIST, NULL, NULL); |
2758 } | 2789 } |
2759 | 2790 |
2760 while (1) | 2791 while (1) |
2761 { | 2792 { |
2762 struct demangle_component *arg = d_expression (di); | 2793 struct demangle_component *arg = d_expression (di); |
2763 if (arg == NULL) | 2794 if (arg == NULL) |
2764 return NULL; | 2795 return NULL; |
2765 | 2796 |
2766 *p = d_make_comp (di, DEMANGLE_COMPONENT_ARGLIST, arg, NULL); | 2797 *p = d_make_comp (di, DEMANGLE_COMPONENT_ARGLIST, arg, NULL); |
2767 if (*p == NULL) | 2798 if (*p == NULL) |
2768 return NULL; | 2799 return NULL; |
2769 p = &d_right (*p); | 2800 p = &d_right (*p); |
2770 | 2801 |
2771 if (d_peek_char (di) == 'E') | 2802 if (d_peek_char (di) == terminator) |
2772 { | 2803 { |
2773 d_advance (di, 1); | 2804 d_advance (di, 1); |
2774 break; | 2805 break; |
2775 } | 2806 } |
2776 } | 2807 } |
2777 | 2808 |
2778 return list; | 2809 return list; |
2779 } | 2810 } |
2780 | 2811 |
2781 /* <expression> ::= <(unary) operator-name> <expression> | 2812 /* <expression> ::= <(unary) operator-name> <expression> |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2852 | 2883 |
2853 name = d_unqualified_name (di); | 2884 name = d_unqualified_name (di); |
2854 if (name == NULL) | 2885 if (name == NULL) |
2855 return NULL; | 2886 return NULL; |
2856 if (d_peek_char (di) == 'I') | 2887 if (d_peek_char (di) == 'I') |
2857 return d_make_comp (di, DEMANGLE_COMPONENT_TEMPLATE, name, | 2888 return d_make_comp (di, DEMANGLE_COMPONENT_TEMPLATE, name, |
2858 d_template_args (di)); | 2889 d_template_args (di)); |
2859 else | 2890 else |
2860 return name; | 2891 return name; |
2861 } | 2892 } |
| 2893 else if ((peek == 'i' || peek == 't') |
| 2894 && d_peek_next_char (di) == 'l') |
| 2895 { |
| 2896 /* Brace-enclosed initializer list, untyped or typed. */ |
| 2897 struct demangle_component *type = NULL; |
| 2898 if (peek == 't') |
| 2899 type = cplus_demangle_type (di); |
| 2900 d_advance (di, 2); |
| 2901 return d_make_comp (di, DEMANGLE_COMPONENT_INITIALIZER_LIST, |
| 2902 type, d_exprlist (di, 'E')); |
| 2903 } |
2862 else | 2904 else |
2863 { | 2905 { |
2864 struct demangle_component *op; | 2906 struct demangle_component *op; |
| 2907 const char *code = NULL; |
2865 int args; | 2908 int args; |
2866 | 2909 |
2867 op = d_operator_name (di); | 2910 op = d_operator_name (di); |
2868 if (op == NULL) | 2911 if (op == NULL) |
2869 return NULL; | 2912 return NULL; |
2870 | 2913 |
2871 if (op->type == DEMANGLE_COMPONENT_OPERATOR) | 2914 if (op->type == DEMANGLE_COMPONENT_OPERATOR) |
2872 » di->expansion += op->u.s_operator.op->len - 2; | 2915 » { |
2873 | 2916 » code = op->u.s_operator.op->code; |
2874 if (op->type == DEMANGLE_COMPONENT_OPERATOR | 2917 » di->expansion += op->u.s_operator.op->len - 2; |
2875 » && strcmp (op->u.s_operator.op->code, "st") == 0) | 2918 » if (strcmp (code, "st") == 0) |
2876 » return d_make_comp (di, DEMANGLE_COMPONENT_UNARY, op, | 2919 » return d_make_comp (di, DEMANGLE_COMPONENT_UNARY, op, |
2877 » » » cplus_demangle_type (di)); | 2920 » » » » cplus_demangle_type (di)); |
| 2921 » } |
2878 | 2922 |
2879 switch (op->type) | 2923 switch (op->type) |
2880 { | 2924 { |
2881 default: | 2925 default: |
2882 return NULL; | 2926 return NULL; |
2883 case DEMANGLE_COMPONENT_OPERATOR: | 2927 case DEMANGLE_COMPONENT_OPERATOR: |
2884 args = op->u.s_operator.op->args; | 2928 args = op->u.s_operator.op->args; |
2885 break; | 2929 break; |
2886 case DEMANGLE_COMPONENT_EXTENDED_OPERATOR: | 2930 case DEMANGLE_COMPONENT_EXTENDED_OPERATOR: |
2887 args = op->u.s_extended_operator.args; | 2931 args = op->u.s_extended_operator.args; |
2888 break; | 2932 break; |
2889 case DEMANGLE_COMPONENT_CAST: | 2933 case DEMANGLE_COMPONENT_CAST: |
2890 args = 1; | 2934 args = 1; |
2891 break; | 2935 break; |
2892 } | 2936 } |
2893 | 2937 |
2894 switch (args) | 2938 switch (args) |
2895 { | 2939 { |
| 2940 case 0: |
| 2941 return d_make_comp (di, DEMANGLE_COMPONENT_NULLARY, op, NULL); |
| 2942 |
2896 case 1: | 2943 case 1: |
2897 { | 2944 { |
2898 struct demangle_component *operand; | 2945 struct demangle_component *operand; |
| 2946 int suffix = 0; |
| 2947 |
| 2948 if (code && (code[0] == 'p' || code[0] == 'm') |
| 2949 && code[1] == code[0]) |
| 2950 /* pp_ and mm_ are the prefix variants. */ |
| 2951 suffix = !d_check_char (di, '_'); |
| 2952 |
2899 if (op->type == DEMANGLE_COMPONENT_CAST | 2953 if (op->type == DEMANGLE_COMPONENT_CAST |
2900 && d_check_char (di, '_')) | 2954 && d_check_char (di, '_')) |
2901 » operand = d_exprlist (di); | 2955 » operand = d_exprlist (di, 'E'); |
2902 else | 2956 else |
2903 operand = d_expression (di); | 2957 operand = d_expression (di); |
2904 » return d_make_comp (di, DEMANGLE_COMPONENT_UNARY, op, | 2958 |
2905 » » » » operand); | 2959 » if (suffix) |
| 2960 » /* Indicate the suffix variant for d_print_comp. */ |
| 2961 » return d_make_comp (di, DEMANGLE_COMPONENT_UNARY, op, |
| 2962 » » » » d_make_comp (di, |
| 2963 » » » » » DEMANGLE_COMPONENT_BINARY_ARGS, |
| 2964 » » » » » operand, operand)); |
| 2965 » else |
| 2966 » return d_make_comp (di, DEMANGLE_COMPONENT_UNARY, op, |
| 2967 » » » » operand); |
2906 } | 2968 } |
2907 case 2: | 2969 case 2: |
2908 { | 2970 { |
2909 struct demangle_component *left; | 2971 struct demangle_component *left; |
2910 struct demangle_component *right; | 2972 struct demangle_component *right; |
2911 const char *code = op->u.s_operator.op->code; | |
2912 | 2973 |
2913 left = d_expression (di); | 2974 left = d_expression (di); |
2914 if (!strcmp (code, "cl")) | 2975 if (!strcmp (code, "cl")) |
2915 » right = d_exprlist (di); | 2976 » right = d_exprlist (di, 'E'); |
2916 else if (!strcmp (code, "dt") || !strcmp (code, "pt")) | 2977 else if (!strcmp (code, "dt") || !strcmp (code, "pt")) |
2917 { | 2978 { |
2918 right = d_unqualified_name (di); | 2979 right = d_unqualified_name (di); |
2919 if (d_peek_char (di) == 'I') | 2980 if (d_peek_char (di) == 'I') |
2920 right = d_make_comp (di, DEMANGLE_COMPONENT_TEMPLATE, | 2981 right = d_make_comp (di, DEMANGLE_COMPONENT_TEMPLATE, |
2921 right, d_template_args (di)); | 2982 right, d_template_args (di)); |
2922 } | 2983 } |
2923 else | 2984 else |
2924 right = d_expression (di); | 2985 right = d_expression (di); |
2925 | 2986 |
2926 return d_make_comp (di, DEMANGLE_COMPONENT_BINARY, op, | 2987 return d_make_comp (di, DEMANGLE_COMPONENT_BINARY, op, |
2927 d_make_comp (di, | 2988 d_make_comp (di, |
2928 DEMANGLE_COMPONENT_BINARY_ARGS, | 2989 DEMANGLE_COMPONENT_BINARY_ARGS, |
2929 left, right)); | 2990 left, right)); |
2930 } | 2991 } |
2931 case 3: | 2992 case 3: |
2932 { | 2993 { |
2933 struct demangle_component *first; | 2994 struct demangle_component *first; |
2934 struct demangle_component *second; | 2995 struct demangle_component *second; |
| 2996 struct demangle_component *third; |
2935 | 2997 |
2936 » first = d_expression (di); | 2998 » if (!strcmp (code, "qu")) |
2937 » second = d_expression (di); | 2999 » { |
| 3000 » » /* ?: expression. */ |
| 3001 » » first = d_expression (di); |
| 3002 » » second = d_expression (di); |
| 3003 » » third = d_expression (di); |
| 3004 » } |
| 3005 » else if (code[0] == 'n') |
| 3006 » { |
| 3007 » » /* new-expression. */ |
| 3008 » » if (code[1] != 'w' && code[1] != 'a') |
| 3009 » » return NULL; |
| 3010 » » first = d_exprlist (di, '_'); |
| 3011 » » second = cplus_demangle_type (di); |
| 3012 » » if (d_peek_char (di) == 'E') |
| 3013 » » { |
| 3014 » » d_advance (di, 1); |
| 3015 » » third = NULL; |
| 3016 » » } |
| 3017 » » else if (d_peek_char (di) == 'p' |
| 3018 » » » && d_peek_next_char (di) == 'i') |
| 3019 » » { |
| 3020 » » /* Parenthesized initializer. */ |
| 3021 » » d_advance (di, 2); |
| 3022 » » third = d_exprlist (di, 'E'); |
| 3023 » » } |
| 3024 » » else if (d_peek_char (di) == 'i' |
| 3025 » » » && d_peek_next_char (di) == 'l') |
| 3026 » » /* initializer-list. */ |
| 3027 » » third = d_expression (di); |
| 3028 » » else |
| 3029 » » return NULL; |
| 3030 » } |
| 3031 » else |
| 3032 » return NULL; |
2938 return d_make_comp (di, DEMANGLE_COMPONENT_TRINARY, op, | 3033 return d_make_comp (di, DEMANGLE_COMPONENT_TRINARY, op, |
2939 d_make_comp (di, | 3034 d_make_comp (di, |
2940 DEMANGLE_COMPONENT_TRINARY_ARG1, | 3035 DEMANGLE_COMPONENT_TRINARY_ARG1, |
2941 first, | 3036 first, |
2942 d_make_comp (di, | 3037 d_make_comp (di, |
2943 DEMANGLE_COMPONENT_TRI
NARY_ARG2, | 3038 DEMANGLE_COMPONENT_TRI
NARY_ARG2, |
2944 » » » » » » » second, | 3039 » » » » » » » second, third))); |
2945 » » » » » » » d_expression (di)))); | |
2946 } | 3040 } |
2947 default: | 3041 default: |
2948 return NULL; | 3042 return NULL; |
2949 } | 3043 } |
2950 } | 3044 } |
2951 } | 3045 } |
2952 | 3046 |
2953 /* <expr-primary> ::= L <type> <(value) number> E | 3047 /* <expr-primary> ::= L <type> <(value) number> E |
2954 ::= L <type> <(value) float> E | 3048 ::= L <type> <(value) float> E |
2955 ::= L <mangled-name> E | 3049 ::= L <mangled-name> E |
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3614 case DEMANGLE_COMPONENT_PACK_EXPANSION: | 3708 case DEMANGLE_COMPONENT_PACK_EXPANSION: |
3615 return NULL; | 3709 return NULL; |
3616 | 3710 |
3617 case DEMANGLE_COMPONENT_LAMBDA: | 3711 case DEMANGLE_COMPONENT_LAMBDA: |
3618 case DEMANGLE_COMPONENT_NAME: | 3712 case DEMANGLE_COMPONENT_NAME: |
3619 case DEMANGLE_COMPONENT_OPERATOR: | 3713 case DEMANGLE_COMPONENT_OPERATOR: |
3620 case DEMANGLE_COMPONENT_BUILTIN_TYPE: | 3714 case DEMANGLE_COMPONENT_BUILTIN_TYPE: |
3621 case DEMANGLE_COMPONENT_SUB_STD: | 3715 case DEMANGLE_COMPONENT_SUB_STD: |
3622 case DEMANGLE_COMPONENT_CHARACTER: | 3716 case DEMANGLE_COMPONENT_CHARACTER: |
3623 case DEMANGLE_COMPONENT_FUNCTION_PARAM: | 3717 case DEMANGLE_COMPONENT_FUNCTION_PARAM: |
| 3718 case DEMANGLE_COMPONENT_UNNAMED_TYPE: |
3624 return NULL; | 3719 return NULL; |
3625 | 3720 |
3626 case DEMANGLE_COMPONENT_EXTENDED_OPERATOR: | 3721 case DEMANGLE_COMPONENT_EXTENDED_OPERATOR: |
3627 return d_find_pack (dpi, dc->u.s_extended_operator.name); | 3722 return d_find_pack (dpi, dc->u.s_extended_operator.name); |
3628 case DEMANGLE_COMPONENT_CTOR: | 3723 case DEMANGLE_COMPONENT_CTOR: |
3629 return d_find_pack (dpi, dc->u.s_ctor.name); | 3724 return d_find_pack (dpi, dc->u.s_ctor.name); |
3630 case DEMANGLE_COMPONENT_DTOR: | 3725 case DEMANGLE_COMPONENT_DTOR: |
3631 return d_find_pack (dpi, dc->u.s_dtor.name); | 3726 return d_find_pack (dpi, dc->u.s_dtor.name); |
3632 | 3727 |
3633 default: | 3728 default: |
(...skipping 21 matching lines...) Expand all Loading... |
3655 | 3750 |
3656 /* DC is a component of a mangled expression. Print it, wrapped in parens | 3751 /* DC is a component of a mangled expression. Print it, wrapped in parens |
3657 if needed. */ | 3752 if needed. */ |
3658 | 3753 |
3659 static void | 3754 static void |
3660 d_print_subexpr (struct d_print_info *dpi, int options, | 3755 d_print_subexpr (struct d_print_info *dpi, int options, |
3661 const struct demangle_component *dc) | 3756 const struct demangle_component *dc) |
3662 { | 3757 { |
3663 int simple = 0; | 3758 int simple = 0; |
3664 if (dc->type == DEMANGLE_COMPONENT_NAME | 3759 if (dc->type == DEMANGLE_COMPONENT_NAME |
| 3760 || dc->type == DEMANGLE_COMPONENT_QUAL_NAME |
| 3761 || dc->type == DEMANGLE_COMPONENT_INITIALIZER_LIST |
3665 || dc->type == DEMANGLE_COMPONENT_FUNCTION_PARAM) | 3762 || dc->type == DEMANGLE_COMPONENT_FUNCTION_PARAM) |
3666 simple = 1; | 3763 simple = 1; |
3667 if (!simple) | 3764 if (!simple) |
3668 d_append_char (dpi, '('); | 3765 d_append_char (dpi, '('); |
3669 d_print_comp (dpi, options, dc); | 3766 d_print_comp (dpi, options, dc); |
3670 if (!simple) | 3767 if (!simple) |
3671 d_append_char (dpi, ')'); | 3768 d_append_char (dpi, ')'); |
3672 } | 3769 } |
3673 | 3770 |
3674 /* Subroutine to handle components. */ | 3771 /* Subroutine to handle components. */ |
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4250 len = dpi->len; | 4347 len = dpi->len; |
4251 flush_count = dpi->flush_count; | 4348 flush_count = dpi->flush_count; |
4252 d_print_comp (dpi, options, d_right (dc)); | 4349 d_print_comp (dpi, options, d_right (dc)); |
4253 /* If that didn't print anything (which can happen with empty | 4350 /* If that didn't print anything (which can happen with empty |
4254 template argument packs), remove the comma and space. */ | 4351 template argument packs), remove the comma and space. */ |
4255 if (dpi->flush_count == flush_count && dpi->len == len) | 4352 if (dpi->flush_count == flush_count && dpi->len == len) |
4256 dpi->len -= 2; | 4353 dpi->len -= 2; |
4257 } | 4354 } |
4258 return; | 4355 return; |
4259 | 4356 |
| 4357 case DEMANGLE_COMPONENT_INITIALIZER_LIST: |
| 4358 { |
| 4359 struct demangle_component *type = d_left (dc); |
| 4360 struct demangle_component *list = d_right (dc); |
| 4361 |
| 4362 if (type) |
| 4363 d_print_comp (dpi, options, type); |
| 4364 d_append_char (dpi, '{'); |
| 4365 d_print_comp (dpi, options, list); |
| 4366 d_append_char (dpi, '}'); |
| 4367 } |
| 4368 return; |
| 4369 |
4260 case DEMANGLE_COMPONENT_OPERATOR: | 4370 case DEMANGLE_COMPONENT_OPERATOR: |
4261 { | 4371 { |
4262 » char c; | 4372 » const struct demangle_operator_info *op = dc->u.s_operator.op; |
| 4373 » int len = op->len; |
4263 | 4374 |
4264 d_append_string (dpi, "operator"); | 4375 d_append_string (dpi, "operator"); |
4265 » c = dc->u.s_operator.op->name[0]; | 4376 » /* Add a space before new/delete. */ |
4266 » if (IS_LOWER (c)) | 4377 » if (IS_LOWER (op->name[0])) |
4267 d_append_char (dpi, ' '); | 4378 d_append_char (dpi, ' '); |
4268 » d_append_buffer (dpi, dc->u.s_operator.op->name, | 4379 » /* Omit a trailing space. */ |
4269 » » » dc->u.s_operator.op->len); | 4380 » if (op->name[len-1] == ' ') |
| 4381 » --len; |
| 4382 » d_append_buffer (dpi, op->name, len); |
4270 return; | 4383 return; |
4271 } | 4384 } |
4272 | 4385 |
4273 case DEMANGLE_COMPONENT_EXTENDED_OPERATOR: | 4386 case DEMANGLE_COMPONENT_EXTENDED_OPERATOR: |
4274 d_append_string (dpi, "operator "); | 4387 d_append_string (dpi, "operator "); |
4275 d_print_comp (dpi, options, dc->u.s_extended_operator.name); | 4388 d_print_comp (dpi, options, dc->u.s_extended_operator.name); |
4276 return; | 4389 return; |
4277 | 4390 |
4278 case DEMANGLE_COMPONENT_CAST: | 4391 case DEMANGLE_COMPONENT_CAST: |
4279 d_append_string (dpi, "operator "); | 4392 d_append_string (dpi, "operator "); |
4280 d_print_cast (dpi, options, dc); | 4393 d_print_cast (dpi, options, dc); |
4281 return; | 4394 return; |
4282 | 4395 |
| 4396 case DEMANGLE_COMPONENT_NULLARY: |
| 4397 d_print_expr_op (dpi, options, d_left (dc)); |
| 4398 return; |
| 4399 |
4283 case DEMANGLE_COMPONENT_UNARY: | 4400 case DEMANGLE_COMPONENT_UNARY: |
4284 if (d_left (dc)->type == DEMANGLE_COMPONENT_OPERATOR | 4401 { |
4285 » && d_left (dc)->u.s_operator.op->len == 1 | 4402 » struct demangle_component *op = d_left (dc); |
4286 » && d_left (dc)->u.s_operator.op->name[0] == '&' | 4403 » struct demangle_component *operand = d_right (dc); |
4287 » && d_right (dc)->type == DEMANGLE_COMPONENT_TYPED_NAME | 4404 » const char *code = NULL; |
4288 » && d_left (d_right (dc))->type == DEMANGLE_COMPONENT_QUAL_NAME | |
4289 » && d_right (d_right (dc))->type == DEMANGLE_COMPONENT_FUNCTION_TYPE) | |
4290 » { | |
4291 » /* Address of a function (therefore in an expression context) must | |
4292 » have its argument list suppressed. | |
4293 | 4405 |
4294 » unary operator ... dc | 4406 » if (op->type == DEMANGLE_COMPONENT_OPERATOR) |
4295 » operator & ... d_left (dc) | 4407 » { |
4296 » typed name ... d_right (dc) | 4408 » code = op->u.s_operator.op->code; |
4297 » » qualified name ... d_left (d_right (dc)) | 4409 » if (!strcmp (code, "ad")) |
4298 » » <names> | 4410 » { |
4299 » » function type ... d_right (d_right (dc)) | 4411 » » /* Don't print the argument list for the address of a |
4300 » » argument list | 4412 » » function. */ |
4301 » » <arguments> */ | 4413 » » if (operand->type == DEMANGLE_COMPONENT_TYPED_NAME |
| 4414 » » && d_left (operand)->type == DEMANGLE_COMPONENT_QUAL_NAME |
| 4415 » » && d_right (operand)->type == DEMANGLE_COMPONENT_FUNCTION_TY
PE) |
| 4416 » » operand = d_left (operand); |
| 4417 » } |
| 4418 » if (operand->type == DEMANGLE_COMPONENT_BINARY_ARGS) |
| 4419 » { |
| 4420 » » /* This indicates a suffix operator. */ |
| 4421 » » operand = d_left (operand); |
| 4422 » » d_print_subexpr (dpi, options, operand); |
| 4423 » » d_print_expr_op (dpi, options, op); |
| 4424 » » return; |
| 4425 » } |
| 4426 » } |
4302 | 4427 |
4303 » d_print_expr_op (dpi, options, d_left (dc)); | 4428 » if (op->type != DEMANGLE_COMPONENT_CAST) |
4304 » d_print_comp (dpi, options, d_left (d_right (dc))); | 4429 » d_print_expr_op (dpi, options, op); |
4305 » return; | 4430 » else |
4306 » } | 4431 » { |
4307 else if (d_left (dc)->type == DEMANGLE_COMPONENT_OPERATOR | 4432 » d_append_char (dpi, '('); |
4308 » && d_left (dc)->u.s_operator.op->len == 1 | 4433 » d_print_cast (dpi, options, op); |
4309 » && d_left (dc)->u.s_operator.op->name[0] == '&' | 4434 » d_append_char (dpi, ')'); |
4310 » && d_right (dc)->type == DEMANGLE_COMPONENT_QUAL_NAME) | 4435 » } |
4311 » { | 4436 » if (code && !strcmp (code, "gs")) |
4312 » /* Keep also already processed variant without the argument list. | 4437 » /* Avoid parens after '::'. */ |
4313 | 4438 » d_print_comp (dpi, options, operand); |
4314 » unary operator ... dc | 4439 » else if (code && !strcmp (code, "st")) |
4315 » operator & ... d_left (dc) | 4440 » /* Always print parens for sizeof (type). */ |
4316 » qualified name ... d_right (dc) | 4441 » { |
4317 » » <names> */ | 4442 » d_append_char (dpi, '('); |
4318 | 4443 » d_print_comp (dpi, options, operand); |
4319 » d_print_expr_op (dpi, options, d_left (dc)); | 4444 » d_append_char (dpi, ')'); |
4320 » d_print_comp (dpi, options, d_right (dc)); | 4445 » } |
4321 » return; | 4446 » else |
4322 » } | 4447 » d_print_subexpr (dpi, options, operand); |
4323 else if (d_left (dc)->type != DEMANGLE_COMPONENT_CAST) | 4448 } |
4324 » d_print_expr_op (dpi, options, d_left (dc)); | |
4325 else | |
4326 » { | |
4327 » d_append_char (dpi, '('); | |
4328 » d_print_cast (dpi, options, d_left (dc)); | |
4329 » d_append_char (dpi, ')'); | |
4330 » } | |
4331 d_print_subexpr (dpi, options, d_right (dc)); | |
4332 return; | 4449 return; |
4333 | 4450 |
4334 case DEMANGLE_COMPONENT_BINARY: | 4451 case DEMANGLE_COMPONENT_BINARY: |
4335 if (d_right (dc)->type != DEMANGLE_COMPONENT_BINARY_ARGS) | 4452 if (d_right (dc)->type != DEMANGLE_COMPONENT_BINARY_ARGS) |
4336 { | 4453 { |
4337 d_print_error (dpi); | 4454 d_print_error (dpi); |
4338 return; | 4455 return; |
4339 } | 4456 } |
4340 | 4457 |
4341 /* We wrap an expression which uses the greater-than operator in | 4458 /* We wrap an expression which uses the greater-than operator in |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4386 d_print_error (dpi); | 4503 d_print_error (dpi); |
4387 return; | 4504 return; |
4388 | 4505 |
4389 case DEMANGLE_COMPONENT_TRINARY: | 4506 case DEMANGLE_COMPONENT_TRINARY: |
4390 if (d_right (dc)->type != DEMANGLE_COMPONENT_TRINARY_ARG1 | 4507 if (d_right (dc)->type != DEMANGLE_COMPONENT_TRINARY_ARG1 |
4391 || d_right (d_right (dc))->type != DEMANGLE_COMPONENT_TRINARY_ARG2) | 4508 || d_right (d_right (dc))->type != DEMANGLE_COMPONENT_TRINARY_ARG2) |
4392 { | 4509 { |
4393 d_print_error (dpi); | 4510 d_print_error (dpi); |
4394 return; | 4511 return; |
4395 } | 4512 } |
4396 d_print_subexpr (dpi, options, d_left (d_right (dc))); | 4513 { |
4397 d_print_expr_op (dpi, options, d_left (dc)); | 4514 » struct demangle_component *op = d_left (dc); |
4398 d_print_subexpr (dpi, options, d_left (d_right (d_right (dc)))); | 4515 » struct demangle_component *first = d_left (d_right (dc)); |
4399 d_append_string (dpi, " : "); | 4516 » struct demangle_component *second = d_left (d_right (d_right (dc))); |
4400 d_print_subexpr (dpi, options, d_right (d_right (d_right (dc)))); | 4517 » struct demangle_component *third = d_right (d_right (d_right (dc))); |
| 4518 |
| 4519 » if (!strcmp (op->u.s_operator.op->code, "qu")) |
| 4520 » { |
| 4521 » d_print_subexpr (dpi, options, first); |
| 4522 » d_print_expr_op (dpi, options, op); |
| 4523 » d_print_subexpr (dpi, options, second); |
| 4524 » d_append_string (dpi, " : "); |
| 4525 » d_print_subexpr (dpi, options, third); |
| 4526 » } |
| 4527 » else |
| 4528 » { |
| 4529 » d_append_string (dpi, "new "); |
| 4530 » if (d_left (first) != NULL) |
| 4531 » { |
| 4532 » » d_print_subexpr (dpi, options, first); |
| 4533 » » d_append_char (dpi, ' '); |
| 4534 » } |
| 4535 » d_print_comp (dpi, options, second); |
| 4536 » if (third) |
| 4537 » d_print_subexpr (dpi, options, third); |
| 4538 » } |
| 4539 } |
4401 return; | 4540 return; |
4402 | 4541 |
4403 case DEMANGLE_COMPONENT_TRINARY_ARG1: | 4542 case DEMANGLE_COMPONENT_TRINARY_ARG1: |
4404 case DEMANGLE_COMPONENT_TRINARY_ARG2: | 4543 case DEMANGLE_COMPONENT_TRINARY_ARG2: |
4405 /* We should only see these are part of DEMANGLE_COMPONENT_TRINARY. */ | 4544 /* We should only see these are part of DEMANGLE_COMPONENT_TRINARY. */ |
4406 d_print_error (dpi); | 4545 d_print_error (dpi); |
4407 return; | 4546 return; |
4408 | 4547 |
4409 case DEMANGLE_COMPONENT_LITERAL: | 4548 case DEMANGLE_COMPONENT_LITERAL: |
4410 case DEMANGLE_COMPONENT_LITERAL_NEG: | 4549 case DEMANGLE_COMPONENT_LITERAL_NEG: |
(...skipping 1173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5584 fprintf (stderr, "Failed: %s\n", argv[i]); | 5723 fprintf (stderr, "Failed: %s\n", argv[i]); |
5585 #endif | 5724 #endif |
5586 } | 5725 } |
5587 } | 5726 } |
5588 } | 5727 } |
5589 | 5728 |
5590 return 0; | 5729 return 0; |
5591 } | 5730 } |
5592 | 5731 |
5593 #endif /* STANDALONE_DEMANGLER */ | 5732 #endif /* STANDALONE_DEMANGLER */ |
OLD | NEW |