resize_section_table cleanup
[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,
59e11e17 3 2003, 2004, 2005, 2007, 2008, 2009, 2010 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 47#define DMGL_RET_POSTFIX (1 << 5) /* Print function return types (when
ddee5e46
DD
48 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 */
b8cdcddf
L
55
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)
f93eaf70 64#define DMGL_GNU_V3 (1 << 14)
4cabd1d1 65#define DMGL_GNAT (1 << 15)
252b5132
RH
66
67/* If none of these are set, use 'current_demangling_style' as the default. */
f93eaf70 68#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
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
78extern enum demangling_styles
79{
2da4c07f 80 no_demangling = -1,
252b5132
RH
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,
b8cdcddf 87 edg_demangling = DMGL_EDG,
f93eaf70 88 gnu_v3_demangling = DMGL_GNU_V3,
4cabd1d1
HPN
89 java_demangling = DMGL_JAVA,
90 gnat_demangling = DMGL_GNAT
252b5132
RH
91} current_demangling_style;
92
93/* Define string names for the various demangling styles. */
94
2da4c07f 95#define NO_DEMANGLING_STYLE_STRING "none"
b8cdcddf
L
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"
f93eaf70 102#define GNU_V3_DEMANGLING_STYLE_STRING "gnu-v3"
4cabd1d1
HPN
103#define JAVA_DEMANGLING_STYLE_STRING "java"
104#define GNAT_DEMANGLING_STYLE_STRING "gnat"
252b5132
RH
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)
f93eaf70 115#define GNU_V3_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_GNU_V3)
4cabd1d1
HPN
116#define JAVA_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_JAVA)
117#define GNAT_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_GNAT)
b8cdcddf
L
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
e6450fe5 122extern const struct demangler_engine
b8cdcddf 123{
e6450fe5
DD
124 const char *const demangling_style_name;
125 const enum demangling_styles demangling_style;
126 const char *const demangling_style_doc;
b8cdcddf 127} libiberty_demanglers[];
252b5132
RH
128
129extern char *
9334f9c6 130cplus_demangle (const char *mangled, int options);
252b5132
RH
131
132extern int
9334f9c6 133cplus_demangle_opname (const char *opname, char *result, int options);
252b5132
RH
134
135extern const char *
9334f9c6 136cplus_mangle_opname (const char *opname, int options);
252b5132
RH
137
138/* Note: This sets global state. FIXME if you care about multi-threading. */
139
140extern void
9334f9c6 141set_cplus_marker_for_demangling (int ch);
252b5132 142
b8cdcddf 143extern enum demangling_styles
9334f9c6 144cplus_demangle_set_style (enum demangling_styles style);
b8cdcddf
L
145
146extern enum demangling_styles
9334f9c6 147cplus_demangle_name_to_style (const char *name);
b8cdcddf 148
208c1674
DD
149/* Callback typedef for allocation-less demangler interfaces. */
150typedef 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. */
155extern int
156cplus_demangle_v3_callback (const char *mangled, int options,
157 demangle_callbackref callback, void *opaque);
42da15d6 158
bc9bf259 159extern char*
208c1674 160cplus_demangle_v3 (const char *mangled, int options);
bc9bf259 161
208c1674
DD
162extern int
163java_demangle_v3_callback (const char *mangled,
164 demangle_callbackref callback, void *opaque);
165
166extern char*
167java_demangle_v3 (const char *mangled);
e61231f1 168
6d390a9e
DD
169char *
170ada_demangle (const char *mangled, int options);
171
e61231f1
JB
172enum gnu_v3_ctor_kinds {
173 gnu_v3_complete_object_ctor = 1,
174 gnu_v3_base_object_ctor,
956a8f8b 175 gnu_v3_complete_object_allocating_ctor,
eafbc3bf
BM
176 /* These are not part of the V3 ABI. Unified constructors are generated
177 as a speed-for-space optimization when the -fdeclone-ctor-dtor option
178 is used, and are always internal symbols. */
179 gnu_v3_unified_ctor,
956a8f8b 180 gnu_v3_object_ctor_group
e61231f1
JB
181};
182
183/* Return non-zero iff NAME is the mangled form of a constructor name
184 in the G++ V3 ABI demangling style. Specifically, return an `enum
185 gnu_v3_ctor_kinds' value indicating what kind of constructor
186 it is. */
457161bf 187extern enum gnu_v3_ctor_kinds
9334f9c6 188 is_gnu_v3_mangled_ctor (const char *name);
e61231f1
JB
189
190
191enum gnu_v3_dtor_kinds {
192 gnu_v3_deleting_dtor = 1,
193 gnu_v3_complete_object_dtor,
956a8f8b 194 gnu_v3_base_object_dtor,
eafbc3bf
BM
195 /* These are not part of the V3 ABI. Unified destructors are generated
196 as a speed-for-space optimization when the -fdeclone-ctor-dtor option
197 is used, and are always internal symbols. */
198 gnu_v3_unified_dtor,
956a8f8b 199 gnu_v3_object_dtor_group
e61231f1
JB
200};
201
202/* Return non-zero iff NAME is the mangled form of a destructor name
203 in the G++ V3 ABI demangling style. Specifically, return an `enum
204 gnu_v3_dtor_kinds' value, indicating what kind of destructor
205 it is. */
457161bf 206extern enum gnu_v3_dtor_kinds
9334f9c6 207 is_gnu_v3_mangled_dtor (const char *name);
e61231f1 208
59727473
DD
209/* The V3 demangler works in two passes. The first pass builds a tree
210 representation of the mangled name, and the second pass turns the
211 tree representation into a demangled string. Here we define an
212 interface to permit a caller to build their own tree
213 representation, which they can pass to the demangler to get a
214 demangled string. This can be used to canonicalize user input into
215 something which the demangler might output. It could also be used
216 by other demanglers in the future. */
217
218/* These are the component types which may be found in the tree. Many
219 component types have one or two subtrees, referred to as left and
220 right (a component type with only one subtree puts it in the left
221 subtree). */
222
223enum demangle_component_type
224{
225 /* A name, with a length and a pointer to a string. */
226 DEMANGLE_COMPONENT_NAME,
227 /* A qualified name. The left subtree is a class or namespace or
228 some such thing, and the right subtree is a name qualified by
229 that class. */
230 DEMANGLE_COMPONENT_QUAL_NAME,
231 /* A local name. The left subtree describes a function, and the
232 right subtree is a name which is local to that function. */
233 DEMANGLE_COMPONENT_LOCAL_NAME,
234 /* A typed name. The left subtree is a name, and the right subtree
235 describes that name as a function. */
236 DEMANGLE_COMPONENT_TYPED_NAME,
237 /* A template. The left subtree is a template name, and the right
238 subtree is a template argument list. */
239 DEMANGLE_COMPONENT_TEMPLATE,
240 /* A template parameter. This holds a number, which is the template
241 parameter index. */
242 DEMANGLE_COMPONENT_TEMPLATE_PARAM,
c743cf5d
DD
243 /* A function parameter. This holds a number, which is the index. */
244 DEMANGLE_COMPONENT_FUNCTION_PARAM,
59727473
DD
245 /* A constructor. This holds a name and the kind of
246 constructor. */
247 DEMANGLE_COMPONENT_CTOR,
248 /* A destructor. This holds a name and the kind of destructor. */
249 DEMANGLE_COMPONENT_DTOR,
250 /* A vtable. This has one subtree, the type for which this is a
251 vtable. */
252 DEMANGLE_COMPONENT_VTABLE,
253 /* A VTT structure. This has one subtree, the type for which this
254 is a VTT. */
255 DEMANGLE_COMPONENT_VTT,
256 /* A construction vtable. The left subtree is the type for which
257 this is a vtable, and the right subtree is the derived type for
258 which this vtable is built. */
259 DEMANGLE_COMPONENT_CONSTRUCTION_VTABLE,
260 /* A typeinfo structure. This has one subtree, the type for which
261 this is the tpeinfo structure. */
262 DEMANGLE_COMPONENT_TYPEINFO,
263 /* A typeinfo name. This has one subtree, the type for which this
264 is the typeinfo name. */
265 DEMANGLE_COMPONENT_TYPEINFO_NAME,
266 /* A typeinfo function. This has one subtree, the type for which
267 this is the tpyeinfo function. */
268 DEMANGLE_COMPONENT_TYPEINFO_FN,
269 /* A thunk. This has one subtree, the name for which this is a
270 thunk. */
271 DEMANGLE_COMPONENT_THUNK,
272 /* A virtual thunk. This has one subtree, the name for which this
273 is a virtual thunk. */
274 DEMANGLE_COMPONENT_VIRTUAL_THUNK,
275 /* A covariant thunk. This has one subtree, the name for which this
276 is a covariant thunk. */
277 DEMANGLE_COMPONENT_COVARIANT_THUNK,
278 /* A Java class. This has one subtree, the type. */
279 DEMANGLE_COMPONENT_JAVA_CLASS,
280 /* A guard variable. This has one subtree, the name for which this
281 is a guard variable. */
282 DEMANGLE_COMPONENT_GUARD,
995b61fe
DD
283 /* The init and wrapper functions for C++11 thread_local variables. */
284 DEMANGLE_COMPONENT_TLS_INIT,
285 DEMANGLE_COMPONENT_TLS_WRAPPER,
59727473
DD
286 /* A reference temporary. This has one subtree, the name for which
287 this is a temporary. */
288 DEMANGLE_COMPONENT_REFTEMP,
839e4798
RH
289 /* A hidden alias. This has one subtree, the encoding for which it
290 is providing alternative linkage. */
291 DEMANGLE_COMPONENT_HIDDEN_ALIAS,
59727473
DD
292 /* A standard substitution. This holds the name of the
293 substitution. */
294 DEMANGLE_COMPONENT_SUB_STD,
295 /* The restrict qualifier. The one subtree is the type which is
296 being qualified. */
297 DEMANGLE_COMPONENT_RESTRICT,
298 /* The volatile qualifier. The one subtree is the type which is
299 being qualified. */
300 DEMANGLE_COMPONENT_VOLATILE,
301 /* The const qualifier. The one subtree is the type which is being
302 qualified. */
303 DEMANGLE_COMPONENT_CONST,
304 /* The restrict qualifier modifying a member function. The one
305 subtree is the type which is being qualified. */
306 DEMANGLE_COMPONENT_RESTRICT_THIS,
307 /* The volatile qualifier modifying a member function. The one
308 subtree is the type which is being qualified. */
309 DEMANGLE_COMPONENT_VOLATILE_THIS,
310 /* The const qualifier modifying a member function. The one subtree
311 is the type which is being qualified. */
312 DEMANGLE_COMPONENT_CONST_THIS,
3a4d2339
DD
313 /* C++11 A reference modifying a member function. The one subtree is the
314 type which is being referenced. */
315 DEMANGLE_COMPONENT_REFERENCE_THIS,
316 /* C++11: An rvalue reference modifying a member function. The one
317 subtree is the type which is being referenced. */
318 DEMANGLE_COMPONENT_RVALUE_REFERENCE_THIS,
59727473
DD
319 /* A vendor qualifier. The left subtree is the type which is being
320 qualified, and the right subtree is the name of the
321 qualifier. */
322 DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL,
323 /* A pointer. The one subtree is the type which is being pointed
324 to. */
325 DEMANGLE_COMPONENT_POINTER,
326 /* A reference. The one subtree is the type which is being
327 referenced. */
328 DEMANGLE_COMPONENT_REFERENCE,
8969a67f
DD
329 /* C++0x: An rvalue reference. The one subtree is the type which is
330 being referenced. */
331 DEMANGLE_COMPONENT_RVALUE_REFERENCE,
59727473
DD
332 /* A complex type. The one subtree is the base type. */
333 DEMANGLE_COMPONENT_COMPLEX,
334 /* An imaginary type. The one subtree is the base type. */
335 DEMANGLE_COMPONENT_IMAGINARY,
336 /* A builtin type. This holds the builtin type information. */
337 DEMANGLE_COMPONENT_BUILTIN_TYPE,
338 /* A vendor's builtin type. This holds the name of the type. */
339 DEMANGLE_COMPONENT_VENDOR_TYPE,
340 /* A function type. The left subtree is the return type. The right
341 subtree is a list of ARGLIST nodes. Either or both may be
342 NULL. */
343 DEMANGLE_COMPONENT_FUNCTION_TYPE,
344 /* An array type. The left subtree is the dimension, which may be
345 NULL, or a string (represented as DEMANGLE_COMPONENT_NAME), or an
346 expression. The right subtree is the element type. */
347 DEMANGLE_COMPONENT_ARRAY_TYPE,
348 /* A pointer to member type. The left subtree is the class type,
349 and the right subtree is the member type. CV-qualifiers appear
350 on the latter. */
351 DEMANGLE_COMPONENT_PTRMEM_TYPE,
d2825c1a
DD
352 /* A fixed-point type. */
353 DEMANGLE_COMPONENT_FIXED_TYPE,
cbc43128
DD
354 /* A vector type. The left subtree is the number of elements,
355 the right subtree is the element type. */
356 DEMANGLE_COMPONENT_VECTOR_TYPE,
59727473
DD
357 /* An argument list. The left subtree is the current argument, and
358 the right subtree is either NULL or another ARGLIST node. */
359 DEMANGLE_COMPONENT_ARGLIST,
360 /* A template argument list. The left subtree is the current
361 template argument, and the right subtree is either NULL or
362 another TEMPLATE_ARGLIST node. */
363 DEMANGLE_COMPONENT_TEMPLATE_ARGLIST,
c7571c06
JM
364 /* An initializer list. The left subtree is either an explicit type or
365 NULL, and the right subtree is a DEMANGLE_COMPONENT_ARGLIST. */
366 DEMANGLE_COMPONENT_INITIALIZER_LIST,
59727473
DD
367 /* An operator. This holds information about a standard
368 operator. */
369 DEMANGLE_COMPONENT_OPERATOR,
370 /* An extended operator. This holds the number of arguments, and
371 the name of the extended operator. */
372 DEMANGLE_COMPONENT_EXTENDED_OPERATOR,
373 /* A typecast, represented as a unary operator. The one subtree is
374 the type to which the argument should be cast. */
375 DEMANGLE_COMPONENT_CAST,
c7571c06
JM
376 /* A nullary expression. The left subtree is the operator. */
377 DEMANGLE_COMPONENT_NULLARY,
59727473
DD
378 /* A unary expression. The left subtree is the operator, and the
379 right subtree is the single argument. */
380 DEMANGLE_COMPONENT_UNARY,
381 /* A binary expression. The left subtree is the operator, and the
382 right subtree is a BINARY_ARGS. */
383 DEMANGLE_COMPONENT_BINARY,
384 /* Arguments to a binary expression. The left subtree is the first
385 argument, and the right subtree is the second argument. */
386 DEMANGLE_COMPONENT_BINARY_ARGS,
387 /* A trinary expression. The left subtree is the operator, and the
388 right subtree is a TRINARY_ARG1. */
389 DEMANGLE_COMPONENT_TRINARY,
390 /* Arguments to a trinary expression. The left subtree is the first
391 argument, and the right subtree is a TRINARY_ARG2. */
392 DEMANGLE_COMPONENT_TRINARY_ARG1,
393 /* More arguments to a trinary expression. The left subtree is the
394 second argument, and the right subtree is the third argument. */
395 DEMANGLE_COMPONENT_TRINARY_ARG2,
396 /* A literal. The left subtree is the type, and the right subtree
397 is the value, represented as a DEMANGLE_COMPONENT_NAME. */
398 DEMANGLE_COMPONENT_LITERAL,
399 /* A negative literal. Like LITERAL, but the value is negated.
400 This is a minor hack: the NAME used for LITERAL points directly
401 to the mangled string, but since negative numbers are mangled
402 using 'n' instead of '-', we want a way to indicate a negative
403 number which involves neither modifying the mangled string nor
404 allocating a new copy of the literal in memory. */
830ef634
DD
405 DEMANGLE_COMPONENT_LITERAL_NEG,
406 /* A libgcj compiled resource. The left subtree is the name of the
407 resource. */
408 DEMANGLE_COMPONENT_JAVA_RESOURCE,
409 /* A name formed by the concatenation of two parts. The left
410 subtree is the first part and the right subtree the second. */
411 DEMANGLE_COMPONENT_COMPOUND_NAME,
412 /* A name formed by a single character. */
ba8cb4ba 413 DEMANGLE_COMPONENT_CHARACTER,
cbc43128
DD
414 /* A number. */
415 DEMANGLE_COMPONENT_NUMBER,
ba8cb4ba 416 /* A decltype type. */
1c08f2c8 417 DEMANGLE_COMPONENT_DECLTYPE,
d5031754
DD
418 /* Global constructors keyed to name. */
419 DEMANGLE_COMPONENT_GLOBAL_CONSTRUCTORS,
420 /* Global destructors keyed to name. */
421 DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS,
664aa91f
DD
422 /* A lambda closure type. */
423 DEMANGLE_COMPONENT_LAMBDA,
424 /* A default argument scope. */
425 DEMANGLE_COMPONENT_DEFAULT_ARG,
426 /* An unnamed type. */
427 DEMANGLE_COMPONENT_UNNAMED_TYPE,
956a8f8b
DD
428 /* A transactional clone. This has one subtree, the encoding for
429 which it is providing alternative linkage. */
430 DEMANGLE_COMPONENT_TRANSACTION_CLONE,
431 /* A non-transactional clone entry point. In the i386/x86_64 abi,
432 the unmangled symbol of a tm_callable becomes a thunk and the
433 non-transactional function version is mangled thus. */
434 DEMANGLE_COMPONENT_NONTRANSACTION_CLONE,
1c08f2c8 435 /* A pack expansion. */
7955ede5 436 DEMANGLE_COMPONENT_PACK_EXPANSION,
1f3de044
DD
437 /* A name with an ABI tag. */
438 DEMANGLE_COMPONENT_TAGGED_NAME,
7955ede5
DD
439 /* A cloned function. */
440 DEMANGLE_COMPONENT_CLONE
59727473
DD
441};
442
443/* Types which are only used internally. */
444
445struct demangle_operator_info;
446struct demangle_builtin_type_info;
447
448/* A node in the tree representation is an instance of a struct
449 demangle_component. Note that the field names of the struct are
450 not well protected against macros defined by the file including
451 this one. We can fix this if it ever becomes a problem. */
452
453struct demangle_component
454{
455 /* The type of this component. */
456 enum demangle_component_type type;
457
458 union
459 {
460 /* For DEMANGLE_COMPONENT_NAME. */
461 struct
462 {
463 /* A pointer to the name (which need not NULL terminated) and
464 its length. */
465 const char *s;
466 int len;
467 } s_name;
468
469 /* For DEMANGLE_COMPONENT_OPERATOR. */
470 struct
471 {
472 /* Operator. */
473 const struct demangle_operator_info *op;
474 } s_operator;
475
476 /* For DEMANGLE_COMPONENT_EXTENDED_OPERATOR. */
477 struct
478 {
479 /* Number of arguments. */
480 int args;
481 /* Name. */
482 struct demangle_component *name;
483 } s_extended_operator;
484
d2825c1a
DD
485 /* For DEMANGLE_COMPONENT_FIXED_TYPE. */
486 struct
487 {
488 /* The length, indicated by a C integer type name. */
489 struct demangle_component *length;
490 /* _Accum or _Fract? */
491 short accum;
492 /* Saturating or not? */
493 short sat;
494 } s_fixed;
495
59727473
DD
496 /* For DEMANGLE_COMPONENT_CTOR. */
497 struct
498 {
499 /* Kind of constructor. */
500 enum gnu_v3_ctor_kinds kind;
501 /* Name. */
502 struct demangle_component *name;
503 } s_ctor;
504
505 /* For DEMANGLE_COMPONENT_DTOR. */
506 struct
507 {
508 /* Kind of destructor. */
509 enum gnu_v3_dtor_kinds kind;
510 /* Name. */
511 struct demangle_component *name;
512 } s_dtor;
513
514 /* For DEMANGLE_COMPONENT_BUILTIN_TYPE. */
515 struct
516 {
517 /* Builtin type. */
518 const struct demangle_builtin_type_info *type;
519 } s_builtin;
520
521 /* For DEMANGLE_COMPONENT_SUB_STD. */
522 struct
523 {
524 /* Standard substitution string. */
525 const char* string;
526 /* Length of string. */
527 int len;
528 } s_string;
529
c743cf5d 530 /* For DEMANGLE_COMPONENT_*_PARAM. */
59727473
DD
531 struct
532 {
c743cf5d 533 /* Parameter index. */
59727473
DD
534 long number;
535 } s_number;
536
830ef634
DD
537 /* For DEMANGLE_COMPONENT_CHARACTER. */
538 struct
539 {
540 int character;
541 } s_character;
542
59727473
DD
543 /* For other types. */
544 struct
545 {
546 /* Left (or only) subtree. */
547 struct demangle_component *left;
548 /* Right subtree. */
549 struct demangle_component *right;
550 } s_binary;
551
664aa91f
DD
552 struct
553 {
554 /* subtree, same place as d_left. */
555 struct demangle_component *sub;
556 /* integer. */
557 int num;
558 } s_unary_num;
559
59727473
DD
560 } u;
561};
562
563/* People building mangled trees are expected to allocate instances of
564 struct demangle_component themselves. They can then call one of
565 the following functions to fill them in. */
566
567/* Fill in most component types with a left subtree and a right
568 subtree. Returns non-zero on success, zero on failure, such as an
569 unrecognized or inappropriate component type. */
570
571extern int
9334f9c6
DD
572cplus_demangle_fill_component (struct demangle_component *fill,
573 enum demangle_component_type,
574 struct demangle_component *left,
575 struct demangle_component *right);
59727473
DD
576
577/* Fill in a DEMANGLE_COMPONENT_NAME. Returns non-zero on success,
578 zero for bad arguments. */
579
580extern int
9334f9c6
DD
581cplus_demangle_fill_name (struct demangle_component *fill,
582 const char *, int);
59727473
DD
583
584/* Fill in a DEMANGLE_COMPONENT_BUILTIN_TYPE, using the name of the
585 builtin type (e.g., "int", etc.). Returns non-zero on success,
586 zero if the type is not recognized. */
587
588extern int
9334f9c6
DD
589cplus_demangle_fill_builtin_type (struct demangle_component *fill,
590 const char *type_name);
59727473
DD
591
592/* Fill in a DEMANGLE_COMPONENT_OPERATOR, using the name of the
593 operator and the number of arguments which it takes (the latter is
594 used to disambiguate operators which can be both binary and unary,
595 such as '-'). Returns non-zero on success, zero if the operator is
596 not recognized. */
597
598extern int
9334f9c6
DD
599cplus_demangle_fill_operator (struct demangle_component *fill,
600 const char *opname, int args);
59727473
DD
601
602/* Fill in a DEMANGLE_COMPONENT_EXTENDED_OPERATOR, providing the
603 number of arguments and the name. Returns non-zero on success,
604 zero for bad arguments. */
605
606extern int
9334f9c6
DD
607cplus_demangle_fill_extended_operator (struct demangle_component *fill,
608 int numargs,
609 struct demangle_component *nm);
59727473
DD
610
611/* Fill in a DEMANGLE_COMPONENT_CTOR. Returns non-zero on success,
612 zero for bad arguments. */
613
614extern int
9334f9c6
DD
615cplus_demangle_fill_ctor (struct demangle_component *fill,
616 enum gnu_v3_ctor_kinds kind,
617 struct demangle_component *name);
59727473
DD
618
619/* Fill in a DEMANGLE_COMPONENT_DTOR. Returns non-zero on success,
620 zero for bad arguments. */
621
622extern int
9334f9c6
DD
623cplus_demangle_fill_dtor (struct demangle_component *fill,
624 enum gnu_v3_dtor_kinds kind,
625 struct demangle_component *name);
59727473
DD
626
627/* This function translates a mangled name into a struct
628 demangle_component tree. The first argument is the mangled name.
629 The second argument is DMGL_* options. This returns a pointer to a
630 tree on success, or NULL on failure. On success, the third
631 argument is set to a block of memory allocated by malloc. This
632 block should be passed to free when the tree is no longer
633 needed. */
634
635extern struct demangle_component *
9334f9c6 636cplus_demangle_v3_components (const char *mangled, int options, void **mem);
59727473
DD
637
638/* This function takes a struct demangle_component tree and returns
639 the corresponding demangled string. The first argument is DMGL_*
640 options. The second is the tree to demangle. The third is a guess
641 at the length of the demangled string, used to initially allocate
642 the return buffer. The fourth is a pointer to a size_t. On
643 success, this function returns a buffer allocated by malloc(), and
644 sets the size_t pointed to by the fourth argument to the size of
645 the allocated buffer (not the length of the returned string). On
646 failure, this function returns NULL, and sets the size_t pointed to
647 by the fourth argument to 0 for an invalid tree, or to 1 for a
648 memory allocation error. */
649
650extern char *
9334f9c6
DD
651cplus_demangle_print (int options,
652 const struct demangle_component *tree,
653 int estimated_length,
654 size_t *p_allocated_size);
59727473 655
208c1674
DD
656/* This function takes a struct demangle_component tree and passes back
657 a demangled string in one or more calls to a callback function.
658 The first argument is DMGL_* options. The second is the tree to
659 demangle. The third is a pointer to a callback function; on each call
660 this receives an element of the demangled string, its length, and an
661 opaque value. The fourth is the opaque value passed to the callback.
662 The callback is called once or more to return the full demangled
663 string. The demangled element string is always nul-terminated, though
664 its length is also provided for convenience. In contrast to
665 cplus_demangle_print(), this function does not allocate heap memory
666 to grow output strings (except perhaps where alloca() is implemented
667 by malloc()), and so is normally safe for use where the heap has been
668 corrupted. On success, this function returns 1; on failure, 0. */
669
670extern int
671cplus_demangle_print_callback (int options,
672 const struct demangle_component *tree,
673 demangle_callbackref callback, void *opaque);
674
87242c64
L
675#ifdef __cplusplus
676}
677#endif /* __cplusplus */
678
252b5132 679#endif /* DEMANGLE_H */
This page took 0.592245 seconds and 4 git commands to generate.