Changeset 609 for branches/GNU/src/binutils/libiberty/cp-demangle.c
- Timestamp:
- Aug 16, 2003, 6:59:22 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GNU/src/binutils/libiberty/cp-demangle.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r608 r609 1 1 /* Demangler for IA64 / g++ V3 ABI. 2 Copyright (C) 2000 Free Software Foundation, Inc.2 Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc. 3 3 Written by Alex Samuel <samuel@codesourcery.com>. 4 4 … … 9 9 the Free Software Foundation; either version 2 of the License, or 10 10 (at your option) any later version. 11 12 In addition to the permissions in the GNU General Public License, the 13 Free Software Foundation gives you unlimited permission to link the 14 compiled version of this file into combinations with other programs, 15 and to distribute those combinations without any restriction coming 16 from the use of this file. (The General Public License restrictions 17 do apply in other respects; for example, they cover modification of 18 the file, and distribution when not linked into a combined 19 executable.) 11 20 12 21 This program is distributed in the hope that it will be useful, … … 42 51 #include <string.h> 43 52 #endif 53 54 #include <ctype.h> 44 55 45 56 #include "ansidecl.h" … … 69 80 #define ANONYMOUS_NAMESPACE_PREFIX "_GLOBAL_" 70 81 82 /* Character(s) to use for namespace separation in demangled output */ 83 #define NAMESPACE_SEPARATOR (dm->style == DMGL_JAVA ? "." : "::") 84 71 85 /* If flag_verbose is zero, some simplifications will be made to the 72 86 output to make it easier to read and supress details that are … … 167 181 /* The most recently demangled source-name. */ 168 182 dyn_string_t last_source_name; 183 184 /* Language style to use for demangled output. */ 185 int style; 186 187 /* Set to non-zero iff this name is a constructor. The actual value 188 indicates what sort of constructor this is; see demangle.h. */ 189 enum gnu_v3_ctor_kinds is_constructor; 190 191 /* Set to non-zero iff this name is a destructor. The actual value 192 indicates what sort of destructor this is; see demangle.h. */ 193 enum gnu_v3_dtor_kinds is_destructor; 194 169 195 }; 170 196 … … 241 267 PARAMS ((demangling_t)); 242 268 static demangling_t demangling_new 243 PARAMS ((const char * ));269 PARAMS ((const char *, int)); 244 270 static void demangling_delete 245 271 PARAMS ((demangling_t)); … … 410 436 { 411 437 string_list_t next = node->next; 412 free (node);438 dyn_string_delete ((dyn_string_t) node); 413 439 node = next; 414 440 } … … 784 810 785 811 static demangling_t 786 demangling_new (name )812 demangling_new (name, style) 787 813 const char *name; 814 int style; 788 815 { 789 816 demangling_t dm; … … 808 835 return NULL; 809 836 } 837 dm->style = style; 838 dm->is_constructor = (enum gnu_v3_ctor_kinds) 0; 839 dm->is_destructor = (enum gnu_v3_dtor_kinds) 0; 810 840 811 841 return dm; … … 871 901 PARAMS ((demangling_t, int, dyn_string_t)); 872 902 static status_t demangle_operator_name 873 PARAMS ((demangling_t, int, int * ));903 PARAMS ((demangling_t, int, int *, int *)); 874 904 static status_t demangle_nv_offset 875 905 PARAMS ((demangling_t)); … … 919 949 PARAMS ((demangling_t, int)); 920 950 static status_t cp_demangle 921 PARAMS ((const char *, dyn_string_t)); 922 #ifdef IN_LIBGCC2 951 PARAMS ((const char *, dyn_string_t, int)); 923 952 static status_t cp_demangle_type 924 953 PARAMS ((const char*, dyn_string_t)); 925 #endif926 954 927 955 /* When passed to demangle_bare_function_type, indicates that the … … 947 975 { 948 976 if (error_message == NULL) 949 error_message = strdup ("Expected ?");977 error_message = (char *) strdup ("Expected ?"); 950 978 error_message[9] = c; 951 979 return error_message; … … 1223 1251 /* We have another level of scope qualification. */ 1224 1252 if (nested) 1225 RETURN_IF_ERROR (result_add (dm, "::"));1253 RETURN_IF_ERROR (result_add (dm, NAMESPACE_SEPARATOR)); 1226 1254 else 1227 1255 nested = 1; … … 1300 1328 *suppress_return_type = 1; 1301 1329 1302 RETURN_IF_ERROR (demangle_operator_name (dm, 0, &num_args ));1330 RETURN_IF_ERROR (demangle_operator_name (dm, 0, &num_args, NULL)); 1303 1331 } 1304 1332 else if (peek == 'C' || peek == 'D') … … 1441 1469 while (length-- > 0) 1442 1470 { 1471 int ch; 1443 1472 if (end_of_name_p (dm)) 1444 1473 return "Unexpected end of name in <identifier>."; 1445 if (!dyn_string_append_char (identifier, next_char (dm))) 1474 ch = next_char (dm); 1475 1476 /* Handle extended Unicode characters. We encode them as __U{hex}_, 1477 where {hex} omits leading 0's. For instance, '$' is encoded as 1478 "__U24_". */ 1479 if (ch == '_' 1480 && peek_char (dm) == '_' 1481 && peek_char_next (dm) == 'U') 1482 { 1483 char buf[10]; 1484 int pos = 0; 1485 advance_char (dm); advance_char (dm); length -= 2; 1486 while (length-- > 0) 1487 { 1488 ch = next_char (dm); 1489 if (!isxdigit (ch)) 1490 break; 1491 buf[pos++] = ch; 1492 } 1493 if (ch != '_' || length < 0) 1494 return STATUS_ERROR; 1495 if (pos == 0) 1496 { 1497 /* __U_ just means __U. */ 1498 if (!dyn_string_append_cstr (identifier, "__U")) 1499 return STATUS_ALLOCATION_FAILED; 1500 continue; 1501 } 1502 else 1503 { 1504 buf[pos] = '\0'; 1505 ch = strtol (buf, 0, 16); 1506 } 1507 } 1508 1509 if (!dyn_string_append_char (identifier, ch)) 1446 1510 return STATUS_ALLOCATION_FAILED; 1447 1511 } … … 1476 1540 the short form is emitted; otherwise the full source form 1477 1541 (`operator +' etc.) is emitted. *NUM_ARGS is set to the number of 1478 operands that the operator takes. 1542 operands that the operator takes. If TYPE_ARG is non-NULL, 1543 *TYPE_ARG is set to 1 if the first argument is a type and 0 1544 otherwise. 1479 1545 1480 1546 <operator-name> … … 1526 1592 ::= ix # [] 1527 1593 ::= qu # ? 1528 ::= sz # sizeof 1594 ::= st # sizeof (a type) 1595 ::= sz # sizeof (an expression) 1529 1596 ::= cv <type> # cast 1530 1597 ::= v [0-9] <source-name> # vendor extended operator */ 1531 1598 1532 1599 static status_t 1533 demangle_operator_name (dm, short_name, num_args )1600 demangle_operator_name (dm, short_name, num_args, type_arg) 1534 1601 demangling_t dm; 1535 1602 int short_name; 1536 1603 int *num_args; 1604 int *type_arg; 1537 1605 { 1538 1606 struct operator_code 1539 1607 { 1540 1608 /* The mangled code for this operator. */ 1541 const char *co de;1609 const char *const code; 1542 1610 /* The source name of this operator. */ 1543 const char * name;1611 const char *const name; 1544 1612 /* The number of arguments this operator takes. */ 1545 int num_args;1613 const int num_args; 1546 1614 }; 1547 1615 … … 1608 1676 DEMANGLE_TRACE ("operator-name", dm); 1609 1677 1678 /* Assume the first argument is not a type. */ 1679 if (type_arg) 1680 *type_arg = 0; 1681 1610 1682 /* Is this a vendor-extended operator? */ 1611 1683 if (c0 == 'v' && IS_DIGIT (c1)) … … 1624 1696 RETURN_IF_ERROR (demangle_type (dm)); 1625 1697 *num_args = 0; 1698 return STATUS_OK; 1699 } 1700 1701 /* Is it the sizeof variant that takes a type? */ 1702 if (c0 == 's' && c1 == 't') 1703 { 1704 RETURN_IF_ERROR (result_add (dm, " sizeof")); 1705 *num_args = 1; 1706 if (type_arg) 1707 *type_arg = 1; 1626 1708 return STATUS_OK; 1627 1709 } … … 1824 1906 if (peek == 'G') 1825 1907 { 1826 /* A guard variable name.Consume the G. */1908 /* Consume the G. */ 1827 1909 advance_char (dm); 1828 RETURN_IF_ERROR (demangle_char (dm, 'V')); 1829 RETURN_IF_ERROR (result_add (dm, "guard variable for ")); 1830 RETURN_IF_ERROR (demangle_name (dm, &unused)); 1910 switch (peek_char (dm)) 1911 { 1912 case 'V': 1913 /* A guard variable name. */ 1914 advance_char (dm); 1915 RETURN_IF_ERROR (result_add (dm, "guard variable for ")); 1916 RETURN_IF_ERROR (demangle_name (dm, &unused)); 1917 break; 1918 1919 case 'R': 1920 /* A reference temporary. */ 1921 advance_char (dm); 1922 RETURN_IF_ERROR (result_add (dm, "reference temporary for ")); 1923 RETURN_IF_ERROR (demangle_name (dm, &unused)); 1924 break; 1925 1926 default: 1927 return "Unrecognized <special-name>."; 1928 } 1831 1929 } 1832 1930 else if (peek == 'T') … … 2011 2109 /* A constructor name. Consume the C. */ 2012 2110 advance_char (dm); 2013 if (peek_char (dm) < '1' || peek_char (dm) > '3') 2111 flavor = next_char (dm); 2112 if (flavor < '1' || flavor > '3') 2014 2113 return "Unrecognized constructor."; 2015 2114 RETURN_IF_ERROR (result_add_string (dm, dm->last_source_name)); 2115 switch (flavor) 2116 { 2117 case '1': dm->is_constructor = gnu_v3_complete_object_ctor; 2118 break; 2119 case '2': dm->is_constructor = gnu_v3_base_object_ctor; 2120 break; 2121 case '3': dm->is_constructor = gnu_v3_complete_object_allocating_ctor; 2122 break; 2123 } 2016 2124 /* Print the flavor of the constructor if in verbose mode. */ 2017 flavor = next_char (dm) - '1';2018 2125 if (flag_verbose) 2019 2126 { 2020 2127 RETURN_IF_ERROR (result_add (dm, "[")); 2021 RETURN_IF_ERROR (result_add (dm, ctor_flavors[flavor ]));2128 RETURN_IF_ERROR (result_add (dm, ctor_flavors[flavor - '1'])); 2022 2129 RETURN_IF_ERROR (result_add_char (dm, ']')); 2023 2130 } … … 2027 2134 /* A destructor name. Consume the D. */ 2028 2135 advance_char (dm); 2029 if (peek_char (dm) < '0' || peek_char (dm) > '2') 2136 flavor = next_char (dm); 2137 if (flavor < '0' || flavor > '2') 2030 2138 return "Unrecognized destructor."; 2031 2139 RETURN_IF_ERROR (result_add_char (dm, '~')); 2032 2140 RETURN_IF_ERROR (result_add_string (dm, dm->last_source_name)); 2141 switch (flavor) 2142 { 2143 case '0': dm->is_destructor = gnu_v3_deleting_dtor; 2144 break; 2145 case '1': dm->is_destructor = gnu_v3_complete_object_dtor; 2146 break; 2147 case '2': dm->is_destructor = gnu_v3_base_object_dtor; 2148 break; 2149 } 2033 2150 /* Print the flavor of the destructor if in verbose mode. */ 2034 flavor = next_char (dm) - '0';2035 2151 if (flag_verbose) 2036 2152 { 2037 2153 RETURN_IF_ERROR (result_add (dm, " [")); 2038 RETURN_IF_ERROR (result_add (dm, dtor_flavors[flavor ]));2154 RETURN_IF_ERROR (result_add (dm, dtor_flavors[flavor - '0'])); 2039 2155 RETURN_IF_ERROR (result_add_char (dm, ']')); 2040 2156 } … … 2094 2210 substitution_start)); 2095 2211 /* Insert an asterisk where we're told to; it doesn't 2096 necessarily go at the end. */ 2097 RETURN_IF_ERROR (result_insert_char (dm, *insert_pos, '*')); 2212 necessarily go at the end. If we're doing Java style output, 2213 there is no pointer symbol. */ 2214 if (dm->style != DMGL_JAVA) 2215 RETURN_IF_ERROR (result_insert_char (dm, *insert_pos, '*')); 2098 2216 /* The next (outermost) pointer or reference character should go 2099 2217 after this one. */ … … 2470 2588 }; 2471 2589 2590 /* Java source names of builtin types. Types that arn't valid in Java 2591 are also included here - we don't fail if someone attempts to demangle a 2592 C++ symbol in Java style. */ 2593 static const char *const java_builtin_type_names[26] = 2594 { 2595 "signed char", /* a */ 2596 "boolean", /* C++ "bool" */ /* b */ 2597 "byte", /* C++ "char" */ /* c */ 2598 "double", /* d */ 2599 "long double", /* e */ 2600 "float", /* f */ 2601 "__float128", /* g */ 2602 "unsigned char", /* h */ 2603 "int", /* i */ 2604 "unsigned", /* j */ 2605 NULL, /* k */ 2606 "long", /* l */ 2607 "unsigned long", /* m */ 2608 "__int128", /* n */ 2609 "unsigned __int128", /* o */ 2610 NULL, /* p */ 2611 NULL, /* q */ 2612 NULL, /* r */ 2613 "short", /* s */ 2614 "unsigned short", /* t */ 2615 NULL, /* u */ 2616 "void", /* v */ 2617 "char", /* C++ "wchar_t" */ /* w */ 2618 "long", /* C++ "long long" */ /* x */ 2619 "unsigned long long", /* y */ 2620 "..." /* z */ 2621 }; 2622 2472 2623 /* Demangles and emits a <builtin-type>. 2473 2624 … … 2512 2663 else if (code >= 'a' && code <= 'z') 2513 2664 { 2514 const char *type_name = builtin_type_names[code - 'a']; 2665 const char *type_name; 2666 /* Java uses different names for some built-in types. */ 2667 if (dm->style == DMGL_JAVA) 2668 type_name = java_builtin_type_names[code - 'a']; 2669 else 2670 type_name = builtin_type_names[code - 'a']; 2515 2671 if (type_name == NULL) 2516 2672 return "Unrecognized <builtin-type> code."; … … 3055 3211 { 3056 3212 int num_args; 3213 int type_arg; 3057 3214 status_t status = STATUS_OK; 3058 3215 dyn_string_t operator_name; … … 3062 3219 first. */ 3063 3220 RETURN_IF_ERROR (result_push (dm)); 3064 RETURN_IF_ERROR (demangle_operator_name (dm, 1, &num_args)); 3221 RETURN_IF_ERROR (demangle_operator_name (dm, 1, &num_args, 3222 &type_arg)); 3065 3223 operator_name = (dyn_string_t) result_pop (dm); 3066 3224 … … 3083 3241 /* Emit its second (if binary) or only (if unary) operand. */ 3084 3242 RETURN_IF_ERROR (result_add_char (dm, '(')); 3085 RETURN_IF_ERROR (demangle_expression (dm)); 3243 if (type_arg) 3244 RETURN_IF_ERROR (demangle_type (dm)); 3245 else 3246 RETURN_IF_ERROR (demangle_expression (dm)); 3086 3247 RETURN_IF_ERROR (result_add_char (dm, ')')); 3087 3248 … … 3370 3531 less than the discriminator ordinal, counting from 3371 3532 zero. */ 3372 RETURN_IF_ERROR (int_to_dyn_string (discriminator + 2,3533 RETURN_IF_ERROR (int_to_dyn_string (discriminator + 1, 3373 3534 (dyn_string_t) dm->result)); 3374 3535 } 3375 3536 else 3376 { 3377 if (flag_verbose) 3378 /* A missing digit correspond to one. */ 3379 RETURN_IF_ERROR (result_add_char (dm, '1')); 3380 } 3537 return STATUS_ERROR; 3381 3538 if (flag_verbose) 3382 3539 RETURN_IF_ERROR (result_add_char (dm, ']')); … … 3396 3553 3397 3554 static status_t 3398 cp_demangle (name, result )3555 cp_demangle (name, result, style) 3399 3556 const char *name; 3400 3557 dyn_string_t result; 3558 int style; 3401 3559 { 3402 3560 status_t status; … … 3405 3563 if (length > 2 && name[0] == '_' && name[1] == 'Z') 3406 3564 { 3407 demangling_t dm = demangling_new (name );3565 demangling_t dm = demangling_new (name, style); 3408 3566 if (dm == NULL) 3409 3567 return STATUS_ALLOCATION_FAILED; … … 3444 3602 an error message, and the contents of RESULT are unchanged. */ 3445 3603 3446 #ifdef IN_LIBGCC23447 3604 static status_t 3448 3605 cp_demangle_type (type_name, result) … … 3451 3608 { 3452 3609 status_t status; 3453 demangling_t dm = demangling_new (type_name );3610 demangling_t dm = demangling_new (type_name, DMGL_GNU_V3); 3454 3611 3455 3612 if (dm == NULL) … … 3482 3639 } 3483 3640 3641 #if defined(IN_LIBGCC2) || defined(IN_GLIBCPP_V3) 3484 3642 extern char *__cxa_demangle PARAMS ((const char *, char *, size_t *, int *)); 3485 3643 … … 3552 3710 /* MANGLED_NAME apprears to be a function or variable name. 3553 3711 Demangle it accordingly. */ 3554 result = cp_demangle (mangled_name, &demangled_name );3712 result = cp_demangle (mangled_name, &demangled_name, 0); 3555 3713 else 3556 3714 /* Try to demangled MANGLED_NAME as the name of a type. */ … … 3589 3747 } 3590 3748 3591 #else /* ! IN_LIBGCC2*/3749 #else /* ! (IN_LIBGCC2 || IN_GLIBCPP_V3) */ 3592 3750 3593 3751 /* Variant entry point for integration with the existing cplus-dem … … 3598 3756 3599 3757 char * 3600 cplus_demangle_v3 (mangled )3758 cplus_demangle_v3 (mangled, options) 3601 3759 const char* mangled; 3760 int options; 3602 3761 { 3603 3762 dyn_string_t demangled; 3604 3763 status_t status; 3605 3606 /* If this isn't a mangled name, don't pretend to demangle it. */ 3607 if (strncmp (mangled, "_Z", 2) != 0) 3608 return NULL; 3764 int type = !!(options & DMGL_TYPES); 3765 3766 if (mangled[0] == '_' && mangled[1] == 'Z') 3767 /* It is not a type. */ 3768 type = 0; 3769 else 3770 { 3771 /* It is a type. Stop if we don't want to demangle types. */ 3772 if (!type) 3773 return NULL; 3774 } 3775 3776 flag_verbose = !!(options & DMGL_VERBOSE); 3609 3777 3610 3778 /* Create a dyn_string to hold the demangled name. */ 3611 3779 demangled = dyn_string_new (0); 3612 3780 /* Attempt the demangling. */ 3613 status = cp_demangle ((char *) mangled, demangled); 3781 if (!type) 3782 /* Appears to be a function or variable name. */ 3783 status = cp_demangle (mangled, demangled, 0); 3784 else 3785 /* Try to demangle it as the name of a type. */ 3786 status = cp_demangle_type (mangled, demangled); 3614 3787 3615 3788 if (STATUS_NO_ERROR (status)) … … 3635 3808 } 3636 3809 3637 #endif /* IN_LIBGCC2 */ 3810 /* Demangle a Java symbol. Java uses a subset of the V3 ABI C++ mangling 3811 conventions, but the output formatting is a little different. 3812 This instructs the C++ demangler not to emit pointer characters ("*"), and 3813 to use Java's namespace separator symbol ("." instead of "::"). It then 3814 does an additional pass over the demangled output to replace instances 3815 of JArray<TYPE> with TYPE[]. */ 3816 3817 char * 3818 java_demangle_v3 (mangled) 3819 const char* mangled; 3820 { 3821 dyn_string_t demangled; 3822 char *next; 3823 char *end; 3824 int len; 3825 status_t status; 3826 int nesting = 0; 3827 char *cplus_demangled; 3828 char *return_value; 3829 3830 /* Create a dyn_string to hold the demangled name. */ 3831 demangled = dyn_string_new (0); 3832 3833 /* Attempt the demangling. */ 3834 status = cp_demangle ((char *) mangled, demangled, DMGL_JAVA); 3835 3836 if (STATUS_NO_ERROR (status)) 3837 /* Demangling succeeded. */ 3838 { 3839 /* Grab the demangled result from the dyn_string. */ 3840 cplus_demangled = dyn_string_release (demangled); 3841 } 3842 else if (status == STATUS_ALLOCATION_FAILED) 3843 { 3844 fprintf (stderr, "Memory allocation failed.\n"); 3845 abort (); 3846 } 3847 else 3848 /* Demangling failed. */ 3849 { 3850 dyn_string_delete (demangled); 3851 return NULL; 3852 } 3853 3854 len = strlen (cplus_demangled); 3855 next = cplus_demangled; 3856 end = next + len; 3857 demangled = NULL; 3858 3859 /* Replace occurances of JArray<TYPE> with TYPE[]. */ 3860 while (next < end) 3861 { 3862 char *open_str = strstr (next, "JArray<"); 3863 char *close_str = NULL; 3864 if (nesting > 0) 3865 close_str = strchr (next, '>'); 3866 3867 if (open_str != NULL && (close_str == NULL || close_str > open_str)) 3868 { 3869 ++nesting; 3870 3871 if (!demangled) 3872 demangled = dyn_string_new(len); 3873 3874 /* Copy prepending symbols, if any. */ 3875 if (open_str > next) 3876 { 3877 open_str[0] = 0; 3878 dyn_string_append_cstr (demangled, next); 3879 } 3880 next = open_str + 7; 3881 } 3882 else if (close_str != NULL) 3883 { 3884 --nesting; 3885 3886 /* Copy prepending type symbol, if any. Squash any spurious 3887 whitespace. */ 3888 if (close_str > next && next[0] != ' ') 3889 { 3890 close_str[0] = 0; 3891 dyn_string_append_cstr (demangled, next); 3892 } 3893 dyn_string_append_cstr (demangled, "[]"); 3894 next = close_str + 1; 3895 } 3896 else 3897 { 3898 /* There are no more arrays. Copy the rest of the symbol, or 3899 simply return the original symbol if no changes were made. */ 3900 if (next == cplus_demangled) 3901 return cplus_demangled; 3902 3903 dyn_string_append_cstr (demangled, next); 3904 next = end; 3905 } 3906 } 3907 3908 free (cplus_demangled); 3909 3910 if (demangled) 3911 return_value = dyn_string_release (demangled); 3912 else 3913 return_value = NULL; 3914 3915 return return_value; 3916 } 3917 3918 #endif /* IN_LIBGCC2 || IN_GLIBCPP_V3 */ 3919 3920 3921 #ifndef IN_GLIBCPP_V3 3922 /* Demangle NAME in the G++ V3 ABI demangling style, and return either 3923 zero, indicating that some error occurred, or a demangling_t 3924 holding the results. */ 3925 static demangling_t 3926 demangle_v3_with_details (name) 3927 const char *name; 3928 { 3929 demangling_t dm; 3930 status_t status; 3931 3932 if (strncmp (name, "_Z", 2)) 3933 return 0; 3934 3935 dm = demangling_new (name, DMGL_GNU_V3); 3936 if (dm == NULL) 3937 { 3938 fprintf (stderr, "Memory allocation failed.\n"); 3939 abort (); 3940 } 3941 3942 status = result_push (dm); 3943 if (! STATUS_NO_ERROR (status)) 3944 { 3945 demangling_delete (dm); 3946 fprintf (stderr, "%s\n", status); 3947 abort (); 3948 } 3949 3950 status = demangle_mangled_name (dm); 3951 if (STATUS_NO_ERROR (status)) 3952 return dm; 3953 3954 demangling_delete (dm); 3955 return 0; 3956 } 3957 3958 3959 /* Return non-zero iff NAME is the mangled form of a constructor name 3960 in the G++ V3 ABI demangling style. Specifically, return: 3961 - '1' if NAME is a complete object constructor, 3962 - '2' if NAME is a base object constructor, or 3963 - '3' if NAME is a complete object allocating constructor. */ 3964 enum gnu_v3_ctor_kinds 3965 is_gnu_v3_mangled_ctor (name) 3966 const char *name; 3967 { 3968 demangling_t dm = demangle_v3_with_details (name); 3969 3970 if (dm) 3971 { 3972 enum gnu_v3_ctor_kinds result = dm->is_constructor; 3973 demangling_delete (dm); 3974 return result; 3975 } 3976 else 3977 return (enum gnu_v3_ctor_kinds) 0; 3978 } 3979 3980 3981 /* Return non-zero iff NAME is the mangled form of a destructor name 3982 in the G++ V3 ABI demangling style. Specifically, return: 3983 - '0' if NAME is a deleting destructor, 3984 - '1' if NAME is a complete object destructor, or 3985 - '2' if NAME is a base object destructor. */ 3986 enum gnu_v3_dtor_kinds 3987 is_gnu_v3_mangled_dtor (name) 3988 const char *name; 3989 { 3990 demangling_t dm = demangle_v3_with_details (name); 3991 3992 if (dm) 3993 { 3994 enum gnu_v3_dtor_kinds result = dm->is_destructor; 3995 demangling_delete (dm); 3996 return result; 3997 } 3998 else 3999 return (enum gnu_v3_dtor_kinds) 0; 4000 } 4001 #endif /* IN_GLIBCPP_V3 */ 4002 3638 4003 3639 4004 #ifdef STANDALONE_DEMANGLER … … 3670 4035 3671 4036 /* Option specification for getopt_long. */ 3672 static struct option long_options[] =4037 static const struct option long_options[] = 3673 4038 { 3674 4039 { "help", no_argument, NULL, 'h' }, … … 3772 4137 3773 4138 /* Attempt to demangle the name. */ 3774 status = cp_demangle (dyn_string_buf (mangled), demangled );4139 status = cp_demangle (dyn_string_buf (mangled), demangled, 0); 3775 4140 3776 4141 /* If the demangling succeeded, great! Print out the … … 3811 4176 { 3812 4177 /* Attempt to demangle. */ 3813 status = cp_demangle (argv[i], result );4178 status = cp_demangle (argv[i], result, 0); 3814 4179 3815 4180 /* If it worked, print the demangled name. */ … … 3819 4184 else if (status == STATUS_ALLOCATION_FAILED) 3820 4185 { 3821 fprintf (stderr, "Memory alloca iton failed.\n");4186 fprintf (stderr, "Memory allocation failed.\n"); 3822 4187 abort (); 3823 4188 } -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.