Rizin
unix-like reverse engineering framework and cli tools
cp-demangle.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include "ansidecl.h"
#include "libiberty.h"
#include "demangle.h"
#include "cp-demangle.h"

Go to the source code of this file.

Classes

struct  d_standard_sub_info
 
struct  d_print_template
 
struct  d_print_mod
 
struct  d_growable_string
 
struct  d_component_stack
 
struct  d_saved_scope
 
struct  d_info_checkpoint
 
struct  d_print_info
 

Macros

#define INT_MAX   (int)(((unsigned int)~0) >> 1) /* 0x7FFFFFFF */
 
#define CP_STATIC_IF_GLIBCPP_V3
 
#define IS_DIGIT(c)   ((c) >= '0' && (c) <= '9')
 
#define IS_UPPER(c)   ((c) >= 'A' && (c) <= 'Z')
 
#define IS_LOWER(c)   ((c) >= 'a' && (c) <= 'z')
 
#define ANONYMOUS_NAMESPACE_PREFIX   "_GLOBAL_"
 
#define ANONYMOUS_NAMESPACE_PREFIX_LEN    (sizeof(ANONYMOUS_NAMESPACE_PREFIX) - 1)
 
#define d_left(dc)   ((dc)->u.s_binary.left)
 
#define d_right(dc)   ((dc)->u.s_binary.right)
 
#define MAX_RECURSION_COUNT   1024
 
#define FNQUAL_COMPONENT_CASE
 
#define NL(s)   s, (sizeof s) - 1
 

Enumerations

enum  { D_PRINT_BUFFER_LENGTH = 256 }
 

Functions

char * alloca ()
 
static struct demangle_componentd_make_empty (struct d_info *)
 
static struct demangle_componentd_make_comp (struct d_info *, enum demangle_component_type, struct demangle_component *, struct demangle_component *)
 
static struct demangle_componentd_make_name (struct d_info *, const char *, int)
 
static struct demangle_componentd_make_demangle_mangled_name (struct d_info *, const char *)
 
static struct demangle_componentd_make_builtin_type (struct d_info *, const struct demangle_builtin_type_info *)
 
static struct demangle_componentd_make_operator (struct d_info *, const struct demangle_operator_info *)
 
static struct demangle_componentd_make_extended_operator (struct d_info *, int, struct demangle_component *)
 
static struct demangle_componentd_make_ctor (struct d_info *, enum gnu_v3_ctor_kinds, struct demangle_component *)
 
static struct demangle_componentd_make_dtor (struct d_info *, enum gnu_v3_dtor_kinds, struct demangle_component *)
 
static struct demangle_componentd_make_template_param (struct d_info *, int)
 
static struct demangle_componentd_make_sub (struct d_info *, const char *, int)
 
static int has_return_type (struct demangle_component *)
 
static int is_ctor_dtor_or_conversion (struct demangle_component *)
 
static struct demangle_componentd_encoding (struct d_info *, int)
 
static struct demangle_componentd_name (struct d_info *)
 
static struct demangle_componentd_nested_name (struct d_info *)
 
static struct demangle_componentd_prefix (struct d_info *)
 
static struct demangle_componentd_unqualified_name (struct d_info *)
 
static struct demangle_componentd_source_name (struct d_info *)
 
static int d_number (struct d_info *)
 
static struct demangle_componentd_identifier (struct d_info *, int)
 
static struct demangle_componentd_operator_name (struct d_info *)
 
static struct demangle_componentd_special_name (struct d_info *)
 
static struct demangle_componentd_parmlist (struct d_info *)
 
static int d_call_offset (struct d_info *, int)
 
static struct demangle_componentd_ctor_dtor_name (struct d_info *)
 
static struct demangle_component ** d_cv_qualifiers (struct d_info *, struct demangle_component **, int)
 
static struct demangle_componentd_ref_qualifier (struct d_info *, struct demangle_component *)
 
static struct demangle_componentd_function_type (struct d_info *)
 
static struct demangle_componentd_bare_function_type (struct d_info *, int)
 
static struct demangle_componentd_class_enum_type (struct d_info *)
 
static struct demangle_componentd_array_type (struct d_info *)
 
static struct demangle_componentd_vector_type (struct d_info *)
 
static struct demangle_componentd_pointer_to_member_type (struct d_info *)
 
static struct demangle_componentd_template_param (struct d_info *)
 
static struct demangle_componentd_template_args (struct d_info *)
 
static struct demangle_componentd_template_args_1 (struct d_info *)
 
static struct demangle_componentd_template_arg (struct d_info *)
 
static struct demangle_componentd_expression (struct d_info *)
 
static struct demangle_componentd_expr_primary (struct d_info *)
 
static struct demangle_componentd_local_name (struct d_info *)
 
static int d_discriminator (struct d_info *)
 
static struct demangle_componentd_lambda (struct d_info *)
 
static struct demangle_componentd_unnamed_type (struct d_info *)
 
static struct demangle_componentd_clone_suffix (struct d_info *, struct demangle_component *)
 
static int d_add_substitution (struct d_info *, struct demangle_component *)
 
static struct demangle_componentd_substitution (struct d_info *, int)
 
static void d_checkpoint (struct d_info *, struct d_info_checkpoint *)
 
static void d_backtrack (struct d_info *, struct d_info_checkpoint *)
 
static void d_growable_string_init (struct d_growable_string *, size_t)
 
static void d_growable_string_resize (struct d_growable_string *, size_t)
 
static void d_growable_string_append_buffer (struct d_growable_string *, const char *, size_t)
 
static void d_growable_string_callback_adapter (const char *, size_t, void *)
 
static void d_print_init (struct d_print_info *, demangle_callbackref, void *, const struct demangle_component *)
 
static void d_print_error (struct d_print_info *)
 
static int d_print_saw_error (struct d_print_info *)
 
static void d_print_flush (struct d_print_info *)
 
static void d_append_char (struct d_print_info *, char)
 
static void d_append_buffer (struct d_print_info *, const char *, size_t)
 
static void d_append_string (struct d_print_info *, const char *)
 
static char d_last_char (struct d_print_info *)
 
static void d_print_comp (struct d_print_info *, int, struct demangle_component *)
 
static void d_print_java_identifier (struct d_print_info *, const char *, int)
 
static void d_print_mod_list (struct d_print_info *, int, struct d_print_mod *, int)
 
static void d_print_mod (struct d_print_info *, int, struct demangle_component *)
 
static void d_print_function_type (struct d_print_info *, int, struct demangle_component *, struct d_print_mod *)
 
static void d_print_array_type (struct d_print_info *, int, struct demangle_component *, struct d_print_mod *)
 
static void d_print_expr_op (struct d_print_info *, int, struct demangle_component *)
 
static void d_print_cast (struct d_print_info *, int, struct demangle_component *)
 
static void d_print_conversion (struct d_print_info *, int, struct demangle_component *)
 
static int d_demangle_callback (const char *, int, demangle_callbackref, void *)
 
static char * d_demangle (const char *, int, size_t *)
 
static int is_fnqual_component_type (enum demangle_component_type type)
 
CP_STATIC_IF_GLIBCPP_V3 int cplus_demangle_fill_name (struct demangle_component *p, const char *s, int len)
 
CP_STATIC_IF_GLIBCPP_V3 int cplus_demangle_fill_extended_operator (struct demangle_component *p, int args, struct demangle_component *name)
 
CP_STATIC_IF_GLIBCPP_V3 int cplus_demangle_fill_ctor (struct demangle_component *p, enum gnu_v3_ctor_kinds kind, struct demangle_component *name)
 
CP_STATIC_IF_GLIBCPP_V3 int cplus_demangle_fill_dtor (struct demangle_component *p, enum gnu_v3_dtor_kinds kind, struct demangle_component *name)
 
static struct demangle_componentd_make_default_arg (struct d_info *di, int num, struct demangle_component *sub)
 
static struct demangle_componentd_make_function_param (struct d_info *di, int i)
 
CP_STATIC_IF_GLIBCPP_V3 struct demangle_componentcplus_demangle_mangled_name (struct d_info *di, int top_level)
 
static struct demangle_componentd_abi_tags (struct d_info *di, struct demangle_component *dc)
 
static struct demangle_componentd_number_component (struct d_info *di)
 
static struct demangle_componentd_make_character (struct d_info *di, int c)
 
static struct demangle_componentd_java_resource (struct d_info *di)
 
static int next_is_type_qual (struct d_info *di)
 
CP_STATIC_IF_GLIBCPP_V3 struct demangle_componentcplus_demangle_type (struct d_info *di)
 
static int d_compact_number (struct d_info *di)
 
static struct demangle_componentd_exprlist (struct d_info *di, char terminator)
 
static int op_is_new_cast (struct demangle_component *op)
 
static struct demangle_componentd_expression_1 (struct d_info *di)
 
static void d_count_templates_scopes (int *num_templates, int *num_scopes, const struct demangle_component *dc)
 
static void d_append_num (struct d_print_info *dpi, int l)
 
CP_STATIC_IF_GLIBCPP_V3 int cplus_demangle_print_callback (int options, struct demangle_component *dc, demangle_callbackref callback, void *opaque)
 
CP_STATIC_IF_GLIBCPP_V3 char * cplus_demangle_print (int options, struct demangle_component *dc, int estimate, size_t *palc)
 
static struct demangle_componentd_index_template_argument (struct demangle_component *args, int i)
 
static struct demangle_componentd_lookup_template_argument (struct d_print_info *dpi, const struct demangle_component *dc)
 
static struct demangle_componentd_find_pack (struct d_print_info *dpi, const struct demangle_component *dc)
 
static int d_pack_length (const struct demangle_component *dc)
 
static int d_args_length (struct d_print_info *dpi, const struct demangle_component *dc)
 
static void d_print_subexpr (struct d_print_info *dpi, int options, struct demangle_component *dc)
 
static void d_save_scope (struct d_print_info *dpi, const struct demangle_component *container)
 
static struct d_saved_scoped_get_saved_scope (struct d_print_info *dpi, const struct demangle_component *container)
 
static int d_maybe_print_fold_expression (struct d_print_info *dpi, int options, struct demangle_component *dc)
 
static void d_print_comp_inner (struct d_print_info *dpi, int options, struct demangle_component *dc)
 
CP_STATIC_IF_GLIBCPP_V3 void cplus_demangle_init_info (const char *mangled, int options, size_t len, struct d_info *di)
 
char * cplus_demangle_v3 (const char *mangled, int options)
 
int cplus_demangle_v3_callback (const char *mangled, int options, demangle_callbackref callback, void *opaque)
 
char * java_demangle_v3 (const char *mangled)
 
int java_demangle_v3_callback (const char *mangled, demangle_callbackref callback, void *opaque)
 
static int is_ctor_or_dtor (const char *mangled, enum gnu_v3_ctor_kinds *ctor_kind, enum gnu_v3_dtor_kinds *dtor_kind)
 
enum gnu_v3_ctor_kinds is_gnu_v3_mangled_ctor (const char *name)
 
enum gnu_v3_dtor_kinds is_gnu_v3_mangled_dtor (const char *name)
 

Variables

CP_STATIC_IF_GLIBCPP_V3 const struct demangle_operator_info cplus_demangle_operators []
 
CP_STATIC_IF_GLIBCPP_V3 const struct demangle_builtin_type_info cplus_demangle_builtin_types [D_BUILTIN_TYPE_COUNT]
 
static const struct d_standard_sub_info standard_subs []
 

Macro Definition Documentation

◆ ANONYMOUS_NAMESPACE_PREFIX

#define ANONYMOUS_NAMESPACE_PREFIX   "_GLOBAL_"

Definition at line 214 of file cp-demangle.c.

◆ ANONYMOUS_NAMESPACE_PREFIX_LEN

#define ANONYMOUS_NAMESPACE_PREFIX_LEN    (sizeof(ANONYMOUS_NAMESPACE_PREFIX) - 1)

Definition at line 215 of file cp-demangle.c.

◆ CP_STATIC_IF_GLIBCPP_V3

#define CP_STATIC_IF_GLIBCPP_V3

Definition at line 182 of file cp-demangle.c.

◆ d_left

#define d_left (   dc)    ((dc)->u.s_binary.left)

Definition at line 242 of file cp-demangle.c.

◆ d_right

#define d_right (   dc)    ((dc)->u.s_binary.right)

Definition at line 243 of file cp-demangle.c.

◆ FNQUAL_COMPONENT_CASE

#define FNQUAL_COMPONENT_CASE
Value:
@ DEMANGLE_COMPONENT_REFERENCE_THIS
Definition: demangle.h:336
@ DEMANGLE_COMPONENT_RESTRICT_THIS
Definition: demangle.h:327
@ DEMANGLE_COMPONENT_TRANSACTION_SAFE
Definition: demangle.h:468
@ DEMANGLE_COMPONENT_RVALUE_REFERENCE_THIS
Definition: demangle.h:339
@ DEMANGLE_COMPONENT_THROW_SPEC
Definition: demangle.h:472
@ DEMANGLE_COMPONENT_VOLATILE_THIS
Definition: demangle.h:330
@ DEMANGLE_COMPONENT_CONST_THIS
Definition: demangle.h:333
@ DEMANGLE_COMPONENT_NOEXCEPT
Definition: demangle.h:471

Definition at line 560 of file cp-demangle.c.

◆ INT_MAX

#define INT_MAX   (int)(((unsigned int)~0) >> 1) /* 0x7FFFFFFF */

Definition at line 131 of file cp-demangle.c.

◆ IS_DIGIT

#define IS_DIGIT (   c)    ((c) >= '0' && (c) <= '9')

Definition at line 208 of file cp-demangle.c.

◆ IS_LOWER

#define IS_LOWER (   c)    ((c) >= 'a' && (c) <= 'z')

Definition at line 210 of file cp-demangle.c.

◆ IS_UPPER

#define IS_UPPER (   c)    ((c) >= 'A' && (c) <= 'Z')

Definition at line 209 of file cp-demangle.c.

◆ MAX_RECURSION_COUNT

#define MAX_RECURSION_COUNT   1024

Definition at line 313 of file cp-demangle.c.

◆ NL

#define NL (   s)    s, (sizeof s) - 1

Definition at line 1663 of file cp-demangle.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
D_PRINT_BUFFER_LENGTH 

Definition at line 315 of file cp-demangle.c.

315 { D_PRINT_BUFFER_LENGTH = 256 };
@ D_PRINT_BUFFER_LENGTH
Definition: cp-demangle.c:315

Function Documentation

◆ alloca()

◆ cplus_demangle_fill_ctor()

CP_STATIC_IF_GLIBCPP_V3 int cplus_demangle_fill_ctor ( struct demangle_component p,
enum gnu_v3_ctor_kinds  kind,
struct demangle_component name 
)

Definition at line 871 of file cp-demangle.c.

873  {
874  if (p == NULL || name == NULL || (int)kind < gnu_v3_complete_object_ctor || (int)kind > gnu_v3_object_ctor_group)
875  return 0;
876  p->d_printing = 0;
877  p->type = DEMANGLE_COMPONENT_CTOR;
878  p->u.s_ctor.kind = kind;
879  p->u.s_ctor.name = name;
880  return 1;
881 }
#define NULL
Definition: cris-opc.c:27
@ gnu_v3_complete_object_ctor
Definition: demangle.h:196
@ gnu_v3_object_ctor_group
Definition: demangle.h:203
@ DEMANGLE_COMPONENT_CTOR
Definition: demangle.h:268
void * p
Definition: libc.cpp:67
const char * name
Definition: op.c:541
Definition: z80asm.h:102

References DEMANGLE_COMPONENT_CTOR, gnu_v3_complete_object_ctor, gnu_v3_object_ctor_group, demangle_component::kind, name, NULL, and p.

Referenced by d_make_ctor().

◆ cplus_demangle_fill_dtor()

CP_STATIC_IF_GLIBCPP_V3 int cplus_demangle_fill_dtor ( struct demangle_component p,
enum gnu_v3_dtor_kinds  kind,
struct demangle_component name 
)

Definition at line 886 of file cp-demangle.c.

888  {
889  if (p == NULL || name == NULL || (int)kind < gnu_v3_deleting_dtor || (int)kind > gnu_v3_object_dtor_group)
890  return 0;
891  p->d_printing = 0;
892  p->type = DEMANGLE_COMPONENT_DTOR;
893  p->u.s_dtor.kind = kind;
894  p->u.s_dtor.name = name;
895  return 1;
896 }
@ gnu_v3_object_dtor_group
Definition: demangle.h:221
@ gnu_v3_deleting_dtor
Definition: demangle.h:214
@ DEMANGLE_COMPONENT_DTOR
Definition: demangle.h:270

References DEMANGLE_COMPONENT_DTOR, gnu_v3_deleting_dtor, gnu_v3_object_dtor_group, demangle_component::kind, name, NULL, and p.

Referenced by d_make_dtor().

◆ cplus_demangle_fill_extended_operator()

CP_STATIC_IF_GLIBCPP_V3 int cplus_demangle_fill_extended_operator ( struct demangle_component p,
int  args,
struct demangle_component name 
)

Definition at line 857 of file cp-demangle.c.

858  {
859  if (p == NULL || args < 0 || name == NULL)
860  return 0;
861  p->d_printing = 0;
863  p->u.s_extended_operator.args = args;
864  p->u.s_extended_operator.name = name;
865  return 1;
866 }
@ DEMANGLE_COMPONENT_EXTENDED_OPERATOR
Definition: demangle.h:396
int args
Definition: mipsasm.c:18

References args, DEMANGLE_COMPONENT_EXTENDED_OPERATOR, name, NULL, and p.

Referenced by d_make_extended_operator().

◆ cplus_demangle_fill_name()

CP_STATIC_IF_GLIBCPP_V3 int cplus_demangle_fill_name ( struct demangle_component p,
const char *  s,
int  len 
)

Definition at line 844 of file cp-demangle.c.

844  {
845  if (p == NULL || s == NULL || len == 0)
846  return 0;
847  p->d_printing = 0;
848  p->type = DEMANGLE_COMPONENT_NAME;
849  p->u.s_name.s = s;
850  p->u.s_name.len = len;
851  return 1;
852 }
size_t len
Definition: 6502dis.c:15
@ DEMANGLE_COMPONENT_NAME
Definition: demangle.h:247
static RzSocket * s
Definition: rtr.c:28

References DEMANGLE_COMPONENT_NAME, len, NULL, p, and s.

Referenced by d_make_name().

◆ cplus_demangle_init_info()

CP_STATIC_IF_GLIBCPP_V3 void cplus_demangle_init_info ( const char *  mangled,
int  options,
size_t  len,
struct d_info di 
)

Definition at line 5681 of file cp-demangle.c.

5682  {
5683  di->s = mangled;
5684  di->send = mangled + len;
5685  di->options = options;
5686 
5687  di->n = mangled;
5688 
5689  /* We can not need more components than twice the number of chars in
5690  the mangled string. Most components correspond directly to
5691  chars, but the ARGLIST types are exceptions. */
5692  di->num_comps = 2 * len;
5693  di->next_comp = 0;
5694 
5695  /* Similarly, we can not need more substitutions than there are
5696  chars in the mangled string. */
5697  di->num_subs = len;
5698  di->next_sub = 0;
5699 
5700  di->last_name = NULL;
5701 
5702  di->expansion = 0;
5703  di->is_expression = 0;
5704  di->is_conversion = 0;
5705 }
static const char struct stat static buf struct stat static buf static vhangup int options
Definition: sflib.h:145
int is_expression
Definition: cp-demangle.h:120
struct demangle_component * last_name
Definition: cp-demangle.h:114
int num_comps
Definition: cp-demangle.h:106
const char * s
Definition: cp-demangle.h:94
const char * send
Definition: cp-demangle.h:96
int options
Definition: cp-demangle.h:98
int next_sub
Definition: cp-demangle.h:110
int next_comp
Definition: cp-demangle.h:104
int is_conversion
Definition: cp-demangle.h:123
int num_subs
Definition: cp-demangle.h:112
const char * n
Definition: cp-demangle.h:100
int expansion
Definition: cp-demangle.h:118

References d_info::expansion, d_info::is_conversion, d_info::is_expression, d_info::last_name, len, d_info::n, d_info::next_comp, d_info::next_sub, NULL, d_info::num_comps, d_info::num_subs, options, d_info::options, d_info::s, and d_info::send.

Referenced by d_demangle_callback(), and is_ctor_or_dtor().

◆ cplus_demangle_mangled_name()

CP_STATIC_IF_GLIBCPP_V3 struct demangle_component* cplus_demangle_mangled_name ( struct d_info di,
int  top_level 
)

Definition at line 1170 of file cp-demangle.c.

1170  {
1171  struct demangle_component *p;
1172 
1173  if (!d_check_char(di, '_')
1174  /* Allow missing _ if not at toplevel to work around a
1175  bug in G++ abi-version=2 mangling; see the comment in
1176  write_template_arg. */
1177  && top_level)
1178  return NULL;
1179  if (!d_check_char(di, 'Z'))
1180  return NULL;
1181  p = d_encoding(di, top_level);
1182 
1183  /* If at top level and parsing parameters, check for a clone
1184  suffix. */
1185  if (top_level && (di->options & DMGL_PARAMS) != 0)
1186  while (d_peek_char(di) == '.' && (IS_LOWER(d_peek_next_char(di)) || d_peek_next_char(di) == '_' || IS_DIGIT(d_peek_next_char(di))))
1187  p = d_clone_suffix(di, p);
1188 
1189  return p;
1190 }
#define IS_LOWER(c)
Definition: cp-demangle.c:210
#define IS_DIGIT(c)
Definition: cp-demangle.c:208
static struct demangle_component * d_encoding(struct d_info *, int)
Definition: cp-demangle.c:1247
static struct demangle_component * d_clone_suffix(struct d_info *, struct demangle_component *)
Definition: cp-demangle.c:3480
#define d_check_char(di, c)
Definition: cp-demangle.h:136
#define d_peek_next_char(di)
Definition: cp-demangle.h:133
#define d_peek_char(di)
Definition: cp-demangle.h:131
#define DMGL_PARAMS
Definition: demangle.h:43

References d_check_char, d_clone_suffix(), d_encoding(), d_peek_char, d_peek_next_char, DMGL_PARAMS, IS_DIGIT, IS_LOWER, NULL, d_info::options, and p.

Referenced by d_demangle_callback(), d_expr_primary(), and is_ctor_or_dtor().

◆ cplus_demangle_print()

CP_STATIC_IF_GLIBCPP_V3 char* cplus_demangle_print ( int  options,
struct demangle_component dc,
int  estimate,
size_t palc 
)

Definition at line 4010 of file cp-demangle.c.

4011  {
4012  struct d_growable_string dgs;
4013 
4014  d_growable_string_init(&dgs, estimate);
4015 
4018  &dgs)) {
4019  free(dgs.buf);
4020  *palc = 0;
4021  return NULL;
4022  }
4023 
4024  *palc = dgs.allocation_failure ? 1 : dgs.alc;
4025  return dgs.buf;
4026 }
CP_STATIC_IF_GLIBCPP_V3 int cplus_demangle_print_callback(int options, struct demangle_component *dc, demangle_callbackref callback, void *opaque)
Definition: cp-demangle.c:3967
static void d_growable_string_callback_adapter(const char *, size_t, void *)
Definition: cp-demangle.c:3720
static void d_growable_string_init(struct d_growable_string *, size_t)
Definition: cp-demangle.c:3658
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130

References d_growable_string::alc, d_growable_string::allocation_failure, d_growable_string::buf, cplus_demangle_print_callback(), d_growable_string_callback_adapter(), d_growable_string_init(), free(), NULL, and options.

◆ cplus_demangle_print_callback()

CP_STATIC_IF_GLIBCPP_V3 int cplus_demangle_print_callback ( int  options,
struct demangle_component dc,
demangle_callbackref  callback,
void *  opaque 
)

Definition at line 3967 of file cp-demangle.c.

3969  {
3970  struct d_print_info dpi;
3971 
3972  d_print_init(&dpi, callback, opaque, dc);
3973 
3974  {
3975 #ifdef CP_DYNAMIC_ARRAYS
3976  /* Avoid zero-length VLAs, which are prohibited by the C99 standard
3977  and flagged as errors by Address Sanitizer. */
3978  __extension__ struct d_saved_scope scopes[(dpi.num_saved_scopes > 0)
3979  ? dpi.num_saved_scopes
3980  : 1];
3981  __extension__ struct d_print_template temps[(dpi.num_copy_templates > 0)
3982  ? dpi.num_copy_templates
3983  : 1];
3984 
3985  dpi.saved_scopes = scopes;
3986  dpi.copy_templates = temps;
3987 #else
3988  dpi.saved_scopes = alloca(dpi.num_saved_scopes * sizeof(*dpi.saved_scopes));
3989  dpi.copy_templates = alloca(dpi.num_copy_templates * sizeof(*dpi.copy_templates));
3990 #endif
3991 
3992  d_print_comp(&dpi, options, dc);
3993  }
3994 
3995  d_print_flush(&dpi);
3996 
3997  return !d_print_saw_error(&dpi);
3998 }
static void d_print_flush(struct d_print_info *)
Definition: cp-demangle.c:3914
static void d_print_comp(struct d_print_info *, int, struct demangle_component *)
Definition: cp-demangle.c:5271
static void d_print_init(struct d_print_info *, demangle_callbackref, void *, const struct demangle_component *)
Definition: cp-demangle.c:3866
static int d_print_saw_error(struct d_print_info *)
Definition: cp-demangle.c:3907
char * alloca()
#define __extension__
Definition: ansidecl.h:408
void * opaque
Definition: cp-demangle.c:328
demangle_callbackref callback
Definition: cp-demangle.c:326

References __extension__, alloca(), d_print_info::callback, CP_STATIC_IF_GLIBCPP_V3, d_print_comp(), d_print_flush(), d_print_init(), d_print_saw_error(), and d_print_info::opaque.

Referenced by cplus_demangle_print(), and d_demangle_callback().

◆ cplus_demangle_type()

CP_STATIC_IF_GLIBCPP_V3 struct demangle_component* cplus_demangle_type ( struct d_info di)

Definition at line 2212 of file cp-demangle.c.

