xref: /dflybsd-src/contrib/gdb-7/include/demangle.h (revision de8e141f24382815c10a4012d209bbbf7abf1112)
15796c8dcSSimon Schubert /* Defs for interface to demanglers.
25796c8dcSSimon Schubert    Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002,
3c50c785cSJohn Marino    2003, 2004, 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
45796c8dcSSimon Schubert 
55796c8dcSSimon Schubert    This program is free software; you can redistribute it and/or
65796c8dcSSimon Schubert    modify it under the terms of the GNU Library General Public License
75796c8dcSSimon Schubert    as published by the Free Software Foundation; either version 2, or
85796c8dcSSimon Schubert    (at your option) any later version.
95796c8dcSSimon Schubert 
105796c8dcSSimon Schubert    In addition to the permissions in the GNU Library General Public
115796c8dcSSimon Schubert    License, the Free Software Foundation gives you unlimited
125796c8dcSSimon Schubert    permission to link the compiled version of this file into
135796c8dcSSimon Schubert    combinations with other programs, and to distribute those
145796c8dcSSimon Schubert    combinations without any restriction coming from the use of this
155796c8dcSSimon Schubert    file.  (The Library Public License restrictions do apply in other
165796c8dcSSimon Schubert    respects; for example, they cover modification of the file, and
175796c8dcSSimon Schubert    distribution when not linked into a combined executable.)
185796c8dcSSimon Schubert 
195796c8dcSSimon Schubert    This program is distributed in the hope that it will be useful, but
205796c8dcSSimon Schubert    WITHOUT ANY WARRANTY; without even the implied warranty of
215796c8dcSSimon Schubert    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
225796c8dcSSimon Schubert    Library General Public License for more details.
235796c8dcSSimon Schubert 
245796c8dcSSimon Schubert    You should have received a copy of the GNU Library General Public
255796c8dcSSimon Schubert    License along with this program; if not, write to the Free Software
265796c8dcSSimon Schubert    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
275796c8dcSSimon Schubert    02110-1301, USA.  */
285796c8dcSSimon Schubert 
295796c8dcSSimon Schubert 
305796c8dcSSimon Schubert #if !defined (DEMANGLE_H)
315796c8dcSSimon Schubert #define DEMANGLE_H
325796c8dcSSimon Schubert 
335796c8dcSSimon Schubert #include "libiberty.h"
345796c8dcSSimon Schubert 
355796c8dcSSimon Schubert #ifdef __cplusplus
365796c8dcSSimon Schubert extern "C" {
375796c8dcSSimon Schubert #endif /* __cplusplus */
385796c8dcSSimon Schubert 
395796c8dcSSimon Schubert /* Options passed to cplus_demangle (in 2nd parameter). */
405796c8dcSSimon Schubert 
415796c8dcSSimon Schubert #define DMGL_NO_OPTS	 0		/* For readability... */
425796c8dcSSimon Schubert #define DMGL_PARAMS	 (1 << 0)	/* Include function args */
435796c8dcSSimon Schubert #define DMGL_ANSI	 (1 << 1)	/* Include const, volatile, etc */
445796c8dcSSimon Schubert #define DMGL_JAVA	 (1 << 2)	/* Demangle as Java rather than C++. */
455796c8dcSSimon Schubert #define DMGL_VERBOSE	 (1 << 3)	/* Include implementation details.  */
465796c8dcSSimon Schubert #define DMGL_TYPES	 (1 << 4)	/* Also try to demangle type encodings.  */
475796c8dcSSimon Schubert #define DMGL_RET_POSTFIX (1 << 5)       /* Print function return types (when
48c50c785cSJohn Marino 					   present) after function signature.
49c50c785cSJohn Marino 					   It applies only to the toplevel
50c50c785cSJohn Marino 					   function type.  */
51c50c785cSJohn Marino #define DMGL_RET_DROP	 (1 << 6)       /* Suppress printing function return
52c50c785cSJohn Marino 					   types, even if present.  It applies
53c50c785cSJohn Marino 					   only to the toplevel function type.
54c50c785cSJohn Marino 					   */
555796c8dcSSimon Schubert 
565796c8dcSSimon Schubert #define DMGL_AUTO	 (1 << 8)
575796c8dcSSimon Schubert #define DMGL_GNU	 (1 << 9)
585796c8dcSSimon Schubert #define DMGL_LUCID	 (1 << 10)
595796c8dcSSimon Schubert #define DMGL_ARM	 (1 << 11)
605796c8dcSSimon Schubert #define DMGL_HP 	 (1 << 12)       /* For the HP aCC compiler;
615796c8dcSSimon Schubert                                             same as ARM except for
625796c8dcSSimon Schubert                                             template arguments, etc. */
635796c8dcSSimon Schubert #define DMGL_EDG	 (1 << 13)
645796c8dcSSimon Schubert #define DMGL_GNU_V3	 (1 << 14)
655796c8dcSSimon Schubert #define DMGL_GNAT	 (1 << 15)
665796c8dcSSimon Schubert 
675796c8dcSSimon Schubert /* If none of these are set, use 'current_demangling_style' as the default. */
685796c8dcSSimon Schubert #define DMGL_STYLE_MASK (DMGL_AUTO|DMGL_GNU|DMGL_LUCID|DMGL_ARM|DMGL_HP|DMGL_EDG|DMGL_GNU_V3|DMGL_JAVA|DMGL_GNAT)
695796c8dcSSimon Schubert 
705796c8dcSSimon Schubert /* Enumeration of possible demangling styles.
715796c8dcSSimon Schubert 
725796c8dcSSimon Schubert    Lucid and ARM styles are still kept logically distinct, even though
735796c8dcSSimon Schubert    they now both behave identically.  The resulting style is actual the
745796c8dcSSimon Schubert    union of both.  I.E. either style recognizes both "__pt__" and "__rf__"
755796c8dcSSimon Schubert    for operator "->", even though the first is lucid style and the second
765796c8dcSSimon Schubert    is ARM style. (FIXME?) */
775796c8dcSSimon Schubert 
785796c8dcSSimon Schubert extern enum demangling_styles
795796c8dcSSimon Schubert {
805796c8dcSSimon Schubert   no_demangling = -1,
815796c8dcSSimon Schubert   unknown_demangling = 0,
825796c8dcSSimon Schubert   auto_demangling = DMGL_AUTO,
835796c8dcSSimon Schubert   gnu_demangling = DMGL_GNU,
845796c8dcSSimon Schubert   lucid_demangling = DMGL_LUCID,
855796c8dcSSimon Schubert   arm_demangling = DMGL_ARM,
865796c8dcSSimon Schubert   hp_demangling = DMGL_HP,
875796c8dcSSimon Schubert   edg_demangling = DMGL_EDG,
885796c8dcSSimon Schubert   gnu_v3_demangling = DMGL_GNU_V3,
895796c8dcSSimon Schubert   java_demangling = DMGL_JAVA,
905796c8dcSSimon Schubert   gnat_demangling = DMGL_GNAT
915796c8dcSSimon Schubert } current_demangling_style;
925796c8dcSSimon Schubert 
935796c8dcSSimon Schubert /* Define string names for the various demangling styles. */
945796c8dcSSimon Schubert 
955796c8dcSSimon Schubert #define NO_DEMANGLING_STYLE_STRING            "none"
965796c8dcSSimon Schubert #define AUTO_DEMANGLING_STYLE_STRING	      "auto"
975796c8dcSSimon Schubert #define GNU_DEMANGLING_STYLE_STRING    	      "gnu"
985796c8dcSSimon Schubert #define LUCID_DEMANGLING_STYLE_STRING	      "lucid"
995796c8dcSSimon Schubert #define ARM_DEMANGLING_STYLE_STRING	      "arm"
1005796c8dcSSimon Schubert #define HP_DEMANGLING_STYLE_STRING	      "hp"
1015796c8dcSSimon Schubert #define EDG_DEMANGLING_STYLE_STRING	      "edg"
1025796c8dcSSimon Schubert #define GNU_V3_DEMANGLING_STYLE_STRING        "gnu-v3"
1035796c8dcSSimon Schubert #define JAVA_DEMANGLING_STYLE_STRING          "java"
1045796c8dcSSimon Schubert #define GNAT_DEMANGLING_STYLE_STRING          "gnat"
1055796c8dcSSimon Schubert 
1065796c8dcSSimon Schubert /* Some macros to test what demangling style is active. */
1075796c8dcSSimon Schubert 
1085796c8dcSSimon Schubert #define CURRENT_DEMANGLING_STYLE current_demangling_style
1095796c8dcSSimon Schubert #define AUTO_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_AUTO)
1105796c8dcSSimon Schubert #define GNU_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_GNU)
1115796c8dcSSimon Schubert #define LUCID_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_LUCID)
1125796c8dcSSimon Schubert #define ARM_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_ARM)
1135796c8dcSSimon Schubert #define HP_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_HP)
1145796c8dcSSimon Schubert #define EDG_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_EDG)
1155796c8dcSSimon Schubert #define GNU_V3_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_GNU_V3)
1165796c8dcSSimon Schubert #define JAVA_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_JAVA)
1175796c8dcSSimon Schubert #define GNAT_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_GNAT)
1185796c8dcSSimon Schubert 
1195796c8dcSSimon Schubert /* Provide information about the available demangle styles. This code is
1205796c8dcSSimon Schubert    pulled from gdb into libiberty because it is useful to binutils also.  */
1215796c8dcSSimon Schubert 
1225796c8dcSSimon Schubert extern const struct demangler_engine
1235796c8dcSSimon Schubert {
1245796c8dcSSimon Schubert   const char *const demangling_style_name;
1255796c8dcSSimon Schubert   const enum demangling_styles demangling_style;
1265796c8dcSSimon Schubert   const char *const demangling_style_doc;
1275796c8dcSSimon Schubert } libiberty_demanglers[];
1285796c8dcSSimon Schubert 
1295796c8dcSSimon Schubert extern char *
1305796c8dcSSimon Schubert cplus_demangle (const char *mangled, int options);
1315796c8dcSSimon Schubert 
1325796c8dcSSimon Schubert extern int
1335796c8dcSSimon Schubert cplus_demangle_opname (const char *opname, char *result, int options);
1345796c8dcSSimon Schubert 
1355796c8dcSSimon Schubert extern const char *
1365796c8dcSSimon Schubert cplus_mangle_opname (const char *opname, int options);
1375796c8dcSSimon Schubert 
1385796c8dcSSimon Schubert /* Note: This sets global state.  FIXME if you care about multi-threading. */
1395796c8dcSSimon Schubert 
1405796c8dcSSimon Schubert extern void
1415796c8dcSSimon Schubert set_cplus_marker_for_demangling (int ch);
1425796c8dcSSimon Schubert 
1435796c8dcSSimon Schubert extern enum demangling_styles
1445796c8dcSSimon Schubert cplus_demangle_set_style (enum demangling_styles style);
1455796c8dcSSimon Schubert 
1465796c8dcSSimon Schubert extern enum demangling_styles
1475796c8dcSSimon Schubert cplus_demangle_name_to_style (const char *name);
1485796c8dcSSimon Schubert 
1495796c8dcSSimon Schubert /* Callback typedef for allocation-less demangler interfaces. */
1505796c8dcSSimon Schubert typedef void (*demangle_callbackref) (const char *, size_t, void *);
1515796c8dcSSimon Schubert 
1525796c8dcSSimon Schubert /* V3 ABI demangling entry points, defined in cp-demangle.c.  Callback
1535796c8dcSSimon Schubert    variants return non-zero on success, zero on error.  char* variants
1545796c8dcSSimon Schubert    return a string allocated by malloc on success, NULL on error.  */
1555796c8dcSSimon Schubert extern int
1565796c8dcSSimon Schubert cplus_demangle_v3_callback (const char *mangled, int options,
1575796c8dcSSimon Schubert                             demangle_callbackref callback, void *opaque);
1585796c8dcSSimon Schubert 
1595796c8dcSSimon Schubert extern char*
1605796c8dcSSimon Schubert cplus_demangle_v3 (const char *mangled, int options);
1615796c8dcSSimon Schubert 
1625796c8dcSSimon Schubert extern int
1635796c8dcSSimon Schubert java_demangle_v3_callback (const char *mangled,
1645796c8dcSSimon Schubert                            demangle_callbackref callback, void *opaque);
1655796c8dcSSimon Schubert 
1665796c8dcSSimon Schubert extern char*
1675796c8dcSSimon Schubert java_demangle_v3 (const char *mangled);
1685796c8dcSSimon Schubert 
169cf7f2e2dSJohn Marino char *
170cf7f2e2dSJohn Marino ada_demangle (const char *mangled, int options);
171cf7f2e2dSJohn Marino 
1725796c8dcSSimon Schubert enum gnu_v3_ctor_kinds {
1735796c8dcSSimon Schubert   gnu_v3_complete_object_ctor = 1,
1745796c8dcSSimon Schubert   gnu_v3_base_object_ctor,
175a45ae5f8SJohn Marino   gnu_v3_complete_object_allocating_ctor,
176a45ae5f8SJohn Marino   gnu_v3_object_ctor_group
1775796c8dcSSimon Schubert };
1785796c8dcSSimon Schubert 
1795796c8dcSSimon Schubert /* Return non-zero iff NAME is the mangled form of a constructor name
1805796c8dcSSimon Schubert    in the G++ V3 ABI demangling style.  Specifically, return an `enum
1815796c8dcSSimon Schubert    gnu_v3_ctor_kinds' value indicating what kind of constructor
1825796c8dcSSimon Schubert    it is.  */
1835796c8dcSSimon Schubert extern enum gnu_v3_ctor_kinds
1845796c8dcSSimon Schubert 	is_gnu_v3_mangled_ctor (const char *name);
1855796c8dcSSimon Schubert 
1865796c8dcSSimon Schubert 
1875796c8dcSSimon Schubert enum gnu_v3_dtor_kinds {
1885796c8dcSSimon Schubert   gnu_v3_deleting_dtor = 1,
1895796c8dcSSimon Schubert   gnu_v3_complete_object_dtor,
190a45ae5f8SJohn Marino   gnu_v3_base_object_dtor,
191a45ae5f8SJohn Marino   gnu_v3_object_dtor_group
1925796c8dcSSimon Schubert };
1935796c8dcSSimon Schubert 
1945796c8dcSSimon Schubert /* Return non-zero iff NAME is the mangled form of a destructor name
1955796c8dcSSimon Schubert    in the G++ V3 ABI demangling style.  Specifically, return an `enum
1965796c8dcSSimon Schubert    gnu_v3_dtor_kinds' value, indicating what kind of destructor
1975796c8dcSSimon Schubert    it is.  */
1985796c8dcSSimon Schubert extern enum gnu_v3_dtor_kinds
1995796c8dcSSimon Schubert 	is_gnu_v3_mangled_dtor (const char *name);
2005796c8dcSSimon Schubert 
2015796c8dcSSimon Schubert /* The V3 demangler works in two passes.  The first pass builds a tree
2025796c8dcSSimon Schubert    representation of the mangled name, and the second pass turns the
2035796c8dcSSimon Schubert    tree representation into a demangled string.  Here we define an
2045796c8dcSSimon Schubert    interface to permit a caller to build their own tree
2055796c8dcSSimon Schubert    representation, which they can pass to the demangler to get a
2065796c8dcSSimon Schubert    demangled string.  This can be used to canonicalize user input into
2075796c8dcSSimon Schubert    something which the demangler might output.  It could also be used
2085796c8dcSSimon Schubert    by other demanglers in the future.  */
2095796c8dcSSimon Schubert 
2105796c8dcSSimon Schubert /* These are the component types which may be found in the tree.  Many
2115796c8dcSSimon Schubert    component types have one or two subtrees, referred to as left and
2125796c8dcSSimon Schubert    right (a component type with only one subtree puts it in the left
2135796c8dcSSimon Schubert    subtree).  */
2145796c8dcSSimon Schubert 
2155796c8dcSSimon Schubert enum demangle_component_type
2165796c8dcSSimon Schubert {
2175796c8dcSSimon Schubert   /* A name, with a length and a pointer to a string.  */
2185796c8dcSSimon Schubert   DEMANGLE_COMPONENT_NAME,
2195796c8dcSSimon Schubert   /* A qualified name.  The left subtree is a class or namespace or
2205796c8dcSSimon Schubert      some such thing, and the right subtree is a name qualified by
2215796c8dcSSimon Schubert      that class.  */
2225796c8dcSSimon Schubert   DEMANGLE_COMPONENT_QUAL_NAME,
2235796c8dcSSimon Schubert   /* A local name.  The left subtree describes a function, and the
2245796c8dcSSimon Schubert      right subtree is a name which is local to that function.  */
2255796c8dcSSimon Schubert   DEMANGLE_COMPONENT_LOCAL_NAME,
2265796c8dcSSimon Schubert   /* A typed name.  The left subtree is a name, and the right subtree
2275796c8dcSSimon Schubert      describes that name as a function.  */
2285796c8dcSSimon Schubert   DEMANGLE_COMPONENT_TYPED_NAME,
2295796c8dcSSimon Schubert   /* A template.  The left subtree is a template name, and the right
2305796c8dcSSimon Schubert      subtree is a template argument list.  */
2315796c8dcSSimon Schubert   DEMANGLE_COMPONENT_TEMPLATE,
2325796c8dcSSimon Schubert   /* A template parameter.  This holds a number, which is the template
2335796c8dcSSimon Schubert      parameter index.  */
2345796c8dcSSimon Schubert   DEMANGLE_COMPONENT_TEMPLATE_PARAM,
2355796c8dcSSimon Schubert   /* A function parameter.  This holds a number, which is the index.  */
2365796c8dcSSimon Schubert   DEMANGLE_COMPONENT_FUNCTION_PARAM,
2375796c8dcSSimon Schubert   /* A constructor.  This holds a name and the kind of
2385796c8dcSSimon Schubert      constructor.  */
2395796c8dcSSimon Schubert   DEMANGLE_COMPONENT_CTOR,
2405796c8dcSSimon Schubert   /* A destructor.  This holds a name and the kind of destructor.  */
2415796c8dcSSimon Schubert   DEMANGLE_COMPONENT_DTOR,
2425796c8dcSSimon Schubert   /* A vtable.  This has one subtree, the type for which this is a
2435796c8dcSSimon Schubert      vtable.  */
2445796c8dcSSimon Schubert   DEMANGLE_COMPONENT_VTABLE,
2455796c8dcSSimon Schubert   /* A VTT structure.  This has one subtree, the type for which this
2465796c8dcSSimon Schubert      is a VTT.  */
2475796c8dcSSimon Schubert   DEMANGLE_COMPONENT_VTT,
2485796c8dcSSimon Schubert   /* A construction vtable.  The left subtree is the type for which
2495796c8dcSSimon Schubert      this is a vtable, and the right subtree is the derived type for
2505796c8dcSSimon Schubert      which this vtable is built.  */
2515796c8dcSSimon Schubert   DEMANGLE_COMPONENT_CONSTRUCTION_VTABLE,
2525796c8dcSSimon Schubert   /* A typeinfo structure.  This has one subtree, the type for which
2535796c8dcSSimon Schubert      this is the tpeinfo structure.  */
2545796c8dcSSimon Schubert   DEMANGLE_COMPONENT_TYPEINFO,
2555796c8dcSSimon Schubert   /* A typeinfo name.  This has one subtree, the type for which this
2565796c8dcSSimon Schubert      is the typeinfo name.  */
2575796c8dcSSimon Schubert   DEMANGLE_COMPONENT_TYPEINFO_NAME,
2585796c8dcSSimon Schubert   /* A typeinfo function.  This has one subtree, the type for which
2595796c8dcSSimon Schubert      this is the tpyeinfo function.  */
2605796c8dcSSimon Schubert   DEMANGLE_COMPONENT_TYPEINFO_FN,
2615796c8dcSSimon Schubert   /* A thunk.  This has one subtree, the name for which this is a
2625796c8dcSSimon Schubert      thunk.  */
2635796c8dcSSimon Schubert   DEMANGLE_COMPONENT_THUNK,
2645796c8dcSSimon Schubert   /* A virtual thunk.  This has one subtree, the name for which this
2655796c8dcSSimon Schubert      is a virtual thunk.  */
2665796c8dcSSimon Schubert   DEMANGLE_COMPONENT_VIRTUAL_THUNK,
2675796c8dcSSimon Schubert   /* A covariant thunk.  This has one subtree, the name for which this
2685796c8dcSSimon Schubert      is a covariant thunk.  */
2695796c8dcSSimon Schubert   DEMANGLE_COMPONENT_COVARIANT_THUNK,
2705796c8dcSSimon Schubert   /* A Java class.  This has one subtree, the type.  */
2715796c8dcSSimon Schubert   DEMANGLE_COMPONENT_JAVA_CLASS,
2725796c8dcSSimon Schubert   /* A guard variable.  This has one subtree, the name for which this
2735796c8dcSSimon Schubert      is a guard variable.  */
2745796c8dcSSimon Schubert   DEMANGLE_COMPONENT_GUARD,
275*ef5ccd6cSJohn Marino   /* The init and wrapper functions for C++11 thread_local variables.  */
276*ef5ccd6cSJohn Marino   DEMANGLE_COMPONENT_TLS_INIT,
277*ef5ccd6cSJohn Marino   DEMANGLE_COMPONENT_TLS_WRAPPER,
2785796c8dcSSimon Schubert   /* A reference temporary.  This has one subtree, the name for which
2795796c8dcSSimon Schubert      this is a temporary.  */
2805796c8dcSSimon Schubert   DEMANGLE_COMPONENT_REFTEMP,
2815796c8dcSSimon Schubert   /* A hidden alias.  This has one subtree, the encoding for which it
2825796c8dcSSimon Schubert      is providing alternative linkage.  */
2835796c8dcSSimon Schubert   DEMANGLE_COMPONENT_HIDDEN_ALIAS,
2845796c8dcSSimon Schubert   /* A standard substitution.  This holds the name of the
2855796c8dcSSimon Schubert      substitution.  */
2865796c8dcSSimon Schubert   DEMANGLE_COMPONENT_SUB_STD,
2875796c8dcSSimon Schubert   /* The restrict qualifier.  The one subtree is the type which is
2885796c8dcSSimon Schubert      being qualified.  */
2895796c8dcSSimon Schubert   DEMANGLE_COMPONENT_RESTRICT,
2905796c8dcSSimon Schubert   /* The volatile qualifier.  The one subtree is the type which is
2915796c8dcSSimon Schubert      being qualified.  */
2925796c8dcSSimon Schubert   DEMANGLE_COMPONENT_VOLATILE,
2935796c8dcSSimon Schubert   /* The const qualifier.  The one subtree is the type which is being
2945796c8dcSSimon Schubert      qualified.  */
2955796c8dcSSimon Schubert   DEMANGLE_COMPONENT_CONST,
2965796c8dcSSimon Schubert   /* The restrict qualifier modifying a member function.  The one
2975796c8dcSSimon Schubert      subtree is the type which is being qualified.  */
2985796c8dcSSimon Schubert   DEMANGLE_COMPONENT_RESTRICT_THIS,
2995796c8dcSSimon Schubert   /* The volatile qualifier modifying a member function.  The one
3005796c8dcSSimon Schubert      subtree is the type which is being qualified.  */
3015796c8dcSSimon Schubert   DEMANGLE_COMPONENT_VOLATILE_THIS,
3025796c8dcSSimon Schubert   /* The const qualifier modifying a member function.  The one subtree
3035796c8dcSSimon Schubert      is the type which is being qualified.  */
3045796c8dcSSimon Schubert   DEMANGLE_COMPONENT_CONST_THIS,
3055796c8dcSSimon Schubert   /* A vendor qualifier.  The left subtree is the type which is being
3065796c8dcSSimon Schubert      qualified, and the right subtree is the name of the
3075796c8dcSSimon Schubert      qualifier.  */
3085796c8dcSSimon Schubert   DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL,
3095796c8dcSSimon Schubert   /* A pointer.  The one subtree is the type which is being pointed
3105796c8dcSSimon Schubert      to.  */
3115796c8dcSSimon Schubert   DEMANGLE_COMPONENT_POINTER,
3125796c8dcSSimon Schubert   /* A reference.  The one subtree is the type which is being
3135796c8dcSSimon Schubert      referenced.  */
3145796c8dcSSimon Schubert   DEMANGLE_COMPONENT_REFERENCE,
3155796c8dcSSimon Schubert   /* C++0x: An rvalue reference.  The one subtree is the type which is
3165796c8dcSSimon Schubert      being referenced.  */
3175796c8dcSSimon Schubert   DEMANGLE_COMPONENT_RVALUE_REFERENCE,
3185796c8dcSSimon Schubert   /* A complex type.  The one subtree is the base type.  */
3195796c8dcSSimon Schubert   DEMANGLE_COMPONENT_COMPLEX,
3205796c8dcSSimon Schubert   /* An imaginary type.  The one subtree is the base type.  */
3215796c8dcSSimon Schubert   DEMANGLE_COMPONENT_IMAGINARY,
3225796c8dcSSimon Schubert   /* A builtin type.  This holds the builtin type information.  */
3235796c8dcSSimon Schubert   DEMANGLE_COMPONENT_BUILTIN_TYPE,
3245796c8dcSSimon Schubert   /* A vendor's builtin type.  This holds the name of the type.  */
3255796c8dcSSimon Schubert   DEMANGLE_COMPONENT_VENDOR_TYPE,
3265796c8dcSSimon Schubert   /* A function type.  The left subtree is the return type.  The right
3275796c8dcSSimon Schubert      subtree is a list of ARGLIST nodes.  Either or both may be
3285796c8dcSSimon Schubert      NULL.  */
3295796c8dcSSimon Schubert   DEMANGLE_COMPONENT_FUNCTION_TYPE,
3305796c8dcSSimon Schubert   /* An array type.  The left subtree is the dimension, which may be
3315796c8dcSSimon Schubert      NULL, or a string (represented as DEMANGLE_COMPONENT_NAME), or an
3325796c8dcSSimon Schubert      expression.  The right subtree is the element type.  */
3335796c8dcSSimon Schubert   DEMANGLE_COMPONENT_ARRAY_TYPE,
3345796c8dcSSimon Schubert   /* A pointer to member type.  The left subtree is the class type,
3355796c8dcSSimon Schubert      and the right subtree is the member type.  CV-qualifiers appear
3365796c8dcSSimon Schubert      on the latter.  */
3375796c8dcSSimon Schubert   DEMANGLE_COMPONENT_PTRMEM_TYPE,
3385796c8dcSSimon Schubert   /* A fixed-point type.  */
3395796c8dcSSimon Schubert   DEMANGLE_COMPONENT_FIXED_TYPE,
340cf7f2e2dSJohn Marino   /* A vector type.  The left subtree is the number of elements,
341cf7f2e2dSJohn Marino      the right subtree is the element type.  */
342cf7f2e2dSJohn Marino   DEMANGLE_COMPONENT_VECTOR_TYPE,
3435796c8dcSSimon Schubert   /* An argument list.  The left subtree is the current argument, and
3445796c8dcSSimon Schubert      the right subtree is either NULL or another ARGLIST node.  */
3455796c8dcSSimon Schubert   DEMANGLE_COMPONENT_ARGLIST,
3465796c8dcSSimon Schubert   /* A template argument list.  The left subtree is the current
3475796c8dcSSimon Schubert      template argument, and the right subtree is either NULL or
3485796c8dcSSimon Schubert      another TEMPLATE_ARGLIST node.  */
3495796c8dcSSimon Schubert   DEMANGLE_COMPONENT_TEMPLATE_ARGLIST,
350*ef5ccd6cSJohn Marino   /* An initializer list.  The left subtree is either an explicit type or
351*ef5ccd6cSJohn Marino      NULL, and the right subtree is a DEMANGLE_COMPONENT_ARGLIST.  */
352*ef5ccd6cSJohn Marino   DEMANGLE_COMPONENT_INITIALIZER_LIST,
3535796c8dcSSimon Schubert   /* An operator.  This holds information about a standard
3545796c8dcSSimon Schubert      operator.  */
3555796c8dcSSimon Schubert   DEMANGLE_COMPONENT_OPERATOR,
3565796c8dcSSimon Schubert   /* An extended operator.  This holds the number of arguments, and
3575796c8dcSSimon Schubert      the name of the extended operator.  */
3585796c8dcSSimon Schubert   DEMANGLE_COMPONENT_EXTENDED_OPERATOR,
3595796c8dcSSimon Schubert   /* A typecast, represented as a unary operator.  The one subtree is
3605796c8dcSSimon Schubert      the type to which the argument should be cast.  */
3615796c8dcSSimon Schubert   DEMANGLE_COMPONENT_CAST,
362*ef5ccd6cSJohn Marino   /* A nullary expression.  The left subtree is the operator.  */
363*ef5ccd6cSJohn Marino   DEMANGLE_COMPONENT_NULLARY,
3645796c8dcSSimon Schubert   /* A unary expression.  The left subtree is the operator, and the
3655796c8dcSSimon Schubert      right subtree is the single argument.  */
3665796c8dcSSimon Schubert   DEMANGLE_COMPONENT_UNARY,
3675796c8dcSSimon Schubert   /* A binary expression.  The left subtree is the operator, and the
3685796c8dcSSimon Schubert      right subtree is a BINARY_ARGS.  */
3695796c8dcSSimon Schubert   DEMANGLE_COMPONENT_BINARY,
3705796c8dcSSimon Schubert   /* Arguments to a binary expression.  The left subtree is the first
3715796c8dcSSimon Schubert      argument, and the right subtree is the second argument.  */
3725796c8dcSSimon Schubert   DEMANGLE_COMPONENT_BINARY_ARGS,
3735796c8dcSSimon Schubert   /* A trinary expression.  The left subtree is the operator, and the
3745796c8dcSSimon Schubert      right subtree is a TRINARY_ARG1.  */
3755796c8dcSSimon Schubert   DEMANGLE_COMPONENT_TRINARY,
3765796c8dcSSimon Schubert   /* Arguments to a trinary expression.  The left subtree is the first
3775796c8dcSSimon Schubert      argument, and the right subtree is a TRINARY_ARG2.  */
3785796c8dcSSimon Schubert   DEMANGLE_COMPONENT_TRINARY_ARG1,
3795796c8dcSSimon Schubert   /* More arguments to a trinary expression.  The left subtree is the
3805796c8dcSSimon Schubert      second argument, and the right subtree is the third argument.  */
3815796c8dcSSimon Schubert   DEMANGLE_COMPONENT_TRINARY_ARG2,
3825796c8dcSSimon Schubert   /* A literal.  The left subtree is the type, and the right subtree
3835796c8dcSSimon Schubert      is the value, represented as a DEMANGLE_COMPONENT_NAME.  */
3845796c8dcSSimon Schubert   DEMANGLE_COMPONENT_LITERAL,
3855796c8dcSSimon Schubert   /* A negative literal.  Like LITERAL, but the value is negated.
3865796c8dcSSimon Schubert      This is a minor hack: the NAME used for LITERAL points directly
3875796c8dcSSimon Schubert      to the mangled string, but since negative numbers are mangled
3885796c8dcSSimon Schubert      using 'n' instead of '-', we want a way to indicate a negative
3895796c8dcSSimon Schubert      number which involves neither modifying the mangled string nor
3905796c8dcSSimon Schubert      allocating a new copy of the literal in memory.  */
3915796c8dcSSimon Schubert   DEMANGLE_COMPONENT_LITERAL_NEG,
3925796c8dcSSimon Schubert   /* A libgcj compiled resource.  The left subtree is the name of the
3935796c8dcSSimon Schubert      resource.  */
3945796c8dcSSimon Schubert   DEMANGLE_COMPONENT_JAVA_RESOURCE,
3955796c8dcSSimon Schubert   /* A name formed by the concatenation of two parts.  The left
3965796c8dcSSimon Schubert      subtree is the first part and the right subtree the second.  */
3975796c8dcSSimon Schubert   DEMANGLE_COMPONENT_COMPOUND_NAME,
3985796c8dcSSimon Schubert   /* A name formed by a single character.  */
3995796c8dcSSimon Schubert   DEMANGLE_COMPONENT_CHARACTER,
400cf7f2e2dSJohn Marino   /* A number.  */
401cf7f2e2dSJohn Marino   DEMANGLE_COMPONENT_NUMBER,
4025796c8dcSSimon Schubert   /* A decltype type.  */
4035796c8dcSSimon Schubert   DEMANGLE_COMPONENT_DECLTYPE,
4045796c8dcSSimon Schubert   /* Global constructors keyed to name.  */
4055796c8dcSSimon Schubert   DEMANGLE_COMPONENT_GLOBAL_CONSTRUCTORS,
4065796c8dcSSimon Schubert   /* Global destructors keyed to name.  */
4075796c8dcSSimon Schubert   DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS,
408cf7f2e2dSJohn Marino   /* A lambda closure type.  */
409cf7f2e2dSJohn Marino   DEMANGLE_COMPONENT_LAMBDA,
410cf7f2e2dSJohn Marino   /* A default argument scope.  */
411cf7f2e2dSJohn Marino   DEMANGLE_COMPONENT_DEFAULT_ARG,
412cf7f2e2dSJohn Marino   /* An unnamed type.  */
413cf7f2e2dSJohn Marino   DEMANGLE_COMPONENT_UNNAMED_TYPE,
414a45ae5f8SJohn Marino   /* A transactional clone.  This has one subtree, the encoding for
415a45ae5f8SJohn Marino      which it is providing alternative linkage.  */
416a45ae5f8SJohn Marino   DEMANGLE_COMPONENT_TRANSACTION_CLONE,
417a45ae5f8SJohn Marino   /* A non-transactional clone entry point.  In the i386/x86_64 abi,
418a45ae5f8SJohn Marino      the unmangled symbol of a tm_callable becomes a thunk and the
419a45ae5f8SJohn Marino      non-transactional function version is mangled thus.  */
420a45ae5f8SJohn Marino   DEMANGLE_COMPONENT_NONTRANSACTION_CLONE,
4215796c8dcSSimon Schubert   /* A pack expansion.  */
422a45ae5f8SJohn Marino   DEMANGLE_COMPONENT_PACK_EXPANSION,
423*ef5ccd6cSJohn Marino   /* A name with an ABI tag.  */
424*ef5ccd6cSJohn Marino   DEMANGLE_COMPONENT_TAGGED_NAME,
425a45ae5f8SJohn Marino   /* A cloned function.  */
426a45ae5f8SJohn Marino   DEMANGLE_COMPONENT_CLONE
4275796c8dcSSimon Schubert };
4285796c8dcSSimon Schubert 
4295796c8dcSSimon Schubert /* Types which are only used internally.  */
4305796c8dcSSimon Schubert 
4315796c8dcSSimon Schubert struct demangle_operator_info;
4325796c8dcSSimon Schubert struct demangle_builtin_type_info;
4335796c8dcSSimon Schubert 
4345796c8dcSSimon Schubert /* A node in the tree representation is an instance of a struct
4355796c8dcSSimon Schubert    demangle_component.  Note that the field names of the struct are
4365796c8dcSSimon Schubert    not well protected against macros defined by the file including
4375796c8dcSSimon Schubert    this one.  We can fix this if it ever becomes a problem.  */
4385796c8dcSSimon Schubert 
4395796c8dcSSimon Schubert struct demangle_component
4405796c8dcSSimon Schubert {
4415796c8dcSSimon Schubert   /* The type of this component.  */
4425796c8dcSSimon Schubert   enum demangle_component_type type;
4435796c8dcSSimon Schubert 
4445796c8dcSSimon Schubert   union
4455796c8dcSSimon Schubert   {
4465796c8dcSSimon Schubert     /* For DEMANGLE_COMPONENT_NAME.  */
4475796c8dcSSimon Schubert     struct
4485796c8dcSSimon Schubert     {
4495796c8dcSSimon Schubert       /* A pointer to the name (which need not NULL terminated) and
4505796c8dcSSimon Schubert 	 its length.  */
4515796c8dcSSimon Schubert       const char *s;
4525796c8dcSSimon Schubert       int len;
4535796c8dcSSimon Schubert     } s_name;
4545796c8dcSSimon Schubert 
4555796c8dcSSimon Schubert     /* For DEMANGLE_COMPONENT_OPERATOR.  */
4565796c8dcSSimon Schubert     struct
4575796c8dcSSimon Schubert     {
4585796c8dcSSimon Schubert       /* Operator.  */
4595796c8dcSSimon Schubert       const struct demangle_operator_info *op;
4605796c8dcSSimon Schubert     } s_operator;
4615796c8dcSSimon Schubert 
4625796c8dcSSimon Schubert     /* For DEMANGLE_COMPONENT_EXTENDED_OPERATOR.  */
4635796c8dcSSimon Schubert     struct
4645796c8dcSSimon Schubert     {
4655796c8dcSSimon Schubert       /* Number of arguments.  */
4665796c8dcSSimon Schubert       int args;
4675796c8dcSSimon Schubert       /* Name.  */
4685796c8dcSSimon Schubert       struct demangle_component *name;
4695796c8dcSSimon Schubert     } s_extended_operator;
4705796c8dcSSimon Schubert 
4715796c8dcSSimon Schubert     /* For DEMANGLE_COMPONENT_FIXED_TYPE.  */
4725796c8dcSSimon Schubert     struct
4735796c8dcSSimon Schubert     {
4745796c8dcSSimon Schubert       /* The length, indicated by a C integer type name.  */
4755796c8dcSSimon Schubert       struct demangle_component *length;
4765796c8dcSSimon Schubert       /* _Accum or _Fract?  */
4775796c8dcSSimon Schubert       short accum;
4785796c8dcSSimon Schubert       /* Saturating or not?  */
4795796c8dcSSimon Schubert       short sat;
4805796c8dcSSimon Schubert     } s_fixed;
4815796c8dcSSimon Schubert 
4825796c8dcSSimon Schubert     /* For DEMANGLE_COMPONENT_CTOR.  */
4835796c8dcSSimon Schubert     struct
4845796c8dcSSimon Schubert     {
4855796c8dcSSimon Schubert       /* Kind of constructor.  */
4865796c8dcSSimon Schubert       enum gnu_v3_ctor_kinds kind;
4875796c8dcSSimon Schubert       /* Name.  */
4885796c8dcSSimon Schubert       struct demangle_component *name;
4895796c8dcSSimon Schubert     } s_ctor;
4905796c8dcSSimon Schubert 
4915796c8dcSSimon Schubert     /* For DEMANGLE_COMPONENT_DTOR.  */
4925796c8dcSSimon Schubert     struct
4935796c8dcSSimon Schubert     {
4945796c8dcSSimon Schubert       /* Kind of destructor.  */
4955796c8dcSSimon Schubert       enum gnu_v3_dtor_kinds kind;
4965796c8dcSSimon Schubert       /* Name.  */
4975796c8dcSSimon Schubert       struct demangle_component *name;
4985796c8dcSSimon Schubert     } s_dtor;
4995796c8dcSSimon Schubert 
5005796c8dcSSimon Schubert     /* For DEMANGLE_COMPONENT_BUILTIN_TYPE.  */
5015796c8dcSSimon Schubert     struct
5025796c8dcSSimon Schubert     {
5035796c8dcSSimon Schubert       /* Builtin type.  */
5045796c8dcSSimon Schubert       const struct demangle_builtin_type_info *type;
5055796c8dcSSimon Schubert     } s_builtin;
5065796c8dcSSimon Schubert 
5075796c8dcSSimon Schubert     /* For DEMANGLE_COMPONENT_SUB_STD.  */
5085796c8dcSSimon Schubert     struct
5095796c8dcSSimon Schubert     {
5105796c8dcSSimon Schubert       /* Standard substitution string.  */
5115796c8dcSSimon Schubert       const char* string;
5125796c8dcSSimon Schubert       /* Length of string.  */
5135796c8dcSSimon Schubert       int len;
5145796c8dcSSimon Schubert     } s_string;
5155796c8dcSSimon Schubert 
5165796c8dcSSimon Schubert     /* For DEMANGLE_COMPONENT_*_PARAM.  */
5175796c8dcSSimon Schubert     struct
5185796c8dcSSimon Schubert     {
5195796c8dcSSimon Schubert       /* Parameter index.  */
5205796c8dcSSimon Schubert       long number;
5215796c8dcSSimon Schubert     } s_number;
5225796c8dcSSimon Schubert 
5235796c8dcSSimon Schubert     /* For DEMANGLE_COMPONENT_CHARACTER.  */
5245796c8dcSSimon Schubert     struct
5255796c8dcSSimon Schubert     {
5265796c8dcSSimon Schubert       int character;
5275796c8dcSSimon Schubert     } s_character;
5285796c8dcSSimon Schubert 
5295796c8dcSSimon Schubert     /* For other types.  */
5305796c8dcSSimon Schubert     struct
5315796c8dcSSimon Schubert     {
5325796c8dcSSimon Schubert       /* Left (or only) subtree.  */
5335796c8dcSSimon Schubert       struct demangle_component *left;
5345796c8dcSSimon Schubert       /* Right subtree.  */
5355796c8dcSSimon Schubert       struct demangle_component *right;
5365796c8dcSSimon Schubert     } s_binary;
5375796c8dcSSimon Schubert 
538cf7f2e2dSJohn Marino     struct
539cf7f2e2dSJohn Marino     {
540cf7f2e2dSJohn Marino       /* subtree, same place as d_left.  */
541cf7f2e2dSJohn Marino       struct demangle_component *sub;
542cf7f2e2dSJohn Marino       /* integer.  */
543cf7f2e2dSJohn Marino       int num;
544cf7f2e2dSJohn Marino     } s_unary_num;
545cf7f2e2dSJohn Marino 
5465796c8dcSSimon Schubert   } u;
5475796c8dcSSimon Schubert };
5485796c8dcSSimon Schubert 
5495796c8dcSSimon Schubert /* People building mangled trees are expected to allocate instances of
5505796c8dcSSimon Schubert    struct demangle_component themselves.  They can then call one of
5515796c8dcSSimon Schubert    the following functions to fill them in.  */
5525796c8dcSSimon Schubert 
5535796c8dcSSimon Schubert /* Fill in most component types with a left subtree and a right
5545796c8dcSSimon Schubert    subtree.  Returns non-zero on success, zero on failure, such as an
5555796c8dcSSimon Schubert    unrecognized or inappropriate component type.  */
5565796c8dcSSimon Schubert 
5575796c8dcSSimon Schubert extern int
5585796c8dcSSimon Schubert cplus_demangle_fill_component (struct demangle_component *fill,
5595796c8dcSSimon Schubert                                enum demangle_component_type,
5605796c8dcSSimon Schubert                                struct demangle_component *left,
5615796c8dcSSimon Schubert                                struct demangle_component *right);
5625796c8dcSSimon Schubert 
5635796c8dcSSimon Schubert /* Fill in a DEMANGLE_COMPONENT_NAME.  Returns non-zero on success,
5645796c8dcSSimon Schubert    zero for bad arguments.  */
5655796c8dcSSimon Schubert 
5665796c8dcSSimon Schubert extern int
5675796c8dcSSimon Schubert cplus_demangle_fill_name (struct demangle_component *fill,
5685796c8dcSSimon Schubert                           const char *, int);
5695796c8dcSSimon Schubert 
5705796c8dcSSimon Schubert /* Fill in a DEMANGLE_COMPONENT_BUILTIN_TYPE, using the name of the
5715796c8dcSSimon Schubert    builtin type (e.g., "int", etc.).  Returns non-zero on success,
5725796c8dcSSimon Schubert    zero if the type is not recognized.  */
5735796c8dcSSimon Schubert 
5745796c8dcSSimon Schubert extern int
5755796c8dcSSimon Schubert cplus_demangle_fill_builtin_type (struct demangle_component *fill,
5765796c8dcSSimon Schubert                                   const char *type_name);
5775796c8dcSSimon Schubert 
5785796c8dcSSimon Schubert /* Fill in a DEMANGLE_COMPONENT_OPERATOR, using the name of the
5795796c8dcSSimon Schubert    operator and the number of arguments which it takes (the latter is
5805796c8dcSSimon Schubert    used to disambiguate operators which can be both binary and unary,
5815796c8dcSSimon Schubert    such as '-').  Returns non-zero on success, zero if the operator is
5825796c8dcSSimon Schubert    not recognized.  */
5835796c8dcSSimon Schubert 
5845796c8dcSSimon Schubert extern int
5855796c8dcSSimon Schubert cplus_demangle_fill_operator (struct demangle_component *fill,
5865796c8dcSSimon Schubert                               const char *opname, int args);
5875796c8dcSSimon Schubert 
5885796c8dcSSimon Schubert /* Fill in a DEMANGLE_COMPONENT_EXTENDED_OPERATOR, providing the
5895796c8dcSSimon Schubert    number of arguments and the name.  Returns non-zero on success,
5905796c8dcSSimon Schubert    zero for bad arguments.  */
5915796c8dcSSimon Schubert 
5925796c8dcSSimon Schubert extern int
5935796c8dcSSimon Schubert cplus_demangle_fill_extended_operator (struct demangle_component *fill,
5945796c8dcSSimon Schubert                                        int numargs,
5955796c8dcSSimon Schubert                                        struct demangle_component *nm);
5965796c8dcSSimon Schubert 
5975796c8dcSSimon Schubert /* Fill in a DEMANGLE_COMPONENT_CTOR.  Returns non-zero on success,
5985796c8dcSSimon Schubert    zero for bad arguments.  */
5995796c8dcSSimon Schubert 
6005796c8dcSSimon Schubert extern int
6015796c8dcSSimon Schubert cplus_demangle_fill_ctor (struct demangle_component *fill,
6025796c8dcSSimon Schubert                           enum gnu_v3_ctor_kinds kind,
6035796c8dcSSimon Schubert                           struct demangle_component *name);
6045796c8dcSSimon Schubert 
6055796c8dcSSimon Schubert /* Fill in a DEMANGLE_COMPONENT_DTOR.  Returns non-zero on success,
6065796c8dcSSimon Schubert    zero for bad arguments.  */
6075796c8dcSSimon Schubert 
6085796c8dcSSimon Schubert extern int
6095796c8dcSSimon Schubert cplus_demangle_fill_dtor (struct demangle_component *fill,
6105796c8dcSSimon Schubert                           enum gnu_v3_dtor_kinds kind,
6115796c8dcSSimon Schubert                           struct demangle_component *name);
6125796c8dcSSimon Schubert 
6135796c8dcSSimon Schubert /* This function translates a mangled name into a struct
6145796c8dcSSimon Schubert    demangle_component tree.  The first argument is the mangled name.
6155796c8dcSSimon Schubert    The second argument is DMGL_* options.  This returns a pointer to a
6165796c8dcSSimon Schubert    tree on success, or NULL on failure.  On success, the third
6175796c8dcSSimon Schubert    argument is set to a block of memory allocated by malloc.  This
6185796c8dcSSimon Schubert    block should be passed to free when the tree is no longer
6195796c8dcSSimon Schubert    needed.  */
6205796c8dcSSimon Schubert 
6215796c8dcSSimon Schubert extern struct demangle_component *
6225796c8dcSSimon Schubert cplus_demangle_v3_components (const char *mangled, int options, void **mem);
6235796c8dcSSimon Schubert 
6245796c8dcSSimon Schubert /* This function takes a struct demangle_component tree and returns
6255796c8dcSSimon Schubert    the corresponding demangled string.  The first argument is DMGL_*
6265796c8dcSSimon Schubert    options.  The second is the tree to demangle.  The third is a guess
6275796c8dcSSimon Schubert    at the length of the demangled string, used to initially allocate
6285796c8dcSSimon Schubert    the return buffer.  The fourth is a pointer to a size_t.  On
6295796c8dcSSimon Schubert    success, this function returns a buffer allocated by malloc(), and
6305796c8dcSSimon Schubert    sets the size_t pointed to by the fourth argument to the size of
6315796c8dcSSimon Schubert    the allocated buffer (not the length of the returned string).  On
6325796c8dcSSimon Schubert    failure, this function returns NULL, and sets the size_t pointed to
6335796c8dcSSimon Schubert    by the fourth argument to 0 for an invalid tree, or to 1 for a
6345796c8dcSSimon Schubert    memory allocation error.  */
6355796c8dcSSimon Schubert 
6365796c8dcSSimon Schubert extern char *
6375796c8dcSSimon Schubert cplus_demangle_print (int options,
6385796c8dcSSimon Schubert                       const struct demangle_component *tree,
6395796c8dcSSimon Schubert                       int estimated_length,
6405796c8dcSSimon Schubert                       size_t *p_allocated_size);
6415796c8dcSSimon Schubert 
6425796c8dcSSimon Schubert /* This function takes a struct demangle_component tree and passes back
6435796c8dcSSimon Schubert    a demangled string in one or more calls to a callback function.
6445796c8dcSSimon Schubert    The first argument is DMGL_* options.  The second is the tree to
6455796c8dcSSimon Schubert    demangle.  The third is a pointer to a callback function; on each call
6465796c8dcSSimon Schubert    this receives an element of the demangled string, its length, and an
6475796c8dcSSimon Schubert    opaque value.  The fourth is the opaque value passed to the callback.
6485796c8dcSSimon Schubert    The callback is called once or more to return the full demangled
6495796c8dcSSimon Schubert    string.  The demangled element string is always nul-terminated, though
6505796c8dcSSimon Schubert    its length is also provided for convenience.  In contrast to
6515796c8dcSSimon Schubert    cplus_demangle_print(), this function does not allocate heap memory
6525796c8dcSSimon Schubert    to grow output strings (except perhaps where alloca() is implemented
6535796c8dcSSimon Schubert    by malloc()), and so is normally safe for use where the heap has been
6545796c8dcSSimon Schubert    corrupted.  On success, this function returns 1; on failure, 0.  */
6555796c8dcSSimon Schubert 
6565796c8dcSSimon Schubert extern int
6575796c8dcSSimon Schubert cplus_demangle_print_callback (int options,
6585796c8dcSSimon Schubert                                const struct demangle_component *tree,
6595796c8dcSSimon Schubert                                demangle_callbackref callback, void *opaque);
6605796c8dcSSimon Schubert 
6615796c8dcSSimon Schubert #ifdef __cplusplus
6625796c8dcSSimon Schubert }
6635796c8dcSSimon Schubert #endif /* __cplusplus */
6645796c8dcSSimon Schubert 
6655796c8dcSSimon Schubert #endif	/* DEMANGLE_H */
666