| 1 | 17 | khays | /* Defs for interface to demanglers.
 | 
      
         | 2 |  |  |    Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002,
 | 
      
         | 3 |  |  |    2003, 2004, 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
 | 
      
         | 4 |  |  |  
 | 
      
         | 5 |  |  |    This program is free software; you can redistribute it and/or
 | 
      
         | 6 |  |  |    modify it under the terms of the GNU Library General Public License
 | 
      
         | 7 |  |  |    as published by the Free Software Foundation; either version 2, or
 | 
      
         | 8 |  |  |    (at your option) any later version.
 | 
      
         | 9 |  |  |  
 | 
      
         | 10 |  |  |    In addition to the permissions in the GNU Library General Public
 | 
      
         | 11 |  |  |    License, the Free Software Foundation gives you unlimited
 | 
      
         | 12 |  |  |    permission to link the compiled version of this file into
 | 
      
         | 13 |  |  |    combinations with other programs, and to distribute those
 | 
      
         | 14 |  |  |    combinations without any restriction coming from the use of this
 | 
      
         | 15 |  |  |    file.  (The Library Public License restrictions do apply in other
 | 
      
         | 16 |  |  |    respects; for example, they cover modification of the file, and
 | 
      
         | 17 |  |  |    distribution when not linked into a combined executable.)
 | 
      
         | 18 |  |  |  
 | 
      
         | 19 |  |  |    This program is distributed in the hope that it will be useful, but
 | 
      
         | 20 |  |  |    WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
      
         | 21 |  |  |    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 | 
      
         | 22 |  |  |    Library General Public License for more details.
 | 
      
         | 23 |  |  |  
 | 
      
         | 24 |  |  |    You should have received a copy of the GNU Library General Public
 | 
      
         | 25 |  |  |    License along with this program; if not, write to the Free Software
 | 
      
         | 26 |  |  |    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
 | 
      
         | 27 |  |  |    02110-1301, USA.  */
 | 
      
         | 28 |  |  |  
 | 
      
         | 29 |  |  |  
 | 
      
         | 30 |  |  | #if !defined (DEMANGLE_H)
 | 
      
         | 31 |  |  | #define DEMANGLE_H
 | 
      
         | 32 |  |  |  
 | 
      
         | 33 |  |  | #include "libiberty.h"
 | 
      
         | 34 |  |  |  
 | 
      
         | 35 |  |  | #ifdef __cplusplus
 | 
      
         | 36 |  |  | extern "C" {
 | 
      
         | 37 |  |  | #endif /* __cplusplus */
 | 
      
         | 38 |  |  |  
 | 
      
         | 39 |  |  | /* Options passed to cplus_demangle (in 2nd parameter). */
 | 
      
         | 40 |  |  |  
 | 
      
         | 41 |  |  | #define DMGL_NO_OPTS     0              /* For readability... */
 | 
      
         | 42 |  |  | #define DMGL_PARAMS      (1 << 0)       /* Include function args */
 | 
      
         | 43 |  |  | #define DMGL_ANSI        (1 << 1)       /* Include const, volatile, etc */
 | 
      
         | 44 |  |  | #define DMGL_JAVA        (1 << 2)       /* Demangle as Java rather than C++. */
 | 
      
         | 45 |  |  | #define DMGL_VERBOSE     (1 << 3)       /* Include implementation details.  */
 | 
      
         | 46 |  |  | #define DMGL_TYPES       (1 << 4)       /* Also try to demangle type encodings.  */
 | 
      
         | 47 |  |  | #define DMGL_RET_POSTFIX (1 << 5)       /* Print function return types (when
 | 
      
         | 48 | 161 | khays |                                            present) after function signature.
 | 
      
         | 49 |  |  |                                            It applies only to the toplevel
 | 
      
         | 50 |  |  |                                            function type.  */
 | 
      
         | 51 |  |  | #define DMGL_RET_DROP    (1 << 6)       /* Suppress printing function return
 | 
      
         | 52 |  |  |                                            types, even if present.  It applies
 | 
      
         | 53 |  |  |                                            only to the toplevel function type.
 | 
      
         | 54 |  |  |                                            */
 | 
      
         | 55 | 17 | khays |  
 | 
      
         | 56 |  |  | #define DMGL_AUTO        (1 << 8)
 | 
      
         | 57 |  |  | #define DMGL_GNU         (1 << 9)
 | 
      
         | 58 |  |  | #define DMGL_LUCID       (1 << 10)
 | 
      
         | 59 |  |  | #define DMGL_ARM         (1 << 11)
 | 
      
         | 60 |  |  | #define DMGL_HP          (1 << 12)       /* For the HP aCC compiler;
 | 
      
         | 61 |  |  |                                             same as ARM except for
 | 
      
         | 62 |  |  |                                             template arguments, etc. */
 | 
      
         | 63 |  |  | #define DMGL_EDG         (1 << 13)
 | 
      
         | 64 |  |  | #define DMGL_GNU_V3      (1 << 14)
 | 
      
         | 65 |  |  | #define DMGL_GNAT        (1 << 15)
 | 
      
         | 66 |  |  |  
 | 
      
         | 67 |  |  | /* If none of these are set, use 'current_demangling_style' as the default. */
 | 
      
         | 68 |  |  | #define DMGL_STYLE_MASK (DMGL_AUTO|DMGL_GNU|DMGL_LUCID|DMGL_ARM|DMGL_HP|DMGL_EDG|DMGL_GNU_V3|DMGL_JAVA|DMGL_GNAT)
 | 
      
         | 69 |  |  |  
 | 
      
         | 70 |  |  | /* Enumeration of possible demangling styles.
 | 
      
         | 71 |  |  |  
 | 
      
         | 72 |  |  |    Lucid and ARM styles are still kept logically distinct, even though
 | 
      
         | 73 |  |  |    they now both behave identically.  The resulting style is actual the
 | 
      
         | 74 |  |  |    union of both.  I.E. either style recognizes both "__pt__" and "__rf__"
 | 
      
         | 75 |  |  |    for operator "->", even though the first is lucid style and the second
 | 
      
         | 76 |  |  |    is ARM style. (FIXME?) */
 | 
      
         | 77 |  |  |  
 | 
      
         | 78 |  |  | extern enum demangling_styles
 | 
      
         | 79 |  |  | {
 | 
      
         | 80 |  |  |   no_demangling = -1,
 | 
      
         | 81 |  |  |   unknown_demangling = 0,
 | 
      
         | 82 |  |  |   auto_demangling = DMGL_AUTO,
 | 
      
         | 83 |  |  |   gnu_demangling = DMGL_GNU,
 | 
      
         | 84 |  |  |   lucid_demangling = DMGL_LUCID,
 | 
      
         | 85 |  |  |   arm_demangling = DMGL_ARM,
 | 
      
         | 86 |  |  |   hp_demangling = DMGL_HP,
 | 
      
         | 87 |  |  |   edg_demangling = DMGL_EDG,
 | 
      
         | 88 |  |  |   gnu_v3_demangling = DMGL_GNU_V3,
 | 
      
         | 89 |  |  |   java_demangling = DMGL_JAVA,
 | 
      
         | 90 |  |  |   gnat_demangling = DMGL_GNAT
 | 
      
         | 91 |  |  | } current_demangling_style;
 | 
      
         | 92 |  |  |  
 | 
      
         | 93 |  |  | /* Define string names for the various demangling styles. */
 | 
      
         | 94 |  |  |  
 | 
      
         | 95 |  |  | #define NO_DEMANGLING_STYLE_STRING            "none"
 | 
      
         | 96 |  |  | #define AUTO_DEMANGLING_STYLE_STRING          "auto"
 | 
      
         | 97 |  |  | #define GNU_DEMANGLING_STYLE_STRING           "gnu"
 | 
      
         | 98 |  |  | #define LUCID_DEMANGLING_STYLE_STRING         "lucid"
 | 
      
         | 99 |  |  | #define ARM_DEMANGLING_STYLE_STRING           "arm"
 | 
      
         | 100 |  |  | #define HP_DEMANGLING_STYLE_STRING            "hp"
 | 
      
         | 101 |  |  | #define EDG_DEMANGLING_STYLE_STRING           "edg"
 | 
      
         | 102 |  |  | #define GNU_V3_DEMANGLING_STYLE_STRING        "gnu-v3"
 | 
      
         | 103 |  |  | #define JAVA_DEMANGLING_STYLE_STRING          "java"
 | 
      
         | 104 |  |  | #define GNAT_DEMANGLING_STYLE_STRING          "gnat"
 | 
      
         | 105 |  |  |  
 | 
      
         | 106 |  |  | /* Some macros to test what demangling style is active. */
 | 
      
         | 107 |  |  |  
 | 
      
         | 108 |  |  | #define CURRENT_DEMANGLING_STYLE current_demangling_style
 | 
      
         | 109 |  |  | #define AUTO_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_AUTO)
 | 
      
         | 110 |  |  | #define GNU_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_GNU)
 | 
      
         | 111 |  |  | #define LUCID_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_LUCID)
 | 
      
         | 112 |  |  | #define ARM_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_ARM)
 | 
      
         | 113 |  |  | #define HP_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_HP)
 | 
      
         | 114 |  |  | #define EDG_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_EDG)
 | 
      
         | 115 |  |  | #define GNU_V3_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_GNU_V3)
 | 
      
         | 116 |  |  | #define JAVA_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_JAVA)
 | 
      
         | 117 |  |  | #define GNAT_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_GNAT)
 | 
      
         | 118 |  |  |  
 | 
      
         | 119 |  |  | /* Provide information about the available demangle styles. This code is
 | 
      
         | 120 |  |  |    pulled from gdb into libiberty because it is useful to binutils also.  */
 | 
      
         | 121 |  |  |  
 | 
      
         | 122 |  |  | extern const struct demangler_engine
 | 
      
         | 123 |  |  | {
 | 
      
         | 124 |  |  |   const char *const demangling_style_name;
 | 
      
         | 125 |  |  |   const enum demangling_styles demangling_style;
 | 
      
         | 126 |  |  |   const char *const demangling_style_doc;
 | 
      
         | 127 |  |  | } libiberty_demanglers[];
 | 
      
         | 128 |  |  |  
 | 
      
         | 129 |  |  | extern char *
 | 
      
         | 130 |  |  | cplus_demangle (const char *mangled, int options);
 | 
      
         | 131 |  |  |  
 | 
      
         | 132 |  |  | extern int
 | 
      
         | 133 |  |  | cplus_demangle_opname (const char *opname, char *result, int options);
 | 
      
         | 134 |  |  |  
 | 
      
         | 135 |  |  | extern const char *
 | 
      
         | 136 |  |  | cplus_mangle_opname (const char *opname, int options);
 | 
      
         | 137 |  |  |  
 | 
      
         | 138 |  |  | /* Note: This sets global state.  FIXME if you care about multi-threading. */
 | 
      
         | 139 |  |  |  
 | 
      
         | 140 |  |  | extern void
 | 
      
         | 141 |  |  | set_cplus_marker_for_demangling (int ch);
 | 
      
         | 142 |  |  |  
 | 
      
         | 143 |  |  | extern enum demangling_styles
 | 
      
         | 144 |  |  | cplus_demangle_set_style (enum demangling_styles style);
 | 
      
         | 145 |  |  |  
 | 
      
         | 146 |  |  | extern enum demangling_styles
 | 
      
         | 147 |  |  | cplus_demangle_name_to_style (const char *name);
 | 
      
         | 148 |  |  |  
 | 
      
         | 149 |  |  | /* Callback typedef for allocation-less demangler interfaces. */
 | 
      
         | 150 |  |  | typedef void (*demangle_callbackref) (const char *, size_t, void *);
 | 
      
         | 151 |  |  |  
 | 
      
         | 152 |  |  | /* V3 ABI demangling entry points, defined in cp-demangle.c.  Callback
 | 
      
         | 153 |  |  |    variants return non-zero on success, zero on error.  char* variants
 | 
      
         | 154 |  |  |    return a string allocated by malloc on success, NULL on error.  */
 | 
      
         | 155 |  |  | extern int
 | 
      
         | 156 |  |  | cplus_demangle_v3_callback (const char *mangled, int options,
 | 
      
         | 157 |  |  |                             demangle_callbackref callback, void *opaque);
 | 
      
         | 158 |  |  |  
 | 
      
         | 159 |  |  | extern char*
 | 
      
         | 160 |  |  | cplus_demangle_v3 (const char *mangled, int options);
 | 
      
         | 161 |  |  |  
 | 
      
         | 162 |  |  | extern int
 | 
      
         | 163 |  |  | java_demangle_v3_callback (const char *mangled,
 | 
      
         | 164 |  |  |                            demangle_callbackref callback, void *opaque);
 | 
      
         | 165 |  |  |  
 | 
      
         | 166 |  |  | extern char*
 | 
      
         | 167 |  |  | java_demangle_v3 (const char *mangled);
 | 
      
         | 168 |  |  |  
 | 
      
         | 169 |  |  | char *
 | 
      
         | 170 |  |  | ada_demangle (const char *mangled, int options);
 | 
      
         | 171 |  |  |  
 | 
      
         | 172 |  |  | enum gnu_v3_ctor_kinds {
 | 
      
         | 173 |  |  |   gnu_v3_complete_object_ctor = 1,
 | 
      
         | 174 |  |  |   gnu_v3_base_object_ctor,
 | 
      
         | 175 | 163 | khays |   gnu_v3_complete_object_allocating_ctor,
 | 
      
         | 176 |  |  |   gnu_v3_object_ctor_group
 | 
      
         | 177 | 17 | khays | };
 | 
      
         | 178 |  |  |  
 | 
      
         | 179 |  |  | /* Return non-zero iff NAME is the mangled form of a constructor name
 | 
      
         | 180 |  |  |    in the G++ V3 ABI demangling style.  Specifically, return an `enum
 | 
      
         | 181 |  |  |    gnu_v3_ctor_kinds' value indicating what kind of constructor
 | 
      
         | 182 |  |  |    it is.  */
 | 
      
         | 183 |  |  | extern enum gnu_v3_ctor_kinds
 | 
      
         | 184 |  |  |         is_gnu_v3_mangled_ctor (const char *name);
 | 
      
         | 185 |  |  |  
 | 
      
         | 186 |  |  |  
 | 
      
         | 187 |  |  | enum gnu_v3_dtor_kinds {
 | 
      
         | 188 |  |  |   gnu_v3_deleting_dtor = 1,
 | 
      
         | 189 |  |  |   gnu_v3_complete_object_dtor,
 | 
      
         | 190 | 163 | khays |   gnu_v3_base_object_dtor,
 | 
      
         | 191 |  |  |   gnu_v3_object_dtor_group
 | 
      
         | 192 | 17 | khays | };
 | 
      
         | 193 |  |  |  
 | 
      
         | 194 |  |  | /* Return non-zero iff NAME is the mangled form of a destructor name
 | 
      
         | 195 |  |  |    in the G++ V3 ABI demangling style.  Specifically, return an `enum
 | 
      
         | 196 |  |  |    gnu_v3_dtor_kinds' value, indicating what kind of destructor
 | 
      
         | 197 |  |  |    it is.  */
 | 
      
         | 198 |  |  | extern enum gnu_v3_dtor_kinds
 | 
      
         | 199 |  |  |         is_gnu_v3_mangled_dtor (const char *name);
 | 
      
         | 200 |  |  |  
 | 
      
         | 201 |  |  | /* The V3 demangler works in two passes.  The first pass builds a tree
 | 
      
         | 202 |  |  |    representation of the mangled name, and the second pass turns the
 | 
      
         | 203 |  |  |    tree representation into a demangled string.  Here we define an
 | 
      
         | 204 |  |  |    interface to permit a caller to build their own tree
 | 
      
         | 205 |  |  |    representation, which they can pass to the demangler to get a
 | 
      
         | 206 |  |  |    demangled string.  This can be used to canonicalize user input into
 | 
      
         | 207 |  |  |    something which the demangler might output.  It could also be used
 | 
      
         | 208 |  |  |    by other demanglers in the future.  */
 | 
      
         | 209 |  |  |  
 | 
      
         | 210 |  |  | /* These are the component types which may be found in the tree.  Many
 | 
      
         | 211 |  |  |    component types have one or two subtrees, referred to as left and
 | 
      
         | 212 |  |  |    right (a component type with only one subtree puts it in the left
 | 
      
         | 213 |  |  |    subtree).  */
 | 
      
         | 214 |  |  |  
 | 
      
         | 215 |  |  | enum demangle_component_type
 | 
      
         | 216 |  |  | {
 | 
      
         | 217 |  |  |   /* A name, with a length and a pointer to a string.  */
 | 
      
         | 218 |  |  |   DEMANGLE_COMPONENT_NAME,
 | 
      
         | 219 |  |  |   /* A qualified name.  The left subtree is a class or namespace or
 | 
      
         | 220 |  |  |      some such thing, and the right subtree is a name qualified by
 | 
      
         | 221 |  |  |      that class.  */
 | 
      
         | 222 |  |  |   DEMANGLE_COMPONENT_QUAL_NAME,
 | 
      
         | 223 |  |  |   /* A local name.  The left subtree describes a function, and the
 | 
      
         | 224 |  |  |      right subtree is a name which is local to that function.  */
 | 
      
         | 225 |  |  |   DEMANGLE_COMPONENT_LOCAL_NAME,
 | 
      
         | 226 |  |  |   /* A typed name.  The left subtree is a name, and the right subtree
 | 
      
         | 227 |  |  |      describes that name as a function.  */
 | 
      
         | 228 |  |  |   DEMANGLE_COMPONENT_TYPED_NAME,
 | 
      
         | 229 |  |  |   /* A template.  The left subtree is a template name, and the right
 | 
      
         | 230 |  |  |      subtree is a template argument list.  */
 | 
      
         | 231 |  |  |   DEMANGLE_COMPONENT_TEMPLATE,
 | 
      
         | 232 |  |  |   /* A template parameter.  This holds a number, which is the template
 | 
      
         | 233 |  |  |      parameter index.  */
 | 
      
         | 234 |  |  |   DEMANGLE_COMPONENT_TEMPLATE_PARAM,
 | 
      
         | 235 |  |  |   /* A function parameter.  This holds a number, which is the index.  */
 | 
      
         | 236 |  |  |   DEMANGLE_COMPONENT_FUNCTION_PARAM,
 | 
      
         | 237 |  |  |   /* A constructor.  This holds a name and the kind of
 | 
      
         | 238 |  |  |      constructor.  */
 | 
      
         | 239 |  |  |   DEMANGLE_COMPONENT_CTOR,
 | 
      
         | 240 |  |  |   /* A destructor.  This holds a name and the kind of destructor.  */
 | 
      
         | 241 |  |  |   DEMANGLE_COMPONENT_DTOR,
 | 
      
         | 242 |  |  |   /* A vtable.  This has one subtree, the type for which this is a
 | 
      
         | 243 |  |  |      vtable.  */
 | 
      
         | 244 |  |  |   DEMANGLE_COMPONENT_VTABLE,
 | 
      
         | 245 |  |  |   /* A VTT structure.  This has one subtree, the type for which this
 | 
      
         | 246 |  |  |      is a VTT.  */
 | 
      
         | 247 |  |  |   DEMANGLE_COMPONENT_VTT,
 | 
      
         | 248 |  |  |   /* A construction vtable.  The left subtree is the type for which
 | 
      
         | 249 |  |  |      this is a vtable, and the right subtree is the derived type for
 | 
      
         | 250 |  |  |      which this vtable is built.  */
 | 
      
         | 251 |  |  |   DEMANGLE_COMPONENT_CONSTRUCTION_VTABLE,
 | 
      
         | 252 |  |  |   /* A typeinfo structure.  This has one subtree, the type for which
 | 
      
         | 253 |  |  |      this is the tpeinfo structure.  */
 | 
      
         | 254 |  |  |   DEMANGLE_COMPONENT_TYPEINFO,
 | 
      
         | 255 |  |  |   /* A typeinfo name.  This has one subtree, the type for which this
 | 
      
         | 256 |  |  |      is the typeinfo name.  */
 | 
      
         | 257 |  |  |   DEMANGLE_COMPONENT_TYPEINFO_NAME,
 | 
      
         | 258 |  |  |   /* A typeinfo function.  This has one subtree, the type for which
 | 
      
         | 259 |  |  |      this is the tpyeinfo function.  */
 | 
      
         | 260 |  |  |   DEMANGLE_COMPONENT_TYPEINFO_FN,
 | 
      
         | 261 |  |  |   /* A thunk.  This has one subtree, the name for which this is a
 | 
      
         | 262 |  |  |      thunk.  */
 | 
      
         | 263 |  |  |   DEMANGLE_COMPONENT_THUNK,
 | 
      
         | 264 |  |  |   /* A virtual thunk.  This has one subtree, the name for which this
 | 
      
         | 265 |  |  |      is a virtual thunk.  */
 | 
      
         | 266 |  |  |   DEMANGLE_COMPONENT_VIRTUAL_THUNK,
 | 
      
         | 267 |  |  |   /* A covariant thunk.  This has one subtree, the name for which this
 | 
      
         | 268 |  |  |      is a covariant thunk.  */
 | 
      
         | 269 |  |  |   DEMANGLE_COMPONENT_COVARIANT_THUNK,
 | 
      
         | 270 |  |  |   /* A Java class.  This has one subtree, the type.  */
 | 
      
         | 271 |  |  |   DEMANGLE_COMPONENT_JAVA_CLASS,
 | 
      
         | 272 |  |  |   /* A guard variable.  This has one subtree, the name for which this
 | 
      
         | 273 |  |  |      is a guard variable.  */
 | 
      
         | 274 |  |  |   DEMANGLE_COMPONENT_GUARD,
 | 
      
         | 275 |  |  |   /* A reference temporary.  This has one subtree, the name for which
 | 
      
         | 276 |  |  |      this is a temporary.  */
 | 
      
         | 277 |  |  |   DEMANGLE_COMPONENT_REFTEMP,
 | 
      
         | 278 |  |  |   /* A hidden alias.  This has one subtree, the encoding for which it
 | 
      
         | 279 |  |  |      is providing alternative linkage.  */
 | 
      
         | 280 |  |  |   DEMANGLE_COMPONENT_HIDDEN_ALIAS,
 | 
      
         | 281 |  |  |   /* A standard substitution.  This holds the name of the
 | 
      
         | 282 |  |  |      substitution.  */
 | 
      
         | 283 |  |  |   DEMANGLE_COMPONENT_SUB_STD,
 | 
      
         | 284 |  |  |   /* The restrict qualifier.  The one subtree is the type which is
 | 
      
         | 285 |  |  |      being qualified.  */
 | 
      
         | 286 |  |  |   DEMANGLE_COMPONENT_RESTRICT,
 | 
      
         | 287 |  |  |   /* The volatile qualifier.  The one subtree is the type which is
 | 
      
         | 288 |  |  |      being qualified.  */
 | 
      
         | 289 |  |  |   DEMANGLE_COMPONENT_VOLATILE,
 | 
      
         | 290 |  |  |   /* The const qualifier.  The one subtree is the type which is being
 | 
      
         | 291 |  |  |      qualified.  */
 | 
      
         | 292 |  |  |   DEMANGLE_COMPONENT_CONST,
 | 
      
         | 293 |  |  |   /* The restrict qualifier modifying a member function.  The one
 | 
      
         | 294 |  |  |      subtree is the type which is being qualified.  */
 | 
      
         | 295 |  |  |   DEMANGLE_COMPONENT_RESTRICT_THIS,
 | 
      
         | 296 |  |  |   /* The volatile qualifier modifying a member function.  The one
 | 
      
         | 297 |  |  |      subtree is the type which is being qualified.  */
 | 
      
         | 298 |  |  |   DEMANGLE_COMPONENT_VOLATILE_THIS,
 | 
      
         | 299 |  |  |   /* The const qualifier modifying a member function.  The one subtree
 | 
      
         | 300 |  |  |      is the type which is being qualified.  */
 | 
      
         | 301 |  |  |   DEMANGLE_COMPONENT_CONST_THIS,
 | 
      
         | 302 |  |  |   /* A vendor qualifier.  The left subtree is the type which is being
 | 
      
         | 303 |  |  |      qualified, and the right subtree is the name of the
 | 
      
         | 304 |  |  |      qualifier.  */
 | 
      
         | 305 |  |  |   DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL,
 | 
      
         | 306 |  |  |   /* A pointer.  The one subtree is the type which is being pointed
 | 
      
         | 307 |  |  |      to.  */
 | 
      
         | 308 |  |  |   DEMANGLE_COMPONENT_POINTER,
 | 
      
         | 309 |  |  |   /* A reference.  The one subtree is the type which is being
 | 
      
         | 310 |  |  |      referenced.  */
 | 
      
         | 311 |  |  |   DEMANGLE_COMPONENT_REFERENCE,
 | 
      
         | 312 |  |  |   /* C++0x: An rvalue reference.  The one subtree is the type which is
 | 
      
         | 313 |  |  |      being referenced.  */
 | 
      
         | 314 |  |  |   DEMANGLE_COMPONENT_RVALUE_REFERENCE,
 | 
      
         | 315 |  |  |   /* A complex type.  The one subtree is the base type.  */
 | 
      
         | 316 |  |  |   DEMANGLE_COMPONENT_COMPLEX,
 | 
      
         | 317 |  |  |   /* An imaginary type.  The one subtree is the base type.  */
 | 
      
         | 318 |  |  |   DEMANGLE_COMPONENT_IMAGINARY,
 | 
      
         | 319 |  |  |   /* A builtin type.  This holds the builtin type information.  */
 | 
      
         | 320 |  |  |   DEMANGLE_COMPONENT_BUILTIN_TYPE,
 | 
      
         | 321 |  |  |   /* A vendor's builtin type.  This holds the name of the type.  */
 | 
      
         | 322 |  |  |   DEMANGLE_COMPONENT_VENDOR_TYPE,
 | 
      
         | 323 |  |  |   /* A function type.  The left subtree is the return type.  The right
 | 
      
         | 324 |  |  |      subtree is a list of ARGLIST nodes.  Either or both may be
 | 
      
         | 325 |  |  |      NULL.  */
 | 
      
         | 326 |  |  |   DEMANGLE_COMPONENT_FUNCTION_TYPE,
 | 
      
         | 327 |  |  |   /* An array type.  The left subtree is the dimension, which may be
 | 
      
         | 328 |  |  |      NULL, or a string (represented as DEMANGLE_COMPONENT_NAME), or an
 | 
      
         | 329 |  |  |      expression.  The right subtree is the element type.  */
 | 
      
         | 330 |  |  |   DEMANGLE_COMPONENT_ARRAY_TYPE,
 | 
      
         | 331 |  |  |   /* A pointer to member type.  The left subtree is the class type,
 | 
      
         | 332 |  |  |      and the right subtree is the member type.  CV-qualifiers appear
 | 
      
         | 333 |  |  |      on the latter.  */
 | 
      
         | 334 |  |  |   DEMANGLE_COMPONENT_PTRMEM_TYPE,
 | 
      
         | 335 |  |  |   /* A fixed-point type.  */
 | 
      
         | 336 |  |  |   DEMANGLE_COMPONENT_FIXED_TYPE,
 | 
      
         | 337 |  |  |   /* A vector type.  The left subtree is the number of elements,
 | 
      
         | 338 |  |  |      the right subtree is the element type.  */
 | 
      
         | 339 |  |  |   DEMANGLE_COMPONENT_VECTOR_TYPE,
 | 
      
         | 340 |  |  |   /* An argument list.  The left subtree is the current argument, and
 | 
      
         | 341 |  |  |      the right subtree is either NULL or another ARGLIST node.  */
 | 
      
         | 342 |  |  |   DEMANGLE_COMPONENT_ARGLIST,
 | 
      
         | 343 |  |  |   /* A template argument list.  The left subtree is the current
 | 
      
         | 344 |  |  |      template argument, and the right subtree is either NULL or
 | 
      
         | 345 |  |  |      another TEMPLATE_ARGLIST node.  */
 | 
      
         | 346 |  |  |   DEMANGLE_COMPONENT_TEMPLATE_ARGLIST,
 | 
      
         | 347 |  |  |   /* An operator.  This holds information about a standard
 | 
      
         | 348 |  |  |      operator.  */
 | 
      
         | 349 |  |  |   DEMANGLE_COMPONENT_OPERATOR,
 | 
      
         | 350 |  |  |   /* An extended operator.  This holds the number of arguments, and
 | 
      
         | 351 |  |  |      the name of the extended operator.  */
 | 
      
         | 352 |  |  |   DEMANGLE_COMPONENT_EXTENDED_OPERATOR,
 | 
      
         | 353 |  |  |   /* A typecast, represented as a unary operator.  The one subtree is
 | 
      
         | 354 |  |  |      the type to which the argument should be cast.  */
 | 
      
         | 355 |  |  |   DEMANGLE_COMPONENT_CAST,
 | 
      
         | 356 |  |  |   /* A unary expression.  The left subtree is the operator, and the
 | 
      
         | 357 |  |  |      right subtree is the single argument.  */
 | 
      
         | 358 |  |  |   DEMANGLE_COMPONENT_UNARY,
 | 
      
         | 359 |  |  |   /* A binary expression.  The left subtree is the operator, and the
 | 
      
         | 360 |  |  |      right subtree is a BINARY_ARGS.  */
 | 
      
         | 361 |  |  |   DEMANGLE_COMPONENT_BINARY,
 | 
      
         | 362 |  |  |   /* Arguments to a binary expression.  The left subtree is the first
 | 
      
         | 363 |  |  |      argument, and the right subtree is the second argument.  */
 | 
      
         | 364 |  |  |   DEMANGLE_COMPONENT_BINARY_ARGS,
 | 
      
         | 365 |  |  |   /* A trinary expression.  The left subtree is the operator, and the
 | 
      
         | 366 |  |  |      right subtree is a TRINARY_ARG1.  */
 | 
      
         | 367 |  |  |   DEMANGLE_COMPONENT_TRINARY,
 | 
      
         | 368 |  |  |   /* Arguments to a trinary expression.  The left subtree is the first
 | 
      
         | 369 |  |  |      argument, and the right subtree is a TRINARY_ARG2.  */
 | 
      
         | 370 |  |  |   DEMANGLE_COMPONENT_TRINARY_ARG1,
 | 
      
         | 371 |  |  |   /* More arguments to a trinary expression.  The left subtree is the
 | 
      
         | 372 |  |  |      second argument, and the right subtree is the third argument.  */
 | 
      
         | 373 |  |  |   DEMANGLE_COMPONENT_TRINARY_ARG2,
 | 
      
         | 374 |  |  |   /* A literal.  The left subtree is the type, and the right subtree
 | 
      
         | 375 |  |  |      is the value, represented as a DEMANGLE_COMPONENT_NAME.  */
 | 
      
         | 376 |  |  |   DEMANGLE_COMPONENT_LITERAL,
 | 
      
         | 377 |  |  |   /* A negative literal.  Like LITERAL, but the value is negated.
 | 
      
         | 378 |  |  |      This is a minor hack: the NAME used for LITERAL points directly
 | 
      
         | 379 |  |  |      to the mangled string, but since negative numbers are mangled
 | 
      
         | 380 |  |  |      using 'n' instead of '-', we want a way to indicate a negative
 | 
      
         | 381 |  |  |      number which involves neither modifying the mangled string nor
 | 
      
         | 382 |  |  |      allocating a new copy of the literal in memory.  */
 | 
      
         | 383 |  |  |   DEMANGLE_COMPONENT_LITERAL_NEG,
 | 
      
         | 384 |  |  |   /* A libgcj compiled resource.  The left subtree is the name of the
 | 
      
         | 385 |  |  |      resource.  */
 | 
      
         | 386 |  |  |   DEMANGLE_COMPONENT_JAVA_RESOURCE,
 | 
      
         | 387 |  |  |   /* A name formed by the concatenation of two parts.  The left
 | 
      
         | 388 |  |  |      subtree is the first part and the right subtree the second.  */
 | 
      
         | 389 |  |  |   DEMANGLE_COMPONENT_COMPOUND_NAME,
 | 
      
         | 390 |  |  |   /* A name formed by a single character.  */
 | 
      
         | 391 |  |  |   DEMANGLE_COMPONENT_CHARACTER,
 | 
      
         | 392 |  |  |   /* A number.  */
 | 
      
         | 393 |  |  |   DEMANGLE_COMPONENT_NUMBER,
 | 
      
         | 394 |  |  |   /* A decltype type.  */
 | 
      
         | 395 |  |  |   DEMANGLE_COMPONENT_DECLTYPE,
 | 
      
         | 396 |  |  |   /* Global constructors keyed to name.  */
 | 
      
         | 397 |  |  |   DEMANGLE_COMPONENT_GLOBAL_CONSTRUCTORS,
 | 
      
         | 398 |  |  |   /* Global destructors keyed to name.  */
 | 
      
         | 399 |  |  |   DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS,
 | 
      
         | 400 |  |  |   /* A lambda closure type.  */
 | 
      
         | 401 |  |  |   DEMANGLE_COMPONENT_LAMBDA,
 | 
      
         | 402 |  |  |   /* A default argument scope.  */
 | 
      
         | 403 |  |  |   DEMANGLE_COMPONENT_DEFAULT_ARG,
 | 
      
         | 404 |  |  |   /* An unnamed type.  */
 | 
      
         | 405 |  |  |   DEMANGLE_COMPONENT_UNNAMED_TYPE,
 | 
      
         | 406 | 163 | khays |   /* A transactional clone.  This has one subtree, the encoding for
 | 
      
         | 407 |  |  |      which it is providing alternative linkage.  */
 | 
      
         | 408 |  |  |   DEMANGLE_COMPONENT_TRANSACTION_CLONE,
 | 
      
         | 409 |  |  |   /* A non-transactional clone entry point.  In the i386/x86_64 abi,
 | 
      
         | 410 |  |  |      the unmangled symbol of a tm_callable becomes a thunk and the
 | 
      
         | 411 |  |  |      non-transactional function version is mangled thus.  */
 | 
      
         | 412 |  |  |   DEMANGLE_COMPONENT_NONTRANSACTION_CLONE,
 | 
      
         | 413 | 17 | khays |   /* A pack expansion.  */
 | 
      
         | 414 | 163 | khays |   DEMANGLE_COMPONENT_PACK_EXPANSION,
 | 
      
         | 415 |  |  |   /* A cloned function.  */
 | 
      
         | 416 |  |  |   DEMANGLE_COMPONENT_CLONE
 | 
      
         | 417 | 17 | khays | };
 | 
      
         | 418 |  |  |  
 | 
      
         | 419 |  |  | /* Types which are only used internally.  */
 | 
      
         | 420 |  |  |  
 | 
      
         | 421 |  |  | struct demangle_operator_info;
 | 
      
         | 422 |  |  | struct demangle_builtin_type_info;
 | 
      
         | 423 |  |  |  
 | 
      
         | 424 |  |  | /* A node in the tree representation is an instance of a struct
 | 
      
         | 425 |  |  |    demangle_component.  Note that the field names of the struct are
 | 
      
         | 426 |  |  |    not well protected against macros defined by the file including
 | 
      
         | 427 |  |  |    this one.  We can fix this if it ever becomes a problem.  */
 | 
      
         | 428 |  |  |  
 | 
      
         | 429 |  |  | struct demangle_component
 | 
      
         | 430 |  |  | {
 | 
      
         | 431 |  |  |   /* The type of this component.  */
 | 
      
         | 432 |  |  |   enum demangle_component_type type;
 | 
      
         | 433 |  |  |  
 | 
      
         | 434 |  |  |   union
 | 
      
         | 435 |  |  |   {
 | 
      
         | 436 |  |  |     /* For DEMANGLE_COMPONENT_NAME.  */
 | 
      
         | 437 |  |  |     struct
 | 
      
         | 438 |  |  |     {
 | 
      
         | 439 |  |  |       /* A pointer to the name (which need not NULL terminated) and
 | 
      
         | 440 |  |  |          its length.  */
 | 
      
         | 441 |  |  |       const char *s;
 | 
      
         | 442 |  |  |       int len;
 | 
      
         | 443 |  |  |     } s_name;
 | 
      
         | 444 |  |  |  
 | 
      
         | 445 |  |  |     /* For DEMANGLE_COMPONENT_OPERATOR.  */
 | 
      
         | 446 |  |  |     struct
 | 
      
         | 447 |  |  |     {
 | 
      
         | 448 |  |  |       /* Operator.  */
 | 
      
         | 449 |  |  |       const struct demangle_operator_info *op;
 | 
      
         | 450 |  |  |     } s_operator;
 | 
      
         | 451 |  |  |  
 | 
      
         | 452 |  |  |     /* For DEMANGLE_COMPONENT_EXTENDED_OPERATOR.  */
 | 
      
         | 453 |  |  |     struct
 | 
      
         | 454 |  |  |     {
 | 
      
         | 455 |  |  |       /* Number of arguments.  */
 | 
      
         | 456 |  |  |       int args;
 | 
      
         | 457 |  |  |       /* Name.  */
 | 
      
         | 458 |  |  |       struct demangle_component *name;
 | 
      
         | 459 |  |  |     } s_extended_operator;
 | 
      
         | 460 |  |  |  
 | 
      
         | 461 |  |  |     /* For DEMANGLE_COMPONENT_FIXED_TYPE.  */
 | 
      
         | 462 |  |  |     struct
 | 
      
         | 463 |  |  |     {
 | 
      
         | 464 |  |  |       /* The length, indicated by a C integer type name.  */
 | 
      
         | 465 |  |  |       struct demangle_component *length;
 | 
      
         | 466 |  |  |       /* _Accum or _Fract?  */
 | 
      
         | 467 |  |  |       short accum;
 | 
      
         | 468 |  |  |       /* Saturating or not?  */
 | 
      
         | 469 |  |  |       short sat;
 | 
      
         | 470 |  |  |     } s_fixed;
 | 
      
         | 471 |  |  |  
 | 
      
         | 472 |  |  |     /* For DEMANGLE_COMPONENT_CTOR.  */
 | 
      
         | 473 |  |  |     struct
 | 
      
         | 474 |  |  |     {
 | 
      
         | 475 |  |  |       /* Kind of constructor.  */
 | 
      
         | 476 |  |  |       enum gnu_v3_ctor_kinds kind;
 | 
      
         | 477 |  |  |       /* Name.  */
 | 
      
         | 478 |  |  |       struct demangle_component *name;
 | 
      
         | 479 |  |  |     } s_ctor;
 | 
      
         | 480 |  |  |  
 | 
      
         | 481 |  |  |     /* For DEMANGLE_COMPONENT_DTOR.  */
 | 
      
         | 482 |  |  |     struct
 | 
      
         | 483 |  |  |     {
 | 
      
         | 484 |  |  |       /* Kind of destructor.  */
 | 
      
         | 485 |  |  |       enum gnu_v3_dtor_kinds kind;
 | 
      
         | 486 |  |  |       /* Name.  */
 | 
      
         | 487 |  |  |       struct demangle_component *name;
 | 
      
         | 488 |  |  |     } s_dtor;
 | 
      
         | 489 |  |  |  
 | 
      
         | 490 |  |  |     /* For DEMANGLE_COMPONENT_BUILTIN_TYPE.  */
 | 
      
         | 491 |  |  |     struct
 | 
      
         | 492 |  |  |     {
 | 
      
         | 493 |  |  |       /* Builtin type.  */
 | 
      
         | 494 |  |  |       const struct demangle_builtin_type_info *type;
 | 
      
         | 495 |  |  |     } s_builtin;
 | 
      
         | 496 |  |  |  
 | 
      
         | 497 |  |  |     /* For DEMANGLE_COMPONENT_SUB_STD.  */
 | 
      
         | 498 |  |  |     struct
 | 
      
         | 499 |  |  |     {
 | 
      
         | 500 |  |  |       /* Standard substitution string.  */
 | 
      
         | 501 |  |  |       const char* string;
 | 
      
         | 502 |  |  |       /* Length of string.  */
 | 
      
         | 503 |  |  |       int len;
 | 
      
         | 504 |  |  |     } s_string;
 | 
      
         | 505 |  |  |  
 | 
      
         | 506 |  |  |     /* For DEMANGLE_COMPONENT_*_PARAM.  */
 | 
      
         | 507 |  |  |     struct
 | 
      
         | 508 |  |  |     {
 | 
      
         | 509 |  |  |       /* Parameter index.  */
 | 
      
         | 510 |  |  |       long number;
 | 
      
         | 511 |  |  |     } s_number;
 | 
      
         | 512 |  |  |  
 | 
      
         | 513 |  |  |     /* For DEMANGLE_COMPONENT_CHARACTER.  */
 | 
      
         | 514 |  |  |     struct
 | 
      
         | 515 |  |  |     {
 | 
      
         | 516 |  |  |       int character;
 | 
      
         | 517 |  |  |     } s_character;
 | 
      
         | 518 |  |  |  
 | 
      
         | 519 |  |  |     /* For other types.  */
 | 
      
         | 520 |  |  |     struct
 | 
      
         | 521 |  |  |     {
 | 
      
         | 522 |  |  |       /* Left (or only) subtree.  */
 | 
      
         | 523 |  |  |       struct demangle_component *left;
 | 
      
         | 524 |  |  |       /* Right subtree.  */
 | 
      
         | 525 |  |  |       struct demangle_component *right;
 | 
      
         | 526 |  |  |     } s_binary;
 | 
      
         | 527 |  |  |  
 | 
      
         | 528 |  |  |     struct
 | 
      
         | 529 |  |  |     {
 | 
      
         | 530 |  |  |       /* subtree, same place as d_left.  */
 | 
      
         | 531 |  |  |       struct demangle_component *sub;
 | 
      
         | 532 |  |  |       /* integer.  */
 | 
      
         | 533 |  |  |       int num;
 | 
      
         | 534 |  |  |     } s_unary_num;
 | 
      
         | 535 |  |  |  
 | 
      
         | 536 |  |  |   } u;
 | 
      
         | 537 |  |  | };
 | 
      
         | 538 |  |  |  
 | 
      
         | 539 |  |  | /* People building mangled trees are expected to allocate instances of
 | 
      
         | 540 |  |  |    struct demangle_component themselves.  They can then call one of
 | 
      
         | 541 |  |  |    the following functions to fill them in.  */
 | 
      
         | 542 |  |  |  
 | 
      
         | 543 |  |  | /* Fill in most component types with a left subtree and a right
 | 
      
         | 544 |  |  |    subtree.  Returns non-zero on success, zero on failure, such as an
 | 
      
         | 545 |  |  |    unrecognized or inappropriate component type.  */
 | 
      
         | 546 |  |  |  
 | 
      
         | 547 |  |  | extern int
 | 
      
         | 548 |  |  | cplus_demangle_fill_component (struct demangle_component *fill,
 | 
      
         | 549 |  |  |                                enum demangle_component_type,
 | 
      
         | 550 |  |  |                                struct demangle_component *left,
 | 
      
         | 551 |  |  |                                struct demangle_component *right);
 | 
      
         | 552 |  |  |  
 | 
      
         | 553 |  |  | /* Fill in a DEMANGLE_COMPONENT_NAME.  Returns non-zero on success,
 | 
      
         | 554 |  |  |    zero for bad arguments.  */
 | 
      
         | 555 |  |  |  
 | 
      
         | 556 |  |  | extern int
 | 
      
         | 557 |  |  | cplus_demangle_fill_name (struct demangle_component *fill,
 | 
      
         | 558 |  |  |                           const char *, int);
 | 
      
         | 559 |  |  |  
 | 
      
         | 560 |  |  | /* Fill in a DEMANGLE_COMPONENT_BUILTIN_TYPE, using the name of the
 | 
      
         | 561 |  |  |    builtin type (e.g., "int", etc.).  Returns non-zero on success,
 | 
      
         | 562 |  |  |    zero if the type is not recognized.  */
 | 
      
         | 563 |  |  |  
 | 
      
         | 564 |  |  | extern int
 | 
      
         | 565 |  |  | cplus_demangle_fill_builtin_type (struct demangle_component *fill,
 | 
      
         | 566 |  |  |                                   const char *type_name);
 | 
      
         | 567 |  |  |  
 | 
      
         | 568 |  |  | /* Fill in a DEMANGLE_COMPONENT_OPERATOR, using the name of the
 | 
      
         | 569 |  |  |    operator and the number of arguments which it takes (the latter is
 | 
      
         | 570 |  |  |    used to disambiguate operators which can be both binary and unary,
 | 
      
         | 571 |  |  |    such as '-').  Returns non-zero on success, zero if the operator is
 | 
      
         | 572 |  |  |    not recognized.  */
 | 
      
         | 573 |  |  |  
 | 
      
         | 574 |  |  | extern int
 | 
      
         | 575 |  |  | cplus_demangle_fill_operator (struct demangle_component *fill,
 | 
      
         | 576 |  |  |                               const char *opname, int args);
 | 
      
         | 577 |  |  |  
 | 
      
         | 578 |  |  | /* Fill in a DEMANGLE_COMPONENT_EXTENDED_OPERATOR, providing the
 | 
      
         | 579 |  |  |    number of arguments and the name.  Returns non-zero on success,
 | 
      
         | 580 |  |  |    zero for bad arguments.  */
 | 
      
         | 581 |  |  |  
 | 
      
         | 582 |  |  | extern int
 | 
      
         | 583 |  |  | cplus_demangle_fill_extended_operator (struct demangle_component *fill,
 | 
      
         | 584 |  |  |                                        int numargs,
 | 
      
         | 585 |  |  |                                        struct demangle_component *nm);
 | 
      
         | 586 |  |  |  
 | 
      
         | 587 |  |  | /* Fill in a DEMANGLE_COMPONENT_CTOR.  Returns non-zero on success,
 | 
      
         | 588 |  |  |    zero for bad arguments.  */
 | 
      
         | 589 |  |  |  
 | 
      
         | 590 |  |  | extern int
 | 
      
         | 591 |  |  | cplus_demangle_fill_ctor (struct demangle_component *fill,
 | 
      
         | 592 |  |  |                           enum gnu_v3_ctor_kinds kind,
 | 
      
         | 593 |  |  |                           struct demangle_component *name);
 | 
      
         | 594 |  |  |  
 | 
      
         | 595 |  |  | /* Fill in a DEMANGLE_COMPONENT_DTOR.  Returns non-zero on success,
 | 
      
         | 596 |  |  |    zero for bad arguments.  */
 | 
      
         | 597 |  |  |  
 | 
      
         | 598 |  |  | extern int
 | 
      
         | 599 |  |  | cplus_demangle_fill_dtor (struct demangle_component *fill,
 | 
      
         | 600 |  |  |                           enum gnu_v3_dtor_kinds kind,
 | 
      
         | 601 |  |  |                           struct demangle_component *name);
 | 
      
         | 602 |  |  |  
 | 
      
         | 603 |  |  | /* This function translates a mangled name into a struct
 | 
      
         | 604 |  |  |    demangle_component tree.  The first argument is the mangled name.
 | 
      
         | 605 |  |  |    The second argument is DMGL_* options.  This returns a pointer to a
 | 
      
         | 606 |  |  |    tree on success, or NULL on failure.  On success, the third
 | 
      
         | 607 |  |  |    argument is set to a block of memory allocated by malloc.  This
 | 
      
         | 608 |  |  |    block should be passed to free when the tree is no longer
 | 
      
         | 609 |  |  |    needed.  */
 | 
      
         | 610 |  |  |  
 | 
      
         | 611 |  |  | extern struct demangle_component *
 | 
      
         | 612 |  |  | cplus_demangle_v3_components (const char *mangled, int options, void **mem);
 | 
      
         | 613 |  |  |  
 | 
      
         | 614 |  |  | /* This function takes a struct demangle_component tree and returns
 | 
      
         | 615 |  |  |    the corresponding demangled string.  The first argument is DMGL_*
 | 
      
         | 616 |  |  |    options.  The second is the tree to demangle.  The third is a guess
 | 
      
         | 617 |  |  |    at the length of the demangled string, used to initially allocate
 | 
      
         | 618 |  |  |    the return buffer.  The fourth is a pointer to a size_t.  On
 | 
      
         | 619 |  |  |    success, this function returns a buffer allocated by malloc(), and
 | 
      
         | 620 |  |  |    sets the size_t pointed to by the fourth argument to the size of
 | 
      
         | 621 |  |  |    the allocated buffer (not the length of the returned string).  On
 | 
      
         | 622 |  |  |    failure, this function returns NULL, and sets the size_t pointed to
 | 
      
         | 623 |  |  |    by the fourth argument to 0 for an invalid tree, or to 1 for a
 | 
      
         | 624 |  |  |    memory allocation error.  */
 | 
      
         | 625 |  |  |  
 | 
      
         | 626 |  |  | extern char *
 | 
      
         | 627 |  |  | cplus_demangle_print (int options,
 | 
      
         | 628 |  |  |                       const struct demangle_component *tree,
 | 
      
         | 629 |  |  |                       int estimated_length,
 | 
      
         | 630 |  |  |                       size_t *p_allocated_size);
 | 
      
         | 631 |  |  |  
 | 
      
         | 632 |  |  | /* This function takes a struct demangle_component tree and passes back
 | 
      
         | 633 |  |  |    a demangled string in one or more calls to a callback function.
 | 
      
         | 634 |  |  |    The first argument is DMGL_* options.  The second is the tree to
 | 
      
         | 635 |  |  |    demangle.  The third is a pointer to a callback function; on each call
 | 
      
         | 636 |  |  |    this receives an element of the demangled string, its length, and an
 | 
      
         | 637 |  |  |    opaque value.  The fourth is the opaque value passed to the callback.
 | 
      
         | 638 |  |  |    The callback is called once or more to return the full demangled
 | 
      
         | 639 |  |  |    string.  The demangled element string is always nul-terminated, though
 | 
      
         | 640 |  |  |    its length is also provided for convenience.  In contrast to
 | 
      
         | 641 |  |  |    cplus_demangle_print(), this function does not allocate heap memory
 | 
      
         | 642 |  |  |    to grow output strings (except perhaps where alloca() is implemented
 | 
      
         | 643 |  |  |    by malloc()), and so is normally safe for use where the heap has been
 | 
      
         | 644 |  |  |    corrupted.  On success, this function returns 1; on failure, 0.  */
 | 
      
         | 645 |  |  |  
 | 
      
         | 646 |  |  | extern int
 | 
      
         | 647 |  |  | cplus_demangle_print_callback (int options,
 | 
      
         | 648 |  |  |                                const struct demangle_component *tree,
 | 
      
         | 649 |  |  |                                demangle_callbackref callback, void *opaque);
 | 
      
         | 650 |  |  |  
 | 
      
         | 651 |  |  | #ifdef __cplusplus
 | 
      
         | 652 |  |  | }
 | 
      
         | 653 |  |  | #endif /* __cplusplus */
 | 
      
         | 654 |  |  |  
 | 
      
         | 655 |  |  | #endif  /* DEMANGLE_H */
 |