2212  {
2213  char peek;
2214  struct demangle_component *ret;
2215  int can_subst;
2216 
2217  /* The ABI specifies that when CV-qualifiers are used, the base type
2218  is substitutable, and the fully qualified type is substitutable,
2219  but the base type with a strict subset of the CV-qualifiers is
2220  not substitutable. The natural recursive implementation of the
2221  CV-qualifiers would cause subsets to be substitutable, so instead
2222  we pull them all off now.
2223 
2224  FIXME: The ABI says that order-insensitive vendor qualifiers
2225  should be handled in the same way, but we have no way to tell
2226  which vendor qualifiers are order-insensitive and which are
2227  order-sensitive. So we just assume that they are all
2228  order-sensitive. g++ 3.4 supports only one vendor qualifier,
2229  __vector, and it treats it as order-sensitive when mangling
2230  names. */
2231 
2232  if (next_is_type_qual(di)) {
2233  struct demangle_component **pret;
2234 
2235  pret = d_cv_qualifiers(di, &ret, 0);
2236  if (pret == NULL)
2237  return NULL;
2238  if (d_peek_char(di) == 'F') {
2239  /* cv-qualifiers before a function type apply to 'this',
2240  so avoid adding the unqualified function type to
2241  the substitution list. */
2242  *pret = d_function_type(di);
2243  } else
2244  *pret = cplus_demangle_type(di);
2245  if (!*pret)
2246  return NULL;
2247  if ((*pret)->type == DEMANGLE_COMPONENT_RVALUE_REFERENCE_THIS || (*pret)->type == DEMANGLE_COMPONENT_REFERENCE_THIS) {
2248  /* Move the ref-qualifier outside the cv-qualifiers so that
2249  they are printed in the right order. */
2250  struct demangle_component *fn = d_left(*pret);
2251  d_left(*pret) = ret;
2252  ret = *pret;
2253  *pret = fn;
2254  }
2255  if (!d_add_substitution(di, ret))
2256  return NULL;
2257  return ret;
2258  }
2259 
2260  can_subst = 1;
2261 
2262  peek = d_peek_char(di);
2263  switch (peek) {
2264  case 'a':
2265  case 'b':
2266  case 'c':
2267  case 'd':
2268  case 'e':
2269  case 'f':
2270  case 'g':
2271  case 'h':
2272  case 'i':
2273  case 'j':
2274  case 'l':
2275  case 'm':
2276  case 'n':
2277  case 'o':
2278  case 's':
2279  case 't':
2280  case 'v':
2281  case 'w':
2282  case 'x':
2283  case 'y':
2284  case 'z':
2285  ret = d_make_builtin_type(di,
2286  &cplus_demangle_builtin_types[peek - 'a']);
2287  di->expansion += ret->u.s_builtin.type->len;
2288  can_subst = 0;
2289  d_advance(di, 1);
2290  break;
2291 
2292  case 'u':
2293  d_advance(di, 1);
2295  d_source_name(di), NULL);
2296  break;
2297 
2298  case 'F':
2299  ret = d_function_type(di);
2300  break;
2301 
2302  case '0':
2303  case '1':
2304  case '2':
2305  case '3':
2306  case '4':
2307  case '5':
2308  case '6':
2309  case '7':
2310  case '8':
2311  case '9':
2312  case 'N':
2313  case 'Z':
2314  ret = d_class_enum_type(di);
2315  break;
2316 
2317  case 'A':
2318  ret = d_array_type(di);
2319  break;
2320 
2321  case 'M':
2322  ret = d_pointer_to_member_type(di);
2323  break;
2324 
2325  case 'T':
2326  ret = d_template_param(di);
2327  if (d_peek_char(di) == 'I') {
2328  /* This may be <template-template-param> <template-args>.
2329  If this is the type for a conversion operator, we can
2330  have a <template-template-param> here only by following
2331  a derivation like this:
2332 
2333  <nested-name>
2334  -> <template-prefix> <template-args>
2335  -> <prefix> <template-unqualified-name> <template-args>
2336  -> <unqualified-name> <template-unqualified-name> <template-args>
2337  -> <source-name> <template-unqualified-name> <template-args>
2338  -> <source-name> <operator-name> <template-args>
2339  -> <source-name> cv <type> <template-args>
2340  -> <source-name> cv <template-template-param> <template-args> <template-args>
2341 
2342  where the <template-args> is followed by another.
2343  Otherwise, we must have a derivation like this:
2344 
2345  <nested-name>
2346  -> <template-prefix> <template-args>
2347  -> <prefix> <template-unqualified-name> <template-args>
2348  -> <unqualified-name> <template-unqualified-name> <template-args>
2349  -> <source-name> <template-unqualified-name> <template-args>
2350  -> <source-name> <operator-name> <template-args>
2351  -> <source-name> cv <type> <template-args>
2352  -> <source-name> cv <template-param> <template-args>
2353 
2354  where we need to leave the <template-args> to be processed
2355  by d_prefix (following the <template-prefix>).
2356 
2357  The <template-template-param> part is a substitution
2358  candidate. */
2359  if (!di->is_conversion) {
2360  if (!d_add_substitution(di, ret))
2361  return NULL;
2363  d_template_args(di));
2364  } else {
2365  struct demangle_component *args;
2366  struct d_info_checkpoint checkpoint;
2367 
2368  d_checkpoint(di, &checkpoint);
2369  args = d_template_args(di);
2370  if (d_peek_char(di) == 'I') {
2371  if (!d_add_substitution(di, ret))
2372  return NULL;
2374  args);
2375  } else
2376  d_backtrack(di, &checkpoint);
2377  }
2378  }
2379  break;
2380 
2381  case 'S':
2382  /* If this is a special substitution, then it is the start of
2383  <class-enum-type>. */
2384  {
2385  char peek_next;
2386 
2387  peek_next = d_peek_next_char(di);
2388  if (IS_DIGIT(peek_next) || peek_next == '_' || IS_UPPER(peek_next)) {
2389  ret = d_substitution(di, 0);
2390  /* The substituted name may have been a template name and
2391  may be followed by tepmlate args. */
2392  if (d_peek_char(di) == 'I')
2394  d_template_args(di));
2395  else
2396  can_subst = 0;
2397  } else {
2398  ret = d_class_enum_type(di);
2399  /* If the substitution was a complete type, then it is not
2400  a new substitution candidate. However, if the
2401  substitution was followed by template arguments, then
2402  the whole thing is a substitution candidate. */
2403  if (ret != NULL && ret->type == DEMANGLE_COMPONENT_SUB_STD)
2404  can_subst = 0;
2405  }
2406  }
2407  break;
2408 
2409  case 'O':
2410  d_advance(di, 1);
2412  cplus_demangle_type(di), NULL);
2413  break;
2414 
2415  case 'P':
2416  d_advance(di, 1);
2418  cplus_demangle_type(di), NULL);
2419  break;
2420 
2421  case 'R':
2422  d_advance(di, 1);
2424  cplus_demangle_type(di), NULL);
2425  break;
2426 
2427  case 'C':
2428  d_advance(di, 1);
2430  cplus_demangle_type(di), NULL);
2431  break;
2432 
2433  case 'G':
2434  d_advance(di, 1);
2436  cplus_demangle_type(di), NULL);
2437  break;
2438 
2439  case 'U':
2440  d_advance(di, 1);
2441  ret = d_source_name(di);
2442  if (d_peek_char(di) == 'I')
2444  d_template_args(di));
2446  cplus_demangle_type(di), ret);
2447  break;
2448 
2449  case 'D':
2450  can_subst = 0;
2451  d_advance(di, 1);
2452  peek = d_next_char(di);
2453  switch (peek) {
2454  case 'T':
2455  case 't':
2456  /* decltype (expression) */
2458  d_expression(di), NULL);
2459  if (ret && d_next_char(di) != 'E')
2460  ret = NULL;
2461  can_subst = 1;
2462  break;
2463 
2464  case 'p':
2465  /* Pack expansion. */
2467  cplus_demangle_type(di), NULL);
2468  can_subst = 1;
2469  break;
2470 
2471  case 'a':
2472  /* auto */
2473  ret = d_make_name(di, "auto", 4);
2474  break;
2475  case 'c':
2476  /* decltype(auto) */
2477  ret = d_make_name(di, "decltype(auto)", 14);
2478  break;
2479 
2480  case 'f':
2481  /* 32-bit decimal floating point */
2483  di->expansion += ret->u.s_builtin.type->len;
2484  break;
2485  case 'd':
2486  /* 64-bit DFP */
2488  di->expansion += ret->u.s_builtin.type->len;
2489  break;
2490  case 'e':
2491  /* 128-bit DFP */
2493  di->expansion += ret->u.s_builtin.type->len;
2494  break;
2495  case 'h':
2496  /* 16-bit half-precision FP */
2498  di->expansion += ret->u.s_builtin.type->len;
2499  break;
2500  case 's':
2501  /* char16_t */
2503  di->expansion += ret->u.s_builtin.type->len;
2504  break;
2505  case 'i':
2506  /* char32_t */
2508  di->expansion += ret->u.s_builtin.type->len;
2509  break;
2510 
2511  case 'F':
2512  /* Fixed point types. DF<int bits><length><fract bits><sat> */
2513  ret = d_make_empty(di);
2515  if ((ret->u.s_fixed.accum = IS_DIGIT(d_peek_char(di))))
2516  /* For demangling we don't care about the bits. */
2517  d_number(di);
2518  ret->u.s_fixed.length = cplus_demangle_type(di);
2519  if (ret->u.s_fixed.length == NULL)
2520  return NULL;
2521  d_number(di);
2522  peek = d_next_char(di);
2523  ret->u.s_fixed.sat = (peek == 's');
2524  break;
2525 
2526  case 'v':
2527  ret = d_vector_type(di);
2528  can_subst = 1;
2529  break;
2530 
2531  case 'n':
2532  /* decltype(nullptr) */
2534  di->expansion += ret->u.s_builtin.type->len;
2535  break;
2536 
2537  default:
2538  return NULL;
2539  }
2540  break;
2541 
2542  default:
2543  return NULL;
2544  }
2545 
2546  if (can_subst) {
2547  if (!d_add_substitution(di, ret))
2548  return NULL;
2549  }
2550 
2551  return ret;
2552 }
#define IS_UPPER(c)
Definition: cp-demangle.c:209
static int next_is_type_qual(struct d_info *di)
Definition: cp-demangle.c:2140
static struct demangle_component * d_make_name(struct d_info *, const char *, int)
Definition: cp-demangle.c:1030
static struct demangle_component * d_make_comp(struct d_info *, enum demangle_component_type, struct demangle_component *, struct demangle_component *)
Definition: cp-demangle.c:915
static struct demangle_component * d_class_enum_type(struct d_info *)
Definition: cp-demangle.c:2764
static struct demangle_component * d_make_builtin_type(struct d_info *, const struct demangle_builtin_type_info *)
Definition: cp-demangle.c:1042
CP_STATIC_IF_GLIBCPP_V3 struct demangle_component * cplus_demangle_type(struct d_info *di)
Definition: cp-demangle.c:2212
static int d_add_substitution(struct d_info *, struct demangle_component *)
Definition: cp-demangle.c:3503
static struct demangle_component * d_template_param(struct d_info *)
Definition: cp-demangle.c:2890
static int d_number(struct d_info *)
Definition: cp-demangle.c:1581
static struct demangle_component ** d_cv_qualifiers(struct d_info *, struct demangle_component **, int)
Definition: cp-demangle.c:2557
static void d_checkpoint(struct d_info *, struct d_info_checkpoint *)
Definition: cp-demangle.c:3640
static struct demangle_component * d_function_type(struct d_info *)
Definition: cp-demangle.c:2670
#define d_left(dc)
Definition: cp-demangle.c:242
static struct demangle_component * d_vector_type(struct d_info *)
Definition: cp-demangle.c:2811
static struct demangle_component * d_array_type(struct d_info *)
Definition: cp-demangle.c:2773
static void d_backtrack(struct d_info *, struct d_info_checkpoint *)
Definition: cp-demangle.c:3648
static struct demangle_component * d_substitution(struct d_info *, int)
Definition: cp-demangle.c:3557
static struct demangle_component * d_source_name(struct d_info *)
Definition: cp-demangle.c:1566
static struct demangle_component * d_expression(struct d_info *)
Definition: cp-demangle.c:3249
CP_STATIC_IF_GLIBCPP_V3 const struct demangle_builtin_type_info cplus_demangle_builtin_types[D_BUILTIN_TYPE_COUNT]
Definition: cp-demangle.c:2174
static struct demangle_component * d_template_args(struct d_info *)
Definition: cp-demangle.c:2906
static struct demangle_component * d_pointer_to_member_type(struct d_info *)
Definition: cp-demangle.c:2835
static struct demangle_component * d_make_empty(struct d_info *)
Definition: cp-demangle.c:901
#define d_next_char(di)
Definition: cp-demangle.h:137
#define d_advance(di, i)
Definition: cp-demangle.h:134
@ DEMANGLE_COMPONENT_PACK_EXPANSION
Definition: demangle.h:464
@ DEMANGLE_COMPONENT_REFERENCE
Definition: demangle.h:349
@ DEMANGLE_COMPONENT_SUB_STD
Definition: demangle.h:315
@ DEMANGLE_COMPONENT_COMPLEX
Definition: demangle.h:354
@ DEMANGLE_COMPONENT_POINTER
Definition: demangle.h:346
@ DEMANGLE_COMPONENT_VENDOR_TYPE
Definition: demangle.h:360
@ DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL
Definition: demangle.h:343
@ DEMANGLE_COMPONENT_RVALUE_REFERENCE
Definition: demangle.h:352
@ DEMANGLE_COMPONENT_DECLTYPE
Definition: demangle.h:445
@ DEMANGLE_COMPONENT_IMAGINARY
Definition: demangle.h:356
@ DEMANGLE_COMPONENT_TEMPLATE
Definition: demangle.h:260
@ DEMANGLE_COMPONENT_FIXED_TYPE
Definition: demangle.h:374
static const char struct stat static buf struct stat static buf static idle const char static path static fd const char static len const void static prot const char struct module static image struct kernel_sym static table unsigned char static buf static fsuid unsigned struct dirent unsigned static count const struct iovec static count static pid const void static len static flags const struct sched_param static p static pid static policy struct timespec static tp static suid unsigned fn
Definition: sflib.h:186
union demangle_component::@376 u
enum demangle_component_type type
Definition: demangle.h:487
struct demangle_component::@376::@383 s_builtin
struct demangle_component::@376::@380 s_fixed

References args, cplus_demangle_builtin_types, d_add_substitution(), d_advance, d_array_type(), d_backtrack(), d_checkpoint(), d_class_enum_type(), d_cv_qualifiers(), d_expression(), d_function_type(), d_left, d_make_builtin_type(), d_make_comp(), d_make_empty(), d_make_name(), d_next_char, d_number(), d_peek_char, d_peek_next_char, d_pointer_to_member_type(), d_source_name(), d_substitution(), d_template_args(), d_template_param(), d_vector_type(), DEMANGLE_COMPONENT_COMPLEX, DEMANGLE_COMPONENT_DECLTYPE, DEMANGLE_COMPONENT_FIXED_TYPE, DEMANGLE_COMPONENT_IMAGINARY, DEMANGLE_COMPONENT_PACK_EXPANSION, DEMANGLE_COMPONENT_POINTER, DEMANGLE_COMPONENT_REFERENCE, DEMANGLE_COMPONENT_REFERENCE_THIS, DEMANGLE_COMPONENT_RVALUE_REFERENCE, DEMANGLE_COMPONENT_RVALUE_REFERENCE_THIS, DEMANGLE_COMPONENT_SUB_STD, DEMANGLE_COMPONENT_TEMPLATE, DEMANGLE_COMPONENT_VENDOR_TYPE, DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL, d_info::expansion, fn, d_info::is_conversion, IS_DIGIT, IS_UPPER, next_is_type_qual(), NULL, demangle_component::s_builtin, demangle_component::s_fixed, demangle_component::type, and demangle_component::u.

Referenced by d_array_type(), d_bare_function_type(), d_ctor_dtor_name(), d_demangle_callback(), d_expr_primary(), d_expression_1(), d_operator_name(), d_parmlist(), d_pointer_to_member_type(), d_prefix(), d_special_name(), d_template_arg(), and d_vector_type().

◆ cplus_demangle_v3()

char* cplus_demangle_v3 ( const char *  mangled,
int  options 
)

Definition at line 5942 of file cp-demangle.c.

5942  {
5943  size_t alc;
5944 
5945  return d_demangle(mangled, options, &alc);
5946 }
static char * d_demangle(const char *, int, size_t *)
Definition: cp-demangle.c:5798

References d_growable_string::alc, d_demangle(), and options.

◆ cplus_demangle_v3_callback()

int cplus_demangle_v3_callback ( const char *  mangled,
int  options,
demangle_callbackref  callback,
void *  opaque 
)

Definition at line 5948 of file cp-demangle.c.

5949  {
5950  return d_demangle_callback(mangled, options, callback, opaque);
5951 }
static int d_demangle_callback(const char *, int, demangle_callbackref, void *)
Definition: cp-demangle.c:5713

References d_demangle_callback(), and options.

◆ d_abi_tags()

static struct demangle_component* d_abi_tags ( struct d_info di,
struct demangle_component dc 
)
static

Definition at line 1300 of file cp-demangle.c.

1300  {
1301  struct demangle_component *hold_last_name;
1302  char peek;
1303 
1304  /* Preserve the last name, so the ABI tag doesn't clobber it. */
1305  hold_last_name = di->last_name;
1306 
1307  while (peek = d_peek_char(di),
1308  peek == 'B') {
1309  struct demangle_component *tag;
1310  d_advance(di, 1);
1311  tag = d_source_name(di);
1313  }
1314 
1315  di->last_name = hold_last_name;
1316 
1317  return dc;
1318 }
@ DEMANGLE_COMPONENT_TAGGED_NAME
Definition: demangle.h:466

References d_advance, d_make_comp(), d_peek_char, d_source_name(), DEMANGLE_COMPONENT_TAGGED_NAME, d_info::last_name, and test-lz4-versions::tag.

Referenced by d_substitution(), and d_unqualified_name().

◆ d_add_substitution()

static int d_add_substitution ( struct d_info di,
struct demangle_component dc 
)
static

Definition at line 3503 of file cp-demangle.c.

3503  {
3504  if (dc == NULL)
3505  return 0;
3506  if (di->next_sub >= di->num_subs)
3507  return 0;
3508  di->subs[di->next_sub] = dc;
3509  ++di->next_sub;
3510  return 1;
3511 }
struct demangle_component ** subs
Definition: cp-demangle.h:108

References d_info::next_sub, NULL, d_info::num_subs, and d_info::subs.

Referenced by cplus_demangle_type(), d_lambda(), d_name(), d_prefix(), d_substitution(), and d_unnamed_type().

◆ d_append_buffer()

static void d_append_buffer ( struct d_print_info dpi,
const char *  s,
size_t  l 
)
inlinestatic

Definition at line 3933 of file cp-demangle.c.

3933  {
3934  size_t i;
3935 
3936  for (i = 0; i < l; i++)
3937  d_append_char(dpi, s[i]);
3938 }
lzma_index ** i
Definition: index.h:629
static void d_append_char(struct d_print_info *, char)
Definition: cp-demangle.c:3924

References d_append_char(), i, and s.

Referenced by d_append_string(), d_print_comp_inner(), and d_print_expr_op().

◆ d_append_char()

static void d_append_char ( struct d_print_info dpi,
char  c 
)
inlinestatic

Definition at line 3924 of file cp-demangle.c.

3924  {
3925  if (dpi->len == sizeof(dpi->buf) - 1)
3926  d_print_flush(dpi);
3927 
3928  dpi->buf[dpi->len++] = c;
3929  dpi->last_char = c;
3930 }
#define c(i)
Definition: sha256.c:43
char buf[D_PRINT_BUFFER_LENGTH]
Definition: cp-demangle.c:319

References d_print_info::buf, c, d_print_flush(), d_print_info::last_char, and d_print_info::len.

Referenced by d_append_buffer(), d_maybe_print_fold_expression(), d_print_array_type(), d_print_comp_inner(), d_print_conversion(), d_print_function_type(), d_print_java_identifier(), d_print_mod(), d_print_mod_list(), and d_print_subexpr().

◆ d_append_num()

static void d_append_num ( struct d_print_info dpi,
int  l 
)
inlinestatic

Definition at line 3946 of file cp-demangle.c.

3946  {
3947  char buf[25];
3948  sprintf(buf, "%d", l);
3949  d_append_string(dpi, buf);
3950 }
static void d_append_string(struct d_print_info *, const char *)
Definition: cp-demangle.c:3941
voidpf void * buf
Definition: ioapi.h:138
sprintf
Definition: kernel.h:365

References d_append_string(), and sprintf.

Referenced by d_print_comp_inner(), and d_print_mod_list().

◆ d_append_string()

static void d_append_string ( struct d_print_info dpi,
const char *  s 
)
inlinestatic

Definition at line 3941 of file cp-demangle.c.

3941  {
3942  d_append_buffer(dpi, s, strlen(s));
3943 }
static void d_append_buffer(struct d_print_info *, const char *, size_t)
Definition: cp-demangle.c:3933

References d_append_buffer(), and s.

Referenced by d_append_num(), d_maybe_print_fold_expression(), d_print_array_type(), d_print_comp_inner(), d_print_mod(), and d_print_mod_list().

◆ d_args_length()

static int d_args_length ( struct d_print_info dpi,
const struct demangle_component dc 
)
static

Definition at line 4133 of file cp-demangle.c.

4133  {
4134  int count = 0;
4135  for (; dc && dc->type == DEMANGLE_COMPONENT_TEMPLATE_ARGLIST;
4136  dc = d_right(dc)) {
4137  struct demangle_component *elt = d_left(dc);
4138  if (elt == NULL)
4139  break;
4141  struct demangle_component *a = d_find_pack(dpi, d_left(elt));
4142  count += d_pack_length(a);
4143  } else
4144  ++count;
4145  }
4146  return count;
4147 }
#define d_right(dc)
Definition: cp-demangle.c:243
static int d_pack_length(const struct demangle_component *dc)
Definition: cp-demangle.c:4120
static struct demangle_component * d_find_pack(struct d_print_info *dpi, const struct demangle_component *dc)
Definition: cp-demangle.c:4072
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void count
Definition: sflib.h:98
@ DEMANGLE_COMPONENT_TEMPLATE_ARGLIST
Definition: demangle.h:384
#define a(i)
Definition: sha256.c:41

References a, count, d_find_pack(), d_left, d_pack_length(), d_right, DEMANGLE_COMPONENT_PACK_EXPANSION, DEMANGLE_COMPONENT_TEMPLATE_ARGLIST, NULL, and demangle_component::type.

Referenced by d_print_comp_inner().

◆ d_array_type()

static struct demangle_component * d_array_type ( struct d_info di)
static

Definition at line 2773 of file cp-demangle.c.

2773  {
2774  char peek;
2775  struct demangle_component *dim;
2776 
2777  if (!d_check_char(di, 'A'))
2778  return NULL;
2779 
2780  peek = d_peek_char(di);
2781  if (peek == '_')
2782  dim = NULL;
2783  else if (IS_DIGIT(peek)) {
2784  const char *s;
2785 
2786  s = d_str(di);
2787  do {
2788  d_advance(di, 1);
2789  peek = d_peek_char(di);
2790  } while (IS_DIGIT(peek));
2791  dim = d_make_name(di, s, d_str(di) - s);
2792  if (dim == NULL)
2793  return NULL;
2794  } else {
2795  dim = d_expression(di);
2796  if (dim == NULL)
2797  return NULL;
2798  }
2799 
2800  if (!d_check_char(di, '_'))
2801  return NULL;
2802 
2804  cplus_demangle_type(di));
2805 }
#define d_str(di)
Definition: cp-demangle.h:138
@ DEMANGLE_COMPONENT_ARRAY_TYPE
Definition: demangle.h:368

References cplus_demangle_type(), d_advance, d_check_char, d_expression(), d_make_comp(), d_make_name(), d_peek_char, d_str, DEMANGLE_COMPONENT_ARRAY_TYPE, IS_DIGIT, NULL, and s.

Referenced by cplus_demangle_type().

◆ d_backtrack()

static void d_backtrack ( struct d_info di,
struct d_info_checkpoint checkpoint 
)
static

Definition at line 3648 of file cp-demangle.c.

3648  {
3649  di->n = checkpoint->n;
3650  di->next_comp = checkpoint->next_comp;
3651  di->next_sub = checkpoint->next_sub;
3652  di->expansion = checkpoint->expansion;
3653 }
const char * n
Definition: cp-demangle.c:306

References d_info_checkpoint::expansion, d_info::expansion, d_info_checkpoint::n, d_info::n, d_info_checkpoint::next_comp, d_info::next_comp, d_info_checkpoint::next_sub, and d_info::next_sub.

Referenced by cplus_demangle_type().

◆ d_bare_function_type()

static struct demangle_component * d_bare_function_type ( struct d_info di,
int  has_return_type 
)
static

Definition at line 2733 of file cp-demangle.c.

2733  {
2734  struct demangle_component *return_type;
2735  struct demangle_component *tl;
2736  char peek;
2737 
2738  /* Detect special qualifier indicating that the first argument
2739  is the return type. */
2740  peek = d_peek_char(di);
2741  if (peek == 'J') {
2742  d_advance(di, 1);
2743  has_return_type = 1;
2744  }
2745 
2746  if (has_return_type) {
2747  return_type = cplus_demangle_type(di);
2748  if (return_type == NULL)
2749  return NULL;
2750  } else
2751  return_type = NULL;
2752 
2753  tl = d_parmlist(di);
2754  if (tl == NULL)
2755  return NULL;
2756 
2758  return_type, tl);
2759 }
static struct demangle_component * d_parmlist(struct d_info *)
Definition: cp-demangle.c:2691
static int has_return_type(struct demangle_component *)
Definition: cp-demangle.c:1202
@ DEMANGLE_COMPONENT_FUNCTION_TYPE
Definition: demangle.h:364

References cplus_demangle_type(), d_advance, d_make_comp(), d_parmlist(), d_peek_char, DEMANGLE_COMPONENT_FUNCTION_TYPE, has_return_type(), and NULL.

Referenced by d_encoding(), and d_function_type().

◆ d_call_offset()

static int d_call_offset ( struct d_info di,
int  c 
)
static

Definition at line 2030 of file cp-demangle.c.

2030  {
2031  if (c == '\0')
2032  c = d_next_char(di);
2033 
2034  if (c == 'h')
2035  d_number(di);
2036  else if (c == 'v') {
2037  d_number(di);
2038  if (!d_check_char(di, '_'))
2039  return 0;
2040  d_number(di);
2041  } else
2042  return 0;
2043 
2044  if (!d_check_char(di, '_'))
2045  return 0;
2046 
2047  return 1;
2048 }

References c, d_check_char, d_next_char, and d_number().

Referenced by d_special_name().

◆ d_checkpoint()

static void d_checkpoint ( struct d_info di,
struct d_info_checkpoint checkpoint 
)
static

Definition at line 3640 of file cp-demangle.c.

3640  {
3641  checkpoint->n = di->n;
3642  checkpoint->next_comp = di->next_comp;
3643  checkpoint->next_sub = di->next_sub;
3644  checkpoint->expansion = di->expansion;
3645 }

References d_info_checkpoint::expansion, d_info::expansion, d_info_checkpoint::n, d_info::n, d_info_checkpoint::next_comp, d_info::next_comp, d_info_checkpoint::next_sub, and d_info::next_sub.

Referenced by cplus_demangle_type().

◆ d_class_enum_type()

static struct demangle_component * d_class_enum_type ( struct d_info di)
static

Definition at line 2764 of file cp-demangle.c.

2764  {
2765  return d_name(di);
2766 }
static struct demangle_component * d_name(struct d_info *)
Definition: cp-demangle.c:1333

References d_name().

Referenced by cplus_demangle_type().

◆ d_clone_suffix()

static struct demangle_component * d_clone_suffix ( struct d_info di,
struct demangle_component encoding 
)
static

Definition at line 3480 of file cp-demangle.c.

3480  {
3481  const char *suffix = d_str(di);
3482  const char *pend = suffix;
3483  struct demangle_component *n;
3484 
3485  if (*pend == '.' && (IS_LOWER(pend[1]) || pend[1] == '_')) {
3486  pend += 2;
3487  while (IS_LOWER(*pend) || *pend == '_')
3488  ++pend;
3489  }
3490  while (*pend == '.' && IS_DIGIT(pend[1])) {
3491  pend += 2;
3492  while (IS_DIGIT(*pend))
3493  ++pend;
3494  }
3495  d_advance(di, pend - suffix);
3496  n = d_make_name(di, suffix, pend - suffix);
3498 }
@ DEMANGLE_COMPONENT_CLONE
Definition: demangle.h:470
unsigned char suffix[65536]
Definition: gun.c:164
int n
Definition: mipsasm.c:19

References d_advance, d_make_comp(), d_make_name(), d_str, DEMANGLE_COMPONENT_CLONE, cmd_descs_generate::encoding, IS_DIGIT, IS_LOWER, n, and suffix.

Referenced by cplus_demangle_mangled_name().

◆ d_compact_number()

static int d_compact_number ( struct d_info di)
static

Definition at line 2871 of file cp-demangle.c.

2871  {
2872  int num;
2873  if (d_peek_char(di) == '_')
2874  num = 0;
2875  else if (d_peek_char(di) == 'n')
2876  return -1;
2877  else
2878  num = d_number(di) + 1;
2879 
2880  if (num < 0 || !d_check_char(di, '_'))
2881  return -1;
2882  return num;
2883 }
static static fork const void static count static fd const char const char static newpath char char char static envp time_t static t const char static mode static whence const char static dir time_t static t unsigned static seconds const char struct utimbuf static buf static inc static sig const char static mode static oldfd struct tms static buf static getgid static geteuid const char static filename static arg static mask struct ustat static ubuf static getppid static setsid static egid sigset_t static set struct timeval struct timezone static tz fd_set fd_set fd_set struct timeval static timeout const char char static bufsiz const char static swapflags void static offset const char static length static mode static who const char struct statfs static buf unsigned unsigned num
Definition: sflib.h:126

References d_check_char, d_number(), d_peek_char, and num.

Referenced by d_expression_1(), d_lambda(), d_local_name(), d_template_param(), and d_unnamed_type().

◆ d_count_templates_scopes()

static void d_count_templates_scopes ( int num_templates,
int num_scopes,
const struct demangle_component dc 
)
static

Definition at line 3734 of file cp-demangle.c.

