Ignore:
Timestamp:
Aug 16, 2003, 6:59:22 PM (22 years ago)
Author:
bird
Message:

binutils v2.14 - offical sources.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/GNU/src/binutils/libiberty/cp-demangle.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r608 r609  
    11/* Demangler for IA64 / g++ V3 ABI.
    2    Copyright (C) 2000 Free Software Foundation, Inc.
     2   Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
    33   Written by Alex Samuel <samuel@codesourcery.com>.
    44
     
    99   the Free Software Foundation; either version 2 of the License, or
    1010   (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.)
    1120
    1221   This program is distributed in the hope that it will be useful,
     
    4251#include <string.h>
    4352#endif
     53
     54#include <ctype.h>
    4455
    4556#include "ansidecl.h"
     
    6980#define ANONYMOUS_NAMESPACE_PREFIX "_GLOBAL_"
    7081
     82/* Character(s) to use for namespace separation in demangled output */
     83#define NAMESPACE_SEPARATOR (dm->style == DMGL_JAVA ? "." : "::")
     84
    7185/* If flag_verbose is zero, some simplifications will be made to the
    7286   output to make it easier to read and supress details that are
     
    167181  /* The most recently demangled source-name.  */
    168182  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
    169195};
    170196
     
    241267  PARAMS ((demangling_t));
    242268static demangling_t demangling_new
    243   PARAMS ((const char *));
     269  PARAMS ((const char *, int));
    244270static void demangling_delete
    245271  PARAMS ((demangling_t));
     
    410436    {
    411437      string_list_t next = node->next;
    412       free (node);
     438      dyn_string_delete ((dyn_string_t) node);
    413439      node = next;
    414440    }
     
    784810
    785811static demangling_t
    786 demangling_new (name)
     812demangling_new (name, style)
    787813     const char *name;
     814     int style;
    788815{
    789816  demangling_t dm;
     
    808835      return NULL;
    809836    }
     837  dm->style = style;
     838  dm->is_constructor = (enum gnu_v3_ctor_kinds) 0;
     839  dm->is_destructor = (enum gnu_v3_dtor_kinds) 0;
    810840
    811841  return dm;
     
    871901  PARAMS ((demangling_t, int, dyn_string_t));
    872902static status_t demangle_operator_name
    873   PARAMS ((demangling_t, int, int *));
     903  PARAMS ((demangling_t, int, int *, int *));
    874904static status_t demangle_nv_offset
    875905  PARAMS ((demangling_t));
     
    919949  PARAMS ((demangling_t, int));
    920950static status_t cp_demangle
    921   PARAMS ((const char *, dyn_string_t));
    922 #ifdef IN_LIBGCC2
     951  PARAMS ((const char *, dyn_string_t, int));
    923952static status_t cp_demangle_type
    924953  PARAMS ((const char*, dyn_string_t));
    925 #endif
    926954
    927955/* When passed to demangle_bare_function_type, indicates that the
     
    947975    {
    948976      if (error_message == NULL)
    949         error_message = strdup ("Expected ?");
     977        error_message = (char *) strdup ("Expected ?");
    950978      error_message[9] = c;
    951979      return error_message;
     
    12231251          /* We have another level of scope qualification.  */
    12241252          if (nested)
    1225             RETURN_IF_ERROR (result_add (dm, "::"));
     1253            RETURN_IF_ERROR (result_add (dm, NAMESPACE_SEPARATOR));
    12261254          else
    12271255            nested = 1;
     
    13001328        *suppress_return_type = 1;
    13011329
    1302       RETURN_IF_ERROR (demangle_operator_name (dm, 0, &num_args));
     1330      RETURN_IF_ERROR (demangle_operator_name (dm, 0, &num_args, NULL));
    13031331    }
    13041332  else if (peek == 'C' || peek == 'D')
     
    14411469  while (length-- > 0)
    14421470    {
     1471      int ch;
    14431472      if (end_of_name_p (dm))
    14441473        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))
    14461510        return STATUS_ALLOCATION_FAILED;
    14471511    }
     
    14761540   the short form is emitted; otherwise the full source form
    14771541   (`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.
    14791545
    14801546    <operator-name>
     
    15261592                  ::= ix        # []           
    15271593                  ::= qu        # ?
    1528                   ::= sz        # sizeof
     1594                  ::= st        # sizeof (a type)
     1595                  ::= sz        # sizeof (an expression)
    15291596                  ::= cv <type> # cast       
    15301597                  ::= v [0-9] <source-name>  # vendor extended operator  */
    15311598
    15321599static status_t
    1533 demangle_operator_name (dm, short_name, num_args)
     1600demangle_operator_name (dm, short_name, num_args, type_arg)
    15341601     demangling_t dm;
    15351602     int short_name;
    15361603     int *num_args;
     1604     int *type_arg;
    15371605{
    15381606  struct operator_code
    15391607  {
    15401608    /* The mangled code for this operator.  */
    1541     const char *code;
     1609    const char *const code;
    15421610    /* The source name of this operator.  */
    1543     const char *name;
     1611    const char *const name;
    15441612    /* The number of arguments this operator takes.  */
    1545     int num_args;
     1613    const int num_args;
    15461614  };
    15471615
     
    16081676  DEMANGLE_TRACE ("operator-name", dm);
    16091677
     1678  /* Assume the first argument is not a type.  */
     1679  if (type_arg)
     1680    *type_arg = 0;
     1681
    16101682  /* Is this a vendor-extended operator?  */
    16111683  if (c0 == 'v' && IS_DIGIT (c1))
     
    16241696      RETURN_IF_ERROR (demangle_type (dm));
    16251697      *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;
    16261708      return STATUS_OK;
    16271709    }
     
    18241906  if (peek == 'G')
    18251907    {
    1826       /* A guard variable name.  Consume the G.  */
     1908      /* Consume the G.  */
    18271909      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        }
    18311929    }
    18321930  else if (peek == 'T')
     
    20112109      /* A constructor name.  Consume the C.  */
    20122110      advance_char (dm);
    2013       if (peek_char (dm) < '1' || peek_char (dm) > '3')
     2111      flavor = next_char (dm);
     2112      if (flavor < '1' || flavor > '3')
    20142113        return "Unrecognized constructor.";
    20152114      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        }
    20162124      /* Print the flavor of the constructor if in verbose mode.  */
    2017       flavor = next_char (dm) - '1';
    20182125      if (flag_verbose)
    20192126        {
    20202127          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']));
    20222129          RETURN_IF_ERROR (result_add_char (dm, ']'));
    20232130        }
     
    20272134      /* A destructor name.  Consume the D.  */
    20282135      advance_char (dm);
    2029       if (peek_char (dm) < '0' || peek_char (dm) > '2')
     2136      flavor = next_char (dm);
     2137      if (flavor < '0' || flavor > '2')
    20302138        return "Unrecognized destructor.";
    20312139      RETURN_IF_ERROR (result_add_char (dm, '~'));
    20322140      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        }
    20332150      /* Print the flavor of the destructor if in verbose mode.  */
    2034       flavor = next_char (dm) - '0';
    20352151      if (flag_verbose)
    20362152        {
    20372153          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']));
    20392155          RETURN_IF_ERROR (result_add_char (dm, ']'));
    20402156        }
     
    20942210                                          substitution_start));
    20952211      /* 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, '*'));
    20982216      /* The next (outermost) pointer or reference character should go
    20992217         after this one.  */
     
    24702588};
    24712589
     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. */
     2593static 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
    24722623/* Demangles and emits a <builtin-type>. 
    24732624
     
    25122663  else if (code >= 'a' && code <= 'z')
    25132664    {
    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'];
    25152671      if (type_name == NULL)
    25162672        return "Unrecognized <builtin-type> code.";
     
    30553211    {
    30563212      int num_args;
     3213      int type_arg;
    30573214      status_t status = STATUS_OK;
    30583215      dyn_string_t operator_name;
     
    30623219         first.  */
    30633220      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));
    30653223      operator_name = (dyn_string_t) result_pop (dm);
    30663224
     
    30833241      /* Emit its second (if binary) or only (if unary) operand.  */
    30843242      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));
    30863247      RETURN_IF_ERROR (result_add_char (dm, ')'));
    30873248
     
    33703531               less than the discriminator ordinal, counting from
    33713532               zero.  */
    3372             RETURN_IF_ERROR (int_to_dyn_string (discriminator + 2,
     3533            RETURN_IF_ERROR (int_to_dyn_string (discriminator + 1,
    33733534                                                (dyn_string_t) dm->result));
    33743535        }
    33753536      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;
    33813538      if (flag_verbose)
    33823539        RETURN_IF_ERROR (result_add_char (dm, ']'));
     
    33963553
    33973554static status_t
    3398 cp_demangle (name, result)
     3555cp_demangle (name, result, style)
    33993556     const char *name;
    34003557     dyn_string_t result;
     3558     int style;
    34013559{
    34023560  status_t status;
     
    34053563  if (length > 2 && name[0] == '_' && name[1] == 'Z')
    34063564    {
    3407       demangling_t dm = demangling_new (name);
     3565      demangling_t dm = demangling_new (name, style);
    34083566      if (dm == NULL)
    34093567        return STATUS_ALLOCATION_FAILED;
     
    34443602   an error message, and the contents of RESULT are unchanged.  */
    34453603
    3446 #ifdef IN_LIBGCC2
    34473604static status_t
    34483605cp_demangle_type (type_name, result)
     
    34513608{
    34523609  status_t status;
    3453   demangling_t dm = demangling_new (type_name);
     3610  demangling_t dm = demangling_new (type_name, DMGL_GNU_V3);
    34543611 
    34553612  if (dm == NULL)
     
    34823639}
    34833640
     3641#if defined(IN_LIBGCC2) || defined(IN_GLIBCPP_V3)
    34843642extern char *__cxa_demangle PARAMS ((const char *, char *, size_t *, int *));
    34853643
     
    35523710    /* MANGLED_NAME apprears to be a function or variable name.
    35533711       Demangle it accordingly.  */
    3554     result = cp_demangle (mangled_name, &demangled_name);
     3712    result = cp_demangle (mangled_name, &demangled_name, 0);
    35553713  else
    35563714    /* Try to demangled MANGLED_NAME as the name of a type.  */
     
    35893747}
    35903748
    3591 #else /* !IN_LIBGCC2 */
     3749#else /* ! (IN_LIBGCC2 || IN_GLIBCPP_V3) */
    35923750
    35933751/* Variant entry point for integration with the existing cplus-dem
     
    35983756
    35993757char *
    3600 cplus_demangle_v3 (mangled)
     3758cplus_demangle_v3 (mangled, options)
    36013759     const char* mangled;
     3760     int options;
    36023761{
    36033762  dyn_string_t demangled;
    36043763  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);
    36093777
    36103778  /* Create a dyn_string to hold the demangled name.  */
    36113779  demangled = dyn_string_new (0);
    36123780  /* 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);
    36143787
    36153788  if (STATUS_NO_ERROR (status))
     
    36353808}
    36363809
    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
     3817char *
     3818java_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.  */
     3925static demangling_t
     3926demangle_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.  */
     3964enum gnu_v3_ctor_kinds
     3965is_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.  */
     3986enum gnu_v3_dtor_kinds
     3987is_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
    36384003
    36394004#ifdef STANDALONE_DEMANGLER
     
    36704035
    36714036/* Option specification for getopt_long.  */
    3672 static struct option long_options[] =
     4037static const struct option long_options[] =
    36734038{
    36744039  { "help",    no_argument, NULL, 'h' },
     
    37724137
    37734138          /* Attempt to demangle the name.  */
    3774           status = cp_demangle (dyn_string_buf (mangled), demangled);
     4139          status = cp_demangle (dyn_string_buf (mangled), demangled, 0);
    37754140
    37764141          /* If the demangling succeeded, great!  Print out the
     
    38114176        {
    38124177          /* Attempt to demangle.  */
    3813           status = cp_demangle (argv[i], result);
     4178          status = cp_demangle (argv[i], result, 0);
    38144179
    38154180          /* If it worked, print the demangled name.  */
     
    38194184          else if (status == STATUS_ALLOCATION_FAILED)
    38204185            {
    3821               fprintf (stderr, "Memory allocaiton failed.\n");
     4186              fprintf (stderr, "Memory allocation failed.\n");
    38224187              abort ();
    38234188            }
Note: See TracChangeset for help on using the changeset viewer.