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