3735  {
3736  if (dc == NULL)
3737  return;
3738 
3739  switch (dc->type) {
3749  break;
3750 
3752  (*num_templates)++;
3753  goto recurse_left_right;
3754 
3758  (*num_scopes)++;
3759  goto recurse_left_right;
3760 
3822  recurse_left_right:
3823  d_count_templates_scopes(num_templates, num_scopes,
3824  d_left(dc));
3825  d_count_templates_scopes(num_templates, num_scopes,
3826  d_right(dc));
3827  break;
3828 
3830  d_count_templates_scopes(num_templates, num_scopes,
3831  dc->u.s_ctor.name);
3832  break;
3833 
3835  d_count_templates_scopes(num_templates, num_scopes,
3836  dc->u.s_dtor.name);
3837  break;
3838 
3840  d_count_templates_scopes(num_templates, num_scopes,
3841  dc->u.s_extended_operator.name);
3842  break;
3843 
3845  d_count_templates_scopes(num_templates, num_scopes,
3846  dc->u.s_fixed.length);
3847  break;
3848 
3851  d_count_templates_scopes(num_templates, num_scopes,
3852  d_left(dc));
3853  break;
3854 
3857  d_count_templates_scopes(num_templates, num_scopes,
3858  dc->u.s_unary_num.sub);
3859  break;
3860  }
3861 }
static void d_count_templates_scopes(int *num_templates, int *num_scopes, const struct demangle_component *dc)
Definition: cp-demangle.c:3734
@ DEMANGLE_COMPONENT_UNNAMED_TYPE
Definition: demangle.h:455
@ DEMANGLE_COMPONENT_TLS_WRAPPER
Definition: demangle.h:306
@ DEMANGLE_COMPONENT_CONST
Definition: demangle.h:324
@ DEMANGLE_COMPONENT_VIRTUAL_THUNK
Definition: demangle.h:295
@ DEMANGLE_COMPONENT_TRINARY_ARG1
Definition: demangle.h:420
@ DEMANGLE_COMPONENT_TRANSACTION_CLONE
Definition: demangle.h:458
@ DEMANGLE_COMPONENT_LITERAL
Definition: demangle.h:426
@ DEMANGLE_COMPONENT_ARGLIST
Definition: demangle.h:380
@ DEMANGLE_COMPONENT_CONVERSION
Definition: demangle.h:403
@ DEMANGLE_COMPONENT_TRINARY
Definition: demangle.h:417
@ DEMANGLE_COMPONENT_TPARM_OBJ
Definition: demangle.h:387
@ DEMANGLE_COMPONENT_TEMPLATE_PARAM
Definition: demangle.h:263
@ DEMANGLE_COMPONENT_TYPEINFO_FN
Definition: demangle.h:289
@ DEMANGLE_COMPONENT_NONTRANSACTION_CLONE
Definition: demangle.h:462
@ DEMANGLE_COMPONENT_CONSTRUCTION_VTABLE
Definition: demangle.h:280
@ DEMANGLE_COMPONENT_QUAL_NAME
Definition: demangle.h:251
@ DEMANGLE_COMPONENT_REFTEMP
Definition: demangle.h:309
@ DEMANGLE_COMPONENT_BUILTIN_TYPE
Definition: demangle.h:358
@ DEMANGLE_COMPONENT_NULLARY
Definition: demangle.h:405
@ DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS
Definition: demangle.h:449
@ DEMANGLE_COMPONENT_DEFAULT_ARG
Definition: demangle.h:453
@ DEMANGLE_COMPONENT_INITIALIZER_LIST
Definition: demangle.h:390
@ DEMANGLE_COMPONENT_PTRMEM_TYPE
Definition: demangle.h:372
@ DEMANGLE_COMPONENT_HIDDEN_ALIAS
Definition: demangle.h:312
@ DEMANGLE_COMPONENT_LOCAL_NAME
Definition: demangle.h:254
@ DEMANGLE_COMPONENT_NUMBER
Definition: demangle.h:443
@ DEMANGLE_COMPONENT_RESTRICT
Definition: demangle.h:318
@ DEMANGLE_COMPONENT_LITERAL_NEG
Definition: demangle.h:433
@ DEMANGLE_COMPONENT_TRINARY_ARG2
Definition: demangle.h:423
@ DEMANGLE_COMPONENT_CAST
Definition: demangle.h:399
@ DEMANGLE_COMPONENT_JAVA_CLASS
Definition: demangle.h:300
@ DEMANGLE_COMPONENT_GUARD
Definition: demangle.h:303
@ DEMANGLE_COMPONENT_BINARY_ARGS
Definition: demangle.h:414
@ DEMANGLE_COMPONENT_LAMBDA
Definition: demangle.h:451
@ DEMANGLE_COMPONENT_TLS_INIT
Definition: demangle.h:305
@ DEMANGLE_COMPONENT_COVARIANT_THUNK
Definition: demangle.h:298
@ DEMANGLE_COMPONENT_THUNK
Definition: demangle.h:292
@ DEMANGLE_COMPONENT_UNARY
Definition: demangle.h:408
@ DEMANGLE_COMPONENT_VECTOR_TYPE
Definition: demangle.h:377
@ DEMANGLE_COMPONENT_COMPOUND_NAME
Definition: demangle.h:439
@ DEMANGLE_COMPONENT_VOLATILE
Definition: demangle.h:321
@ DEMANGLE_COMPONENT_TYPED_NAME
Definition: demangle.h:257
@ DEMANGLE_COMPONENT_CHARACTER
Definition: demangle.h:441
@ DEMANGLE_COMPONENT_OPERATOR
Definition: demangle.h:393
@ DEMANGLE_COMPONENT_TYPEINFO_NAME
Definition: demangle.h:286
@ DEMANGLE_COMPONENT_VTT
Definition: demangle.h:276
@ DEMANGLE_COMPONENT_GLOBAL_CONSTRUCTORS
Definition: demangle.h:447
@ DEMANGLE_COMPONENT_JAVA_RESOURCE
Definition: demangle.h:436
@ DEMANGLE_COMPONENT_VTABLE
Definition: demangle.h:273
@ DEMANGLE_COMPONENT_TYPEINFO
Definition: demangle.h:283
@ DEMANGLE_COMPONENT_FUNCTION_PARAM
Definition: demangle.h:265
@ DEMANGLE_COMPONENT_BINARY
Definition: demangle.h:411
int type
Definition: mipsasm.c:17
struct demangle_component::@376::@381 s_ctor
struct demangle_component::@376::@382 s_dtor
struct demangle_component::@376::@379 s_extended_operator
struct demangle_component::@376::@388 s_unary_num

References d_left, d_right, DEMANGLE_COMPONENT_ARGLIST, DEMANGLE_COMPONENT_ARRAY_TYPE, DEMANGLE_COMPONENT_BINARY, DEMANGLE_COMPONENT_BINARY_ARGS, DEMANGLE_COMPONENT_BUILTIN_TYPE, DEMANGLE_COMPONENT_CAST, DEMANGLE_COMPONENT_CHARACTER, DEMANGLE_COMPONENT_CLONE, DEMANGLE_COMPONENT_COMPLEX, DEMANGLE_COMPONENT_COMPOUND_NAME, DEMANGLE_COMPONENT_CONST, DEMANGLE_COMPONENT_CONST_THIS, DEMANGLE_COMPONENT_CONSTRUCTION_VTABLE, DEMANGLE_COMPONENT_CONVERSION, DEMANGLE_COMPONENT_COVARIANT_THUNK, DEMANGLE_COMPONENT_CTOR, DEMANGLE_COMPONENT_DECLTYPE, DEMANGLE_COMPONENT_DEFAULT_ARG, DEMANGLE_COMPONENT_DTOR, DEMANGLE_COMPONENT_EXTENDED_OPERATOR, DEMANGLE_COMPONENT_FIXED_TYPE, DEMANGLE_COMPONENT_FUNCTION_PARAM, DEMANGLE_COMPONENT_FUNCTION_TYPE, DEMANGLE_COMPONENT_GLOBAL_CONSTRUCTORS, DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS, DEMANGLE_COMPONENT_GUARD, DEMANGLE_COMPONENT_HIDDEN_ALIAS, DEMANGLE_COMPONENT_IMAGINARY, DEMANGLE_COMPONENT_INITIALIZER_LIST, DEMANGLE_COMPONENT_JAVA_CLASS, DEMANGLE_COMPONENT_JAVA_RESOURCE, DEMANGLE_COMPONENT_LAMBDA, DEMANGLE_COMPONENT_LITERAL, DEMANGLE_COMPONENT_LITERAL_NEG, DEMANGLE_COMPONENT_LOCAL_NAME, DEMANGLE_COMPONENT_NAME, DEMANGLE_COMPONENT_NOEXCEPT, DEMANGLE_COMPONENT_NONTRANSACTION_CLONE, DEMANGLE_COMPONENT_NULLARY, DEMANGLE_COMPONENT_NUMBER, DEMANGLE_COMPONENT_OPERATOR, DEMANGLE_COMPONENT_PACK_EXPANSION, DEMANGLE_COMPONENT_POINTER, DEMANGLE_COMPONENT_PTRMEM_TYPE, DEMANGLE_COMPONENT_QUAL_NAME, DEMANGLE_COMPONENT_REFERENCE, DEMANGLE_COMPONENT_REFERENCE_THIS, DEMANGLE_COMPONENT_REFTEMP, DEMANGLE_COMPONENT_RESTRICT, DEMANGLE_COMPONENT_RESTRICT_THIS, DEMANGLE_COMPONENT_RVALUE_REFERENCE, DEMANGLE_COMPONENT_RVALUE_REFERENCE_THIS, DEMANGLE_COMPONENT_SUB_STD, DEMANGLE_COMPONENT_TAGGED_NAME, DEMANGLE_COMPONENT_TEMPLATE, DEMANGLE_COMPONENT_TEMPLATE_ARGLIST, DEMANGLE_COMPONENT_TEMPLATE_PARAM, DEMANGLE_COMPONENT_THROW_SPEC, DEMANGLE_COMPONENT_THUNK, DEMANGLE_COMPONENT_TLS_INIT, DEMANGLE_COMPONENT_TLS_WRAPPER, DEMANGLE_COMPONENT_TPARM_OBJ, DEMANGLE_COMPONENT_TRANSACTION_CLONE, DEMANGLE_COMPONENT_TRANSACTION_SAFE, DEMANGLE_COMPONENT_TRINARY, DEMANGLE_COMPONENT_TRINARY_ARG1, DEMANGLE_COMPONENT_TRINARY_ARG2, DEMANGLE_COMPONENT_TYPED_NAME, DEMANGLE_COMPONENT_TYPEINFO, DEMANGLE_COMPONENT_TYPEINFO_FN, DEMANGLE_COMPONENT_TYPEINFO_NAME, DEMANGLE_COMPONENT_UNARY, DEMANGLE_COMPONENT_UNNAMED_TYPE, DEMANGLE_COMPONENT_VECTOR_TYPE, DEMANGLE_COMPONENT_VENDOR_TYPE, DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL, DEMANGLE_COMPONENT_VIRTUAL_THUNK, DEMANGLE_COMPONENT_VOLATILE, DEMANGLE_COMPONENT_VOLATILE_THIS, DEMANGLE_COMPONENT_VTABLE, DEMANGLE_COMPONENT_VTT, NULL, demangle_component::s_ctor, demangle_component::s_dtor, demangle_component::s_extended_operator, demangle_component::s_fixed, demangle_component::s_unary_num, type, demangle_component::type, and demangle_component::u.

Referenced by d_print_init().

◆ d_ctor_dtor_name()

static struct demangle_component * d_ctor_dtor_name ( struct d_info di)
static

Definition at line 2059 of file cp-demangle.c.

2059  {
2060  if (di->last_name != NULL) {
2062  di->expansion += di->last_name->u.s_name.len;
2063  else if (di->last_name->type == DEMANGLE_COMPONENT_SUB_STD)
2064  di->expansion += di->last_name->u.s_string.len;
2065  }
2066  switch (d_peek_char(di)) {
2067  case 'C': {
2068  enum gnu_v3_ctor_kinds kind;
2069  int inheriting = 0;
2070 
2071  if (d_peek_next_char(di) == 'I') {
2072  inheriting = 1;
2073  d_advance(di, 1);
2074  }
2075 
2076  switch (d_peek_next_char(di)) {
2077  case '1':
2079  break;
2080  case '2':
2081  kind = gnu_v3_base_object_ctor;
2082  break;
2083  case '3':
2085  break;
2086  case '4':
2087  kind = gnu_v3_unified_ctor;
2088  break;
2089  case '5':
2090  kind = gnu_v3_object_ctor_group;
2091  break;
2092  default:
2093  return NULL;
2094  }
2095 
2096  d_advance(di, 2);
2097 
2098  if (inheriting)
2099  cplus_demangle_type(di);
2100 
2101  return d_make_ctor(di, kind, di->last_name);
2102  }
2103 
2104  case 'D': {
2105  enum gnu_v3_dtor_kinds kind;
2106 
2107  switch (d_peek_next_char(di)) {
2108  case '0':
2109  kind = gnu_v3_deleting_dtor;
2110  break;
2111  case '1':
2113  break;
2114  case '2':
2115  kind = gnu_v3_base_object_dtor;
2116  break;
2117  /* digit '3' is not used */
2118  case '4':
2119  kind = gnu_v3_unified_dtor;
2120  break;
2121  case '5':
2122  kind = gnu_v3_object_dtor_group;
2123  break;
2124  default:
2125  return NULL;
2126  }
2127  d_advance(di, 2);
2128  return d_make_dtor(di, kind, di->last_name);
2129  }
2130 
2131  default:
2132  return NULL;
2133  }
2134 }
static struct demangle_component * d_make_ctor(struct d_info *, enum gnu_v3_ctor_kinds, struct demangle_component *)
Definition: cp-demangle.c:1098
static struct demangle_component * d_make_dtor(struct d_info *, enum gnu_v3_dtor_kinds, struct demangle_component *)
Definition: cp-demangle.c:1111
gnu_v3_ctor_kinds
Definition: demangle.h:195
@ gnu_v3_complete_object_allocating_ctor
Definition: demangle.h:198
@ gnu_v3_unified_ctor
Definition: demangle.h:202
@ gnu_v3_base_object_ctor
Definition: demangle.h:197
gnu_v3_dtor_kinds
Definition: demangle.h:213
@ gnu_v3_unified_dtor
Definition: demangle.h:220
@ gnu_v3_base_object_dtor
Definition: demangle.h:216
@ gnu_v3_complete_object_dtor
Definition: demangle.h:215
struct demangle_component::@376::@384 s_string
struct demangle_component::@376::@377 s_name

References cplus_demangle_type(), d_advance, d_make_ctor(), d_make_dtor(), d_peek_char, d_peek_next_char, DEMANGLE_COMPONENT_NAME, DEMANGLE_COMPONENT_SUB_STD, d_info::expansion, gnu_v3_base_object_ctor, gnu_v3_base_object_dtor, gnu_v3_complete_object_allocating_ctor, gnu_v3_complete_object_ctor, gnu_v3_complete_object_dtor, gnu_v3_deleting_dtor, gnu_v3_object_ctor_group, gnu_v3_object_dtor_group, gnu_v3_unified_ctor, gnu_v3_unified_dtor, demangle_component::kind, d_info::last_name, NULL, demangle_component::s_name, demangle_component::s_string, demangle_component::type, and demangle_component::u.

Referenced by d_unqualified_name().

◆ d_cv_qualifiers()

static struct demangle_component ** d_cv_qualifiers ( struct d_info di,
struct demangle_component **  pret,
int  member_fn 
)
static

Definition at line 2557 of file cp-demangle.c.

2558  {
2559  struct demangle_component **pstart;
2560  char peek;
2561 
2562  pstart = pret;
2563  peek = d_peek_char(di);
2564  while (next_is_type_qual(di)) {
2565  enum demangle_component_type t;
2566  struct demangle_component *right = NULL;
2567 
2568  d_advance(di, 1);
2569  if (peek == 'r') {
2570  t = (member_fn
2573  di->expansion += sizeof "restrict";
2574  } else if (peek == 'V') {
2575  t = (member_fn
2578  di->expansion += sizeof "volatile";
2579  } else if (peek == 'K') {
2580  t = (member_fn
2583  di->expansion += sizeof "const";
2584  } else {
2585  peek = d_next_char(di);
2586  if (peek == 'x') {
2588  di->expansion += sizeof "transaction_safe";
2589  } else if (peek == 'o' || peek == 'O') {
2591  di->expansion += sizeof "noexcept";
2592  if (peek == 'O') {
2593  right = d_expression(di);
2594  if (right == NULL)
2595  return NULL;
2596  if (!d_check_char(di, 'E'))
2597  return NULL;
2598  }
2599  } else if (peek == 'w') {
2601  di->expansion += sizeof "throw";
2602  right = d_parmlist(di);
2603  if (right == NULL)
2604  return NULL;
2605  if (!d_check_char(di, 'E'))
2606  return NULL;
2607  } else
2608  return NULL;
2609  }
2610 
2611  *pret = d_make_comp(di, t, NULL, right);
2612  if (*pret == NULL)
2613  return NULL;
2614  pret = &d_left(*pret);
2615 
2616  peek = d_peek_char(di);
2617  }
2618 
2619  if (!member_fn && peek == 'F') {
2620  while (pstart != pret) {
2621  switch ((*pstart)->type) {
2623  (*pstart)->type = DEMANGLE_COMPONENT_RESTRICT_THIS;
2624  break;
2626  (*pstart)->type = DEMANGLE_COMPONENT_VOLATILE_THIS;
2627  break;
2629  (*pstart)->type = DEMANGLE_COMPONENT_CONST_THIS;
2630  break;
2631  default:
2632  break;
2633  }
2634  pstart = &d_left(*pstart);
2635  }
2636  }
2637 
2638  return pret;
2639 }
demangle_component_type
Definition: demangle.h:245
struct demangle_component * right
Definition: demangle.h:584

References d_advance, d_check_char, d_expression(), d_left, d_make_comp(), d_next_char, d_parmlist(), d_peek_char, DEMANGLE_COMPONENT_CONST, DEMANGLE_COMPONENT_CONST_THIS, DEMANGLE_COMPONENT_NOEXCEPT, DEMANGLE_COMPONENT_RESTRICT, DEMANGLE_COMPONENT_RESTRICT_THIS, DEMANGLE_COMPONENT_THROW_SPEC, DEMANGLE_COMPONENT_TRANSACTION_SAFE, DEMANGLE_COMPONENT_VOLATILE, DEMANGLE_COMPONENT_VOLATILE_THIS, d_info::expansion, next_is_type_qual(), NULL, and demangle_component::right.

Referenced by cplus_demangle_type(), and d_nested_name().

◆ d_demangle()

static char * d_demangle ( const char *  mangled,
int  options,
size_t palc 
)
static

Definition at line 5798 of file cp-demangle.c.

5798  {
5799  struct d_growable_string dgs;
5800  int status;
5801 
5802  d_growable_string_init(&dgs, 0);
5803 
5804  status = d_demangle_callback(mangled, options,
5806  if (status == 0) {
5807  free(dgs.buf);
5808  *palc = 0;
5809  return NULL;
5810  }
5811 
5812  *palc = dgs.allocation_failure ? 1 : dgs.alc;
5813  return dgs.buf;
5814 }
static const char struct stat static buf struct stat static buf static vhangup int status
Definition: sflib.h:145

References d_growable_string::alc, d_growable_string::allocation_failure, d_growable_string::buf, d_demangle_callback(), d_growable_string_callback_adapter(), d_growable_string_init(), free(), NULL, options, and status.

Referenced by cplus_demangle_v3(), and java_demangle_v3().

◆ d_demangle_callback()

static int d_demangle_callback ( const char *  mangled,
int  options,
demangle_callbackref  callback,
void *  opaque 
)
static

Definition at line 5713 of file cp-demangle.c.

5714  {
5715  enum {
5716  DCT_TYPE,
5717  DCT_MANGLED,
5718  DCT_GLOBAL_CTORS,
5719  DCT_GLOBAL_DTORS
5720  } type;
5721  struct d_info di;
5722  struct demangle_component *dc;
5723  int status;
5724 
5725  if (mangled[0] == '_' && mangled[1] == 'Z')
5726  type = DCT_MANGLED;
5727  else if (strncmp(mangled, "_GLOBAL_", 8) == 0 && (mangled[8] == '.' || mangled[8] == '_' || mangled[8] == '$') && (mangled[9] == 'D' || mangled[9] == 'I') && mangled[10] == '_')
5728  type = mangled[9] == 'I' ? DCT_GLOBAL_CTORS : DCT_GLOBAL_DTORS;
5729  else {
5730  if ((options & DMGL_TYPES) == 0)
5731  return 0;
5732  type = DCT_TYPE;
5733  }
5734 
5735  cplus_demangle_init_info(mangled, options, strlen(mangled), &di);
5736 
5737  {
5738 #ifdef CP_DYNAMIC_ARRAYS
5739  __extension__ struct demangle_component comps[di.num_comps];
5740  __extension__ struct demangle_component *subs[di.num_subs];
5741 
5742  di.comps = comps;
5743  di.subs = subs;
5744 #else
5745  di.comps = alloca(di.num_comps * sizeof(*di.comps));
5746  di.subs = alloca(di.num_subs * sizeof(*di.subs));
5747 #endif
5748 
5749  switch (type) {
5750  case DCT_TYPE:
5751  dc = cplus_demangle_type(&di);
5752  break;
5753  case DCT_MANGLED:
5754  dc = cplus_demangle_mangled_name(&di, 1);
5755  break;
5756  case DCT_GLOBAL_CTORS:
5757  case DCT_GLOBAL_DTORS:
5758  d_advance(&di, 11);
5759  dc = d_make_comp(&di,
5760  (type == DCT_GLOBAL_CTORS
5764  NULL);
5765  d_advance(&di, strlen(d_str(&di)));
5766  break;
5767  default:
5768  abort(); /* We have listed all the cases. */
5769  }
5770 
5771  /* If DMGL_PARAMS is set, then if we didn't consume the entire
5772  mangled string, then we didn't successfully demangle it. If
5773  DMGL_PARAMS is not set, we didn't look at the trailing
5774  parameters. */
5775  if (((options & DMGL_PARAMS) != 0) && d_peek_char(&di) != '\0')
5776  dc = NULL;
5777 
5778 #ifdef CP_DEMANGLE_DEBUG
5779  d_dump(dc, 0);
5780 #endif
5781 
5782  status = (dc != NULL)
5783  ? cplus_demangle_print_callback(options, dc, callback, opaque)
5784  : 0;
5785  }
5786 
5787  return status;
5788 }
CP_STATIC_IF_GLIBCPP_V3 struct demangle_component * cplus_demangle_mangled_name(struct d_info *di, int top_level)
Definition: cp-demangle.c:1170
static struct demangle_component * d_make_demangle_mangled_name(struct d_info *, const char *)
Definition: cp-demangle.c:1020
CP_STATIC_IF_GLIBCPP_V3 void cplus_demangle_init_info(const char *mangled, int options, size_t len, struct d_info *di)
Definition: cp-demangle.c:5681
#define DMGL_TYPES
Definition: demangle.h:47

References __extension__, alloca(), cplus_demangle_init_info(), cplus_demangle_mangled_name(), cplus_demangle_print_callback(), cplus_demangle_type(), d_advance, d_make_comp(), d_make_demangle_mangled_name(), d_peek_char, d_str, DEMANGLE_COMPONENT_GLOBAL_CONSTRUCTORS, DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS, DMGL_PARAMS, DMGL_TYPES, NULL, options, status, and type.

Referenced by cplus_demangle_v3_callback(), d_demangle(), and java_demangle_v3_callback().

◆ d_discriminator()

static int d_discriminator ( struct d_info di)
static

Definition at line 3387 of file cp-demangle.c.

3387  {
3388  int discrim, num_underscores = 1;
3389 
3390  if (d_peek_char(di) != '_')
3391  return 1;
3392  d_advance(di, 1);
3393  if (d_peek_char(di) == '_') {
3394  ++num_underscores;
3395  d_advance(di, 1);
3396  }
3397 
3398  discrim = d_number(di);
3399  if (discrim < 0)
3400  return 0;
3401  if (num_underscores > 1 && discrim >= 10) {
3402  if (d_peek_char(di) == '_')
3403  d_advance(di, 1);
3404  else
3405  return 0;
3406  }
3407 
3408  return 1;
3409 }

References d_advance, d_number(), and d_peek_char.

Referenced by d_local_name(), and d_unqualified_name().

◆ d_encoding()

static struct demangle_component * d_encoding ( struct d_info di,
int  top_level 
)
static

Definition at line 1247 of file cp-demangle.c.

1247  {
1248  char peek = d_peek_char(di);
1249  struct demangle_component *dc;
1250 
1251  if (peek == 'G' || peek == 'T')
1252  dc = d_special_name(di);
1253  else {
1254  dc = d_name(di);
1255 
1256  if (!dc)
1257  /* Failed already. */;
1258  else if (top_level && (di->options & DMGL_PARAMS) == 0) {
1259  /* Strip off any initial CV-qualifiers, as they really apply
1260  to the `this' parameter, and they were not output by the
1261  v2 demangler without DMGL_PARAMS. */
1262  while (is_fnqual_component_type(dc->type))
1263  dc = d_left(dc);
1264 
1265  /* If the top level is a DEMANGLE_COMPONENT_LOCAL_NAME, then
1266  there may be function-qualifiers on its right argument which
1267  really apply here; this happens when parsing a class
1268  which is local to a function. */
1270  while (is_fnqual_component_type(d_right(dc)->type))
1271  d_right(dc) = d_left(d_right(dc));
1272  } else {
1273  peek = d_peek_char(di);
1274  if (peek != '\0' && peek != 'E') {
1275  struct demangle_component *ftype;
1276 
1277  ftype = d_bare_function_type(di, has_return_type(dc));
1278  if (ftype) {
1279  /* If this is a non-top-level local-name, clear the
1280  return type, so it doesn't confuse the user by
1281  being confused with the return type of whaever
1282  this is nested within. */
1283  if (!top_level && dc->type == DEMANGLE_COMPONENT_LOCAL_NAME && ftype->type == DEMANGLE_COMPONENT_FUNCTION_TYPE)
1284  d_left(ftype) = NULL;
1285 
1287  dc, ftype);
1288  } else
1289  dc = NULL;
1290  }
1291  }
1292  }
1293 
1294  return dc;
1295 }
static int is_fnqual_component_type(enum demangle_component_type type)
Definition: cp-demangle.c:574
static struct demangle_component * d_special_name(struct d_info *)
Definition: cp-demangle.c:1894
static struct demangle_component * d_bare_function_type(struct d_info *, int)
Definition: cp-demangle.c:2733

References d_bare_function_type(), d_left, d_make_comp(), d_name(), d_peek_char, d_right, d_special_name(), DEMANGLE_COMPONENT_FUNCTION_TYPE, DEMANGLE_COMPONENT_LOCAL_NAME, DEMANGLE_COMPONENT_TYPED_NAME, DMGL_PARAMS, has_return_type(), is_fnqual_component_type(), NULL, d_info::options, type, and demangle_component::type.

Referenced by cplus_demangle_mangled_name(), d_local_name(), d_make_demangle_mangled_name(), and d_special_name().

◆ d_expr_primary()

static struct demangle_component * d_expr_primary ( struct d_info di)
static

Definition at line 3265 of file cp-demangle.c.

3265  {
3266  struct demangle_component *ret;
3267 
3268  if (!d_check_char(di, 'L'))
3269  return NULL;
3270  if (d_peek_char(di) == '_'
3271  /* Workaround for G++ bug; see comment in write_template_arg. */
3272  || d_peek_char(di) == 'Z')
3273  ret = cplus_demangle_mangled_name(di, 0);
3274  else {
3275  struct demangle_component *type;
3276  enum demangle_component_type t;
3277  const char *s;
3278 
3279  type = cplus_demangle_type(di);
3280  if (type == NULL)
3281  return NULL;
3282 
3283  /* If we have a type we know how to print, we aren't going to
3284  print the type name itself. */
3285  if (type->type == DEMANGLE_COMPONENT_BUILTIN_TYPE && type->u.s_builtin.type->print != D_PRINT_DEFAULT)
3286  di->expansion -= type->u.s_builtin.type->len;
3287 
3288  /* Rather than try to interpret the literal value, we just
3289  collect it as a string. Note that it's possible to have a
3290  floating point literal here. The ABI specifies that the
3291  format of such literals is machine independent. That's fine,
3292  but what's not fine is that versions of g++ up to 3.2 with
3293  -fabi-version=1 used upper case letters in the hex constant,
3294  and dumped out gcc's internal representation. That makes it
3295  hard to tell where the constant ends, and hard to dump the
3296  constant in any readable form anyhow. We don't attempt to
3297  handle these cases. */
3298 
3300  if (d_peek_char(di) == 'n') {
3302  d_advance(di, 1);
3303  }
3304  s = d_str(di);
3305  while (d_peek_char(di) != 'E') {
3306  if (d_peek_char(di) == '\0')
3307  return NULL;
3308  d_advance(di, 1);
3309  }
3310  ret = d_make_comp(di, t, type, d_make_name(di, s, d_str(di) - s));
3311  }
3312  if (!d_check_char(di, 'E'))
3313  return NULL;
3314  return ret;
3315 }
@ D_PRINT_DEFAULT
Definition: cp-demangle.h:54

References cplus_demangle_mangled_name(), cplus_demangle_type(), d_advance, d_check_char, d_make_comp(), d_make_name(), d_peek_char, D_PRINT_DEFAULT, d_str, DEMANGLE_COMPONENT_BUILTIN_TYPE, DEMANGLE_COMPONENT_LITERAL, DEMANGLE_COMPONENT_LITERAL_NEG, d_info::expansion, NULL, s, and type.

Referenced by d_expression_1(), and d_template_arg().

◆ d_expression()

static struct demangle_component * d_expression ( struct d_info di)
static

Definition at line 3249 of file cp-demangle.c.

3249  {
3250  struct demangle_component *ret;
3251  int was_expression = di->is_expression;
3252 
3253  di->is_expression = 1;
3254  ret = d_expression_1(di);
3255  di->is_expression = was_expression;
3256  return ret;
3257 }
static struct demangle_component * d_expression_1(struct d_info *di)
Definition: cp-demangle.c:3041

References d_expression_1(), and d_info::is_expression.

Referenced by cplus_demangle_type(), d_array_type(), d_cv_qualifiers(), d_exprlist(), d_template_arg(), and d_vector_type().

◆ d_expression_1()

static struct demangle_component* d_expression_1 ( struct d_info di)
inlinestatic

Definition at line 3041 of file cp-demangle.c.

3041  {
3042  char peek;
3043 
3044  peek = d_peek_char(di);
3045  if (peek == 'L')
3046  return d_expr_primary(di);
3047  else if (peek == 'T')
3048  return d_template_param(di);
3049  else if (peek == 's' && d_peek_next_char(di) == 'r') {
3050  struct demangle_component *type;
3051  struct demangle_component *name;
3052 
3053  d_advance(di, 2);
3054  type = cplus_demangle_type(di);
3055  name = d_unqualified_name(di);
3056  if (d_peek_char(di) != 'I')
3058  else
3061  d_template_args(di)));
3062  } else if (peek == 's' && d_peek_next_char(di) == 'p') {
3063  d_advance(di, 2);
3065  d_expression_1(di), NULL);
3066  } else if (peek == 'f' && d_peek_next_char(di) == 'p') {
3067  /* Function parameter used in a late-specified return type. */
3068  int index;
3069  d_advance(di, 2);
3070  if (d_peek_char(di) == 'T') {
3071  /* 'this' parameter. */
3072  d_advance(di, 1);
3073  index = 0;
3074  } else {
3075  index = d_compact_number(di);
3076  if (index == INT_MAX || index == -1)
3077  return NULL;
3078  index++;
3079  }
3080  return d_make_function_param(di, index);
3081  } else if (IS_DIGIT(peek) || (peek == 'o' && d_peek_next_char(di) == 'n')) {
3082  /* We can get an unqualified name as an expression in the case of
3083  a dependent function call, i.e. decltype(f(t)). */
3084  struct demangle_component *name;
3085 
3086  if (peek == 'o')
3087  /* operator-function-id, i.e. operator+(t). */
3088  d_advance(di, 2);
3089 
3090  name = d_unqualified_name(di);
3091  if (name == NULL)
3092  return NULL;
3093  if (d_peek_char(di) == 'I')
3095  d_template_args(di));
3096  else
3097  return name;
3098  } else if ((peek == 'i' || peek == 't') && d_peek_next_char(di) == 'l') {
3099  /* Brace-enclosed initializer list, untyped or typed. */
3100  struct demangle_component *type = NULL;
3101  d_advance(di, 2);
3102  if (peek == 't')
3103  type = cplus_demangle_type(di);
3104  if (!d_peek_next_char(di))
3105  return NULL;
3107  type, d_exprlist(di, 'E'));
3108  } else {
3109  struct demangle_component *op;
3110  const char *code = NULL;
3111  int args;
3112 
3113  op = d_operator_name(di);
3114  if (op == NULL)
3115  return NULL;
3116 
3117  if (op->type == DEMANGLE_COMPONENT_OPERATOR) {
3118  code = op->u.s_operator.op->code;
3119  di->expansion += op->u.s_operator.op->len - 2;
3120  if (strcmp(code, "st") == 0)
3122  cplus_demangle_type(di));
3123  }
3124 
3125  switch (op->type) {
3126  default:
3127  return NULL;
3129  args = op->u.s_operator.op->args;
3130  break;
3132  args = op->u.s_extended_operator.args;
3133  break;
3135  args = 1;
3136  break;
3137  }
3138 
3139  switch (args) {
3140  case 0:
3142 
3143  case 1: {
3144  struct demangle_component *operand;
3145  int suffix = 0;
3146 
3147  if (code && (code[0] == 'p' || code[0] == 'm') && code[1] == code[0])
3148  /* pp_ and mm_ are the prefix variants. */
3149  suffix = !d_check_char(di, '_');
3150 
3151  if (op->type == DEMANGLE_COMPONENT_CAST && d_check_char(di, '_'))
3152  operand = d_exprlist(di, 'E');
3153  else if (code && !strcmp(code, "sP"))
3154  operand = d_template_args_1(di);
3155  else
3156  operand = d_expression_1(di);
3157 
3158  if (suffix)
3159  /* Indicate the suffix variant for d_print_comp. */
3161  operand, operand);
3162 
3164  }
3165  case 2: {
3166  struct demangle_component *left;
3167  struct demangle_component *right;
3168 
3169  if (code == NULL)
3170  return NULL;
3171  if (op_is_new_cast(op))
3172  left = cplus_demangle_type(di);
3173  else if (code[0] == 'f')
3174  /* fold-expression. */
3175  left = d_operator_name(di);
3176  else
3177  left = d_expression_1(di);
3178  if (!strcmp(code, "cl"))
3179  right = d_exprlist(di, 'E');
3180  else if (!strcmp(code, "dt") || !strcmp(code, "pt")) {
3181  right = d_unqualified_name(di);
3182  if (d_peek_char(di) == 'I')
3184  right, d_template_args(di));
3185  } else
3186  right = d_expression_1(di);
3187 
3189  d_make_comp(di,
3191  left, right));
3192  }
3193  case 3: {
3194  struct demangle_component *first;
3195  struct demangle_component *second;
3196  struct demangle_component *third;
3197 
3198  if (code == NULL)
3199  return NULL;
3200  else if (!strcmp(code, "qu")) {
3201  /* ?: expression. */
3202  first = d_expression_1(di);
3203  second = d_expression_1(di);
3204  third = d_expression_1(di);
3205  if (third == NULL)
3206  return NULL;
3207  } else if (code[0] == 'f') {
3208  /* fold-expression. */
3209  first = d_operator_name(di);
3210  second = d_expression_1(di);
3211  third = d_expression_1(di);
3212  if (third == NULL)
3213  return NULL;
3214  } else if (code[0] == 'n') {
3215  /* new-expression. */
3216  if (code[1] != 'w' && code[1] != 'a')
3217  return NULL;
3218  first = d_exprlist(di, '_');
3219  second = cplus_demangle_type(di);
3220  if (d_peek_char(di) == 'E') {
3221  d_advance(di, 1);
3222  third = NULL;
3223  } else if (d_peek_char(di) == 'p' && d_peek_next_char(di) == 'i') {
3224  /* Parenthesized initializer. */
3225  d_advance(di, 2);
3226  third = d_exprlist(di, 'E');
3227  } else if (d_peek_char(di) == 'i' && d_peek_next_char(di) == 'l')
3228  /* initializer-list. */
3229  third = d_expression_1(di);
3230  else
3231  return NULL;
3232  } else
3233  return NULL;
3235  d_make_comp(di,
3237  first,
3238  d_make_comp(di,
3240  second, third)));
3241  }
3242  default:
3243  return NULL;
3244  }
3245  }
3246 }
ut8 op
Definition: 6502dis.c:13
operand
Definition: arc-opc.c:39
static int d_compact_number(struct d_info *di)
Definition: cp-demangle.c:2871
static int op_is_new_cast(struct demangle_component *op)
Definition: cp-demangle.c:3024
static struct demangle_component * d_unqualified_name(struct d_info *)
Definition: cp-demangle.c:1517
static struct demangle_component * d_operator_name(struct d_info *)
Definition: cp-demangle.c:1738
#define INT_MAX
Definition: cp-demangle.c:131
static struct demangle_component * d_make_function_param(struct d_info *di, int i)
Definition: cp-demangle.c:1138
static struct demangle_component * d_exprlist(struct d_info *di, char terminator)
Definition: cp-demangle.c:2992
static struct demangle_component * d_expr_primary(struct d_info *)
Definition: cp-demangle.c:3265
static struct demangle_component * d_template_args_1(struct d_info *)
Definition: cp-demangle.c:2917
Definition: inftree9.h:24
struct demangle_component * left
Definition: demangle.h:582
Definition: dis.c:32
struct op_code code
Definition: dis.c:33

