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