References args, op::code, cplus_demangle_type(), d_advance, d_check_char, d_compact_number(), d_expr_primary(), d_exprlist(), d_make_comp(), d_make_function_param(), d_operator_name(), d_peek_char, d_peek_next_char, d_template_args(), d_template_args_1(), d_template_param(), d_unqualified_name(), DEMANGLE_COMPONENT_BINARY, DEMANGLE_COMPONENT_BINARY_ARGS, DEMANGLE_COMPONENT_CAST, DEMANGLE_COMPONENT_EXTENDED_OPERATOR, DEMANGLE_COMPONENT_INITIALIZER_LIST, DEMANGLE_COMPONENT_NULLARY, DEMANGLE_COMPONENT_OPERATOR, DEMANGLE_COMPONENT_PACK_EXPANSION, DEMANGLE_COMPONENT_QUAL_NAME, DEMANGLE_COMPONENT_TEMPLATE, DEMANGLE_COMPONENT_TRINARY, DEMANGLE_COMPONENT_TRINARY_ARG1, DEMANGLE_COMPONENT_TRINARY_ARG2, DEMANGLE_COMPONENT_UNARY, d_info::expansion, INT_MAX, IS_DIGIT, demangle_component::left, name, NULL, op, op_is_new_cast(), demangle_component::right, suffix, and type.

Referenced by d_expression().

◆ d_exprlist()

static struct demangle_component* d_exprlist ( struct d_info di,
char  terminator 
)
static

Definition at line 2992 of file cp-demangle.c.

2992  {
2993  struct demangle_component *list = NULL;
2994  struct demangle_component **p = &list;
2995 
2996  if (d_peek_char(di) == terminator) {
2997  d_advance(di, 1);
2999  }
3000 
3001  while (1) {
3002  struct demangle_component *arg = d_expression(di);
3003  if (arg == NULL)
3004  return NULL;
3005 
3007  if (*p == NULL)
3008  return NULL;
3009  p = &d_right(*p);
3010 
3011  if (d_peek_char(di) == terminator) {
3012  d_advance(di, 1);
3013  break;
3014  }
3015  }
3016 
3017  return list;
3018 }
static void list(RzEgg *egg)
Definition: rz-gg.c:52

References d_advance, d_expression(), d_make_comp(), d_peek_char, d_right, DEMANGLE_COMPONENT_ARGLIST, list(), NULL, and p.

Referenced by d_expression_1().

◆ d_find_pack()

static struct demangle_component* d_find_pack ( struct d_print_info dpi,
const struct demangle_component dc 
)
static

Definition at line 4072 of file cp-demangle.c.

4073  {
4074  struct demangle_component *a;
4075  if (dc == NULL)
4076  return NULL;
4077 
4078  switch (dc->type) {
4080  a = d_lookup_template_argument(dpi, dc);
4081  if (a && a->type == DEMANGLE_COMPONENT_TEMPLATE_ARGLIST)
4082  return a;
4083  return NULL;
4084 
4086  return NULL;
4087 
4100  return NULL;
4101 
4103  return d_find_pack(dpi, dc->u.s_extended_operator.name);
4105  return d_find_pack(dpi, dc->u.s_ctor.name);
4107  return d_find_pack(dpi, dc->u.s_dtor.name);
4108 
4109  default:
4110  a = d_find_pack(dpi, d_left(dc));
4111  if (a)
4112  return a;
4113  return d_find_pack(dpi, d_right(dc));
4114  }
4115 }
static struct demangle_component * d_lookup_template_argument(struct d_print_info *dpi, const struct demangle_component *dc)
Definition: cp-demangle.c:4058

References a, d_left, d_lookup_template_argument(), d_right, DEMANGLE_COMPONENT_BUILTIN_TYPE, DEMANGLE_COMPONENT_CHARACTER, DEMANGLE_COMPONENT_CTOR, DEMANGLE_COMPONENT_DEFAULT_ARG, DEMANGLE_COMPONENT_DTOR, DEMANGLE_COMPONENT_EXTENDED_OPERATOR, DEMANGLE_COMPONENT_FIXED_TYPE, DEMANGLE_COMPONENT_FUNCTION_PARAM, DEMANGLE_COMPONENT_LAMBDA, DEMANGLE_COMPONENT_NAME, DEMANGLE_COMPONENT_NUMBER, DEMANGLE_COMPONENT_OPERATOR, DEMANGLE_COMPONENT_PACK_EXPANSION, DEMANGLE_COMPONENT_SUB_STD, DEMANGLE_COMPONENT_TAGGED_NAME, DEMANGLE_COMPONENT_TEMPLATE_ARGLIST, DEMANGLE_COMPONENT_TEMPLATE_PARAM, DEMANGLE_COMPONENT_UNNAMED_TYPE, NULL, demangle_component::s_ctor, demangle_component::s_dtor, demangle_component::s_extended_operator, demangle_component::type, and demangle_component::u.

Referenced by d_args_length(), and d_print_comp_inner().

◆ d_function_type()

static struct demangle_component * d_function_type ( struct d_info di)
static

Definition at line 2670 of file cp-demangle.c.

2670  {
2671  struct demangle_component *ret;
2672 
2673  if (!d_check_char(di, 'F'))
2674  return NULL;
2675  if (d_peek_char(di) == 'Y') {
2676  /* Function has C linkage. We don't print this information.
2677  FIXME: We should print it in verbose mode. */
2678  d_advance(di, 1);
2679  }
2680  ret = d_bare_function_type(di, 1);
2681  ret = d_ref_qualifier(di, ret);
2682 
2683  if (!d_check_char(di, 'E'))
2684  return NULL;
2685  return ret;
2686 }
static struct demangle_component * d_ref_qualifier(struct d_info *, struct demangle_component *)
Definition: cp-demangle.c:2645

References d_advance, d_bare_function_type(), d_check_char, d_peek_char, d_ref_qualifier(), and NULL.

Referenced by cplus_demangle_type().

◆ d_get_saved_scope()

static struct d_saved_scope* d_get_saved_scope ( struct d_print_info dpi,
const struct demangle_component container 
)
static

Definition at line 4205 of file cp-demangle.c.

4206  {
4207  int i;
4208 
4209  for (i = 0; i < dpi->next_saved_scope; i++)
4210  if (dpi->saved_scopes[i].container == container)
4211  return &dpi->saved_scopes[i];
4212 
4213  return NULL;
4214 }
struct d_saved_scope * saved_scopes
Definition: cp-demangle.c:350
int next_saved_scope
Definition: cp-demangle.c:352
const struct demangle_component * container
Definition: cp-demangle.c:295

References d_saved_scope::container, i, d_print_info::next_saved_scope, NULL, and d_print_info::saved_scopes.

Referenced by d_print_comp_inner().

◆ d_growable_string_append_buffer()

static void d_growable_string_append_buffer ( struct d_growable_string dgs,
const char *  s,
size_t  l 
)
inlinestatic

Definition at line 3701 of file cp-demangle.c.

3702  {
3703  size_t need;
3704 
3705  need = dgs->len + l + 1;
3706  if (need > dgs->alc)
3707  d_growable_string_resize(dgs, need);
3708 
3709  if (dgs->allocation_failure)
3710  return;
3711 
3712  memcpy(dgs->buf + dgs->len, s, l);
3713  dgs->buf[dgs->len + l] = '\0';
3714  dgs->len += l;
3715 }
static void d_growable_string_resize(struct d_growable_string *, size_t)
Definition: cp-demangle.c:3671
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))

References d_growable_string::alc, d_growable_string::allocation_failure, d_growable_string::buf, d_growable_string_resize(), d_growable_string::len, memcpy(), and s.

Referenced by d_growable_string_callback_adapter().

◆ d_growable_string_callback_adapter()

static void d_growable_string_callback_adapter ( const char *  s,
size_t  l,
void *  opaque 
)
static

Definition at line 3720 of file cp-demangle.c.

3720  {
3721  struct d_growable_string *dgs = (struct d_growable_string *)opaque;
3722 
3724 }
static void d_growable_string_append_buffer(struct d_growable_string *, const char *, size_t)
Definition: cp-demangle.c:3701

References d_growable_string_append_buffer(), and s.

Referenced by cplus_demangle_print(), and d_demangle().

◆ d_growable_string_init()

static void d_growable_string_init ( struct d_growable_string dgs,
size_t  estimate 
)
static

Definition at line 3658 of file cp-demangle.c.

3658  {
3659  dgs->buf = NULL;
3660  dgs->len = 0;
3661  dgs->alc = 0;
3662  dgs->allocation_failure = 0;
3663 
3664  if (estimate > 0)
3665  d_growable_string_resize(dgs, estimate);
3666 }

References d_growable_string::alc, d_growable_string::allocation_failure, d_growable_string::buf, d_growable_string_resize(), d_growable_string::len, and NULL.

Referenced by cplus_demangle_print(), and d_demangle().

◆ d_growable_string_resize()

static void d_growable_string_resize ( struct d_growable_string dgs,
size_t  need 
)
inlinestatic

Definition at line 3671 of file cp-demangle.c.

3671  {
3672  size_t newalc;
3673  char *newbuf;
3674 
3675  if (dgs->allocation_failure)
3676  return;
3677 
3678  /* Start allocation at two bytes to avoid any possibility of confusion
3679  with the special value of 1 used as a return in *palc to indicate
3680  allocation failures. */
3681  newalc = dgs->alc > 0 ? dgs->alc : 2;
3682  while (newalc < need)
3683  newalc <<= 1;
3684 
3685  newbuf = (char *)realloc(dgs->buf, newalc);
3686  if (newbuf == NULL) {
3687  free(dgs->buf);
3688  dgs->buf = NULL;
3689  dgs->len = 0;
3690  dgs->alc = 0;
3691  dgs->allocation_failure = 1;
3692  return;
3693  }
3694  dgs->buf = newbuf;
3695  dgs->alc = newalc;
3696 }
void * realloc(void *ptr, size_t size)
Definition: malloc.c:144

References d_growable_string::alc, d_growable_string::allocation_failure, d_growable_string::buf, free(), d_growable_string::len, NULL, and realloc().

Referenced by d_growable_string_append_buffer(), and d_growable_string_init().

◆ d_identifier()

static struct demangle_component * d_identifier ( struct d_info di,
int  len 
)
static

Definition at line 1624 of file cp-demangle.c.

1624  {
1625  const char *name;
1626 
1627  name = d_str(di);
1628 
1629  if (di->send - name < len)
1630  return NULL;
1631 
1632  d_advance(di, len);
1633 
1634  /* A Java mangled name may have a trailing '$' if it is a C++
1635  keyword. This '$' is not included in the length count. We just
1636  ignore the '$'. */
1637  if ((di->options & DMGL_JAVA) != 0 && d_peek_char(di) == '$')
1638  d_advance(di, 1);
1639 
1640  /* Look for something which looks like a gcc encoding of an
1641  anonymous namespace, and replace it with a more user friendly
1642  name. */
1644  const char *s;
1645 
1647  if ((*s == '.' || *s == '_' || *s == '$') && s[1] == 'N') {
1648  di->expansion -= len - sizeof "(anonymous namespace)";
1649  return d_make_name(di, "(anonymous namespace)",
1650  sizeof "(anonymous namespace)" - 1);
1651  }
1652  }
1653 
1654  return d_make_name(di, name, len);
1655 }
#define ANONYMOUS_NAMESPACE_PREFIX_LEN
Definition: cp-demangle.c:215
#define ANONYMOUS_NAMESPACE_PREFIX
Definition: cp-demangle.c:214
#define DMGL_JAVA
Definition: demangle.h:45

References ANONYMOUS_NAMESPACE_PREFIX, ANONYMOUS_NAMESPACE_PREFIX_LEN, d_advance, d_make_name(), d_peek_char, d_str, DMGL_JAVA, d_info::expansion, len, name, NULL, d_info::options, s, and d_info::send.

Referenced by d_source_name().

◆ d_index_template_argument()

static struct demangle_component* d_index_template_argument ( struct demangle_component args,
int  i 
)
static

Definition at line 4032 of file cp-demangle.c.

4032  {
4033  struct demangle_component *a;
4034 
4035  if (i < 0)
4036  /* Print the whole argument pack. */
4037  return args;
4038 
4039  for (a = args;
4040  a != NULL;
4041  a = d_right(a)) {
4043  return NULL;
4044  if (i <= 0)
4045  break;
4046  --i;
4047  }
4048  if (i != 0 || a == NULL)
4049  return NULL;
4050 
4051  return d_left(a);
4052 }

References a, args, d_left, d_right, DEMANGLE_COMPONENT_TEMPLATE_ARGLIST, i, and NULL.

Referenced by d_lookup_template_argument(), and d_print_comp_inner().

◆ d_java_resource()

static struct demangle_component* d_java_resource ( struct d_info di)
static

Definition at line 1798 of file cp-demangle.c.

1798  {
1799  struct demangle_component *p = NULL;
1800  struct demangle_component *next = NULL;
1801  int len, i;
1802  char c;
1803  const char *str;
1804 
1805  len = d_number(di);
1806  if (len <= 1)
1807  return NULL;
1808 
1809  /* Eat the leading '_'. */
1810  if (d_next_char(di) != '_')
1811  return NULL;
1812  len--;
1813 
1814  str = d_str(di);
1815  i = 0;
1816 
1817  while (len > 0) {
1818  c = str[i];
1819  if (!c)
1820  return NULL;
1821 
1822  /* Each chunk is either a '$' escape... */
1823  if (c == '$') {
1824  i++;
1825  switch (str[i++]) {
1826  case 'S':
1827  c = '/';
1828  break;
1829  case '_':
1830  c = '.';
1831  break;
1832  case '$':
1833  c = '$';
1834  break;
1835  default:
1836  return NULL;
1837  }
1838  next = d_make_character(di, c);
1839  d_advance(di, i);
1840  str = d_str(di);
1841  len -= i;
1842  i = 0;
1843  if (next == NULL)
1844  return NULL;
1845  }
1846  /* ... or a sequence of characters. */
1847  else {
1848  while (i < len && str[i] && str[i] != '$')
1849  i++;
1850 
1851  next = d_make_name(di, str, i);
1852  d_advance(di, i);
1853  str = d_str(di);
1854  len -= i;
1855  i = 0;
1856  if (next == NULL)
1857  return NULL;
1858  }
1859 
1860  if (p == NULL)
1861  p = next;
1862  else {
1864  if (p == NULL)
1865  return NULL;
1866  }
1867  }
1868 
1870 
1871  return p;
1872 }
static struct demangle_component * d_make_character(struct d_info *di, int c)
Definition: cp-demangle.c:1787

References c, d_advance, d_make_character(), d_make_comp(), d_make_name(), d_next_char, d_number(), d_str, DEMANGLE_COMPONENT_COMPOUND_NAME, DEMANGLE_COMPONENT_JAVA_RESOURCE, i, len, NULL, p, and cmd_descs_generate::str.

Referenced by d_special_name().

◆ d_lambda()

static struct demangle_component * d_lambda ( struct d_info di)
static

Definition at line 3414 of file cp-demangle.c.

3414  {
3415  struct demangle_component *tl;
3416  struct demangle_component *ret;
3417  int num;
3418 
3419  if (!d_check_char(di, 'U'))
3420  return NULL;
3421  if (!d_check_char(di, 'l'))
3422  return NULL;
3423 
3424  tl = d_parmlist(di);
3425  if (tl == NULL)
3426  return NULL;
3427 
3428  if (!d_check_char(di, 'E'))
3429  return NULL;
3430 
3431  num = d_compact_number(di);
3432  if (num < 0)
3433  return NULL;
3434 
3435  ret = d_make_empty(di);
3436  if (ret) {
3438  ret->u.s_unary_num.sub = tl;
3439  ret->u.s_unary_num.num = num;
3440  }
3441 
3442  if (!d_add_substitution(di, ret))
3443  return NULL;
3444 
3445  return ret;
3446 }

References d_add_substitution(), d_check_char, d_compact_number(), d_make_empty(), d_parmlist(), DEMANGLE_COMPONENT_LAMBDA, NULL, num, demangle_component::s_unary_num, demangle_component::type, and demangle_component::u.

Referenced by d_unqualified_name().

◆ d_last_char()

static char d_last_char ( struct d_print_info dpi)
inlinestatic

Definition at line 3953 of file cp-demangle.c.

3953  {
3954  return dpi->last_char;
3955 }

References d_print_info::last_char.

Referenced by d_print_comp_inner(), d_print_conversion(), d_print_function_type(), and d_print_mod().

◆ d_local_name()

static struct demangle_component * d_local_name ( struct d_info di)
static

Definition at line 3323 of file cp-demangle.c.

3323  {
3324  struct demangle_component *function;
3325  struct demangle_component *name;
3326 
3327  if (!d_check_char(di, 'Z'))
3328  return NULL;
3329 
3330  function = d_encoding(di, 0);
3331  if (!function)
3332  return NULL;
3333 
3334  if (!d_check_char(di, 'E'))
3335  return NULL;
3336 
3337  if (d_peek_char(di) == 's') {
3338  d_advance(di, 1);
3339  if (!d_discriminator(di))
3340  return NULL;
3341  name = d_make_name(di, "string literal", sizeof "string literal" - 1);
3342  } else {
3343  int num = -1;
3344 
3345  if (d_peek_char(di) == 'd') {
3346  /* Default argument scope: d <number> _. */
3347  d_advance(di, 1);
3348  num = d_compact_number(di);
3349  if (num < 0)
3350  return NULL;
3351  }
3352 
3353  name = d_name(di);
3354 
3355  if (name
3356  /* Lambdas and unnamed types have internal discriminators
3357  and are not functions. */
3359  /* Read and ignore an optional discriminator. */
3360  if (!d_discriminator(di))
3361  return NULL;
3362  }
3363 
3364  if (num >= 0)
3365  name = d_make_default_arg(di, num, name);
3366  }
3367 
3368  /* Elide the return type of the containing function so as to not
3369  confuse the user thinking it is the return type of whatever local
3370  function we might be containing. */
3371  if (function->type == DEMANGLE_COMPONENT_TYPED_NAME && d_right(function)->type == DEMANGLE_COMPONENT_FUNCTION_TYPE)
3372  d_left(d_right(function)) = NULL;
3373 
3374  return d_make_comp(di, DEMANGLE_COMPONENT_LOCAL_NAME, function, name);
3375 }
static int d_discriminator(struct d_info *)
Definition: cp-demangle.c:3387
static struct demangle_component * d_make_default_arg(struct d_info *di, int num, struct demangle_component *sub)
Definition: cp-demangle.c:1084

References d_advance, d_check_char, d_compact_number(), d_discriminator(), d_encoding(), d_left, d_make_comp(), d_make_default_arg(), d_make_name(), d_name(), d_peek_char, d_right, DEMANGLE_COMPONENT_FUNCTION_TYPE, DEMANGLE_COMPONENT_LAMBDA, DEMANGLE_COMPONENT_LOCAL_NAME, DEMANGLE_COMPONENT_TYPED_NAME, DEMANGLE_COMPONENT_UNNAMED_TYPE, name, NULL, num, and type.

Referenced by d_name().

◆ d_lookup_template_argument()

static struct demangle_component* d_lookup_template_argument ( struct d_print_info dpi,
const struct demangle_component dc 
)
static

Definition at line 4058 of file cp-demangle.c.

4059  {
4060  if (dpi->templates == NULL) {
4061  d_print_error(dpi);
4062  return NULL;
4063  }
4064 
4066  dc->u.s_number.number);
4067 }
static struct demangle_component * d_index_template_argument(struct demangle_component *args, int i)
Definition: cp-demangle.c:4032
static void d_print_error(struct d_print_info *)
Definition: cp-demangle.c:3902
struct d_print_template * templates
Definition: cp-demangle.c:330
const struct demangle_component * template_decl
Definition: cp-demangle.c:251
struct demangle_component::@376::@385 s_number

References d_index_template_argument(), d_print_error(), d_right, NULL, demangle_component::s_number, d_print_template::template_decl, d_print_info::templates, and demangle_component::u.

Referenced by d_find_pack(), and d_print_comp_inner().

◆ d_make_builtin_type()

static struct demangle_component * d_make_builtin_type ( struct d_info di,
const struct demangle_builtin_type_info type 
)
static

Definition at line 1042 of file cp-demangle.c.

1043  {
1044  struct demangle_component *p;
1045 
1046  if (type == NULL)
1047  return NULL;
1048  p = d_make_empty(di);
1049  if (p != NULL) {
1051  p->u.s_builtin.type = type;
1052  }
1053  return p;
1054 }

References d_make_empty(), DEMANGLE_COMPONENT_BUILTIN_TYPE, NULL, p, and type.

Referenced by cplus_demangle_type().

◆ d_make_character()

static struct demangle_component* d_make_character ( struct d_info di,
int  c 
)
static

Definition at line 1787 of file cp-demangle.c.

1787  {
1788  struct demangle_component *p;
1789  p = d_make_empty(di);
1790  if (p != NULL) {
1792  p->u.s_character.character = c;
1793  }
1794  return p;
1795 }

References c, d_make_empty(), DEMANGLE_COMPONENT_CHARACTER, NULL, and p.

Referenced by d_java_resource().

◆ d_make_comp()

static struct demangle_component * d_make_comp ( struct d_info di,
enum demangle_component_type  type,
struct demangle_component left,
struct demangle_component right 
)
static

Definition at line 915 of file cp-demangle.c.

917  {
918  struct demangle_component *p;
919 
920  /* We check for errors here. A typical error would be a NULL return
921  from a subroutine. We catch those here, and return NULL
922  upward. */
923  switch (type) {
924  /* These types require two parameters. */
943  if (left == NULL || right == NULL)
944  return NULL;
945  break;
946 
947  /* These types only require one parameter. */
980  if (left == NULL)
981  return NULL;
982  break;
983 
984  /* This needs a right parameter, but the left parameter can be
985  empty. */
988  if (right == NULL)
989  return NULL;
990  break;
991 
992  /* These are allowed to have no parameters--in some cases they
993  will be filled in later. */
1001  break;
1002 
1003  /* Other types should not be seen here. */
1004  default:
1005  return NULL;
1006  }
1007 
1008  p = d_make_empty(di);
1009  if (p != NULL) {
1010  p->type = type;
1011  p->u.s_binary.left = left;
1012  p->u.s_binary.right = right;
1013  }
1014  return p;
1015 }
#define FNQUAL_COMPONENT_CASE
Definition: cp-demangle.c:560

References d_make_empty(), DEMANGLE_COMPONENT_ARGLIST, DEMANGLE_COMPONENT_ARRAY_TYPE, DEMANGLE_COMPONENT_BINARY, DEMANGLE_COMPONENT_BINARY_ARGS, DEMANGLE_COMPONENT_CAST, DEMANGLE_COMPONENT_CLONE, DEMANGLE_COMPONENT_COMPLEX, DEMANGLE_COMPONENT_COMPOUND_NAME, DEMANGLE_COMPONENT_CONST, DEMANGLE_COMPONENT_CONSTRUCTION_VTABLE, DEMANGLE_COMPONENT_CONVERSION, DEMANGLE_COMPONENT_COVARIANT_THUNK, DEMANGLE_COMPONENT_DECLTYPE, DEMANGLE_COMPONENT_FUNCTION_TYPE, DEMANGLE_COMPONENT_GLOBAL_CONSTRUCTORS, DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS, DEMANGLE_COMPONENT_GUARD, DEMANGLE_COMPONENT_HIDDEN_ALIAS, DEMANGLE_COMPONENT_IMAGINARY, DEMANGLE_COMPONENT_INITIALIZER_LIST, DEMANGLE_COMPONENT_JAVA_CLASS, DEMANGLE_COMPONENT_JAVA_RESOURCE, DEMANGLE_COMPONENT_LITERAL, DEMANGLE_COMPONENT_LITERAL_NEG, DEMANGLE_COMPONENT_LOCAL_NAME, DEMANGLE_COMPONENT_NONTRANSACTION_CLONE, DEMANGLE_COMPONENT_NULLARY, DEMANGLE_COMPONENT_PACK_EXPANSION, DEMANGLE_COMPONENT_POINTER, DEMANGLE_COMPONENT_PTRMEM_TYPE, DEMANGLE_COMPONENT_QUAL_NAME, DEMANGLE_COMPONENT_REFERENCE, DEMANGLE_COMPONENT_REFTEMP, DEMANGLE_COMPONENT_RESTRICT, DEMANGLE_COMPONENT_RVALUE_REFERENCE, DEMANGLE_COMPONENT_TAGGED_NAME, DEMANGLE_COMPONENT_TEMPLATE, DEMANGLE_COMPONENT_TEMPLATE_ARGLIST, DEMANGLE_COMPONENT_THUNK, DEMANGLE_COMPONENT_TLS_INIT, DEMANGLE_COMPONENT_TLS_WRAPPER, DEMANGLE_COMPONENT_TPARM_OBJ, DEMANGLE_COMPONENT_TRANSACTION_CLONE, DEMANGLE_COMPONENT_TRINARY, DEMANGLE_COMPONENT_TRINARY_ARG1, DEMANGLE_COMPONENT_TRINARY_ARG2, DEMANGLE_COMPONENT_TYPED_NAME, DEMANGLE_COMPONENT_TYPEINFO, DEMANGLE_COMPONENT_TYPEINFO_FN, DEMANGLE_COMPONENT_TYPEINFO_NAME, DEMANGLE_COMPONENT_UNARY, DEMANGLE_COMPONENT_VECTOR_TYPE, DEMANGLE_COMPONENT_VENDOR_TYPE, DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL, DEMANGLE_COMPONENT_VIRTUAL_THUNK, DEMANGLE_COMPONENT_VOLATILE, DEMANGLE_COMPONENT_VTABLE, DEMANGLE_COMPONENT_VTT, FNQUAL_COMPONENT_CASE, demangle_component::left, NULL, p, demangle_component::right, and type.

Referenced by cplus_demangle_type(), d_abi_tags(), d_array_type(), d_bare_function_type(), d_clone_suffix(), d_cv_qualifiers(), d_demangle_callback(), d_encoding(), d_expr_primary(), d_expression_1(), d_exprlist(), d_java_resource(), d_local_name(), d_name(), d_operator_name(), d_parmlist(), d_pointer_to_member_type(), d_prefix(), d_ref_qualifier(), d_special_name(), d_template_args_1(), d_unqualified_name(), and d_vector_type().

◆ d_make_ctor()

static struct demangle_component * d_make_ctor ( struct d_info di,
enum gnu_v3_ctor_kinds  kind,
struct demangle_component name 
)
static

Definition at line 1098 of file cp-demangle.c.

1099  {
1100  struct demangle_component *p;
1101 
1102  p = d_make_empty(di);
1104  return NULL;
1105  return p;
1106 }
CP_STATIC_IF_GLIBCPP_V3 int cplus_demangle_fill_ctor(struct demangle_component *p, enum gnu_v3_ctor_kinds kind, struct demangle_component *name)
Definition: cp-demangle.c:871
enum gnu_v3_ctor_kinds kind
Definition: demangle.h:535

References cplus_demangle_fill_ctor(), d_make_empty(), demangle_component::kind, NULL, and p.

Referenced by d_ctor_dtor_name().

◆ d_make_default_arg()

static struct demangle_component* d_make_default_arg ( struct d_info di,
int  num,
struct demangle_component sub 
)
static

Definition at line 1084 of file cp-demangle.c.

1085  {
1086  struct demangle_component *p = d_make_empty(di);
1087  if (p) {
1089  p->u.s_unary_num.num = num;
1090  p->u.s_unary_num.sub = sub;
1091  }
1092  return p;
1093 }
struct demangle_component * sub
Definition: demangle.h:590

References d_make_empty(), DEMANGLE_COMPONENT_DEFAULT_ARG, num, p, and demangle_component::sub.

Referenced by d_local_name().

◆ d_make_demangle_mangled_name()

static struct demangle_component * d_make_demangle_mangled_name ( struct d_info di,
const char *  s 
)
static

Definition at line 1020 of file cp-demangle.c.

1020  {
1021  if (d_peek_char(di) != '_' || d_peek_next_char(di) != 'Z')
1022  return d_make_name(di, s, strlen(s));
1023  d_advance(di, 2);
1024  return d_encoding(di, 0);
1025 }

References d_advance, d_encoding(), d_make_name(), d_peek_char, d_peek_next_char, and s.

Referenced by d_demangle_callback().

◆ d_make_dtor()

static struct demangle_component * d_make_dtor ( struct d_info di,
enum gnu_v3_dtor_kinds  kind,
struct demangle_component name 
)
static

Definition at line 1111 of file cp-demangle.c.

1112  {
1113  struct demangle_component *p;
1114 
1115  p = d_make_empty(di);
1117  return NULL;
1118  return p;
1119 }
CP_STATIC_IF_GLIBCPP_V3 int cplus_demangle_fill_dtor(struct demangle_component *p, enum gnu_v3_dtor_kinds kind, struct demangle_component *name)
Definition: cp-demangle.c:886

References cplus_demangle_fill_dtor(), d_make_empty(), demangle_component::kind, NULL, and p.

Referenced by d_ctor_dtor_name().

◆ d_make_empty()

static struct demangle_component * d_make_empty ( struct d_info di)
static

Definition at line 901 of file cp-demangle.c.

901  {
902  struct demangle_component *p;
903 
904  if (di->next_comp >= di->num_comps)
905  return NULL;
906  p = &di->comps[di->next_comp];
907  p->d_printing = 0;
908  ++di->next_comp;
909  return p;
910 }
struct demangle_component * comps
Definition: cp-demangle.h:102

References d_info::comps, d_info::next_comp, NULL, d_info::num_comps, and p.

Referenced by cplus_demangle_type(), d_lambda(), d_make_builtin_type(), d_make_character(), d_make_comp(), d_make_ctor(), d_make_default_arg(), d_make_dtor(), d_make_extended_operator(), d_make_function_param(), d_make_name(), d_make_operator(), d_make_sub(), d_make_template_param(), d_number_component(), and d_unnamed_type().

◆ d_make_extended_operator()

static struct demangle_component * d_make_extended_operator ( struct d_info di,
int  args,
struct demangle_component name 
)
static

Definition at line 1073 of file cp-demangle.c.

1074  {
1075  struct demangle_component *p;
1076 
1077  p = d_make_empty(di);
1079  return NULL;
1080  return p;
1081 }
CP_STATIC_IF_GLIBCPP_V3 int cplus_demangle_fill_extended_operator(struct demangle_component *p, int args, struct demangle_component *name)
Definition: cp-demangle.c:857

References args, cplus_demangle_fill_extended_operator(), d_make_empty(), NULL, and p.

Referenced by d_operator_name().

◆ d_make_function_param()

static struct demangle_component* d_make_function_param ( struct d_info di,
int  i 
)
static

Definition at line 1138 of file cp-demangle.c.

1138  {
1139  struct demangle_component *p;
1140 
1141  p = d_make_empty(di);
1142  if (p != NULL) {
1144  p->u.s_number.number = i;
1145  }
1146  return p;
1147 }

References d_make_empty(), DEMANGLE_COMPONENT_FUNCTION_PARAM, i, NULL, and p.

Referenced by d_expression_1().

◆ d_make_name()

static struct demangle_component * d_make_name ( struct d_info di,
const char *  s,
int  len 
)
static

Definition at line 1030 of file cp-demangle.c.

1030  {
1031  struct demangle_component *p;
1032 
1033  p = d_make_empty(di);
1034  if (!cplus_demangle_fill_name(p, s, len))
1035  return NULL;
1036  return p;
1037 }
CP_STATIC_IF_GLIBCPP_V3 int cplus_demangle_fill_name(struct demangle_component *p, const char *s, int len)
Definition: cp-demangle.c:844

References cplus_demangle_fill_name(), d_make_empty(), len, NULL, p, and s.

Referenced by cplus_demangle_type(), d_array_type(), d_clone_suffix(), d_expr_primary(), d_identifier(), d_java_resource(), d_local_name(), d_make_demangle_mangled_name(), and d_name().

◆ d_make_operator()

static struct demangle_component * d_make_operator ( struct d_info di,
const struct demangle_operator_info op 
)
static

Definition at line 1059 of file cp-demangle.c.

1059  {
1060  struct demangle_component *p;
1061 
1062  p = d_make_empty(di);
1063  if (p != NULL) {
1065  p->u.s_operator.op = op;
1066  }
1067  return p;
1068 }

References d_make_empty(), DEMANGLE_COMPONENT_OPERATOR, NULL, op, and p.

Referenced by d_operator_name().

◆ d_make_sub()

static struct demangle_component * d_make_sub ( struct d_info di,
const char *  name,
int  len 
)
static

Definition at line 1152 of file cp-demangle.c.

1152  {
1153  struct demangle_component *p;
1154 
1155  p = d_make_empty(di);
1156  if (p != NULL) {
1157  p->type = DEMANGLE_COMPONENT_SUB_STD;
1158  p->u.s_string.string = name;
1159  p->u.s_string.len = len;
1160  }
1161  return p;
1162 }

References d_make_empty(), DEMANGLE_COMPONENT_SUB_STD, len, name, NULL, and p.

Referenced by d_substitution().

◆ d_make_template_param()

static struct demangle_component * d_make_template_param ( struct d_info di,
int  i 
)
static

Definition at line 1124 of file cp-demangle.c.

1124  {
1125  struct demangle_component *p;
1126 
1127  p = d_make_empty(di);
1128  if (p != NULL) {
1130  p->u.s_number.number = i;
1131  }
1132  return p;
1133 }

References d_make_empty(), DEMANGLE_COMPONENT_TEMPLATE_PARAM, i, NULL, and p.

Referenced by d_template_param().

◆ d_maybe_print_fold_expression()

static int d_maybe_print_fold_expression ( struct d_print_info dpi,
int  options,
struct demangle_component dc 
)
static

Definition at line 4220 of file cp-demangle.c.

4221  {
4222  struct demangle_component *ops, *operator_, *op1, *op2;
4223  int save_idx;
4224 
4225  const char *fold_code = d_left(dc)->u.s_operator.op->code;
4226  if (fold_code[0] != 'f')
4227  return 0;
4228 
4229  ops = d_right(dc);
4230  operator_ = d_left(ops);
4231  op1 = d_right(ops);
4232  op2 = 0;
4233  if (op1->type == DEMANGLE_COMPONENT_TRINARY_ARG2) {
4234  op2 = d_right(op1);
4235  op1 = d_left(op1);
4236  }
4237 
4238  /* Print the whole pack. */
4239  save_idx = dpi->pack_index;
4240  dpi->pack_index = -1;
4241 
4242  switch (fold_code[1]) {
4243  /* Unary left fold, (... + X). */
4244  case 'l':
4245  d_append_string(dpi, "(...");
4246  d_print_expr_op(dpi, options, operator_);
4247  d_print_subexpr(dpi, options, op1);
4248  d_append_char(dpi, ')');
4249  break;
4250 
4251  /* Unary right fold, (X + ...). */
4252  case 'r':
4253  d_append_char(dpi, '(');
4254  d_print_subexpr(dpi, options, op1);
4255  d_print_expr_op(dpi, options, operator_);
4256  d_append_string(dpi, "...)");
4257  break;
4258 
4259  /* Binary left fold, (42 + ... + X). */
4260  case 'L':
4261  /* Binary right fold, (X + ... + 42). */
4262  case 'R':
4263  d_append_char(dpi, '(');
4264  d_print_subexpr(dpi, options, op1);
4265  d_print_expr_op(dpi, options, operator_);
4266  d_append_string(dpi, "...");
4267  d_print_expr_op(dpi, options, operator_);
4268  d_print_subexpr(dpi, options, op2);
4269  d_append_char(dpi, ')');
4270  break;
4271  }
4272 
4273  dpi->pack_index = save_idx;
4274  return 1;
4275 }
static struct @29 ops[]
static void d_print_subexpr(struct d_print_info *dpi, int options, struct demangle_component *dc)
Definition: cp-demangle.c:4153
static void d_print_expr_op(struct d_print_info *, int, struct demangle_component *)
Definition: cp-demangle.c:5620

References d_append_char(), d_append_string(), d_left, d_print_expr_op(), d_print_subexpr(), d_right, DEMANGLE_COMPONENT_TRINARY_ARG2, ops, options, d_print_info::pack_index, and demangle_component::type.

Referenced by d_print_comp_inner().

◆ d_name()

static struct demangle_component * d_name ( struct d_info di)
static

Definition at line 1333 of file cp-demangle.c.

1333  {
1334  char peek = d_peek_char(di);
1335  struct demangle_component *dc;
1336 
1337  switch (peek) {
1338  case 'N':
1339  return d_nested_name(di);
1340 
1341  case 'Z':
1342  return d_local_name(di);
1343 
1344  case 'U':
1345  return d_unqualified_name(di);
1346 
1347  case 'S': {
1348  int subst;
1349 
1350  if (d_peek_next_char(di) != 't') {
1351  dc = d_substitution(di, 0);
1352  subst = 1;
1353  } else {
1354  d_advance(di, 2);
1356  d_make_name(di, "std", 3),
1357  d_unqualified_name(di));
1358  di->expansion += 3;
1359  subst = 0;
1360  }
1361 
1362  if (d_peek_char(di) != 'I') {
1363  /* The grammar does not permit this case to occur if we
1364  called d_substitution() above (i.e., subst == 1). We
1365  don't bother to check. */
1366  } else {
1367  /* This is <template-args>, which means that we just saw
1368  <unscoped-template-name>, which is a substitution
1369  candidate if we didn't just get it from a
1370  substitution. */
1371  if (!subst) {
1372  if (!d_add_substitution(di, dc))
1373  return NULL;
1374  }
1376  d_template_args(di));
1377  }
1378 
1379  return dc;
1380  }
1381 
1382  case 'L':
1383  default:
1384  dc = d_unqualified_name(di);
1385  if (d_peek_char(di) == 'I') {
1386  /* This is <template-args>, which means that we just saw
1387  <unscoped-template-name>, which is a substitution
1388  candidate. */
1389  if (!d_add_substitution(di, dc))
1390  return NULL;
1392  d_template_args(di));
1393  }
1394  return dc;
1395  }
1396 }
static struct demangle_component * d_nested_name(struct d_info *)
Definition: cp-demangle.c:1403
static struct demangle_component * d_local_name(struct d_info *)
Definition: cp-demangle.c:3323

References d_add_substitution(), d_advance, d_local_name(), d_make_comp(), d_make_name(), d_nested_name(), d_peek_char, d_peek_next_char, d_substitution(), d_template_args(), d_unqualified_name(), DEMANGLE_COMPONENT_QUAL_NAME, DEMANGLE_COMPONENT_TEMPLATE, d_info::expansion, and NULL.

Referenced by d_class_enum_type(), d_encoding(), d_local_name(), and d_special_name().

◆ d_nested_name()

static struct demangle_component * d_nested_name ( struct d_info di)
static

Definition at line 1403 of file cp-demangle.c.

1403  {
1404  struct demangle_component *ret;
1405  struct demangle_component **pret;
1406  struct demangle_component *rqual;
1407 
1408  if (!d_check_char(di, 'N'))
1409  return NULL;
1410 
1411  pret = d_cv_qualifiers(di, &ret, 1);
1412  if (pret == NULL)
1413  return NULL;
1414 
1415  /* Parse the ref-qualifier now and then attach it
1416  once we have something to attach it to. */
1417  rqual = d_ref_qualifier(di, NULL);
1418 
1419  *pret = d_prefix(di);
1420  if (*pret == NULL)
1421  return NULL;
1422 
1423  if (rqual) {
1424  d_left(rqual) = ret;
1425  ret = rqual;
1426  }
1427 
1428  if (!d_check_char(di, 'E'))
1429  return NULL;
1430 
1431  return ret;
1432 }
static struct demangle_component * d_prefix(struct d_info *)
Definition: cp-demangle.c:1447

References d_check_char, d_cv_qualifiers(), d_left, d_prefix(), d_ref_qualifier(), and NULL.

Referenced by d_name().

◆ d_number()

static int d_number ( struct d_info di)
static

Definition at line 1581 of file cp-demangle.c.

1581  {
1582  int negative;
1583  char peek;
1584  int ret;
1585 
1586  negative = 0;
1587  peek = d_peek_char(di);
1588  if (peek == 'n') {
1589  negative = 1;
1590  d_advance(di, 1);
1591  peek = d_peek_char(di);
1592  }
1593 
1594  ret = 0;
1595  while (1) {
1596  if (!IS_DIGIT(peek)) {
1597  if (negative)
1598  ret = -ret;
1599  return ret;
1600  }
1601  if (ret > ((INT_MAX - (peek - '0')) / 10))
1602  return -1;
1603  ret = ret * 10 + peek - '0';
1604  d_advance(di, 1);
1605  peek = d_peek_char(di);
1606  }
1607 }

References d_advance, d_peek_char, INT_MAX, and IS_DIGIT.

Referenced by cplus_demangle_type(), d_call_offset(), d_compact_number(), d_discriminator(), d_java_resource(), d_number_component(), d_source_name(), and d_special_name().

◆ d_number_component()

static struct demangle_component* d_number_component ( struct d_info di)
static

Definition at line 1612 of file cp-demangle.c.

1612  {
1613  struct demangle_component *ret = d_make_empty(di);
1614  if (ret) {
1616  ret->u.s_number.number = d_number(di);
1617  }
1618  return ret;
1619 }

References d_make_empty(), d_number(), DEMANGLE_COMPONENT_NUMBER, demangle_component::s_number, demangle_component::type, and demangle_component::u.

Referenced by d_special_name(), and d_vector_type().

◆ d_operator_name()

static struct demangle_component * d_operator_name ( struct d_info di)
static

Definition at line 1738 of file cp-demangle.c.

1738  {
1739  char c1;
1740  char c2;
1741 
1742  c1 = d_next_char(di);
1743  c2 = d_next_char(di);
1744  if (c1 == 'v' && IS_DIGIT(c2))
1745  return d_make_extended_operator(di, c2 - '0', d_source_name(di));
1746  else if (c1 == 'c' && c2 == 'v') {
1747  struct demangle_component *type;
1748  int was_conversion = di->is_conversion;
1749  struct demangle_component *res;
1750 
1751  di->is_conversion = !di->is_expression;
1752  type = cplus_demangle_type(di);
1753  if (di->is_conversion)
1755  else
1757  di->is_conversion = was_conversion;
1758  return res;
1759  } else {
1760  /* LOW is the inclusive lower bound. */
1761  int low = 0;
1762  /* HIGH is the exclusive upper bound. We subtract one to ignore
1763  the sentinel at the end of the array. */
1764  int high = ((sizeof(cplus_demangle_operators) / sizeof(cplus_demangle_operators[0])) - 1);
1765 
1766  while (1) {
1767  int i;
1768  const struct demangle_operator_info *p;
1769 
1770  i = low + (high - low) / 2;
1772 
1773  if (c1 == p->code[0] && c2 == p->code[1])
1774  return d_make_operator(di, p);
1775 
1776  if (c1 < p->code[0] || (c1 == p->code[0] && c2 < p->code[1]))
1777  high = i;
1778  else
1779  low = i + 1;
1780  if (low == high)
1781  return NULL;
1782  }
1783  }
1784 }
lsl lsr asr ror lsl lsr asr ror lsl lsl lsr asr ror lsl lsr asr ror lsl lsr asr ror lsl lsr asr ror lsl lsr asr ror lsl lsr asr ror lsl lsr asr ror lsl lsr asr ror lsl lsr asr ror lsl lsr asr ror c1
lsl lsr asr ror lsl lsr asr ror lsl lsl lsr asr ror lsl lsr asr ror lsl lsr asr ror lsl lsr asr ror lsl lsr asr ror lsl lsr asr ror lsl lsr asr ror lsl lsr asr ror lsl lsr asr ror lsl lsr asr ror c2
CP_STATIC_IF_GLIBCPP_V3 const struct demangle_operator_info cplus_demangle_operators[]
Definition: cp-demangle.c:1666
static struct demangle_component * d_make_operator(struct d_info *, const struct demangle_operator_info *)
Definition: cp-demangle.c:1059
static struct demangle_component * d_make_extended_operator(struct d_info *, int, struct demangle_component *)
Definition: cp-demangle.c:1073

References c1, c2, cplus_demangle_operators, cplus_demangle_type(), d_make_comp(), d_make_extended_operator(), d_make_operator(), d_next_char, d_source_name(), DEMANGLE_COMPONENT_CAST, DEMANGLE_COMPONENT_CONVERSION, i, d_info::is_conversion, IS_DIGIT, d_info::is_expression, NULL, p, and type.

Referenced by d_expression_1(), and d_unqualified_name().

◆ d_pack_length()

static int d_pack_length ( const struct demangle_component dc)
static

Definition at line 4120 of file cp-demangle.c.

4120  {
4121  int count = 0;
4122  while (dc && dc->type == DEMANGLE_COMPONENT_TEMPLATE_ARGLIST && d_left(dc) != NULL) {
4123  ++count;
4124  dc = d_right(dc);
4125  }
4126  return count;
4127 }

References count, d_left, d_right, DEMANGLE_COMPONENT_TEMPLATE_ARGLIST, NULL, and demangle_component::type.

Referenced by d_args_length(), and d_print_comp_inner().

◆ d_parmlist()

static struct demangle_component * d_parmlist ( struct d_info di)
static

Definition at line 2691 of file cp-demangle.c.

2691  {
2692  struct demangle_component *tl;
2693  struct demangle_component **ptl;
2694 
2695  tl = NULL;
2696  ptl = &tl;
2697  while (1) {
2698  struct demangle_component *type;
2699 
2700  char peek = d_peek_char(di);
2701  if (peek == '\0' || peek == 'E' || peek == '.')
2702  break;
2703  if ((peek == 'R' || peek == 'O') && d_peek_next_char(di) == 'E')
2704  /* Function ref-qualifier, not a ref prefix for a parameter type. */
2705  break;
2706  type = cplus_demangle_type(di);
2707  if (type == NULL)
2708  return NULL;
2710  if (*ptl == NULL)
2711  return NULL;
2712  ptl = &d_right(*ptl);
2713  }
2714 
2715  /* There should be at least one parameter type besides the optional
2716  return type. A function which takes no arguments will have a
2717  single parameter type void. */
2718  if (tl == NULL)
2719  return NULL;
2720 
2721  /* If we have a single parameter type void, omit it. */
2722  if (d_right(tl) == NULL && d_left(tl)->type == DEMANGLE_COMPONENT_BUILTIN_TYPE && d_left(tl)->u.s_builtin.type->print == D_PRINT_VOID) {
2723  di->expansion -= d_left(tl)->u.s_builtin.type->len;
2724  d_left(tl) = NULL;
2725  }
2726 
2727  return tl;
2728 }
@ D_PRINT_VOID
Definition: cp-demangle.h:72

References cplus_demangle_type(), d_left, d_make_comp(), d_peek_char, d_peek_next_char, D_PRINT_VOID, d_right, DEMANGLE_COMPONENT_ARGLIST, DEMANGLE_COMPONENT_BUILTIN_TYPE, d_info::expansion, NULL, type, and demangle_component::u.

Referenced by d_bare_function_type(), d_cv_qualifiers(), and d_lambda().

◆ d_pointer_to_member_type()

static struct demangle_component * d_pointer_to_member_type ( struct d_info di)
static

Definition at line 2835 of file cp-demangle.c.

2835  {
2836  struct demangle_component *cl;
2837  struct demangle_component *mem;
2838 
2839  if (!d_check_char(di, 'M'))
2840  return NULL;
2841 
2842  cl = cplus_demangle_type(di);
2843  if (cl == NULL)
2844  return NULL;
2845 
2846  /* The ABI says, "The type of a non-static member function is considered
2847  to be different, for the purposes of substitution, from the type of a
2848  namespace-scope or static member function whose type appears
2849  similar. The types of two non-static member functions are considered
2850  to be different, for the purposes of substitution, if the functions
2851  are members of different classes. In other words, for the purposes of
2852  substitution, the class of which the function is a member is
2853  considered part of the type of function."
2854 
2855  For a pointer to member function, this call to cplus_demangle_type
2856  will end up adding a (possibly qualified) non-member function type to
2857  the substitution table, which is not correct; however, the member
2858  function type will never be used in a substitution, so putting the
2859  wrong type in the substitution table is harmless. */
2860 
2861  mem = cplus_demangle_type(di);
2862  if (mem == NULL)
2863  return NULL;
2864 
2866 }
void * mem
Definition: libc.cpp:91

References cplus_demangle_type(), d_check_char, d_make_comp(), DEMANGLE_COMPONENT_PTRMEM_TYPE, mem, and NULL.

Referenced by cplus_demangle_type().

◆ d_prefix()

static struct demangle_component * d_prefix ( struct d_info di)
static

Definition at line 1447 of file cp-demangle.c.

1447  {
1448  struct demangle_component *ret = NULL;
1449 
1450  while (1) {
1451  char peek;
1452  enum demangle_component_type comb_type;
1453  struct demangle_component *dc;
1454 
1455  peek = d_peek_char(di);
1456  if (peek == '\0')
1457  return NULL;
1458 
1459  /* The older code accepts a <local-name> here, but I don't see
1460  that in the grammar. The older code does not accept a
1461  <template-param> here. */
1462 
1463  comb_type = DEMANGLE_COMPONENT_QUAL_NAME;
1464  if (peek == 'D') {
1465  char peek2 = d_peek_next_char(di);
1466  if (peek2 == 'T' || peek2 == 't')
1467  /* Decltype. */
1468  dc = cplus_demangle_type(di);
1469  else
1470  /* Destructor name. */
1471  dc = d_unqualified_name(di);
1472  } else if (IS_DIGIT(peek) || IS_LOWER(peek) || peek == 'C' || peek == 'U' || peek == 'L')
1473  dc = d_unqualified_name(di);
1474  else if (peek == 'S')
1475  dc = d_substitution(di, 1);
1476  else if (peek == 'I') {
1477  if (ret == NULL)
1478  return NULL;
1479  comb_type = DEMANGLE_COMPONENT_TEMPLATE;
1480  dc = d_template_args(di);
1481  } else if (peek == 'T')
1482  dc = d_template_param(di);
1483  else if (peek == 'E')
1484  return ret;
1485  else if (peek == 'M') {
1486  /* Initializer scope for a lambda. We don't need to represent
1487  this; the normal code will just treat the variable as a type
1488  scope, which gives appropriate output. */
1489  if (ret == NULL)
1490  return NULL;
1491  d_advance(di, 1);
1492  continue;
1493  } else
1494  return NULL;
1495 
1496  if (ret == NULL)
1497  ret = dc;
1498  else
1499  ret = d_make_comp(di, comb_type, ret, dc);
1500 
1501  if (peek != 'S' && d_peek_char(di) != 'E') {
1502  if (!d_add_substitution(di, ret))
1503  return NULL;
1504  }
1505  }
1506 }

References cplus_demangle_type(), d_add_substitution(), d_advance, d_make_comp(), d_peek_char, d_peek_next_char, d_substitution(), d_template_args(), d_template_param(), d_unqualified_name(), DEMANGLE_COMPONENT_QUAL_NAME, DEMANGLE_COMPONENT_TEMPLATE, IS_DIGIT, IS_LOWER, and NULL.

Referenced by d_nested_name().

◆ d_print_array_type()

static void d_print_array_type ( struct d_print_info dpi,
int  options,
struct demangle_component dc,
struct d_print_mod mods 
)
static

Definition at line 5573 of file cp-demangle.c.

5575  {
5576  int need_space;
5577 
5578  need_space = 1;
5579  if (mods != NULL) {
5580  int need_paren;
5581  struct d_print_mod *p;
5582 
5583  need_paren = 0;
5584  for (p = mods; p != NULL; p = p->next) {
5585  if (!p->printed) {
5586  if (p->mod->type == DEMANGLE_COMPONENT_ARRAY_TYPE) {
5587  need_space = 0;
5588  break;
5589  } else {
5590  need_paren = 1;
5591  need_space = 1;
5592  break;
5593  }
5594  }
5595  }
5596 
5597  if (need_paren)
5598  d_append_string(dpi, " (");
5599 
5600  d_print_mod_list(dpi, options, mods, 0);
5601 
5602  if (need_paren)
5603  d_append_char(dpi, ')');
5604  }
5605 
5606  if (need_space)
5607  d_append_char(dpi, ' ');
5608 
5609  d_append_char(dpi, '[');
5610 
5611  if (d_left(dc) != NULL)
5612  d_print_comp(dpi, options, d_left(dc));
5613 
5614  d_append_char(dpi, ']');
5615 }
static void d_print_mod_list(struct d_print_info *, int, struct d_print_mod *, int)
Definition: cp-demangle.c:5341

References d_append_char(), d_append_string(), d_left, d_print_comp(), d_print_mod_list(), DEMANGLE_COMPONENT_ARRAY_TYPE, NULL, options, and p.

Referenced by d_print_comp_inner(), and d_print_mod_list().

◆ d_print_cast()

static void d_print_cast ( struct d_print_info dpi,
int  options,
struct demangle_component dc 
)
static

Definition at line 5632 of file cp-demangle.c.

5633  {
5634  d_print_comp(dpi, options, d_left(dc));
5635 }

References d_left, d_print_comp(), and options.

Referenced by d_print_comp_inner().

◆ d_print_comp()

static void d_print_comp ( struct d_print_info dpi,
int  options,
struct demangle_component dc 
)
static

Definition at line 5271 of file cp-demangle.c.

5272  {
5273  struct d_component_stack self;
5274  if (dc == NULL || dc->d_printing > 1 || dpi->recursion > MAX_RECURSION_COUNT) {
5275  d_print_error(dpi);
5276  return;
5277  }
5278 
5279  dc->d_printing++;
5280  dpi->recursion++;
5281 
5282  self.dc = dc;
5283  self.parent = dpi->component_stack;
5284  dpi->component_stack = &self;
5285 
5286  d_print_comp_inner(dpi, options, dc);
5287 
5288  dpi->component_stack = self.parent;
5289  dc->d_printing--;
5290  dpi->recursion--;
5291 }
static void d_print_comp_inner(struct d_print_info *dpi, int options, struct demangle_component *dc)
Definition: cp-demangle.c:4280
#define MAX_RECURSION_COUNT
Definition: cp-demangle.c:313
const struct d_component_stack * parent
Definition: cp-demangle.c:287
const struct demangle_component * dc
Definition: cp-demangle.c:285
const struct d_component_stack * component_stack
Definition: cp-demangle.c:348

References d_print_info::component_stack, d_print_comp_inner(), d_print_error(), demangle_component::d_printing, d_component_stack::dc, MAX_RECURSION_COUNT, NULL, options, d_component_stack::parent, and d_print_info::recursion.

Referenced by cplus_demangle_print_callback(), d_print_array_type(), d_print_cast(), d_print_comp_inner(), d_print_conversion(), d_print_expr_op(), d_print_function_type(), d_print_mod(), d_print_mod_list(), and d_print_subexpr().

◆ d_print_comp_inner()

static void d_print_comp_inner ( struct d_print_info dpi,
int  options,
struct demangle_component dc 
)
static

Definition at line 4280 of file cp-demangle.c.

4281  {
4282  /* Magic variable to let reference smashing skip over the next modifier
4283  without needing to modify *dc. */
4284  struct demangle_component *mod_inner = NULL;
4285 
4286  /* Variable used to store the current templates while a previously
4287  captured scope is used. */
4288  struct d_print_template *saved_templates;
4289 
4290  /* Nonzero if templates have been stored in the above variable. */
4291  int need_template_restore = 0;
4292 
4293  if (dc == NULL) {
4294  d_print_error(dpi);
4295  return;
4296  }
4297  if (d_print_saw_error(dpi))
4298  return;
4299 
4300  switch (dc->type) {
4302  if ((options & DMGL_JAVA) == 0)
4303  d_append_buffer(dpi, dc->u.s_name.s, dc->u.s_name.len);
4304  else
4305  d_print_java_identifier(dpi, dc->u.s_name.s, dc->u.s_name.len);
4306  return;
4307 
4309  d_print_comp(dpi, options, d_left(dc));
4310  d_append_string(dpi, "[abi:");
4311  d_print_comp(dpi, options, d_right(dc));
4312  d_append_char(dpi, ']');
4313  return;
4314 
4317  d_print_comp(dpi, options, d_left(dc));
4318  if ((options & DMGL_JAVA) == 0)
4319  d_append_string(dpi, "::");
4320  else
4321  d_append_char(dpi, '.');
4322  {
4323  struct demangle_component *local_name = d_right(dc);
4324  if (local_name->type == DEMANGLE_COMPONENT_DEFAULT_ARG) {
4325  d_append_string(dpi, "{default arg#");
4326  d_append_num(dpi, local_name->u.s_unary_num.num + 1);
4327  d_append_string(dpi, "}::");
4328  local_name = local_name->u.s_unary_num.sub;
4329  }
4330  d_print_comp(dpi, options, local_name);
4331  }
4332  return;
4333 
4335  struct d_print_mod *hold_modifiers;
4336  struct demangle_component *typed_name;
4337  struct d_print_mod adpm[4];
4338  unsigned int i;
4339  struct d_print_template dpt;
4340  dpt.next = NULL;
4341 
4342  /* Pass the name down to the type so that it can be printed in
4343  the right place for the type. We also have to pass down
4344  any CV-qualifiers, which apply to the this parameter. */
4345  hold_modifiers = dpi->modifiers;
4346  dpi->modifiers = 0;
4347  i = 0;
4348  typed_name = d_left(dc);
4349  while (typed_name != NULL) {
4350  if (i >= sizeof adpm / sizeof adpm[0]) {
4351  d_print_error(dpi);
4352  return;
4353  }
4354 
4355  adpm[i].next = dpi->modifiers;
4356  dpi->modifiers = &adpm[i];
4357  adpm[i].mod = typed_name;
4358  adpm[i].printed = 0;
4359  adpm[i].templates = dpi->templates;
4360  ++i;
4361 
4362  if (!is_fnqual_component_type(typed_name->type))
4363  break;
4364 
4365  typed_name = d_left(typed_name);
4366  }
4367 
4368  if (typed_name == NULL) {
4369  d_print_error(dpi);
4370  return;
4371  }
4372 
4373  /* If typed_name is a DEMANGLE_COMPONENT_LOCAL_NAME, then
4374  there may be CV-qualifiers on its right argument which
4375  really apply here; this happens when parsing a class that
4376  is local to a function. */
4377  if (typed_name->type == DEMANGLE_COMPONENT_LOCAL_NAME) {
4378  typed_name = d_right(typed_name);
4379  if (typed_name->type == DEMANGLE_COMPONENT_DEFAULT_ARG)
4380  typed_name = typed_name->u.s_unary_num.sub;
4381  if (typed_name == NULL) {
4382  d_print_error(dpi);
4383  return;
4384  }
4385  while (is_fnqual_component_type(typed_name->type)) {
4386  if (i >= sizeof adpm / sizeof adpm[0]) {
4387  d_print_error(dpi);
4388  return;
4389  }
4390 
4391  adpm[i] = adpm[i - 1];
4392  adpm[i].next = &adpm[i - 1];
4393  dpi->modifiers = &adpm[i];
4394 
4395  adpm[i - 1].mod = typed_name;
4396  adpm[i - 1].printed = 0;
4397  adpm[i - 1].templates = dpi->templates;
4398  ++i;
4399 
4400  typed_name = d_left(typed_name);
4401  }
4402  }
4403 
4404  /* If typed_name is a template, then it applies to the
4405  function type as well. */
4406  if (typed_name->type == DEMANGLE_COMPONENT_TEMPLATE) {
4407  dpt.next = dpi->templates;
4408  dpi->templates = &dpt;
4409  dpt.template_decl = typed_name;
4410  }
4411 
4412  d_print_comp(dpi, options, d_right(dc));
4413 
4414  if (typed_name->type == DEMANGLE_COMPONENT_TEMPLATE)
4415  dpi->templates = dpt.next;
4416 
4417  /* If the modifiers didn't get printed by the type, print them
4418  now. */
4419  while (i > 0) {
4420  --i;
4421  if (!adpm[i].printed) {
4422  d_append_char(dpi, ' ');
4423  d_print_mod(dpi, options, adpm[i].mod);
4424  }
4425  }
4426 
4427  dpi->modifiers = hold_modifiers;
4428 
4429  return;
4430  }
4431 
4433  struct d_print_mod *hold_dpm;
4434  struct demangle_component *dcl;
4435  const struct demangle_component *hold_current;
4436 
4437  /* This template may need to be referenced by a cast operator
4438  contained in its subtree. */
4439  hold_current = dpi->current_template;
4440  dpi->current_template = dc;
4441 
4442  /* Don't push modifiers into a template definition. Doing so
4443  could give the wrong definition for a template argument.
4444  Instead, treat the template essentially as a name. */
4445 
4446  hold_dpm = dpi->modifiers;
4447  dpi->modifiers = NULL;
4448 
4449  dcl = d_left(dc);
4450 
4451  if ((options & DMGL_JAVA) != 0 && dcl->type == DEMANGLE_COMPONENT_NAME && dcl->u.s_name.len == 6 && strncmp(dcl->u.s_name.s, "JArray", 6) == 0) {
4452  /* Special-case Java arrays, so that JArray<TYPE> appears
4453  instead as TYPE[]. */
4454 
4455  d_print_comp(dpi, options, d_right(dc));
4456  d_append_string(dpi, "[]");
4457  } else {
4458  d_print_comp(dpi, options, dcl);
4459  if (d_last_char(dpi) == '<')
4460  d_append_char(dpi, ' ');
4461  d_append_char(dpi, '<');
4462  d_print_comp(dpi, options, d_right(dc));
4463  /* Avoid generating two consecutive '>' characters, to avoid
4464  the C++ syntactic ambiguity. */
4465  if (d_last_char(dpi) == '>')
4466  d_append_char(dpi, ' ');
4467  d_append_char(dpi, '>');
4468  }
4469 
4470  dpi->modifiers = hold_dpm;
4471  dpi->current_template = hold_current;
4472 
4473  return;
4474  }
4475 
4477  if (dpi->is_lambda_arg) {
4478  /* Show the template parm index, as that's how g++ displays
4479  these, and future proofs us against potential
4480  '[]<typename T> (T *a, T *b) {...}'. */
4481  d_append_buffer(dpi, "auto:", 5);
4482  d_append_num(dpi, dc->u.s_number.number + 1);
4483  } else {
4484  struct d_print_template *hold_dpt;
4485  struct demangle_component *a = d_lookup_template_argument(dpi, dc);
4486 
4487  if (a && a->type == DEMANGLE_COMPONENT_TEMPLATE_ARGLIST)
4489 
4490  if (a == NULL) {
4491  d_print_error(dpi);
4492  return;
4493  }
4494 
4495  /* While processing this parameter, we need to pop the list
4496  of templates. This is because the template parameter may
4497  itself be a reference to a parameter of an outer
4498  template. */
4499 
4500  hold_dpt = dpi->templates;
4501  dpi->templates = hold_dpt->next;
4502 
4503  d_print_comp(dpi, options, a);
4504 
4505  dpi->templates = hold_dpt;
4506  }
4507  return;
4508 
4510  d_append_string(dpi, "template parameter object for ");
4511  d_print_comp(dpi, options, d_left(dc));
4512  return;
4513 
4515  d_print_comp(dpi, options, dc->u.s_ctor.name);
4516  return;
4517 
4519  d_append_char(dpi, '~');
4520  d_print_comp(dpi, options, dc->u.s_dtor.name);
4521  return;
4522 
4524  d_append_string(dpi, "vtable for ");
4525  d_print_comp(dpi, options, d_left(dc));
4526  return;
4527 
4529  d_append_string(dpi, "VTT for ");
4530  d_print_comp(dpi, options, d_left(dc));
4531  return;
4532 
4534  d_append_string(dpi, "construction vtable for ");
4535  d_print_comp(dpi, options, d_left(dc));
4536  d_append_string(dpi, "-in-");
4537  d_print_comp(dpi, options, d_right(dc));
4538  return;
4539 
4541  d_append_string(dpi, "typeinfo for ");
4542  d_print_comp(dpi, options, d_left(dc));
4543  return;
4544 
4546  d_append_string(dpi, "typeinfo name for ");
4547  d_print_comp(dpi, options, d_left(dc));
4548  return;
4549 
4551  d_append_string(dpi, "typeinfo fn for ");
4552  d_print_comp(dpi, options, d_left(dc));
4553  return;
4554 
4556  d_append_string(dpi, "non-virtual thunk to ");
4557  d_print_comp(dpi, options, d_left(dc));
4558  return;
4559 
4561  d_append_string(dpi, "virtual thunk to ");
4562  d_print_comp(dpi, options, d_left(dc));
4563  return;
4564 
4566  d_append_string(dpi, "covariant return thunk to ");
4567  d_print_comp(dpi, options, d_left(dc));
4568  return;
4569 
4571  d_append_string(dpi, "java Class for ");
4572  d_print_comp(dpi, options, d_left(dc));
4573  return;
4574 
4576  d_append_string(dpi, "guard variable for ");
4577  d_print_comp(dpi, options, d_left(dc));
4578  return;
4579 
4581  d_append_string(dpi, "TLS init function for ");
4582  d_print_comp(dpi, options, d_left(dc));
4583  return;
4584 
4586  d_append_string(dpi, "TLS wrapper function for ");
4587  d_print_comp(dpi, options, d_left(dc));
4588  return;
4589 
4591  d_append_string(dpi, "reference temporary #");
4592  d_print_comp(dpi, options, d_right(dc));
4593  d_append_string(dpi, " for ");
4594  d_print_comp(dpi, options, d_left(dc));
4595  return;
4596 
4598  d_append_string(dpi, "hidden alias for ");
4599  d_print_comp(dpi, options, d_left(dc));
4600  return;
4601 
4603  d_append_string(dpi, "transaction clone for ");
4604  d_print_comp(dpi, options, d_left(dc));
4605  return;
4606 
4608  d_append_string(dpi, "non-transaction clone for ");
4609  d_print_comp(dpi, options, d_left(dc));
4610  return;
4611 
4613  d_append_buffer(dpi, dc->u.s_string.string, dc->u.s_string.len);
4614  return;
4615 
4618  case DEMANGLE_COMPONENT_CONST: {
4619  struct d_print_mod *pdpm;
4620 
4621  /* When printing arrays, it's possible to have cases where the
4622  same CV-qualifier gets pushed on the stack multiple times.
4623  We only need to print it once. */
4624 
4625  for (pdpm = dpi->modifiers; pdpm != NULL; pdpm = pdpm->next) {
4626  if (!pdpm->printed) {
4628  break;
4629  if (pdpm->mod->type == dc->type) {
4630  d_print_comp(dpi, options, d_left(dc));
4631  return;
4632  }
4633  }
4634  }
4635  }
4636  goto modifier;
4637 
4640  /* Handle reference smashing: & + && = &. */
4641  struct demangle_component *sub = d_left(dc);
4643  struct d_saved_scope *scope = d_get_saved_scope(dpi, sub);
4644  struct demangle_component *a;
4645 
4646  if (scope == NULL) {
4647  /* This is the first time SUB has been traversed.
4648  We need to capture the current templates so
4649  they can be restored if SUB is reentered as a
4650  substitution. */
4651  d_save_scope(dpi, sub);
4652  if (d_print_saw_error(dpi))
4653  return;
4654  } else {
4655  const struct d_component_stack *dcse;
4656  int found_self_or_parent = 0;
4657 
4658  /* This traversal is reentering SUB as a substition.
4659  If we are not beneath SUB or DC in the tree then we
4660  need to restore SUB's template stack temporarily. */
4661  for (dcse = dpi->component_stack; dcse != NULL;
4662  dcse = dcse->parent) {
4663  if (dcse->dc == sub || (dcse->dc == dc && dcse != dpi->component_stack)) {
4664  found_self_or_parent = 1;
4665  break;
4666  }
4667  }
4668 
4669  if (!found_self_or_parent) {
4670  saved_templates = dpi->templates;
4671  dpi->templates = scope->templates;
4672  need_template_restore = 1;
4673  }
4674  }
4675 
4676  a = d_lookup_template_argument(dpi, sub);
4677  if (a && a->type == DEMANGLE_COMPONENT_TEMPLATE_ARGLIST)
4679 
4680  if (a == NULL) {
4681  if (need_template_restore)
4682  dpi->templates = saved_templates;
4683 
4684  d_print_error(dpi);
4685  return;
4686  }
4687 
4688  sub = a;
4689  }
4690 
4691  if (sub->type == DEMANGLE_COMPONENT_REFERENCE || sub->type == dc->type)
4692  dc = sub;
4693  else if (sub->type == DEMANGLE_COMPONENT_RVALUE_REFERENCE)
4694  mod_inner = d_left(sub);
4695  }
4696  /* Fall through. */
4697 
4703  modifier : {
4704  /* We keep a list of modifiers on the stack. */
4705  struct d_print_mod dpm;
4706 
4707  dpm.next = dpi->modifiers;
4708  dpi->modifiers = &dpm;
4709  dpm.mod = dc;
4710  dpm.printed = 0;
4711  dpm.templates = dpi->templates;
4712 
4713  if (!mod_inner)
4714  mod_inner = d_left(dc);
4715 
4716  d_print_comp(dpi, options, mod_inner);
4717 
4718  /* If the modifier didn't get printed by the type, print it
4719  now. */
4720  if (!dpm.printed)
4721  d_print_mod(dpi, options, dc);
4722 
4723  dpi->modifiers = dpm.next;
4724 
4725  if (need_template_restore)
4726  dpi->templates = saved_templates;
4727 
4728  return;
4729  }
4730 
4732  if ((options & DMGL_JAVA) == 0)
4733  d_append_buffer(dpi, dc->u.s_builtin.type->name,
4734  dc->u.s_builtin.type->len);
4735  else
4736  d_append_buffer(dpi, dc->u.s_builtin.type->java_name,
4737  dc->u.s_builtin.type->java_len);
4738  return;
4739 
4741  d_print_comp(dpi, options, d_left(dc));
4742  return;
4743 
4745  if ((options & DMGL_RET_POSTFIX) != 0)
4748  dc, dpi->modifiers);
4749 
4750  /* Print return type if present */
4751  if (d_left(dc) != NULL && (options & DMGL_RET_POSTFIX) != 0)
4753  d_left(dc));
4754  else if (d_left(dc) != NULL && (options & DMGL_RET_DROP) == 0) {
4755  struct d_print_mod dpm;
4756 
4757  /* We must pass this type down as a modifier in order to
4758  print it in the right location. */
4759  dpm.next = dpi->modifiers;
4760  dpi->modifiers = &dpm;
4761  dpm.mod = dc;
4762  dpm.printed = 0;
4763  dpm.templates = dpi->templates;
4764 
4766  d_left(dc));
4767 
4768  dpi->modifiers = dpm.next;
4769 
4770  if (dpm.printed)
4771  return;
4772 
4773  /* In standard prefix notation, there is a space between the
4774  return type and the function signature. */
4775  if ((options & DMGL_RET_POSTFIX) == 0)
4776  d_append_char(dpi, ' ');
4777  }
4778 
4779  if ((options & DMGL_RET_POSTFIX) == 0)
4782  dc, dpi->modifiers);
4783 
4784  return;
4785  }
4786 
4788  struct d_print_mod *hold_modifiers;
4789  struct d_print_mod adpm[4];
4790  unsigned int i;
4791  struct d_print_mod *pdpm;
4792 
4793  /* We must pass this type down as a modifier in order to print
4794  multi-dimensional arrays correctly. If the array itself is
4795  CV-qualified, we act as though the element type were
4796  CV-qualified. We do this by copying the modifiers down
4797  rather than fiddling pointers, so that we don't wind up
4798  with a d_print_mod higher on the stack pointing into our
4799  stack frame after we return. */
4800 
4801  hold_modifiers = dpi->modifiers;
4802 
4803  adpm[0].next = hold_modifiers;
4804  dpi->modifiers = &adpm[0];
4805  adpm[0].mod = dc;
4806  adpm[0].printed = 0;
4807  adpm[0].templates = dpi->templates;
4808 
4809  i = 1;
4810  pdpm = hold_modifiers;
4811  while (pdpm != NULL && (pdpm->mod->type == DEMANGLE_COMPONENT_RESTRICT || pdpm->mod->type == DEMANGLE_COMPONENT_VOLATILE || pdpm->mod->type == DEMANGLE_COMPONENT_CONST)) {
4812  if (!pdpm->printed) {
4813  if (i >= sizeof adpm / sizeof adpm[0]) {
4814  d_print_error(dpi);
4815  return;
4816  }
4817 
4818  adpm[i] = *pdpm;
4819  adpm[i].next = dpi->modifiers;
4820  dpi->modifiers = &adpm[i];
4821  pdpm->printed = 1;
4822  ++i;
4823  }
4824 
4825  pdpm = pdpm->next;
4826  }
4827 
4828  d_print_comp(dpi, options, d_right(dc));
4829 
4830  dpi->modifiers = hold_modifiers;
4831 
4832  if (adpm[0].printed)
4833  return;
4834 
4835  while (i > 1) {
4836  --i;
4837  d_print_mod(dpi, options, adpm[i].mod);
4838  }
4839 
4840  d_print_array_type(dpi, options, dc, dpi->modifiers);
4841 
4842  return;
4843  }
4844 
4847  struct d_print_mod dpm;
4848 
4849  dpm.next = dpi->modifiers;
4850  dpi->modifiers = &dpm;
4851  dpm.mod = dc;
4852  dpm.printed = 0;
4853  dpm.templates = dpi->templates;
4854 
4855  d_print_comp(dpi, options, d_right(dc));
4856 
4857  /* If the modifier didn't get printed by the type, print it
4858  now. */
4859  if (!dpm.printed)
4860  d_print_mod(dpi, options, dc);
4861 
4862  dpi->modifiers = dpm.next;
4863 
4864  return;
4865  }
4866 
4868  if (dc->u.s_fixed.sat)
4869  d_append_string(dpi, "_Sat ");
4870  /* Don't print "int _Accum". */
4871  if (dc->u.s_fixed.length->u.s_builtin.type != &cplus_demangle_builtin_types['i' - 'a']) {
4872  d_print_comp(dpi, options, dc->u.s_fixed.length);
4873  d_append_char(dpi, ' ');
4874  }
4875  if (dc->u.s_fixed.accum)
4876  d_append_string(dpi, "_Accum");
4877  else
4878  d_append_string(dpi, "_Fract");
4879  return;
4880 
4883  if (d_left(dc) != NULL)
4884  d_print_comp(dpi, options, d_left(dc));
4885  if (d_right(dc) != NULL) {
4886  size_t len;
4887  unsigned long int flush_count;
4888  /* Make sure ", " isn't flushed by d_append_string, otherwise
4889  dpi->len -= 2 wouldn't work. */
4890  if (dpi->len >= sizeof(dpi->buf) - 2)
4891  d_print_flush(dpi);
4892  d_append_string(dpi, ", ");
4893  len = dpi->len;
4894  flush_count = dpi->flush_count;
4895  d_print_comp(dpi, options, d_right(dc));
4896  /* If that didn't print anything (which can happen with empty
4897  template argument packs), remove the comma and space. */
4898  if (dpi->flush_count == flush_count && dpi->len == len)
4899  dpi->len -= 2;
4900  }
4901  return;
4902 
4904  struct demangle_component *type = d_left(dc);
4905  struct demangle_component *list = d_right(dc);
4906 
4907  if (type)
4908  d_print_comp(dpi, options, type);
4909  d_append_char(dpi, '{');
4910  d_print_comp(dpi, options, list);
4911  d_append_char(dpi, '}');
4912  }
4913  return;
4914 
4916  const struct demangle_operator_info *op = dc->u.s_operator.op;
4917  int len = op->len;
4918 
4919  d_append_string(dpi, "operator");
4920  /* Add a space before new/delete. */
4921  if (IS_LOWER(op->name[0]))
4922  d_append_char(dpi, ' ');
4923  /* Omit a trailing space. */
4924  if (op->name[len - 1] == ' ')
4925  --len;
4926  d_append_buffer(dpi, op->name, len);
4927  return;
4928  }
4929 
4931  d_append_string(dpi, "operator ");
4932  d_print_comp(dpi, options, dc->u.s_extended_operator.name);
4933  return;
4934 
4936  d_append_string(dpi, "operator ");
4937  d_print_conversion(dpi, options, dc);
4938  return;
4939 
4941  d_print_expr_op(dpi, options, d_left(dc));
4942  return;
4943 
4944  case DEMANGLE_COMPONENT_UNARY: {
4945  struct demangle_component *op = d_left(dc);
4946  struct demangle_component *operand = d_right(dc);
4947  const char *code = NULL;
4948 
4949  if (op->type == DEMANGLE_COMPONENT_OPERATOR) {
4950  code = op->u.s_operator.op->code;
4951  if (!strcmp(code, "ad")) {
4952  /* Don't print the argument list for the address of a
4953  function. */
4955  operand = d_left(operand);
4956  }
4957  if (operand->type == DEMANGLE_COMPONENT_BINARY_ARGS) {
4958  /* This indicates a suffix operator. */
4959  operand = d_left(operand);
4961  d_print_expr_op(dpi, options, op);
4962  return;
4963  }
4964  }
4965 
4966  /* For sizeof..., just print the pack length. */
4967  if (code && !strcmp(code, "sZ")) {
4968  struct demangle_component *a = d_find_pack(dpi, operand);
4969  int len = d_pack_length(a);
4970  d_append_num(dpi, len);
4971  return;
4972  } else if (code && !strcmp(code, "sP")) {
4973  int len = d_args_length(dpi, operand);
4974  d_append_num(dpi, len);
4975  return;
4976  }
4977 
4978  if (op->type != DEMANGLE_COMPONENT_CAST)
4979  d_print_expr_op(dpi, options, op);
4980  else {
4981  d_append_char(dpi, '(');
4982  d_print_cast(dpi, options, op);
4983  d_append_char(dpi, ')');
4984  }
4985  if (code && !strcmp(code, "gs"))
4986  /* Avoid parens after '::'. */
4987  d_print_comp(dpi, options, operand);
4988  else if (code && !strcmp(code, "st"))
4989  /* Always print parens for sizeof (type). */
4990  {
4991  d_append_char(dpi, '(');
4992  d_print_comp(dpi, options, operand);
4993  d_append_char(dpi, ')');
4994  } else
4996  }
4997  return;
4998 
5001  d_print_error(dpi);
5002  return;
5003  }
5004 
5005  if (op_is_new_cast(d_left(dc))) {
5006  d_print_expr_op(dpi, options, d_left(dc));
5007  d_append_char(dpi, '<');
5008  d_print_comp(dpi, options, d_left(d_right(dc)));
5009  d_append_string(dpi, ">(");
5010  d_print_comp(dpi, options, d_right(d_right(dc)));
5011  d_append_char(dpi, ')');
5012  return;
5013  }
5014 
5015  if (d_maybe_print_fold_expression(dpi, options, dc))
5016  return;
5017 
5018  /* We wrap an expression which uses the greater-than operator in
5019  an extra layer of parens so that it does not get confused
5020  with the '>' which ends the template parameters. */
5021  if (d_left(dc)->type == DEMANGLE_COMPONENT_OPERATOR && d_left(dc)->u.s_operator.op->len == 1 && d_left(dc)->u.s_operator.op->name[0] == '>')
5022  d_append_char(dpi, '(');
5023 
5024  if (strcmp(d_left(dc)->u.s_operator.op->code, "cl") == 0 && d_left(d_right(dc))->type == DEMANGLE_COMPONENT_TYPED_NAME) {
5025  /* Function call used in an expression should not have printed types
5026  of the function arguments. Values of the function arguments still
5027  get printed below. */
5028 
5029  const struct demangle_component *func = d_left(d_right(dc));
5030 
5032  d_print_error(dpi);
5033  d_print_subexpr(dpi, options, d_left(func));
5034  } else
5035  d_print_subexpr(dpi, options, d_left(d_right(dc)));
5036  if (strcmp(d_left(dc)->u.s_operator.op->code, "ix") == 0) {
5037  d_append_char(dpi, '[');
5038  d_print_comp(dpi, options, d_right(d_right(dc)));
5039  d_append_char(dpi, ']');
5040  } else {
5041  if (strcmp(d_left(dc)->u.s_operator.op->code, "cl") != 0)
5042  d_print_expr_op(dpi, options, d_left(dc));
5043  d_print_subexpr(dpi, options, d_right(d_right(dc)));
5044  }
5045 
5046  if (d_left(dc)->type == DEMANGLE_COMPONENT_OPERATOR && d_left(dc)->u.s_operator.op->len == 1 && d_left(dc)->u.s_operator.op->name[0] == '>')
5047  d_append_char(dpi, ')');
5048 
5049  return;
5050 
5052  /* We should only see this as part of DEMANGLE_COMPONENT_BINARY. */
5053  d_print_error(dpi);
5054  return;
5055 
5058  d_print_error(dpi);
5059  return;
5060  }
5061  if (d_maybe_print_fold_expression(dpi, options, dc))
5062  return;
5063  {
5064  struct demangle_component *op = d_left(dc);
5065  struct demangle_component *first = d_left(d_right(dc));
5066  struct demangle_component *second = d_left(d_right(d_right(dc)));
5067  struct demangle_component *third = d_right(d_right(d_right(dc)));
5068 
5069  if (!strcmp(op->u.s_operator.op->code, "qu")) {
5070  d_print_subexpr(dpi, options, first);
5071  d_print_expr_op(dpi, options, op);
5072  d_print_subexpr(dpi, options, second);
5073  d_append_string(dpi, " : ");
5074  d_print_subexpr(dpi, options, third);
5075  } else {
5076  d_append_string(dpi, "new ");
5077  if (d_left(first) != NULL) {
5078  d_print_subexpr(dpi, options, first);
5079  d_append_char(dpi, ' ');
5080  }
5081  d_print_comp(dpi, options, second);
5082  if (third)
5083  d_print_subexpr(dpi, options, third);
5084  }
5085  }
5086  return;
5087 
5090  /* We should only see these are part of DEMANGLE_COMPONENT_TRINARY. */
5091  d_print_error(dpi);
5092  return;
5093 
5096  enum d_builtin_type_print tp;
5097 
5098  /* For some builtin types, produce simpler output. */
5099  tp = D_PRINT_DEFAULT;
5101  tp = d_left(dc)->u.s_builtin.type->print;
5102  switch (tp) {
5103  case D_PRINT_INT:
5104  case D_PRINT_UNSIGNED:
5105  case D_PRINT_LONG:
5106  case D_PRINT_UNSIGNED_LONG:
5107  case D_PRINT_LONG_LONG:
5109  if (d_right(dc)->type == DEMANGLE_COMPONENT_NAME) {
5111  d_append_char(dpi, '-');
5112  d_print_comp(dpi, options, d_right(dc));
5113  switch (tp) {
5114  default:
5115  break;
5116  case D_PRINT_UNSIGNED:
5117  d_append_char(dpi, 'u');
5118  break;
5119  case D_PRINT_LONG:
5120  d_append_char(dpi, 'l');
5121  break;
5122  case D_PRINT_UNSIGNED_LONG:
5123  d_append_string(dpi, "ul");
5124  break;
5125  case D_PRINT_LONG_LONG:
5126  d_append_string(dpi, "ll");
5127  break;
5129  d_append_string(dpi, "ull");
5130  break;
5131  }
5132  return;
5133  }
5134  break;
5135 
5136  case D_PRINT_BOOL:
5137  if (d_right(dc)->type == DEMANGLE_COMPONENT_NAME && d_right(dc)->u.s_name.len == 1 && dc->type == DEMANGLE_COMPONENT_LITERAL) {
5138  switch (d_right(dc)->u.s_name.s[0]) {
5139  case '0':
5140  d_append_string(dpi, "false");
5141  return;
5142  case '1':
5143  d_append_string(dpi, "true");
5144  return;
5145  default:
5146  break;
5147  }
5148  }
5149  break;
5150 
5151  default:
5152  break;
5153  }
5154  }
5155 
5156  d_append_char(dpi, '(');
5157  d_print_comp(dpi, options, d_left(dc));
5158  d_append_char(dpi, ')');
5160  d_append_char(dpi, '-');
5161  if (tp == D_PRINT_FLOAT)
5162  d_append_char(dpi, '[');
5163  d_print_comp(dpi, options, d_right(dc));
5164  if (tp == D_PRINT_FLOAT)
5165  d_append_char(dpi, ']');
5166  }
5167  return;
5168 
5170  d_append_num(dpi, dc->u.s_number.number);
5171  return;
5172 
5174  d_append_string(dpi, "java resource ");
5175  d_print_comp(dpi, options, d_left(dc));
5176  return;
5177 
5179  d_print_comp(dpi, options, d_left(dc));
5180  d_print_comp(dpi, options, d_right(dc));
5181  return;
5182 
5184  d_append_char(dpi, dc->u.s_character.character);
5185  return;
5186 
5188  d_append_string(dpi, "decltype (");
5189  d_print_comp(dpi, options, d_left(dc));
5190  d_append_char(dpi, ')');
5191  return;
5192 
5194  int len;
5195  int i;
5196  struct demangle_component *a = d_find_pack(dpi, d_left(dc));
5197  if (a == NULL) {
5198  /* d_find_pack won't find anything if the only packs involved
5199  in this expansion are function parameter packs; in that
5200  case, just print the pattern and "...". */
5201  d_print_subexpr(dpi, options, d_left(dc));
5202  d_append_string(dpi, "...");
5203  return;
5204  }
5205 
5206  len = d_pack_length(a);
5207  dc = d_left(dc);
5208  for (i = 0; i < len; ++i) {
5209  dpi->pack_index = i;
5210  d_print_comp(dpi, options, dc);
5211  if (i < len - 1)
5212  d_append_string(dpi, ", ");
5213  }
5214  }
5215  return;
5216 
5218  long num = dc->u.s_number.number;
5219  if (num == 0)
5220  d_append_string(dpi, "this");
5221  else {
5222  d_append_string(dpi, "{parm#");
5223  d_append_num(dpi, num);
5224  d_append_char(dpi, '}');
5225  }
5226  }
5227  return;
5228 
5230  d_append_string(dpi, "global constructors keyed to ");
5231  d_print_comp(dpi, options, dc->u.s_binary.left);
5232  return;
5233 
5235  d_append_string(dpi, "global destructors keyed to ");
5236  d_print_comp(dpi, options, dc->u.s_binary.left);
5237  return;
5238 
5240  d_append_string(dpi, "{lambda(");
5241  /* Generic lambda auto parms are mangled as the template type
5242  parm they are. */
5243  dpi->is_lambda_arg++;
5244  d_print_comp(dpi, options, dc->u.s_unary_num.sub);
5245  dpi->is_lambda_arg--;
5246  d_append_string(dpi, ")#");
5247  d_append_num(dpi, dc->u.s_unary_num.num + 1);
5248  d_append_char(dpi, '}');
5249  return;
5250 
5252  d_append_string(dpi, "{unnamed type#");
5253  d_append_num(dpi, dc->u.s_number.number + 1);
5254  d_append_char(dpi, '}');
5255  return;
5256 
5258  d_print_comp(dpi, options, d_left(dc));
5259  d_append_string(dpi, " [clone ");
5260  d_print_comp(dpi, options, d_right(dc));
5261  d_append_char(dpi, ']');
5262  return;
5263 
5264  default:
5265  d_print_error(dpi);
5266  return;
5267  }
5268 }
static void d_save_scope(struct d_print_info *dpi, const struct demangle_component *container)
Definition: cp-demangle.c:4168
static void d_print_array_type(struct d_print_info *, int, struct demangle_component *, struct d_print_mod *)
Definition: cp-demangle.c:5573
static void d_print_mod(struct d_print_info *, int, struct demangle_component *)
Definition: cp-demangle.c:5413
static int d_args_length(struct d_print_info *dpi, const struct demangle_component *dc)
Definition: cp-demangle.c:4133
static void d_print_function_type(struct d_print_info *, int, struct demangle_component *, struct d_print_mod *)
Definition: cp-demangle.c:5501
static void d_print_java_identifier(struct d_print_info *, const char *, int)
Definition: cp-demangle.c:5299
static struct d_saved_scope * d_get_saved_scope(struct d_print_info *dpi, const struct demangle_component *container)
Definition: cp-demangle.c:4205
static int d_maybe_print_fold_expression(struct d_print_info *dpi, int options, struct demangle_component *dc)
Definition: cp-demangle.c:4220
static void d_print_conversion(struct d_print_info *, int, struct demangle_component *)
Definition: cp-demangle.c:5640
static char d_last_char(struct d_print_info *)
Definition: cp-demangle.c:3953
static void d_print_cast(struct d_print_info *, int, struct demangle_component *)
Definition: cp-demangle.c:5632
static void d_append_num(struct d_print_info *dpi, int l)
Definition: cp-demangle.c:3946
d_builtin_type_print
Definition: cp-demangle.h:52
@ D_PRINT_FLOAT
Definition: cp-demangle.h:70
@ D_PRINT_LONG
Definition: cp-demangle.h:60
@ D_PRINT_BOOL
Definition: cp-demangle.h:68
@ D_PRINT_UNSIGNED_LONG
Definition: cp-demangle.h:62
@ D_PRINT_INT
Definition: cp-demangle.h:56
@ D_PRINT_UNSIGNED
Definition: cp-demangle.h:58
@ D_PRINT_UNSIGNED_LONG_LONG
Definition: cp-demangle.h:66
@ D_PRINT_LONG_LONG
Definition: cp-demangle.h:64
int mod(int a, int b)
Definition: crypto_rot.c:8
#define DMGL_RET_POSTFIX
Definition: demangle.h:48
#define DMGL_RET_DROP
Definition: demangle.h:49
const struct demangle_component * current_template
Definition: cp-demangle.c:362
unsigned long int flush_count
Definition: cp-demangle.c:346
struct d_print_mod * modifiers
Definition: cp-demangle.c:333
struct demangle_component * mod
Definition: cp-demangle.c:261
struct d_print_mod * next
Definition: cp-demangle.c:259
struct d_print_template * next
Definition: cp-demangle.c:249
struct d_print_template * templates
Definition: cp-demangle.c:298
struct demangle_component::@376::@378 s_operator
struct demangle_component::@376::@387 s_binary
struct demangle_component::@376::@386 s_character

References a, d_print_info::buf, op::code, d_print_info::component_stack, cplus_demangle_builtin_types, d_print_info::current_template, d_append_buffer(), d_append_char(), d_append_num(), d_append_string(), d_args_length(), d_find_pack(), d_get_saved_scope(), d_index_template_argument(), d_last_char(), d_left, d_lookup_template_argument(), d_maybe_print_fold_expression(), d_pack_length(), d_print_array_type(), D_PRINT_BOOL, d_print_cast(), d_print_comp(), d_print_conversion(), D_PRINT_DEFAULT, d_print_error(), d_print_expr_op(), D_PRINT_FLOAT, d_print_flush(), d_print_function_type(), D_PRINT_INT, d_print_java_identifier(), D_PRINT_LONG, D_PRINT_LONG_LONG, d_print_mod(), d_print_saw_error(), d_print_subexpr(), D_PRINT_UNSIGNED, D_PRINT_UNSIGNED_LONG, D_PRINT_UNSIGNED_LONG_LONG, d_right, d_save_scope(), d_component_stack::dc, DEMANGLE_COMPONENT_ARGLIST, DEMANGLE_COMPONENT_ARRAY_TYPE, DEMANGLE_COMPONENT_BINARY, DEMANGLE_COMPONENT_BINARY_ARGS, DEMANGLE_COMPONENT_BUILTIN_TYPE, DEMANGLE_COMPONENT_CAST, DEMANGLE_COMPONENT_CHARACTER, DEMANGLE_COMPONENT_CLONE, DEMANGLE_COMPONENT_COMPLEX, DEMANGLE_COMPONENT_COMPOUND_NAME, DEMANGLE_COMPONENT_CONST, DEMANGLE_COMPONENT_CONSTRUCTION_VTABLE, DEMANGLE_COMPONENT_CONVERSION, DEMANGLE_COMPONENT_COVARIANT_THUNK, DEMANGLE_COMPONENT_CTOR, DEMANGLE_COMPONENT_DECLTYPE, DEMANGLE_COMPONENT_DEFAULT_ARG, DEMANGLE_COMPONENT_DTOR, DEMANGLE_COMPONENT_EXTENDED_OPERATOR, DEMANGLE_COMPONENT_FIXED_TYPE, DEMANGLE_COMPONENT_FUNCTION_PARAM, DEMANGLE_COMPONENT_FUNCTION_TYPE, DEMANGLE_COMPONENT_GLOBAL_CONSTRUCTORS, DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS, DEMANGLE_COMPONENT_GUARD, DEMANGLE_COMPONENT_HIDDEN_ALIAS, DEMANGLE_COMPONENT_IMAGINARY, DEMANGLE_COMPONENT_INITIALIZER_LIST, DEMANGLE_COMPONENT_JAVA_CLASS, DEMANGLE_COMPONENT_JAVA_RESOURCE, DEMANGLE_COMPONENT_LAMBDA, DEMANGLE_COMPONENT_LITERAL, DEMANGLE_COMPONENT_LITERAL_NEG, DEMANGLE_COMPONENT_LOCAL_NAME, DEMANGLE_COMPONENT_NAME, DEMANGLE_COMPONENT_NONTRANSACTION_CLONE, DEMANGLE_COMPONENT_NULLARY, DEMANGLE_COMPONENT_NUMBER, DEMANGLE_COMPONENT_OPERATOR, DEMANGLE_COMPONENT_PACK_EXPANSION, DEMANGLE_COMPONENT_POINTER, DEMANGLE_COMPONENT_PTRMEM_TYPE, DEMANGLE_COMPONENT_QUAL_NAME, DEMANGLE_COMPONENT_REFERENCE, DEMANGLE_COMPONENT_REFTEMP, DEMANGLE_COMPONENT_RESTRICT, DEMANGLE_COMPONENT_RVALUE_REFERENCE, DEMANGLE_COMPONENT_SUB_STD, DEMANGLE_COMPONENT_TAGGED_NAME, DEMANGLE_COMPONENT_TEMPLATE, DEMANGLE_COMPONENT_TEMPLATE_ARGLIST, DEMANGLE_COMPONENT_TEMPLATE_PARAM, DEMANGLE_COMPONENT_THUNK, DEMANGLE_COMPONENT_TLS_INIT, DEMANGLE_COMPONENT_TLS_WRAPPER, DEMANGLE_COMPONENT_TPARM_OBJ, DEMANGLE_COMPONENT_TRANSACTION_CLONE, DEMANGLE_COMPONENT_TRINARY, DEMANGLE_COMPONENT_TRINARY_ARG1, DEMANGLE_COMPONENT_TRINARY_ARG2, DEMANGLE_COMPONENT_TYPED_NAME, DEMANGLE_COMPONENT_TYPEINFO, DEMANGLE_COMPONENT_TYPEINFO_FN, DEMANGLE_COMPONENT_TYPEINFO_NAME, DEMANGLE_COMPONENT_UNARY, DEMANGLE_COMPONENT_UNNAMED_TYPE, DEMANGLE_COMPONENT_VECTOR_TYPE, DEMANGLE_COMPONENT_VENDOR_TYPE, DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL, DEMANGLE_COMPONENT_VIRTUAL_THUNK, DEMANGLE_COMPONENT_VOLATILE, DEMANGLE_COMPONENT_VTABLE, DEMANGLE_COMPONENT_VTT, DMGL_JAVA, DMGL_RET_DROP, DMGL_RET_POSTFIX, d_print_info::flush_count, FNQUAL_COMPONENT_CASE, i, is_fnqual_component_type(), d_print_info::is_lambda_arg, IS_LOWER, len, d_print_info::len, list(), mod(), d_print_mod::mod, d_print_info::modifiers, d_print_template::next, d_print_mod::next, NULL, num, op_is_new_cast(), options, d_print_info::pack_index, d_component_stack::parent, d_print_mod::printed, demangle_component::s_binary, demangle_component::s_builtin, demangle_component::s_character, demangle_component::s_ctor, demangle_component::s_dtor, demangle_component::s_extended_operator, demangle_component::s_fixed, demangle_component::s_name, demangle_component::s_number, demangle_component::s_operator, demangle_component::s_string, demangle_component::s_unary_num, demangle_component::sub, d_print_template::template_decl, d_print_mod::templates, d_saved_scope::templates, d_print_info::templates, type, demangle_component::type, and demangle_component::u.

Referenced by d_print_comp().

◆ d_print_conversion()

static void d_print_conversion ( struct d_print_info dpi,
int  options,
struct demangle_component dc 
)
static

Definition at line 5640 of file cp-demangle.c.

5641  {
5642  struct d_print_template dpt = { 0 };
5643 
5644  /* For a conversion operator, we need the template parameters from
5645  the enclosing template in scope for processing the type. */
5646  if (dpi->current_template != NULL) {
5647  dpt.next = dpi->templates;
5648  dpi->templates = &dpt;
5649  dpt.template_decl = dpi->current_template;
5650  }
5651 
5652  if (d_left(dc)->type != DEMANGLE_COMPONENT_TEMPLATE) {
5653  d_print_comp(dpi, options, d_left(dc));
5654  if (dpi->current_template != NULL)
5655  dpi->templates = dpt.next;
5656  } else {
5657  d_print_comp(dpi, options, d_left(d_left(dc)));
5658 
5659  /* For a templated cast operator, we need to remove the template
5660  parameters from scope after printing the operator name,
5661  so we need to handle the template printing here. */
5662  if (dpi->current_template != NULL)
5663  dpi->templates = dpt.next;
5664 
5665  if (d_last_char(dpi) == '<')
5666  d_append_char(dpi, ' ');
5667  d_append_char(dpi, '<');
5668  d_print_comp(dpi, options, d_right(d_left(dc)));
5669  /* Avoid generating two consecutive '>' characters, to avoid
5670  the C++ syntactic ambiguity. */
5671  if (d_last_char(dpi) == '>')
5672  d_append_char(dpi, ' ');
5673  d_append_char(dpi, '>');
5674  }
5675 }

References d_print_info::current_template, d_append_char(), d_last_char(), d_left, d_print_comp(), d_right, DEMANGLE_COMPONENT_TEMPLATE, d_print_template::next, NULL, options, d_print_template::template_decl, d_print_info::templates, and type.

Referenced by d_print_comp_inner().

◆ d_print_error()

static void d_print_error ( struct d_print_info dpi)
inlinestatic

Definition at line 3902 of file cp-demangle.c.

3902  {
3903  dpi->demangle_failure = 1;
3904 }
int demangle_failure
Definition: cp-demangle.c:335

References d_print_info::demangle_failure.

Referenced by d_lookup_template_argument(), d_print_comp(), d_print_comp_inner(), and d_save_scope().

◆ d_print_expr_op()

static void d_print_expr_op ( struct d_print_info dpi,
int  options,
struct demangle_component dc 
)
static

Definition at line 5620 of file cp-demangle.c.

5621  {
5622  if (dc->type == DEMANGLE_COMPONENT_OPERATOR)
5623  d_append_buffer(dpi, dc->u.s_operator.op->name,
5624  dc->u.s_operator.op->len);
5625  else
5626  d_print_comp(dpi, options, dc);
5627 }

References d_append_buffer(), d_print_comp(), DEMANGLE_COMPONENT_OPERATOR, options, demangle_component::s_operator, demangle_component::type, and demangle_component::u.

Referenced by d_maybe_print_fold_expression(), and d_print_comp_inner().

◆ d_print_flush()

static void d_print_flush ( struct d_print_info dpi)
inlinestatic

Definition at line 3914 of file cp-demangle.c.

3914  {
3915  dpi->buf[dpi->len] = '\0';
3916  dpi->callback(dpi->buf, dpi->len, dpi->opaque);
3917  dpi->len = 0;
3918  dpi->flush_count++;
3919 }

References d_print_info::buf, d_print_info::callback, d_print_info::flush_count, d_print_info::len, and d_print_info::opaque.

Referenced by cplus_demangle_print_callback(), d_append_char(), and d_print_comp_inner().

◆ d_print_function_type()

static void d_print_function_type ( struct d_print_info dpi,
int  options,
struct demangle_component dc,
struct d_print_mod mods 
)
static

Definition at line 5501 of file cp-demangle.c.

5503  {
5504  int need_paren;
5505  int need_space;
5506  struct d_print_mod *p;
5507  struct d_print_mod *hold_modifiers;
5508 
5509  need_paren = 0;
5510  need_space = 0;
5511  for (p = mods; p != NULL; p = p->next) {
5512  if (p->printed)
5513  break;
5514 
5515  switch (p->mod->type) {
5519  need_paren = 1;
5520  break;
5528  need_space = 1;
5529  need_paren = 1;
5530  break;
5532  break;
5533  default:
5534  break;
5535  }
5536  if (need_paren)
5537  break;
5538  }
5539 
5540  if (need_paren) {
5541  if (!need_space) {
5542  if (d_last_char(dpi) != '(' && d_last_char(dpi) != '*')
5543  need_space = 1;
5544  }
5545  if (need_space && d_last_char(dpi) != ' ')
5546  d_append_char(dpi, ' ');
5547  d_append_char(dpi, '(');
5548  }
5549 
5550  hold_modifiers = dpi->modifiers;
5551  dpi->modifiers = NULL;
5552 
5553  d_print_mod_list(dpi, options, mods, 0);
5554 
5555  if (need_paren)
5556  d_append_char(dpi, ')');
5557 
5558  d_append_char(dpi, '(');
5559 
5560  if (d_right(dc) != NULL)
5561  d_print_comp(dpi, options, d_right(dc));
5562 
5563  d_append_char(dpi, ')');
5564 
5565  d_print_mod_list(dpi, options, mods, 1);
5566 
5567  dpi->modifiers = hold_modifiers;
5568 }

References d_append_char(), d_last_char(), d_print_comp(), d_print_mod_list(), d_right, DEMANGLE_COMPONENT_COMPLEX, DEMANGLE_COMPONENT_CONST, DEMANGLE_COMPONENT_IMAGINARY, DEMANGLE_COMPONENT_POINTER, DEMANGLE_COMPONENT_PTRMEM_TYPE, DEMANGLE_COMPONENT_REFERENCE, DEMANGLE_COMPONENT_RESTRICT, DEMANGLE_COMPONENT_RVALUE_REFERENCE, DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL, DEMANGLE_COMPONENT_VOLATILE, FNQUAL_COMPONENT_CASE, d_print_info::modifiers, NULL, options, and p.

Referenced by d_print_comp_inner(), and d_print_mod_list().

◆ d_print_init()

static void d_print_init ( struct d_print_info dpi,
demangle_callbackref  callback,
void *  opaque,
const struct demangle_component dc 
)
static

Definition at line 3866 of file cp-demangle.c.

3867  {
3868  dpi->len = 0;
3869  dpi->last_char = '\0';
3870  dpi->templates = NULL;
3871  dpi->modifiers = NULL;
3872  dpi->pack_index = 0;
3873  dpi->flush_count = 0;
3874 
3875  dpi->callback = callback;
3876  dpi->opaque = opaque;
3877 
3878  dpi->demangle_failure = 0;
3879  dpi->recursion = 0;
3880  dpi->is_lambda_arg = 0;
3881 
3882  dpi->component_stack = NULL;
3883 
3884  dpi->saved_scopes = NULL;
3885  dpi->next_saved_scope = 0;
3886  dpi->num_saved_scopes = 0;
3887 
3888  dpi->copy_templates = NULL;
3889  dpi->next_copy_template = 0;
3890  dpi->num_copy_templates = 0;
3891 
3893  &dpi->num_saved_scopes, dc);
3894  dpi->num_copy_templates *= dpi->num_saved_scopes;
3895 
3896  dpi->current_template = NULL;
3897 }
int num_saved_scopes
Definition: cp-demangle.c:354
struct d_print_template * copy_templates
Definition: cp-demangle.c:356
int next_copy_template
Definition: cp-demangle.c:358
int num_copy_templates
Definition: cp-demangle.c:360

References d_print_info::callback, d_print_info::component_stack, d_print_info::copy_templates, d_print_info::current_template, d_count_templates_scopes(), d_print_info::demangle_failure, d_print_info::flush_count, d_print_info::is_lambda_arg, d_print_info::last_char, d_print_info::len, d_print_info::modifiers, d_print_info::next_copy_template, d_print_info::next_saved_scope, NULL, d_print_info::num_copy_templates, d_print_info::num_saved_scopes, d_print_info::opaque, d_print_info::pack_index, d_print_info::recursion, d_print_info::saved_scopes, and d_print_info::templates.

Referenced by cplus_demangle_print_callback().

◆ d_print_java_identifier()

static void d_print_java_identifier ( struct d_print_info dpi,
const char *  name,
int  len 
)
static

Definition at line 5299 of file cp-demangle.c.

5299  {
5300  const char *p;
5301  const char *end;
5302 
5303  end = name + len;
5304  for (p = name; p < end; ++p) {
5305  if (end - p > 3 && p[0] == '_' && p[1] == '_' && p[2] == 'U') {
5306  unsigned long c;
5307  const char *q;
5308 
5309  c = 0;
5310  for (q = p + 3; q < end; ++q) {
5311  int dig;
5312 
5313  if (IS_DIGIT(*q))
5314  dig = *q - '0';
5315  else if (*q >= 'A' && *q <= 'F')
5316  dig = *q - 'A' + 10;
5317  else if (*q >= 'a' && *q <= 'f')
5318  dig = *q - 'a' + 10;
5319  else
5320  break;
5321 
5322  c = c * 16 + dig;
5323  }
5324  /* If the Unicode character is larger than 256, we don't try
5325  to deal with it here. FIXME. */
5326  if (q < end && *q == '_' && c < 256) {
5327  d_append_char(dpi, c);
5328  p = q;
5329  continue;
5330  }
5331  }
5332 
5333  d_append_char(dpi, *p);
5334  }
5335 }

References c, d_append_char(), test_evm::end, IS_DIGIT, len, and p.

Referenced by d_print_comp_inner().

◆ d_print_mod()

static void d_print_mod ( struct d_print_info dpi,
int  options,
struct demangle_component mod 
)
static

Definition at line 5413 of file cp-demangle.c.

5414  {
5415  switch (mod->type) {
5418  d_append_string(dpi, " restrict");
5419  return;
5422  d_append_string(dpi, " volatile");
5423  return;
5426  d_append_string(dpi, " const");
5427  return;
5429  d_append_string(dpi, " transaction_safe");
5430  return;
5432  d_append_string(dpi, " noexcept");
5433  if (d_right(mod)) {
5434  d_append_char(dpi, '(');
5435  d_print_comp(dpi, options, d_right(mod));
5436  d_append_char(dpi, ')');
5437  }
5438  return;
5440  d_append_string(dpi, " throw");
5441  if (d_right(mod)) {
5442  d_append_char(dpi, '(');
5443  d_print_comp(dpi, options, d_right(mod));
5444  d_append_char(dpi, ')');
5445  }
5446  return;
5448  d_append_char(dpi, ' ');
5449  d_print_comp(dpi, options, d_right(mod));
5450  return;
5452  /* There is no pointer symbol in Java. */
5453  if ((options & DMGL_JAVA) == 0)
5454  d_append_char(dpi, '*');
5455  return;
5457  /* For the ref-qualifier, put a space before the &. */
5458  d_append_char(dpi, ' ');
5459  /* FALLTHRU */
5461  d_append_char(dpi, '&');
5462  return;
5464  d_append_char(dpi, ' ');
5465  /* FALLTHRU */
5467  d_append_string(dpi, "&&");
5468  return;
5470  d_append_string(dpi, "complex ");
5471  return;
5473  d_append_string(dpi, "imaginary ");
5474  return;
5476  if (d_last_char(dpi) != '(')
5477  d_append_char(dpi, ' ');
5478  d_print_comp(dpi, options, d_left(mod));
5479  d_append_string(dpi, "::*");
5480  return;
5482  d_print_comp(dpi, options, d_left(mod));
5483  return;
5485  d_append_string(dpi, " __vector(");
5486  d_print_comp(dpi, options, d_left(mod));
5487  d_append_char(dpi, ')');
5488  return;
5489 
5490  default:
5491  /* Otherwise, we have something that won't go back on the
5492  modifier stack, so we can just print it. */
5493  d_print_comp(dpi, options, mod);
5494  return;
5495  }
5496 }

References d_append_char(), d_append_string(), d_last_char(), d_left, d_print_comp(), d_right, DEMANGLE_COMPONENT_COMPLEX, DEMANGLE_COMPONENT_CONST, DEMANGLE_COMPONENT_CONST_THIS, DEMANGLE_COMPONENT_IMAGINARY, DEMANGLE_COMPONENT_NOEXCEPT, DEMANGLE_COMPONENT_POINTER, DEMANGLE_COMPONENT_PTRMEM_TYPE, DEMANGLE_COMPONENT_REFERENCE, DEMANGLE_COMPONENT_REFERENCE_THIS, DEMANGLE_COMPONENT_RESTRICT, DEMANGLE_COMPONENT_RESTRICT_THIS, DEMANGLE_COMPONENT_RVALUE_REFERENCE, DEMANGLE_COMPONENT_RVALUE_REFERENCE_THIS, DEMANGLE_COMPONENT_THROW_SPEC, DEMANGLE_COMPONENT_TRANSACTION_SAFE, DEMANGLE_COMPONENT_TYPED_NAME, DEMANGLE_COMPONENT_VECTOR_TYPE, DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL, DEMANGLE_COMPONENT_VOLATILE, DEMANGLE_COMPONENT_VOLATILE_THIS, DMGL_JAVA, mod(), and options.

Referenced by d_print_comp_inner(), and d_print_mod_list().

◆ d_print_mod_list()

static void d_print_mod_list ( struct d_print_info dpi,
int  options,
struct d_print_mod mods,
int  suffix 
)
static

Definition at line 5341 of file cp-demangle.c.

5342  {
5343  struct d_print_template *hold_dpt;
5344 
5345  if (mods == NULL || d_print_saw_error(dpi))
5346  return;
5347 
5348  if (mods->printed || (!suffix && (is_fnqual_component_type(mods->mod->type)))) {
5349  d_print_mod_list(dpi, options, mods->next, suffix);
5350  return;
5351  }
5352 
5353  mods->printed = 1;
5354 
5355  hold_dpt = dpi->templates;
5356  dpi->templates = mods->templates;
5357 
5358  if (mods->mod->type == DEMANGLE_COMPONENT_FUNCTION_TYPE) {
5359  d_print_function_type(dpi, options, mods->mod, mods->next);
5360  dpi->templates = hold_dpt;
5361  return;
5362  } else if (mods->mod->type == DEMANGLE_COMPONENT_ARRAY_TYPE) {
5363  d_print_array_type(dpi, options, mods->mod, mods->next);
5364  dpi->templates = hold_dpt;
5365  return;
5366  } else if (mods->mod->type == DEMANGLE_COMPONENT_LOCAL_NAME) {
5367  struct d_print_mod *hold_modifiers;
5368  struct demangle_component *dc;
5369 
5370  /* When this is on the modifier stack, we have pulled any
5371  qualifiers off the right argument already. Otherwise, we
5372  print it as usual, but don't let the left argument see any
5373  modifiers. */
5374 
5375  hold_modifiers = dpi->modifiers;
5376  dpi->modifiers = NULL;
5377  d_print_comp(dpi, options, d_left(mods->mod));
5378  dpi->modifiers = hold_modifiers;
5379 
5380  if ((options & DMGL_JAVA) == 0)
5381  d_append_string(dpi, "::");
5382  else
5383  d_append_char(dpi, '.');
5384 
5385  dc = d_right(mods->mod);
5386 
5387  if (dc->type == DEMANGLE_COMPONENT_DEFAULT_ARG) {
5388  d_append_string(dpi, "{default arg#");
5389  d_append_num(dpi, dc->u.s_unary_num.num + 1);
5390  d_append_string(dpi, "}::");
5391  dc = dc->u.s_unary_num.sub;
5392  }
5393 
5394  while (is_fnqual_component_type(dc->type))
5395  dc = d_left(dc);
5396 
5397  d_print_comp(dpi, options, dc);
5398 
5399  dpi->templates = hold_dpt;
5400  return;
5401  }
5402 
5403  d_print_mod(dpi, options, mods->mod);
5404 
5405  dpi->templates = hold_dpt;
5406 
5407  d_print_mod_list(dpi, options, mods->next, suffix);
5408 }
struct d_print_template * templates
Definition: cp-demangle.c:265

References d_append_char(), d_append_num(), d_append_string(), d_left, d_print_array_type(), d_print_comp(), d_print_function_type(), d_print_mod(), d_print_saw_error(), d_right, DEMANGLE_COMPONENT_ARRAY_TYPE, DEMANGLE_COMPONENT_DEFAULT_ARG, DEMANGLE_COMPONENT_FUNCTION_TYPE, DEMANGLE_COMPONENT_LOCAL_NAME, DMGL_JAVA, is_fnqual_component_type(), d_print_mod::mod, d_print_info::modifiers, d_print_mod::next, NULL, options, d_print_mod::printed, demangle_component::s_unary_num, suffix, d_print_mod::templates, d_print_info::templates, demangle_component::type, and demangle_component::u.

Referenced by d_print_array_type(), and d_print_function_type().

◆ d_print_saw_error()

static int d_print_saw_error ( struct d_print_info dpi)
inlinestatic

Definition at line 3907 of file cp-demangle.c.

3907  {
3908  return dpi->demangle_failure != 0;
3909 }

References d_print_info::demangle_failure.

Referenced by cplus_demangle_print_callback(), d_print_comp_inner(), and d_print_mod_list().

◆ d_print_subexpr()

static void d_print_subexpr ( struct d_print_info dpi,
int  options,
struct demangle_component dc 
)
static

Definition at line 4153 of file cp-demangle.c.

4154  {
4155  int simple = 0;
4157  simple = 1;
4158  if (!simple)
4159  d_append_char(dpi, '(');
4160  d_print_comp(dpi, options, dc);
4161  if (!simple)
4162  d_append_char(dpi, ')');
4163 }

References d_append_char(), d_print_comp(), DEMANGLE_COMPONENT_FUNCTION_PARAM, DEMANGLE_COMPONENT_INITIALIZER_LIST, DEMANGLE_COMPONENT_NAME, DEMANGLE_COMPONENT_QUAL_NAME, options, and demangle_component::type.

Referenced by d_maybe_print_fold_expression(), and d_print_comp_inner().

◆ d_ref_qualifier()

static struct demangle_component * d_ref_qualifier ( struct d_info di,
struct demangle_component sub 
)
static

Definition at line 2645 of file cp-demangle.c.

2645  {
2646  struct demangle_component *ret = sub;
2647  char peek;
2648 
2649  peek = d_peek_char(di);
2650  if (peek == 'R' || peek == 'O') {
2651  enum demangle_component_type t;
2652  if (peek == 'R') {
2654  di->expansion += sizeof "&";
2655  } else {
2657  di->expansion += sizeof "&&";
2658  }
2659  d_advance(di, 1);
2660 
2661  ret = d_make_comp(di, t, ret, NULL);
2662  }
2663 
2664  return ret;
2665 }

References d_advance, d_make_comp(), d_peek_char, DEMANGLE_COMPONENT_REFERENCE_THIS, DEMANGLE_COMPONENT_RVALUE_REFERENCE_THIS, d_info::expansion, NULL, and demangle_component::sub.

Referenced by d_function_type(), and d_nested_name().

◆ d_save_scope()

static void d_save_scope ( struct d_print_info dpi,
const struct demangle_component container 
)
static

Definition at line 4168 of file cp-demangle.c.

4169  {
4170  struct d_saved_scope *scope;
4171  struct d_print_template *src, **link;
4172 
4173  if (dpi->next_saved_scope >= dpi->num_saved_scopes) {
4174  d_print_error(dpi);
4175  return;
4176  }
4177  scope = &dpi->saved_scopes[dpi->next_saved_scope];
4178  dpi->next_saved_scope++;
4179 
4180  scope->container = container;
4181  link = &scope->templates;
4182 
4183  for (src = dpi->templates; src != NULL; src = src->next) {
4184  struct d_print_template *dst;
4185 
4186  if (dpi->next_copy_template >= dpi->num_copy_templates) {
4187  d_print_error(dpi);
4188  return;
4189  }
4190  dst = &dpi->copy_templates[dpi->next_copy_template];
4191  dpi->next_copy_template++;
4192 
4193  dst->template_decl = src->template_decl;
4194  *link = dst;
4195  link = &dst->next;
4196  }
4197 
4198  *link = NULL;
4199 }
lzma_index * src
Definition: index.h:567
static static fork const void static count static fd link
Definition: sflib.h:33
char * dst
Definition: lz4.h:724

References d_saved_scope::container, d_print_info::copy_templates, d_print_error(), dst, link, d_print_info::next_copy_template, d_print_info::next_saved_scope, NULL, d_print_info::num_copy_templates, d_print_info::num_saved_scopes, d_print_info::saved_scopes, src, d_saved_scope::templates, and d_print_info::templates.

Referenced by d_print_comp_inner().

◆ d_source_name()

static struct demangle_component * d_source_name ( struct d_info di)
static

Definition at line 1566 of file cp-demangle.c.

1566  {
1567  int len;
1568  struct demangle_component *ret;
1569 
1570  len = d_number(di);
1571  if (len <= 0)
1572  return NULL;
1573  ret = d_identifier(di, len);
1574  di->last_name = ret;
1575  return ret;
1576 }
static struct demangle_component * d_identifier(struct d_info *, int)
Definition: cp-demangle.c:1624

References d_identifier(), d_number(), d_info::last_name, len, and NULL.

Referenced by cplus_demangle_type(), d_abi_tags(), d_operator_name(), and d_unqualified_name().

◆ d_special_name()

static struct demangle_component * d_special_name ( struct d_info di)
static

Definition at line 1894 of file cp-demangle.c.

1894  {
1895  di->expansion += 20;
1896  if (d_check_char(di, 'T')) {
1897  switch (d_next_char(di)) {
1898  case 'V':
1899  di->expansion -= 5;
1901  cplus_demangle_type(di), NULL);
1902  case 'T':
1903  di->expansion -= 10;
1905  cplus_demangle_type(di), NULL);
1906  case 'I':
1908  cplus_demangle_type(di), NULL);
1909  case 'S':
1911  cplus_demangle_type(di), NULL);
1912 
1913  case 'h':
1914  if (!d_call_offset(di, 'h'))
1915  return NULL;
1917  d_encoding(di, 0), NULL);
1918 
1919  case 'v':
1920  if (!d_call_offset(di, 'v'))
1921  return NULL;
1923  d_encoding(di, 0), NULL);
1924 
1925  case 'c':
1926  if (!d_call_offset(di, '\0'))
1927  return NULL;
1928  if (!d_call_offset(di, '\0'))
1929  return NULL;
1931  d_encoding(di, 0), NULL);
1932 
1933  case 'C': {
1934  struct demangle_component *derived_type;
1935  int offset;
1936  struct demangle_component *base_type;
1937 
1938  derived_type = cplus_demangle_type(di);
1939  offset = d_number(di);
1940  if (offset < 0)
1941  return NULL;
1942  if (!d_check_char(di, '_'))
1943  return NULL;
1944  base_type = cplus_demangle_type(di);
1945  /* We don't display the offset. FIXME: We should display
1946  it in verbose mode. */
1947  di->expansion += 5;
1949  base_type, derived_type);
1950  }
1951 
1952  case 'F':
1954  cplus_demangle_type(di), NULL);
1955  case 'J':
1957  cplus_demangle_type(di), NULL);
1958 
1959  case 'H':
1961  d_name(di), NULL);
1962 
1963  case 'W':
1965  d_name(di), NULL);
1966 
1967  case 'A':
1969  d_template_arg(di), NULL);
1970 
1971  default:
1972  return NULL;
1973  }
1974  } else if (d_check_char(di, 'G')) {
1975  switch (d_next_char(di)) {
1976  case 'V':
1978  d_name(di), NULL);
1979 
1980  case 'R': {
1981  struct demangle_component *name = d_name(di);
1983  d_number_component(di));
1984  }
1985 
1986  case 'A':
1988  d_encoding(di, 0), NULL);
1989 
1990  case 'T':
1991  switch (d_next_char(di)) {
1992  case 'n':
1994  d_encoding(di, 0), NULL);
1995  default:
1996  /* ??? The proposal is that other letters (such as 'h') stand
1997  for different variants of transaction cloning, such as
1998  compiling directly for hardware transaction support. But
1999  they still should all be transactional clones of some sort
2000  so go ahead and call them that. */
2001  case 't':
2003  d_encoding(di, 0), NULL);
2004  }
2005 
2006  case 'r':
2007  return d_java_resource(di);
2008 
2009  default:
2010  return NULL;
2011  }
2012  } else
2013  return NULL;
2014 }
static struct demangle_component * d_template_arg(struct d_info *)
Definition: cp-demangle.c:2964
static int d_call_offset(struct d_info *, int)
Definition: cp-demangle.c:2030
static struct demangle_component * d_java_resource(struct d_info *di)
Definition: cp-demangle.c:1798
static struct demangle_component * d_number_component(struct d_info *di)
Definition: cp-demangle.c:1612
voidpf uLong offset
Definition: ioapi.h:144

References cplus_demangle_type(), d_call_offset(), d_check_char, d_encoding(), d_java_resource(), d_make_comp(), d_name(), d_next_char, d_number(), d_number_component(), d_template_arg(), DEMANGLE_COMPONENT_CONSTRUCTION_VTABLE, DEMANGLE_COMPONENT_COVARIANT_THUNK, DEMANGLE_COMPONENT_GUARD, DEMANGLE_COMPONENT_HIDDEN_ALIAS, DEMANGLE_COMPONENT_JAVA_CLASS, DEMANGLE_COMPONENT_NONTRANSACTION_CLONE, DEMANGLE_COMPONENT_REFTEMP, DEMANGLE_COMPONENT_THUNK, DEMANGLE_COMPONENT_TLS_INIT, DEMANGLE_COMPONENT_TLS_WRAPPER, DEMANGLE_COMPONENT_TPARM_OBJ, DEMANGLE_COMPONENT_TRANSACTION_CLONE, DEMANGLE_COMPONENT_TYPEINFO, DEMANGLE_COMPONENT_TYPEINFO_FN, DEMANGLE_COMPONENT_TYPEINFO_NAME, DEMANGLE_COMPONENT_VIRTUAL_THUNK, DEMANGLE_COMPONENT_VTABLE, DEMANGLE_COMPONENT_VTT, d_info::expansion, and NULL.

Referenced by d_encoding().

◆ d_substitution()

static struct demangle_component * d_substitution ( struct d_info di,
int  prefix 
)
static

Definition at line 3557 of file cp-demangle.c.

3557  {
3558  char c;
3559 
3560  if (!d_check_char(di, 'S'))
3561  return NULL;
3562 
3563  c = d_next_char(di);
3564  if (c == '_' || IS_DIGIT(c) || IS_UPPER(c)) {
3565  unsigned int id;
3566 
3567  id = 0;
3568  if (c != '_') {
3569  do {
3570  unsigned int new_id;
3571 
3572  if (IS_DIGIT(c))
3573  new_id = id * 36 + c - '0';
3574  else if (IS_UPPER(c))
3575  new_id = id * 36 + c - 'A' + 10;
3576  else
3577  return NULL;
3578  if (new_id < id)
3579  return NULL;
3580  id = new_id;
3581  c = d_next_char(di);
3582  } while (c != '_');
3583 
3584  ++id;
3585  }
3586 
3587  if (id >= (unsigned int)di->next_sub)
3588  return NULL;
3589 
3590  return di->subs[id];
3591  } else {
3592  int verbose;
3593  const struct d_standard_sub_info *p;
3594  const struct d_standard_sub_info *pend;
3595 
3596  verbose = (di->options & DMGL_VERBOSE) != 0;
3597  if (!verbose && prefix) {
3598  char peek;
3599 
3600  peek = d_peek_char(di);
3601  if (peek == 'C' || peek == 'D')
3602  verbose = 1;
3603  }
3604 
3605  pend = (&standard_subs[0] + sizeof standard_subs / sizeof standard_subs[0]);
3606  for (p = &standard_subs[0]; p < pend; ++p) {
3607  if (c == p->code) {
3608  const char *s;
3609  int len;
3610  struct demangle_component *dc;
3611 
3612  if (p->set_last_name != NULL)
3613  di->last_name = d_make_sub(di, p->set_last_name,
3614  p->set_last_name_len);
3615  if (verbose) {
3616  s = p->full_expansion;
3617  len = p->full_len;
3618  } else {
3619  s = p->simple_expansion;
3620  len = p->simple_len;
3621  }
3622  di->expansion += len;
3623  dc = d_make_sub(di, s, len);
3624  if (d_peek_char(di) == 'B') {
3625  /* If there are ABI tags on the abbreviation, it becomes
3626  a substitution candidate. */
3627  dc = d_abi_tags(di, dc);
3628  if (!d_add_substitution(di, dc))
3629  return NULL;
3630  }
3631  return dc;
3632  }
3633  }
3634 
3635  return NULL;
3636  }
3637 }
static struct demangle_component * d_make_sub(struct d_info *, const char *, int)
Definition: cp-demangle.c:1152
static const struct d_standard_sub_info standard_subs[]
Definition: cp-demangle.c:3532
static struct demangle_component * d_abi_tags(struct d_info *di, struct demangle_component *dc)
Definition: cp-demangle.c:1300
#define DMGL_VERBOSE
Definition: demangle.h:46
unsigned short prefix[65536]
Definition: gun.c:163
int id
Definition: op.c:540
static int verbose
Definition: z80asm.c:73

References c, d_abi_tags(), d_add_substitution(), d_check_char, d_make_sub(), d_next_char, d_peek_char, DMGL_VERBOSE, d_info::expansion, id, IS_DIGIT, IS_UPPER, d_info::last_name, len, d_info::next_sub, NULL, d_info::options, p, prefix, s, standard_subs, d_info::subs, and verbose.

Referenced by cplus_demangle_type(), d_name(), and d_prefix().

◆ d_template_arg()

static struct demangle_component * d_template_arg ( struct d_info di)
static

Definition at line 2964 of file cp-demangle.c.

2964  {
2965  struct demangle_component *ret;
2966 
2967  switch (d_peek_char(di)) {
2968  case 'X':
2969  d_advance(di, 1);
2970  ret = d_expression(di);
2971  if (!d_check_char(di, 'E'))
2972  return NULL;
2973  return ret;
2974 
2975  case 'L':
2976  return d_expr_primary(di);
2977 
2978  case 'I':
2979  case 'J':
2980  /* An argument pack. */
2981  return d_template_args(di);
2982 
2983  default:
2984  return cplus_demangle_type(di);
2985  }
2986 }

References cplus_demangle_type(), d_advance, d_check_char, d_expr_primary(), d_expression(), d_peek_char, d_template_args(), and NULL.

Referenced by d_special_name(), and d_template_args_1().

◆ d_template_args()

static struct demangle_component * d_template_args ( struct d_info di)
static

Definition at line 2906 of file cp-demangle.c.

2906  {
2907  if (d_peek_char(di) != 'I' && d_peek_char(di) != 'J')
2908  return NULL;
2909  d_advance(di, 1);
2910 
2911  return d_template_args_1(di);
2912 }

References d_advance, d_peek_char, d_template_args_1(), and NULL.

Referenced by cplus_demangle_type(), d_expression_1(), d_name(), d_prefix(), and d_template_arg().

◆ d_template_args_1()

static struct demangle_component * d_template_args_1 ( struct d_info di)
static

Definition at line 2917 of file cp-demangle.c.

2917  {
2918  struct demangle_component *hold_last_name;
2919  struct demangle_component *al;
2920  struct demangle_component **pal;
2921 
2922  /* Preserve the last name we saw--don't let the template arguments
2923  clobber it, as that would give us the wrong name for a subsequent
2924  constructor or destructor. */
2925  hold_last_name = di->last_name;
2926 
2927  if (d_peek_char(di) == 'E') {
2928  /* An argument pack can be empty. */
2929  d_advance(di, 1);
2931  }
2932 
2933  al = NULL;
2934  pal = &al;
2935  while (1) {
2936  struct demangle_component *a;
2937 
2938  a = d_template_arg(di);
2939  if (a == NULL)
2940  return NULL;
2941 
2943  if (*pal == NULL)
2944  return NULL;
2945  pal = &d_right(*pal);
2946 
2947  if (d_peek_char(di) == 'E') {
2948  d_advance(di, 1);
2949  break;
2950  }
2951  }
2952 
2953  di->last_name = hold_last_name;
2954 
2955  return al;
2956 }

References a, al, d_advance, d_make_comp(), d_peek_char, d_right, d_template_arg(), DEMANGLE_COMPONENT_TEMPLATE_ARGLIST, d_info::last_name, and NULL.

Referenced by d_expression_1(), and d_template_args().

◆ d_template_param()

static struct demangle_component * d_template_param ( struct d_info di)
static

Definition at line 2890 of file cp-demangle.c.

2890  {
2891  int param;
2892 
2893  if (!d_check_char(di, 'T'))
2894  return NULL;
2895 
2896  param = d_compact_number(di);
2897  if (param < 0)
2898  return NULL;
2899 
2900  return d_make_template_param(di, param);
2901 }
static struct demangle_component * d_make_template_param(struct d_info *, int)
Definition: cp-demangle.c:1124

References d_check_char, d_compact_number(), d_make_template_param(), and NULL.

Referenced by cplus_demangle_type(), d_expression_1(), and d_prefix().

◆ d_unnamed_type()

static struct demangle_component * d_unnamed_type ( struct d_info di)
static

Definition at line 3451 of file cp-demangle.c.

3451  {
3452  struct demangle_component *ret;
3453  int num;
3454 
3455  if (!d_check_char(di, 'U'))
3456  return NULL;
3457  if (!d_check_char(di, 't'))
3458  return NULL;
3459 
3460  num = d_compact_number(di);
3461  if (num < 0)
3462  return NULL;
3463 
3464  ret = d_make_empty(di);
3465  if (ret) {
3467  ret->u.s_number.number = num;
3468  }
3469 
3470  if (!d_add_substitution(di, ret))
3471  return NULL;
3472 
3473  return ret;
3474 }

References d_add_substitution(), d_check_char, d_compact_number(), d_make_empty(), DEMANGLE_COMPONENT_UNNAMED_TYPE, NULL, num, demangle_component::s_number, demangle_component::type, and demangle_component::u.

Referenced by d_unqualified_name().

◆ d_unqualified_name()

static struct demangle_component * d_unqualified_name ( struct d_info di)
static

Definition at line 1517 of file cp-demangle.c.

1517  {
1518  struct demangle_component *ret;
1519  char peek;
1520 
1521  peek = d_peek_char(di);
1522  if (IS_DIGIT(peek))
1523  ret = d_source_name(di);
1524  else if (IS_LOWER(peek)) {
1525  if (peek == 'o' && d_peek_next_char(di) == 'n')
1526  d_advance(di, 2);
1527  ret = d_operator_name(di);
1528  if (ret != NULL && ret->type == DEMANGLE_COMPONENT_OPERATOR) {
1529  di->expansion += sizeof "operator" + ret->u.s_operator.op->len - 2;
1530  if (!strcmp(ret->u.s_operator.op->code, "li"))
1531  ret = d_make_comp(di, DEMANGLE_COMPONENT_UNARY, ret,
1532  d_source_name(di));
1533  }
1534  } else if (peek == 'C' || peek == 'D')
1535  ret = d_ctor_dtor_name(di);
1536  else if (peek == 'L') {
1537  d_advance(di, 1);
1538 
1539  ret = d_source_name(di);
1540  if (ret == NULL)
1541  return NULL;
1542  if (!d_discriminator(di))
1543  return NULL;
1544  } else if (peek == 'U') {
1545  switch (d_peek_next_char(di)) {
1546  case 'l':
1547  ret = d_lambda(di);
1548  break;
1549  case 't':
1550  ret = d_unnamed_type(di);
1551  break;
1552  default:
1553  return NULL;
1554  }
1555  } else
1556  return NULL;
1557 
1558  if (d_peek_char(di) == 'B')
1559  ret = d_abi_tags(di, ret);
1560  return ret;
1561 }
static struct demangle_component * d_unnamed_type(struct d_info *)
Definition: cp-demangle.c:3451
static struct demangle_component * d_ctor_dtor_name(struct d_info *)
Definition: cp-demangle.c:2059
static struct demangle_component * d_lambda(struct d_info *)
Definition: cp-demangle.c:3414

References d_abi_tags(), d_advance, d_ctor_dtor_name(), d_discriminator(), d_lambda(), d_make_comp(), d_operator_name(), d_peek_char, d_peek_next_char, d_source_name(), d_unnamed_type(), DEMANGLE_COMPONENT_OPERATOR, DEMANGLE_COMPONENT_UNARY, d_info::expansion, IS_DIGIT, IS_LOWER, NULL, demangle_component::s_operator, demangle_component::type, and demangle_component::u.

Referenced by d_expression_1(), d_name(), and d_prefix().

◆ d_vector_type()

static struct demangle_component * d_vector_type ( struct d_info di)
static

Definition at line 2811 of file cp-demangle.c.

2811  {
2812  char peek;
2813  struct demangle_component *dim;
2814 
2815  peek = d_peek_char(di);
2816  if (peek == '_') {
2817  d_advance(di, 1);
2818  dim = d_expression(di);
2819  } else
2820  dim = d_number_component(di);
2821 
2822  if (dim == NULL)
2823  return NULL;
2824 
2825  if (!d_check_char(di, '_'))
2826  return NULL;
2827 
2829  cplus_demangle_type(di));
2830 }

References cplus_demangle_type(), d_advance, d_check_char, d_expression(), d_make_comp(), d_number_component(), d_peek_char, DEMANGLE_COMPONENT_VECTOR_TYPE, and NULL.

Referenced by cplus_demangle_type().

◆ has_return_type()

static int has_return_type ( struct demangle_component dc)
static

Definition at line 1202 of file cp-demangle.c.

1202  {
1203  if (dc == NULL)
1204  return 0;
1205  switch (dc->type) {
1206  default:
1207  return 0;
1209  return has_return_type(d_right(dc));
1211  return !is_ctor_dtor_or_conversion(d_left(dc));
1213  return has_return_type(d_left(dc));
1214  }
1215 }
static int is_ctor_dtor_or_conversion(struct demangle_component *)
Definition: cp-demangle.c:1221

References d_left, d_right, DEMANGLE_COMPONENT_LOCAL_NAME, DEMANGLE_COMPONENT_TEMPLATE, FNQUAL_COMPONENT_CASE, is_ctor_dtor_or_conversion(), NULL, and demangle_component::type.

Referenced by d_bare_function_type(), and d_encoding().

◆ is_ctor_dtor_or_conversion()

static int is_ctor_dtor_or_conversion ( struct demangle_component dc)
static

Definition at line 1221 of file cp-demangle.c.

1221  {
1222  if (dc == NULL)
1223  return 0;
1224  switch (dc->type) {
1225  default:
1226  return 0;
1229  return is_ctor_dtor_or_conversion(d_right(dc));
1233  return 1;
1234  }
1235 }

References d_right, DEMANGLE_COMPONENT_CONVERSION, DEMANGLE_COMPONENT_CTOR, DEMANGLE_COMPONENT_DTOR, DEMANGLE_COMPONENT_LOCAL_NAME, DEMANGLE_COMPONENT_QUAL_NAME, NULL, and demangle_component::type.

Referenced by has_return_type().

◆ is_ctor_or_dtor()

static int is_ctor_or_dtor ( const char *  mangled,
enum gnu_v3_ctor_kinds ctor_kind,
enum gnu_v3_dtor_kinds dtor_kind 
)
static

Definition at line 5982 of file cp-demangle.c.

5984  {
5985  struct d_info di;
5986  struct demangle_component *dc;
5987  int ret;
5988 
5989  *ctor_kind = (enum gnu_v3_ctor_kinds)0;
5990  *dtor_kind = (enum gnu_v3_dtor_kinds)0;
5991 
5992  cplus_demangle_init_info(mangled, DMGL_GNU_V3, strlen(mangled), &di);
5993 
5994  {
5995 #ifdef CP_DYNAMIC_ARRAYS
5996  __extension__ struct demangle_component comps[di.num_comps];
5997  __extension__ struct demangle_component *subs[di.num_subs];
5998 
5999  di.comps = comps;
6000  di.subs = subs;
6001 #else
6002  di.comps = alloca(di.num_comps * sizeof(*di.comps));
6003  di.subs = alloca(di.num_subs * sizeof(*di.subs));
6004 #endif
6005 
6006  dc = cplus_demangle_mangled_name(&di, 1);
6007 
6008  /* Note that because we did not pass DMGL_PARAMS, we don't expect
6009  to demangle the entire string. */
6010 
6011  ret = 0;
6012  while (dc != NULL) {
6013  switch (dc->type) {
6014  /* These cannot appear on a constructor or destructor. */
6020  default:
6021  dc = NULL;
6022  break;
6025  dc = d_left(dc);
6026  break;
6029  dc = d_right(dc);
6030  break;
6032  *ctor_kind = dc->u.s_ctor.kind;
6033  ret = 1;
6034  dc = NULL;
6035  break;
6037  *dtor_kind = dc->u.s_dtor.kind;
6038  ret = 1;
6039  dc = NULL;
6040  break;
6041  }
6042  }
6043  }
6044 
6045  return ret;
6046 }
#define DMGL_GNU_V3
Definition: demangle.h:57

References __extension__, alloca(), cplus_demangle_init_info(), cplus_demangle_mangled_name(), d_left, d_right, DEMANGLE_COMPONENT_CONST_THIS, DEMANGLE_COMPONENT_CTOR, DEMANGLE_COMPONENT_DTOR, DEMANGLE_COMPONENT_LOCAL_NAME, DEMANGLE_COMPONENT_QUAL_NAME, DEMANGLE_COMPONENT_REFERENCE_THIS, DEMANGLE_COMPONENT_RESTRICT_THIS, DEMANGLE_COMPONENT_RVALUE_REFERENCE_THIS, DEMANGLE_COMPONENT_TEMPLATE, DEMANGLE_COMPONENT_TYPED_NAME, DEMANGLE_COMPONENT_VOLATILE_THIS, DMGL_GNU_V3, NULL, demangle_component::s_ctor, demangle_component::s_dtor, demangle_component::type, and demangle_component::u.

◆ is_fnqual_component_type()

static int is_fnqual_component_type ( enum demangle_component_type  type)
static

Definition at line 574 of file cp-demangle.c.

574  {
575  switch (type) {
577  return 1;
578  default:
579  break;
580  }
581  return 0;
582 }

References FNQUAL_COMPONENT_CASE, and type.

Referenced by d_encoding(), d_print_comp_inner(), and d_print_mod_list().

◆ is_gnu_v3_mangled_ctor()

enum gnu_v3_ctor_kinds is_gnu_v3_mangled_ctor ( const char *  name)

Definition at line 5982 of file cp-demangle.c.

6052  {
6053  enum gnu_v3_ctor_kinds ctor_kind;
6054  enum gnu_v3_dtor_kinds dtor_kind;
6055 
6056  if (!is_ctor_or_dtor(name, &ctor_kind, &dtor_kind))
6057  return (enum gnu_v3_ctor_kinds)0;
6058  return ctor_kind;
6059 }
static int is_ctor_or_dtor(const char *mangled, enum gnu_v3_ctor_kinds *ctor_kind, enum gnu_v3_dtor_kinds *dtor_kind)
Definition: cp-demangle.c:5982

◆ is_gnu_v3_mangled_dtor()

enum gnu_v3_dtor_kinds is_gnu_v3_mangled_dtor ( const char *  name)

Definition at line 5982 of file cp-demangle.c.

6065  {
6066  enum gnu_v3_ctor_kinds ctor_kind;
6067  enum gnu_v3_dtor_kinds dtor_kind;
6068 
6069  if (!is_ctor_or_dtor(name, &ctor_kind, &dtor_kind))
6070  return (enum gnu_v3_dtor_kinds)0;
6071  return dtor_kind;
6072 }

◆ java_demangle_v3()

char* java_demangle_v3 ( const char *  mangled)

Definition at line 5960 of file cp-demangle.c.

5960  {
5961  size_t alc;
5962 
5963  return d_demangle(mangled, DMGL_JAVA | DMGL_PARAMS | DMGL_RET_POSTFIX, &alc);
5964 }

References d_growable_string::alc, d_demangle(), DMGL_JAVA, DMGL_PARAMS, and DMGL_RET_POSTFIX.

◆ java_demangle_v3_callback()

int java_demangle_v3_callback ( const char *  mangled,
demangle_callbackref  callback,
void *  opaque 
)

Definition at line 5966 of file cp-demangle.c.

5967  {
5968  return d_demangle_callback(mangled,
5970  callback, opaque);
5971 }

References d_demangle_callback(), DMGL_JAVA, DMGL_PARAMS, and DMGL_RET_POSTFIX.

◆ next_is_type_qual()

static int next_is_type_qual ( struct d_info di)
static

Definition at line 2140 of file cp-demangle.c.

2140  {
2141  char peek = d_peek_char(di);
2142  if (peek == 'r' || peek == 'V' || peek == 'K')
2143  return 1;
2144  if (peek == 'D') {
2145  peek = d_peek_next_char(di);
2146  if (peek == 'x' || peek == 'o' || peek == 'O' || peek == 'w')
2147  return 1;
2148  }
2149  return 0;
2150 }

References d_peek_char, and d_peek_next_char.

Referenced by cplus_demangle_type(), and d_cv_qualifiers().

◆ op_is_new_cast()

static int op_is_new_cast ( struct demangle_component op)
static

Definition at line 3024 of file cp-demangle.c.

3024  {
3025  const char *code = op->u.s_operator.op->code;
3026  return (code[1] == 'c' && (code[0] == 's' || code[0] == 'd' || code[0] == 'c' || code[0] == 'r'));
3027 }

References op::code.

Referenced by d_expression_1(), and d_print_comp_inner().

Variable Documentation

◆ cplus_demangle_builtin_types

Definition at line 2172 of file cp-demangle.c.

Referenced by cplus_demangle_type(), and d_print_comp_inner().

◆ cplus_demangle_operators

CP_STATIC_IF_GLIBCPP_V3 const struct demangle_operator_info cplus_demangle_operators[]

Definition at line 1665 of file cp-demangle.c.

Referenced by d_operator_name().

◆ standard_subs

const struct d_standard_sub_info standard_subs[]
static
Initial value:
= {
{ 't', NL("std"),
NL("std"),
NULL, 0 },
{ 'a', NL("std::allocator"),
NL("std::allocator"),
NL("allocator") },
{ 'b', NL("std::basic_string"),
NL("std::basic_string"),
NL("basic_string") },
{ 's', NL("std::string"),
NL("std::basic_string<char, std::char_traits<char>, std::allocator<char> >"),
NL("basic_string") },
{ 'i', NL("std::istream"),
NL("std::basic_istream<char, std::char_traits<char> >"),
NL("basic_istream") },
{ 'o', NL("std::ostream"),
NL("std::basic_ostream<char, std::char_traits<char> >"),
NL("basic_ostream") },
{ 'd', NL("std::iostream"),
NL("std::basic_iostream<char, std::char_traits<char> >"),
NL("basic_iostream") }
}
#define NL(s)
Definition: cp-demangle.c:1663

Definition at line 3503 of file cp-demangle.c.

Referenced by d_substitution().