Rev 5191 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5191 | Rev 6324 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | /* Demangler for g++ V3 ABI. |
1 | /* Demangler for g++ V3 ABI. |
2 | Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 |
2 | Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2014 |
3 | Free Software Foundation, Inc. |
3 | Free Software Foundation, Inc. |
4 | Written by Ian Lance Taylor |
4 | Written by Ian Lance Taylor |
Line 5... | Line 5... | ||
5 | 5 | ||
Line 273... | Line 273... | ||
273 | size_t alc; |
273 | size_t alc; |
274 | /* Set to 1 if we had a memory allocation failure. */ |
274 | /* Set to 1 if we had a memory allocation failure. */ |
275 | int allocation_failure; |
275 | int allocation_failure; |
276 | }; |
276 | }; |
Line -... | Line 277... | ||
- | 277 | ||
- | 278 | /* Stack of components, innermost first, used to avoid loops. */ |
|
- | 279 | ||
- | 280 | struct d_component_stack |
|
- | 281 | { |
|
- | 282 | /* This component. */ |
|
- | 283 | const struct demangle_component *dc; |
|
- | 284 | /* This component's parent. */ |
|
- | 285 | const struct d_component_stack *parent; |
|
- | 286 | }; |
|
- | 287 | ||
- | 288 | /* A demangle component and some scope captured when it was first |
|
- | 289 | traversed. */ |
|
- | 290 | ||
- | 291 | struct d_saved_scope |
|
- | 292 | { |
|
- | 293 | /* The component whose scope this is. */ |
|
- | 294 | const struct demangle_component *container; |
|
- | 295 | /* The list of templates, if any, that was current when this |
|
- | 296 | scope was captured. */ |
|
- | 297 | struct d_print_template *templates; |
|
- | 298 | }; |
|
- | 299 | ||
- | 300 | /* Checkpoint structure to allow backtracking. This holds copies |
|
- | 301 | of the fields of struct d_info that need to be restored |
|
- | 302 | if a trial parse needs to be backtracked over. */ |
|
- | 303 | ||
- | 304 | struct d_info_checkpoint |
|
- | 305 | { |
|
- | 306 | const char *n; |
|
- | 307 | int next_comp; |
|
- | 308 | int next_sub; |
|
- | 309 | int did_subs; |
|
- | 310 | int expansion; |
|
- | 311 | }; |
|
277 | 312 | ||
278 | enum { D_PRINT_BUFFER_LENGTH = 256 }; |
313 | enum { D_PRINT_BUFFER_LENGTH = 256 }; |
279 | struct d_print_info |
314 | struct d_print_info |
280 | { |
315 | { |
281 | /* Fixed-length allocated buffer for demangled data, flushed to the |
316 | /* Fixed-length allocated buffer for demangled data, flushed to the |
Line 300... | Line 335... | ||
300 | /* The current index into any template argument packs we are using |
335 | /* The current index into any template argument packs we are using |
301 | for printing. */ |
336 | for printing. */ |
302 | int pack_index; |
337 | int pack_index; |
303 | /* Number of d_print_flush calls so far. */ |
338 | /* Number of d_print_flush calls so far. */ |
304 | unsigned long int flush_count; |
339 | unsigned long int flush_count; |
- | 340 | /* Stack of components, innermost first, used to avoid loops. */ |
|
- | 341 | const struct d_component_stack *component_stack; |
|
- | 342 | /* Array of saved scopes for evaluating substitutions. */ |
|
- | 343 | struct d_saved_scope *saved_scopes; |
|
- | 344 | /* Index of the next unused saved scope in the above array. */ |
|
- | 345 | int next_saved_scope; |
|
- | 346 | /* Number of saved scopes in the above array. */ |
|
- | 347 | int num_saved_scopes; |
|
- | 348 | /* Array of templates for saving into scopes. */ |
|
- | 349 | struct d_print_template *copy_templates; |
|
- | 350 | /* Index of the next unused copy template in the above array. */ |
|
- | 351 | int next_copy_template; |
|
- | 352 | /* Number of copy templates in the above array. */ |
|
- | 353 | int num_copy_templates; |
|
- | 354 | /* The nearest enclosing template, if any. */ |
|
- | 355 | const struct demangle_component *current_template; |
|
305 | }; |
356 | }; |
Line 306... | Line 357... | ||
306 | 357 | ||
307 | #ifdef CP_DEMANGLE_DEBUG |
358 | #ifdef CP_DEMANGLE_DEBUG |
308 | static void d_dump (struct demangle_component *, int); |
359 | static void d_dump (struct demangle_component *, int); |
Line 426... | Line 477... | ||
426 | static int |
477 | static int |
427 | d_add_substitution (struct d_info *, struct demangle_component *); |
478 | d_add_substitution (struct d_info *, struct demangle_component *); |
Line 428... | Line 479... | ||
428 | 479 | ||
Line -... | Line 480... | ||
- | 480 | static struct demangle_component *d_substitution (struct d_info *, int); |
|
- | 481 | ||
- | 482 | static void d_checkpoint (struct d_info *, struct d_info_checkpoint *); |
|
- | 483 | ||
429 | static struct demangle_component *d_substitution (struct d_info *, int); |
484 | static void d_backtrack (struct d_info *, struct d_info_checkpoint *); |
Line 430... | Line 485... | ||
430 | 485 | ||
431 | static void d_growable_string_init (struct d_growable_string *, size_t); |
486 | static void d_growable_string_init (struct d_growable_string *, size_t); |
Line 438... | Line 493... | ||
438 | const char *, size_t); |
493 | const char *, size_t); |
439 | static void |
494 | static void |
440 | d_growable_string_callback_adapter (const char *, size_t, void *); |
495 | d_growable_string_callback_adapter (const char *, size_t, void *); |
Line 441... | Line 496... | ||
441 | 496 | ||
442 | static void |
497 | static void |
- | 498 | d_print_init (struct d_print_info *, demangle_callbackref, void *, |
|
Line 443... | Line 499... | ||
443 | d_print_init (struct d_print_info *, demangle_callbackref, void *); |
499 | const struct demangle_component *); |
Line 444... | Line 500... | ||
444 | 500 | ||
Line 517... | Line 573... | ||
517 | d_dump (dc->u.s_binary.right, indent + 2); |
573 | d_dump (dc->u.s_binary.right, indent + 2); |
518 | return; |
574 | return; |
519 | case DEMANGLE_COMPONENT_TEMPLATE_PARAM: |
575 | case DEMANGLE_COMPONENT_TEMPLATE_PARAM: |
520 | printf ("template parameter %ld\n", dc->u.s_number.number); |
576 | printf ("template parameter %ld\n", dc->u.s_number.number); |
521 | return; |
577 | return; |
- | 578 | case DEMANGLE_COMPONENT_FUNCTION_PARAM: |
|
- | 579 | printf ("function parameter %ld\n", dc->u.s_number.number); |
|
- | 580 | return; |
|
522 | case DEMANGLE_COMPONENT_CTOR: |
581 | case DEMANGLE_COMPONENT_CTOR: |
523 | printf ("constructor %d\n", (int) dc->u.s_ctor.kind); |
582 | printf ("constructor %d\n", (int) dc->u.s_ctor.kind); |
524 | d_dump (dc->u.s_ctor.name, indent + 2); |
583 | d_dump (dc->u.s_ctor.name, indent + 2); |
525 | return; |
584 | return; |
526 | case DEMANGLE_COMPONENT_DTOR: |
585 | case DEMANGLE_COMPONENT_DTOR: |
Line 652... | Line 711... | ||
652 | break; |
711 | break; |
653 | case DEMANGLE_COMPONENT_PTRMEM_TYPE: |
712 | case DEMANGLE_COMPONENT_PTRMEM_TYPE: |
654 | printf ("pointer to member type\n"); |
713 | printf ("pointer to member type\n"); |
655 | break; |
714 | break; |
656 | case DEMANGLE_COMPONENT_FIXED_TYPE: |
715 | case DEMANGLE_COMPONENT_FIXED_TYPE: |
657 | printf ("fixed-point type\n"); |
716 | printf ("fixed-point type, accum? %d, sat? %d\n", |
- | 717 | dc->u.s_fixed.accum, dc->u.s_fixed.sat); |
|
- | 718 | d_dump (dc->u.s_fixed.length, indent + 2) |
|
658 | break; |
719 | break; |
659 | case DEMANGLE_COMPONENT_ARGLIST: |
720 | case DEMANGLE_COMPONENT_ARGLIST: |
660 | printf ("argument list\n"); |
721 | printf ("argument list\n"); |
661 | break; |
722 | break; |
662 | case DEMANGLE_COMPONENT_TEMPLATE_ARGLIST: |
723 | case DEMANGLE_COMPONENT_TEMPLATE_ARGLIST: |
Line 702... | Line 763... | ||
702 | printf ("compound name\n"); |
763 | printf ("compound name\n"); |
703 | break; |
764 | break; |
704 | case DEMANGLE_COMPONENT_CHARACTER: |
765 | case DEMANGLE_COMPONENT_CHARACTER: |
705 | printf ("character '%c'\n", dc->u.s_character.character); |
766 | printf ("character '%c'\n", dc->u.s_character.character); |
706 | return; |
767 | return; |
- | 768 | case DEMANGLE_COMPONENT_NUMBER: |
|
- | 769 | printf ("number %ld\n", dc->u.s_number.number); |
|
- | 770 | return; |
|
707 | case DEMANGLE_COMPONENT_DECLTYPE: |
771 | case DEMANGLE_COMPONENT_DECLTYPE: |
708 | printf ("decltype\n"); |
772 | printf ("decltype\n"); |
709 | break; |
773 | break; |
710 | case DEMANGLE_COMPONENT_PACK_EXPANSION: |
774 | case DEMANGLE_COMPONENT_PACK_EXPANSION: |
711 | printf ("pack expansion\n"); |
775 | printf ("pack expansion\n"); |
Line 1236... | Line 1300... | ||
1236 | /* |
1300 | /* |
Line 1237... | Line 1301... | ||
1237 | 1301 | ||
1238 | static struct demangle_component * |
1302 | static struct demangle_component * |
1239 | d_abi_tags (struct d_info *di, struct demangle_component *dc) |
1303 | d_abi_tags (struct d_info *di, struct demangle_component *dc) |
- | 1304 | { |
|
1240 | { |
1305 | struct demangle_component *hold_last_name; |
- | 1306 | char peek; |
|
- | 1307 | ||
- | 1308 | /* Preserve the last name, so the ABI tag doesn't clobber it. */ |
|
- | 1309 | hold_last_name = di->last_name; |
|
1241 | char peek; |
1310 | |
1242 | while (peek = d_peek_char (di), |
1311 | while (peek = d_peek_char (di), |
1243 | peek == 'B') |
1312 | peek == 'B') |
1244 | { |
1313 | { |
1245 | struct demangle_component *tag; |
1314 | struct demangle_component *tag; |
1246 | d_advance (di, 1); |
1315 | d_advance (di, 1); |
1247 | tag = d_source_name (di); |
1316 | tag = d_source_name (di); |
1248 | dc = d_make_comp (di, DEMANGLE_COMPONENT_TAGGED_NAME, dc, tag); |
1317 | dc = d_make_comp (di, DEMANGLE_COMPONENT_TAGGED_NAME, dc, tag); |
- | 1318 | } |
|
- | 1319 | ||
- | 1320 | di->last_name = hold_last_name; |
|
1249 | } |
1321 | |
1250 | return dc; |
1322 | return dc; |
Line 1251... | Line 1323... | ||
1251 | } |
1323 | } |
1252 | 1324 | ||
Line 1274... | Line 1346... | ||
1274 | return d_nested_name (di); |
1346 | return d_nested_name (di); |
Line 1275... | Line 1347... | ||
1275 | 1347 | ||
1276 | case 'Z': |
1348 | case 'Z': |
Line 1277... | Line -... | ||
1277 | return d_local_name (di); |
- | |
1278 | 1349 | return d_local_name (di); |
|
1279 | case 'L': |
1350 | |
Line 1280... | Line 1351... | ||
1280 | case 'U': |
1351 | case 'U': |
1281 | return d_unqualified_name (di); |
1352 | return d_unqualified_name (di); |
Line 1321... | Line 1392... | ||
1321 | } |
1392 | } |
Line 1322... | Line 1393... | ||
1322 | 1393 | ||
1323 | return dc; |
1394 | return dc; |
Line -... | Line 1395... | ||
- | 1395 | } |
|
1324 | } |
1396 | |
1325 | 1397 | case 'L': |
|
1326 | default: |
1398 | default: |
1327 | dc = d_unqualified_name (di); |
1399 | dc = d_unqualified_name (di); |
1328 | if (d_peek_char (di) == 'I') |
1400 | if (d_peek_char (di) == 'I') |
Line 1716... | Line 1788... | ||
1716 | c1 = d_next_char (di); |
1788 | c1 = d_next_char (di); |
1717 | c2 = d_next_char (di); |
1789 | c2 = d_next_char (di); |
1718 | if (c1 == 'v' && IS_DIGIT (c2)) |
1790 | if (c1 == 'v' && IS_DIGIT (c2)) |
1719 | return d_make_extended_operator (di, c2 - '0', d_source_name (di)); |
1791 | return d_make_extended_operator (di, c2 - '0', d_source_name (di)); |
1720 | else if (c1 == 'c' && c2 == 'v') |
1792 | else if (c1 == 'c' && c2 == 'v') |
- | 1793 | { |
|
- | 1794 | struct demangle_component *type; |
|
1721 | return d_make_comp (di, DEMANGLE_COMPONENT_CAST, |
1795 | int was_conversion = di->is_conversion; |
- | 1796 | ||
- | 1797 | di->is_conversion = ! di->is_expression; |
|
1722 | cplus_demangle_type (di), NULL); |
1798 | type = cplus_demangle_type (di); |
- | 1799 | di->is_conversion = was_conversion; |
|
- | 1800 | return d_make_comp (di, DEMANGLE_COMPONENT_CAST, type, NULL); |
|
- | 1801 | } |
|
1723 | else |
1802 | else |
1724 | { |
1803 | { |
1725 | /* LOW is the inclusive lower bound. */ |
1804 | /* LOW is the inclusive lower bound. */ |
1726 | int low = 0; |
1805 | int low = 0; |
1727 | /* HIGH is the exclusive upper bound. We subtract one to ignore |
1806 | /* HIGH is the exclusive upper bound. We subtract one to ignore |
Line 2063... | Line 2142... | ||
2063 | kind = gnu_v3_base_object_ctor; |
2142 | kind = gnu_v3_base_object_ctor; |
2064 | break; |
2143 | break; |
2065 | case '3': |
2144 | case '3': |
2066 | kind = gnu_v3_complete_object_allocating_ctor; |
2145 | kind = gnu_v3_complete_object_allocating_ctor; |
2067 | break; |
2146 | break; |
- | 2147 | case '4': |
|
- | 2148 | kind = gnu_v3_unified_ctor; |
|
- | 2149 | break; |
|
2068 | case '5': |
2150 | case '5': |
2069 | kind = gnu_v3_object_ctor_group; |
2151 | kind = gnu_v3_object_ctor_group; |
2070 | break; |
2152 | break; |
2071 | default: |
2153 | default: |
2072 | return NULL; |
2154 | return NULL; |
Line 2088... | Line 2170... | ||
2088 | kind = gnu_v3_complete_object_dtor; |
2170 | kind = gnu_v3_complete_object_dtor; |
2089 | break; |
2171 | break; |
2090 | case '2': |
2172 | case '2': |
2091 | kind = gnu_v3_base_object_dtor; |
2173 | kind = gnu_v3_base_object_dtor; |
2092 | break; |
2174 | break; |
- | 2175 | /* digit '3' is not used */ |
|
- | 2176 | case '4': |
|
- | 2177 | kind = gnu_v3_unified_dtor; |
|
- | 2178 | break; |
|
2093 | case '5': |
2179 | case '5': |
2094 | kind = gnu_v3_object_dtor_group; |
2180 | kind = gnu_v3_object_dtor_group; |
2095 | break; |
2181 | break; |
2096 | default: |
2182 | default: |
2097 | return NULL; |
2183 | return NULL; |
Line 2266... | Line 2352... | ||
2266 | 2352 | ||
2267 | case 'T': |
2353 | case 'T': |
2268 | ret = d_template_param (di); |
2354 | ret = d_template_param (di); |
2269 | if (d_peek_char (di) == 'I') |
2355 | if (d_peek_char (di) == 'I') |
2270 | { |
2356 | { |
- | 2357 | /* This may be |
|
- | 2358 | If this is the type for a conversion operator, we can |
|
- | 2359 | have a |
|
- | 2360 | a derivation like this: |
|
- | 2361 | ||
- | 2362 | ||
- | 2363 | -> |
|
- | 2364 | -> |
|
- | 2365 | -> |
|
- | 2366 | -> |
|
- | 2367 | -> |
|
- | 2368 | -> |
|
- | 2369 | -> |
|
- | 2370 | ||
- | 2371 | where the |
|
- | 2372 | Otherwise, we must have a derivation like this: |
|
- | 2373 | ||
- | 2374 | ||
- | 2375 | -> |
|
- | 2376 | -> |
|
- | 2377 | -> |
|
- | 2378 | -> |
|
- | 2379 | -> |
|
- | 2380 | -> |
|
- | 2381 | -> |
|
- | 2382 | ||
- | 2383 | where we need to leave the |
|
- | 2384 | by d_prefix (following the |
|
2271 | /* This is |
2385 | |
2272 |
|
2386 | The |
- | 2387 | candidate. */ |
|
- | 2388 | if (! di->is_conversion) |
|
2273 | candidate. */ |
2389 | { |
2274 | if (! d_add_substitution (di, ret)) |
2390 | if (! d_add_substitution (di, ret)) |
2275 | return NULL; |
2391 | return NULL; |
2276 | ret = d_make_comp (di, DEMANGLE_COMPONENT_TEMPLATE, ret, |
2392 | ret = d_make_comp (di, DEMANGLE_COMPONENT_TEMPLATE, ret, |
2277 | d_template_args (di)); |
2393 | d_template_args (di)); |
- | 2394 | } |
|
- | 2395 | else |
|
- | 2396 | { |
|
- | 2397 | struct demangle_component *args; |
|
- | 2398 | struct d_info_checkpoint checkpoint; |
|
- | 2399 | ||
- | 2400 | d_checkpoint (di, &checkpoint); |
|
- | 2401 | args = d_template_args (di); |
|
- | 2402 | if (d_peek_char (di) == 'I') |
|
- | 2403 | { |
|
- | 2404 | if (! d_add_substitution (di, ret)) |
|
- | 2405 | return NULL; |
|
- | 2406 | ret = d_make_comp (di, DEMANGLE_COMPONENT_TEMPLATE, ret, |
|
- | 2407 | args); |
|
- | 2408 | } |
|
- | 2409 | else |
|
- | 2410 | d_backtrack (di, &checkpoint); |
|
- | 2411 | } |
|
2278 | } |
2412 | } |
Line 2279... | Line 2413... | ||
2279 | break; |
2413 | break; |
2280 | 2414 | ||
2281 | case 'S': |
2415 | case 'S': |
Line 2342... | Line 2476... | ||
2342 | break; |
2476 | break; |
Line 2343... | Line 2477... | ||
2343 | 2477 | ||
2344 | case 'U': |
2478 | case 'U': |
2345 | d_advance (di, 1); |
2479 | d_advance (di, 1); |
- | 2480 | ret = d_source_name (di); |
|
- | 2481 | if (d_peek_char (di) == 'I') |
|
- | 2482 | ret = d_make_comp (di, DEMANGLE_COMPONENT_TEMPLATE, ret, |
|
2346 | ret = d_source_name (di); |
2483 | d_template_args (di)); |
2347 | ret = d_make_comp (di, DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL, |
2484 | ret = d_make_comp (di, DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL, |
2348 | cplus_demangle_type (di), ret); |
2485 | cplus_demangle_type (di), ret); |
Line 2349... | Line 2486... | ||
2349 | break; |
2486 | break; |
Line 2958... | Line 3095... | ||
2958 | ::= sr |
3095 | ::= sr |
2959 | ::= sr |
3096 | ::= sr |
2960 | ::= |
3097 | ::= |
2961 | */ |
3098 | */ |
Line 2962... | Line 3099... | ||
2962 | 3099 | ||
2963 | static struct demangle_component * |
3100 | static inline struct demangle_component * |
2964 | d_expression (struct d_info *di) |
3101 | d_expression_1 (struct d_info *di) |
2965 | { |
3102 | { |
Line 2966... | Line 3103... | ||
2966 | char peek; |
3103 | char peek; |
2967 | 3104 | ||
Line 2987... | Line 3124... | ||
2987 | } |
3124 | } |
2988 | else if (peek == 's' && d_peek_next_char (di) == 'p') |
3125 | else if (peek == 's' && d_peek_next_char (di) == 'p') |
2989 | { |
3126 | { |
2990 | d_advance (di, 2); |
3127 | d_advance (di, 2); |
2991 | return d_make_comp (di, DEMANGLE_COMPONENT_PACK_EXPANSION, |
3128 | return d_make_comp (di, DEMANGLE_COMPONENT_PACK_EXPANSION, |
2992 | d_expression (di), NULL); |
3129 | d_expression_1 (di), NULL); |
2993 | } |
3130 | } |
2994 | else if (peek == 'f' && d_peek_next_char (di) == 'p') |
3131 | else if (peek == 'f' && d_peek_next_char (di) == 'p') |
2995 | { |
3132 | { |
2996 | /* Function parameter used in a late-specified return type. */ |
3133 | /* Function parameter used in a late-specified return type. */ |
2997 | int index; |
3134 | int index; |
Line 3092... | Line 3229... | ||
3092 | 3229 | ||
3093 | if (op->type == DEMANGLE_COMPONENT_CAST |
3230 | if (op->type == DEMANGLE_COMPONENT_CAST |
3094 | && d_check_char (di, '_')) |
3231 | && d_check_char (di, '_')) |
3095 | operand = d_exprlist (di, 'E'); |
3232 | operand = d_exprlist (di, 'E'); |
3096 | else |
3233 | else |
Line 3097... | Line 3234... | ||
3097 | operand = d_expression (di); |
3234 | operand = d_expression_1 (di); |
3098 | 3235 | ||
3099 | if (suffix) |
3236 | if (suffix) |
3100 | /* Indicate the suffix variant for d_print_comp. */ |
3237 | /* Indicate the suffix variant for d_print_comp. */ |
Line 3112... | Line 3249... | ||
3112 | struct demangle_component *right; |
3249 | struct demangle_component *right; |
Line 3113... | Line 3250... | ||
3113 | 3250 | ||
3114 | if (op_is_new_cast (op)) |
3251 | if (op_is_new_cast (op)) |
3115 | left = cplus_demangle_type (di); |
3252 | left = cplus_demangle_type (di); |
3116 | else |
3253 | else |
3117 | left = d_expression (di); |
3254 | left = d_expression_1 (di); |
3118 | if (!strcmp (code, "cl")) |
3255 | if (!strcmp (code, "cl")) |
3119 | right = d_exprlist (di, 'E'); |
3256 | right = d_exprlist (di, 'E'); |
3120 | else if (!strcmp (code, "dt") || !strcmp (code, "pt")) |
3257 | else if (!strcmp (code, "dt") || !strcmp (code, "pt")) |
3121 | { |
3258 | { |
3122 | right = d_unqualified_name (di); |
3259 | right = d_unqualified_name (di); |
3123 | if (d_peek_char (di) == 'I') |
3260 | if (d_peek_char (di) == 'I') |
3124 | right = d_make_comp (di, DEMANGLE_COMPONENT_TEMPLATE, |
3261 | right = d_make_comp (di, DEMANGLE_COMPONENT_TEMPLATE, |
3125 | right, d_template_args (di)); |
3262 | right, d_template_args (di)); |
3126 | } |
3263 | } |
3127 | else |
3264 | else |
Line 3128... | Line 3265... | ||
3128 | right = d_expression (di); |
3265 | right = d_expression_1 (di); |
3129 | 3266 | ||
3130 | return d_make_comp (di, DEMANGLE_COMPONENT_BINARY, op, |
3267 | return d_make_comp (di, DEMANGLE_COMPONENT_BINARY, op, |
3131 | d_make_comp (di, |
3268 | d_make_comp (di, |
Line 3139... | Line 3276... | ||
3139 | struct demangle_component *third; |
3276 | struct demangle_component *third; |
Line 3140... | Line 3277... | ||
3140 | 3277 | ||
3141 | if (!strcmp (code, "qu")) |
3278 | if (!strcmp (code, "qu")) |
3142 | { |
3279 | { |
3143 | /* ?: expression. */ |
3280 | /* ?: expression. */ |
3144 | first = d_expression (di); |
3281 | first = d_expression_1 (di); |
3145 | second = d_expression (di); |
3282 | second = d_expression_1 (di); |
3146 | third = d_expression (di); |
3283 | third = d_expression_1 (di); |
3147 | } |
3284 | } |
3148 | else if (code[0] == 'n') |
3285 | else if (code[0] == 'n') |
3149 | { |
3286 | { |
3150 | /* new-expression. */ |
3287 | /* new-expression. */ |
Line 3165... | Line 3302... | ||
3165 | third = d_exprlist (di, 'E'); |
3302 | third = d_exprlist (di, 'E'); |
3166 | } |
3303 | } |
3167 | else if (d_peek_char (di) == 'i' |
3304 | else if (d_peek_char (di) == 'i' |
3168 | && d_peek_next_char (di) == 'l') |
3305 | && d_peek_next_char (di) == 'l') |
3169 | /* initializer-list. */ |
3306 | /* initializer-list. */ |
3170 | third = d_expression (di); |
3307 | third = d_expression_1 (di); |
3171 | else |
3308 | else |
3172 | return NULL; |
3309 | return NULL; |
3173 | } |
3310 | } |
3174 | else |
3311 | else |
3175 | return NULL; |
3312 | return NULL; |
Line 3185... | Line 3322... | ||
3185 | return NULL; |
3322 | return NULL; |
3186 | } |
3323 | } |
3187 | } |
3324 | } |
3188 | } |
3325 | } |
Line -... | Line 3326... | ||
- | 3326 | ||
- | 3327 | static struct demangle_component * |
|
- | 3328 | d_expression (struct d_info *di) |
|
- | 3329 | { |
|
- | 3330 | struct demangle_component *ret; |
|
- | 3331 | int was_expression = di->is_expression; |
|
- | 3332 | ||
- | 3333 | di->is_expression = 1; |
|
- | 3334 | ret = d_expression_1 (di); |
|
- | 3335 | di->is_expression = was_expression; |
|
- | 3336 | return ret; |
|
- | 3337 | } |
|
3189 | 3338 | ||
3190 | /* |
3339 | /* |
3191 | ::= L |
3340 | ::= L |
3192 | ::= L |
3341 | ::= L |
Line 3547... | Line 3696... | ||
3547 | { |
3696 | { |
3548 | if (c == p->code) |
3697 | if (c == p->code) |
3549 | { |
3698 | { |
3550 | const char *s; |
3699 | const char *s; |
3551 | int len; |
3700 | int len; |
- | 3701 | struct demangle_component *c; |
|
Line 3552... | Line 3702... | ||
3552 | 3702 | ||
3553 | if (p->set_last_name != NULL) |
3703 | if (p->set_last_name != NULL) |
3554 | di->last_name = d_make_sub (di, p->set_last_name, |
3704 | di->last_name = d_make_sub (di, p->set_last_name, |
3555 | p->set_last_name_len); |
3705 | p->set_last_name_len); |
Line 3562... | Line 3712... | ||
3562 | { |
3712 | { |
3563 | s = p->simple_expansion; |
3713 | s = p->simple_expansion; |
3564 | len = p->simple_len; |
3714 | len = p->simple_len; |
3565 | } |
3715 | } |
3566 | di->expansion += len; |
3716 | di->expansion += len; |
3567 | return d_make_sub (di, s, len); |
3717 | c = d_make_sub (di, s, len); |
- | 3718 | if (d_peek_char (di) == 'B') |
|
- | 3719 | { |
|
- | 3720 | /* If there are ABI tags on the abbreviation, it becomes |
|
- | 3721 | a substitution candidate. */ |
|
- | 3722 | c = d_abi_tags (di, c); |
|
- | 3723 | d_add_substitution (di, c); |
|
- | 3724 | } |
|
- | 3725 | return c; |
|
3568 | } |
3726 | } |
3569 | } |
3727 | } |
Line 3570... | Line 3728... | ||
3570 | 3728 | ||
3571 | return NULL; |
3729 | return NULL; |
3572 | } |
3730 | } |
Line -... | Line 3731... | ||
- | 3731 | } |
|
- | 3732 | ||
- | 3733 | static void |
|
- | 3734 | d_checkpoint (struct d_info *di, struct d_info_checkpoint *checkpoint) |
|
- | 3735 | { |
|
- | 3736 | checkpoint->n = di->n; |
|
- | 3737 | checkpoint->next_comp = di->next_comp; |
|
- | 3738 | checkpoint->next_sub = di->next_sub; |
|
- | 3739 | checkpoint->did_subs = di->did_subs; |
|
- | 3740 | checkpoint->expansion = di->expansion; |
|
- | 3741 | } |
|
- | 3742 | ||
- | 3743 | static void |
|
- | 3744 | d_backtrack (struct d_info *di, struct d_info_checkpoint *checkpoint) |
|
- | 3745 | { |
|
- | 3746 | di->n = checkpoint->n; |
|
- | 3747 | di->next_comp = checkpoint->next_comp; |
|
- | 3748 | di->next_sub = checkpoint->next_sub; |
|
- | 3749 | di->did_subs = checkpoint->did_subs; |
|
- | 3750 | di->expansion = checkpoint->expansion; |
|
3573 | } |
3751 | } |
Line 3574... | Line 3752... | ||
3574 | 3752 | ||
3575 | /* Initialize a growable string. */ |
3753 | /* Initialize a growable string. */ |
3576 | 3754 | ||
Line 3646... | Line 3824... | ||
3646 | struct d_growable_string *dgs = (struct d_growable_string*) opaque; |
3824 | struct d_growable_string *dgs = (struct d_growable_string*) opaque; |
Line 3647... | Line 3825... | ||
3647 | 3825 | ||
3648 | d_growable_string_append_buffer (dgs, s, l); |
3826 | d_growable_string_append_buffer (dgs, s, l); |
Line -... | Line 3827... | ||
- | 3827 | } |
|
- | 3828 | ||
- | 3829 | /* Walk the tree, counting the number of templates encountered, and |
|
- | 3830 | the number of times a scope might be saved. These counts will be |
|
- | 3831 | used to allocate data structures for d_print_comp, so the logic |
|
- | 3832 | here must mirror the logic d_print_comp will use. It is not |
|
- | 3833 | important that the resulting numbers are exact, so long as they |
|
- | 3834 | are larger than the actual numbers encountered. */ |
|
- | 3835 | ||
- | 3836 | static void |
|
- | 3837 | d_count_templates_scopes (int *num_templates, int *num_scopes, |
|
- | 3838 | const struct demangle_component *dc) |
|
- | 3839 | { |
|
- | 3840 | if (dc == NULL) |
|
- | 3841 | return; |
|
- | 3842 | ||
- | 3843 | switch (dc->type) |
|
- | 3844 | { |
|
- | 3845 | case DEMANGLE_COMPONENT_NAME: |
|
- | 3846 | case DEMANGLE_COMPONENT_TEMPLATE_PARAM: |
|
- | 3847 | case DEMANGLE_COMPONENT_FUNCTION_PARAM: |
|
- | 3848 | case DEMANGLE_COMPONENT_SUB_STD: |
|
- | 3849 | case DEMANGLE_COMPONENT_BUILTIN_TYPE: |
|
- | 3850 | case DEMANGLE_COMPONENT_OPERATOR: |
|
- | 3851 | case DEMANGLE_COMPONENT_CHARACTER: |
|
- | 3852 | case DEMANGLE_COMPONENT_NUMBER: |
|
- | 3853 | case DEMANGLE_COMPONENT_UNNAMED_TYPE: |
|
- | 3854 | break; |
|
- | 3855 | ||
- | 3856 | case DEMANGLE_COMPONENT_TEMPLATE: |
|
- | 3857 | (*num_templates)++; |
|
- | 3858 | goto recurse_left_right; |
|
- | 3859 | ||
- | 3860 | case DEMANGLE_COMPONENT_REFERENCE: |
|
- | 3861 | case DEMANGLE_COMPONENT_RVALUE_REFERENCE: |
|
- | 3862 | if (d_left (dc)->type == DEMANGLE_COMPONENT_TEMPLATE_PARAM) |
|
- | 3863 | (*num_scopes)++; |
|
- | 3864 | goto recurse_left_right; |
|
- | 3865 | ||
- | 3866 | case DEMANGLE_COMPONENT_QUAL_NAME: |
|
- | 3867 | case DEMANGLE_COMPONENT_LOCAL_NAME: |
|
- | 3868 | case DEMANGLE_COMPONENT_TYPED_NAME: |
|
- | 3869 | case DEMANGLE_COMPONENT_VTABLE: |
|
- | 3870 | case DEMANGLE_COMPONENT_VTT: |
|
- | 3871 | case DEMANGLE_COMPONENT_CONSTRUCTION_VTABLE: |
|
- | 3872 | case DEMANGLE_COMPONENT_TYPEINFO: |
|
- | 3873 | case DEMANGLE_COMPONENT_TYPEINFO_NAME: |
|
- | 3874 | case DEMANGLE_COMPONENT_TYPEINFO_FN: |
|
- | 3875 | case DEMANGLE_COMPONENT_THUNK: |
|
- | 3876 | case DEMANGLE_COMPONENT_VIRTUAL_THUNK: |
|
- | 3877 | case DEMANGLE_COMPONENT_COVARIANT_THUNK: |
|
- | 3878 | case DEMANGLE_COMPONENT_JAVA_CLASS: |
|
- | 3879 | case DEMANGLE_COMPONENT_GUARD: |
|
- | 3880 | case DEMANGLE_COMPONENT_TLS_INIT: |
|
- | 3881 | case DEMANGLE_COMPONENT_TLS_WRAPPER: |
|
- | 3882 | case DEMANGLE_COMPONENT_REFTEMP: |
|
- | 3883 | case DEMANGLE_COMPONENT_HIDDEN_ALIAS: |
|
- | 3884 | case DEMANGLE_COMPONENT_RESTRICT: |
|
- | 3885 | case DEMANGLE_COMPONENT_VOLATILE: |
|
- | 3886 | case DEMANGLE_COMPONENT_CONST: |
|
- | 3887 | case DEMANGLE_COMPONENT_RESTRICT_THIS: |
|
- | 3888 | case DEMANGLE_COMPONENT_VOLATILE_THIS: |
|
- | 3889 | case DEMANGLE_COMPONENT_CONST_THIS: |
|
- | 3890 | case DEMANGLE_COMPONENT_REFERENCE_THIS: |
|
- | 3891 | case DEMANGLE_COMPONENT_RVALUE_REFERENCE_THIS: |
|
- | 3892 | case DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL: |
|
- | 3893 | case DEMANGLE_COMPONENT_POINTER: |
|
- | 3894 | case DEMANGLE_COMPONENT_COMPLEX: |
|
- | 3895 | case DEMANGLE_COMPONENT_IMAGINARY: |
|
- | 3896 | case DEMANGLE_COMPONENT_VENDOR_TYPE: |
|
- | 3897 | case DEMANGLE_COMPONENT_FUNCTION_TYPE: |
|
- | 3898 | case DEMANGLE_COMPONENT_ARRAY_TYPE: |
|
- | 3899 | case DEMANGLE_COMPONENT_PTRMEM_TYPE: |
|
- | 3900 | case DEMANGLE_COMPONENT_VECTOR_TYPE: |
|
- | 3901 | case DEMANGLE_COMPONENT_ARGLIST: |
|
- | 3902 | case DEMANGLE_COMPONENT_TEMPLATE_ARGLIST: |
|
- | 3903 | case DEMANGLE_COMPONENT_INITIALIZER_LIST: |
|
- | 3904 | case DEMANGLE_COMPONENT_CAST: |
|
- | 3905 | case DEMANGLE_COMPONENT_NULLARY: |
|
- | 3906 | case DEMANGLE_COMPONENT_UNARY: |
|
- | 3907 | case DEMANGLE_COMPONENT_BINARY: |
|
- | 3908 | case DEMANGLE_COMPONENT_BINARY_ARGS: |
|
- | 3909 | case DEMANGLE_COMPONENT_TRINARY: |
|
- | 3910 | case DEMANGLE_COMPONENT_TRINARY_ARG1: |
|
- | 3911 | case DEMANGLE_COMPONENT_TRINARY_ARG2: |
|
- | 3912 | case DEMANGLE_COMPONENT_LITERAL: |
|
- | 3913 | case DEMANGLE_COMPONENT_LITERAL_NEG: |
|
- | 3914 | case DEMANGLE_COMPONENT_JAVA_RESOURCE: |
|
- | 3915 | case DEMANGLE_COMPONENT_COMPOUND_NAME: |
|
- | 3916 | case DEMANGLE_COMPONENT_DECLTYPE: |
|
- | 3917 | case DEMANGLE_COMPONENT_TRANSACTION_CLONE: |
|
- | 3918 | case DEMANGLE_COMPONENT_NONTRANSACTION_CLONE: |
|
- | 3919 | case DEMANGLE_COMPONENT_PACK_EXPANSION: |
|
- | 3920 | case DEMANGLE_COMPONENT_TAGGED_NAME: |
|
- | 3921 | case DEMANGLE_COMPONENT_CLONE: |
|
- | 3922 | recurse_left_right: |
|
- | 3923 | d_count_templates_scopes (num_templates, num_scopes, |
|
- | 3924 | d_left (dc)); |
|
- | 3925 | d_count_templates_scopes (num_templates, num_scopes, |
|
- | 3926 | d_right (dc)); |
|
- | 3927 | break; |
|
- | 3928 | ||
- | 3929 | case DEMANGLE_COMPONENT_CTOR: |
|
- | 3930 | d_count_templates_scopes (num_templates, num_scopes, |
|
- | 3931 | dc->u.s_ctor.name); |
|
- | 3932 | break; |
|
- | 3933 | ||
- | 3934 | case DEMANGLE_COMPONENT_DTOR: |
|
- | 3935 | d_count_templates_scopes (num_templates, num_scopes, |
|
- | 3936 | dc->u.s_dtor.name); |
|
- | 3937 | break; |
|
- | 3938 | ||
- | 3939 | case DEMANGLE_COMPONENT_EXTENDED_OPERATOR: |
|
- | 3940 | d_count_templates_scopes (num_templates, num_scopes, |
|
- | 3941 | dc->u.s_extended_operator.name); |
|
- | 3942 | break; |
|
- | 3943 | ||
- | 3944 | case DEMANGLE_COMPONENT_FIXED_TYPE: |
|
- | 3945 | d_count_templates_scopes (num_templates, num_scopes, |
|
- | 3946 | dc->u.s_fixed.length); |
|
- | 3947 | break; |
|
- | 3948 | ||
- | 3949 | case DEMANGLE_COMPONENT_GLOBAL_CONSTRUCTORS: |
|
- | 3950 | case DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS: |
|
- | 3951 | d_count_templates_scopes (num_templates, num_scopes, |
|
- | 3952 | d_left (dc)); |
|
- | 3953 | break; |
|
- | 3954 | ||
- | 3955 | case DEMANGLE_COMPONENT_LAMBDA: |
|
- | 3956 | case DEMANGLE_COMPONENT_DEFAULT_ARG: |
|
- | 3957 | d_count_templates_scopes (num_templates, num_scopes, |
|
- | 3958 | dc->u.s_unary_num.sub); |
|
- | 3959 | break; |
|
- | 3960 | } |
|
3649 | } |
3961 | } |
Line 3650... | Line 3962... | ||
3650 | 3962 | ||
3651 | /* Initialize a print information structure. */ |
3963 | /* Initialize a print information structure. */ |
3652 | 3964 | ||
3653 | static void |
3965 | static void |
3654 | d_print_init (struct d_print_info *dpi, demangle_callbackref callback, |
3966 | d_print_init (struct d_print_info *dpi, demangle_callbackref callback, |
3655 | void *opaque) |
3967 | void *opaque, const struct demangle_component *dc) |
3656 | { |
3968 | { |
3657 | dpi->len = 0; |
3969 | dpi->len = 0; |
Line 3663... | Line 3975... | ||
3663 | 3975 | ||
3664 | dpi->callback = callback; |
3976 | dpi->callback = callback; |
Line 3665... | Line 3977... | ||
3665 | dpi->opaque = opaque; |
3977 | dpi->opaque = opaque; |
- | 3978 | ||
- | 3979 | dpi->demangle_failure = 0; |
|
- | 3980 | ||
- | 3981 | dpi->component_stack = NULL; |
|
- | 3982 | ||
- | 3983 | dpi->saved_scopes = NULL; |
|
- | 3984 | dpi->next_saved_scope = 0; |
|
- | 3985 | dpi->num_saved_scopes = 0; |
|
- | 3986 | ||
- | 3987 | dpi->copy_templates = NULL; |
|
- | 3988 | dpi->next_copy_template = 0; |
|
- | 3989 | dpi->num_copy_templates = 0; |
|
- | 3990 | ||
- | 3991 | d_count_templates_scopes (&dpi->num_copy_templates, |
|
- | 3992 | &dpi->num_saved_scopes, dc); |
|
- | 3993 | dpi->num_copy_templates *= dpi->num_saved_scopes; |
|
3666 | 3994 | ||
Line 3667... | Line 3995... | ||
3667 | dpi->demangle_failure = 0; |
3995 | dpi->current_template = NULL; |
Line 3668... | Line 3996... | ||
3668 | } |
3996 | } |
Line 3748... | Line 4076... | ||
3748 | const struct demangle_component *dc, |
4076 | const struct demangle_component *dc, |
3749 | demangle_callbackref callback, void *opaque) |
4077 | demangle_callbackref callback, void *opaque) |
3750 | { |
4078 | { |
3751 | struct d_print_info dpi; |
4079 | struct d_print_info dpi; |
Line 3752... | Line 4080... | ||
3752 | 4080 | ||
- | 4081 | d_print_init (&dpi, callback, opaque, dc); |
|
- | 4082 | ||
- | 4083 | { |
|
- | 4084 | #ifdef CP_DYNAMIC_ARRAYS |
|
- | 4085 | __extension__ struct d_saved_scope scopes[dpi.num_saved_scopes]; |
|
- | 4086 | __extension__ struct d_print_template temps[dpi.num_copy_templates]; |
|
- | 4087 | ||
- | 4088 | dpi.saved_scopes = scopes; |
|
- | 4089 | dpi.copy_templates = temps; |
|
- | 4090 | #else |
|
- | 4091 | dpi.saved_scopes = alloca (dpi.num_saved_scopes |
|
- | 4092 | * sizeof (*dpi.saved_scopes)); |
|
- | 4093 | dpi.copy_templates = alloca (dpi.num_copy_templates |
|
- | 4094 | * sizeof (*dpi.copy_templates)); |
|
Line 3753... | Line 4095... | ||
3753 | d_print_init (&dpi, callback, opaque); |
4095 | #endif |
- | 4096 | ||
Line 3754... | Line 4097... | ||
3754 | 4097 | d_print_comp (&dpi, options, dc); |
|
Line 3755... | Line 4098... | ||
3755 | d_print_comp (&dpi, options, dc); |
4098 | } |
3756 | 4099 | ||
Line 3911... | Line 4254... | ||
3911 | d_print_comp (dpi, options, dc); |
4254 | d_print_comp (dpi, options, dc); |
3912 | if (!simple) |
4255 | if (!simple) |
3913 | d_append_char (dpi, ')'); |
4256 | d_append_char (dpi, ')'); |
3914 | } |
4257 | } |
Line -... | Line 4258... | ||
- | 4258 | ||
- | 4259 | /* Save the current scope. */ |
|
- | 4260 | ||
- | 4261 | static void |
|
- | 4262 | d_save_scope (struct d_print_info *dpi, |
|
- | 4263 | const struct demangle_component *container) |
|
- | 4264 | { |
|
- | 4265 | struct d_saved_scope *scope; |
|
- | 4266 | struct d_print_template *src, **link; |
|
- | 4267 | ||
- | 4268 | if (dpi->next_saved_scope >= dpi->num_saved_scopes) |
|
- | 4269 | { |
|
- | 4270 | d_print_error (dpi); |
|
- | 4271 | return; |
|
- | 4272 | } |
|
- | 4273 | scope = &dpi->saved_scopes[dpi->next_saved_scope]; |
|
- | 4274 | dpi->next_saved_scope++; |
|
- | 4275 | ||
- | 4276 | scope->container = container; |
|
- | 4277 | link = &scope->templates; |
|
- | 4278 | ||
- | 4279 | for (src = dpi->templates; src != NULL; src = src->next) |
|
- | 4280 | { |
|
- | 4281 | struct d_print_template *dst; |
|
- | 4282 | ||
- | 4283 | if (dpi->next_copy_template >= dpi->num_copy_templates) |
|
- | 4284 | { |
|
- | 4285 | d_print_error (dpi); |
|
- | 4286 | return; |
|
- | 4287 | } |
|
- | 4288 | dst = &dpi->copy_templates[dpi->next_copy_template]; |
|
- | 4289 | dpi->next_copy_template++; |
|
- | 4290 | ||
- | 4291 | dst->template_decl = src->template_decl; |
|
- | 4292 | *link = dst; |
|
- | 4293 | link = &dst->next; |
|
- | 4294 | } |
|
- | 4295 | ||
- | 4296 | *link = NULL; |
|
- | 4297 | } |
|
- | 4298 | ||
- | 4299 | /* Attempt to locate a previously saved scope. Returns NULL if no |
|
- | 4300 | corresponding saved scope was found. */ |
|
- | 4301 | ||
- | 4302 | static struct d_saved_scope * |
|
- | 4303 | d_get_saved_scope (struct d_print_info *dpi, |
|
- | 4304 | const struct demangle_component *container) |
|
- | 4305 | { |
|
- | 4306 | int i; |
|
- | 4307 | ||
- | 4308 | for (i = 0; i < dpi->next_saved_scope; i++) |
|
- | 4309 | if (dpi->saved_scopes[i].container == container) |
|
- | 4310 | return &dpi->saved_scopes[i]; |
|
- | 4311 | ||
- | 4312 | return NULL; |
|
- | 4313 | } |
|
3915 | 4314 | ||
Line 3916... | Line 4315... | ||
3916 | /* Subroutine to handle components. */ |
4315 | /* Subroutine to handle components. */ |
3917 | 4316 | ||
3918 | static void |
4317 | static void |
3919 | d_print_comp (struct d_print_info *dpi, int options, |
4318 | d_print_comp_inner (struct d_print_info *dpi, int options, |
3920 | const struct demangle_component *dc) |
4319 | const struct demangle_component *dc) |
3921 | { |
4320 | { |
3922 | /* Magic variable to let reference smashing skip over the next modifier |
4321 | /* Magic variable to let reference smashing skip over the next modifier |
Line -... | Line 4322... | ||
- | 4322 | without needing to modify *dc. */ |
|
- | 4323 | const struct demangle_component *mod_inner = NULL; |
|
- | 4324 | ||
- | 4325 | /* Variable used to store the current templates while a previously |
|
- | 4326 | captured scope is used. */ |
|
- | 4327 | struct d_print_template *saved_templates; |
|
- | 4328 | ||
3923 | without needing to modify *dc. */ |
4329 | /* Nonzero if templates have been stored in the above variable. */ |
3924 | const struct demangle_component *mod_inner = NULL; |
4330 | int need_template_restore = 0; |
3925 | 4331 | ||
3926 | if (dc == NULL) |
4332 | if (dc == NULL) |
3927 | { |
4333 | { |
Line 4083... | Line 4489... | ||
4083 | 4489 | ||
4084 | case DEMANGLE_COMPONENT_TEMPLATE: |
4490 | case DEMANGLE_COMPONENT_TEMPLATE: |
4085 | { |
4491 | { |
4086 | struct d_print_mod *hold_dpm; |
4492 | struct d_print_mod *hold_dpm; |
- | 4493 | struct demangle_component *dcl; |
|
- | 4494 | const struct demangle_component *hold_current; |
|
- | 4495 | ||
- | 4496 | /* This template may need to be referenced by a cast operator |
|
- | 4497 | contained in its subtree. */ |
|
- | 4498 | hold_current = dpi->current_template; |
|
Line 4087... | Line 4499... | ||
4087 | struct demangle_component *dcl; |
4499 | dpi->current_template = dc; |
4088 | 4500 | ||
4089 | /* Don't push modifiers into a template definition. Doing so |
4501 | /* Don't push modifiers into a template definition. Doing so |
Line 4119... | Line 4531... | ||
4119 | d_append_char (dpi, ' '); |
4531 | d_append_char (dpi, ' '); |
4120 | d_append_char (dpi, '>'); |
4532 | d_append_char (dpi, '>'); |
4121 | } |
4533 | } |
Line 4122... | Line 4534... | ||
4122 | 4534 | ||
- | 4535 | dpi->modifiers = hold_dpm; |
|
Line 4123... | Line 4536... | ||
4123 | dpi->modifiers = hold_dpm; |
4536 | dpi->current_template = hold_current; |
4124 | 4537 | ||
Line 4125... | Line 4538... | ||
4125 | return; |
4538 | return; |
Line 4289... | Line 4702... | ||
4289 | { |
4702 | { |
4290 | /* Handle reference smashing: & + && = &. */ |
4703 | /* Handle reference smashing: & + && = &. */ |
4291 | const struct demangle_component *sub = d_left (dc); |
4704 | const struct demangle_component *sub = d_left (dc); |
4292 | if (sub->type == DEMANGLE_COMPONENT_TEMPLATE_PARAM) |
4705 | if (sub->type == DEMANGLE_COMPONENT_TEMPLATE_PARAM) |
4293 | { |
4706 | { |
- | 4707 | struct d_saved_scope *scope = d_get_saved_scope (dpi, sub); |
|
- | 4708 | struct demangle_component *a; |
|
- | 4709 | ||
- | 4710 | if (scope == NULL) |
|
- | 4711 | { |
|
- | 4712 | /* This is the first time SUB has been traversed. |
|
- | 4713 | We need to capture the current templates so |
|
- | 4714 | they can be restored if SUB is reentered as a |
|
- | 4715 | substitution. */ |
|
- | 4716 | d_save_scope (dpi, sub); |
|
- | 4717 | if (d_print_saw_error (dpi)) |
|
- | 4718 | return; |
|
- | 4719 | } |
|
- | 4720 | else |
|
- | 4721 | { |
|
- | 4722 | const struct d_component_stack *dcse; |
|
- | 4723 | int found_self_or_parent = 0; |
|
- | 4724 | ||
- | 4725 | /* This traversal is reentering SUB as a substition. |
|
- | 4726 | If we are not beneath SUB or DC in the tree then we |
|
- | 4727 | need to restore SUB's template stack temporarily. */ |
|
- | 4728 | for (dcse = dpi->component_stack; dcse != NULL; |
|
- | 4729 | dcse = dcse->parent) |
|
- | 4730 | { |
|
- | 4731 | if (dcse->dc == sub |
|
- | 4732 | || (dcse->dc == dc |
|
- | 4733 | && dcse != dpi->component_stack)) |
|
- | 4734 | { |
|
- | 4735 | found_self_or_parent = 1; |
|
- | 4736 | break; |
|
- | 4737 | } |
|
- | 4738 | } |
|
- | 4739 | ||
- | 4740 | if (!found_self_or_parent) |
|
- | 4741 | { |
|
- | 4742 | saved_templates = dpi->templates; |
|
- | 4743 | dpi->templates = scope->templates; |
|
- | 4744 | need_template_restore = 1; |
|
- | 4745 | } |
|
- | 4746 | } |
|
- | 4747 | ||
4294 | struct demangle_component *a = d_lookup_template_argument (dpi, sub); |
4748 | a = d_lookup_template_argument (dpi, sub); |
4295 | if (a && a->type == DEMANGLE_COMPONENT_TEMPLATE_ARGLIST) |
4749 | if (a && a->type == DEMANGLE_COMPONENT_TEMPLATE_ARGLIST) |
4296 | a = d_index_template_argument (a, dpi->pack_index); |
4750 | a = d_index_template_argument (a, dpi->pack_index); |
Line 4297... | Line 4751... | ||
4297 | 4751 | ||
4298 | if (a == NULL) |
4752 | if (a == NULL) |
- | 4753 | { |
|
- | 4754 | if (need_template_restore) |
|
- | 4755 | dpi->templates = saved_templates; |
|
4299 | { |
4756 | |
4300 | d_print_error (dpi); |
4757 | d_print_error (dpi); |
4301 | return; |
4758 | return; |
Line 4302... | Line 4759... | ||
4302 | } |
4759 | } |
Line 4342... | Line 4799... | ||
4342 | if (! dpm.printed) |
4799 | if (! dpm.printed) |
4343 | d_print_mod (dpi, options, dc); |
4800 | d_print_mod (dpi, options, dc); |
Line 4344... | Line 4801... | ||
4344 | 4801 | ||
Line -... | Line 4802... | ||
- | 4802 | dpi->modifiers = dpm.next; |
|
- | 4803 | ||
- | 4804 | if (need_template_restore) |
|
4345 | dpi->modifiers = dpm.next; |
4805 | dpi->templates = saved_templates; |
4346 | 4806 | ||
Line 4347... | Line 4807... | ||
4347 | return; |
4807 | return; |
4348 | } |
4808 | } |
Line 4919... | Line 5379... | ||
4919 | d_print_error (dpi); |
5379 | d_print_error (dpi); |
4920 | return; |
5380 | return; |
4921 | } |
5381 | } |
4922 | } |
5382 | } |
Line -... | Line 5383... | ||
- | 5383 | ||
- | 5384 | static void |
|
- | 5385 | d_print_comp (struct d_print_info *dpi, int options, |
|
- | 5386 | const struct demangle_component *dc) |
|
- | 5387 | { |
|
- | 5388 | struct d_component_stack self; |
|
- | 5389 | ||
- | 5390 | self.dc = dc; |
|
- | 5391 | self.parent = dpi->component_stack; |
|
- | 5392 | dpi->component_stack = &self; |
|
- | 5393 | ||
- | 5394 | d_print_comp_inner (dpi, options, dc); |
|
- | 5395 | ||
- | 5396 | dpi->component_stack = self.parent; |
|
- | 5397 | } |
|
4923 | 5398 | ||
4924 | /* Print a Java dentifier. For Java we try to handle encoded extended |
5399 | /* Print a Java dentifier. For Java we try to handle encoded extended |
4925 | Unicode characters. The C++ ABI doesn't mention Unicode encoding, |
5400 | Unicode characters. The C++ ABI doesn't mention Unicode encoding, |
4926 | so we don't it for C++. Characters are encoded as |
5401 | so we don't it for C++. Characters are encoded as |
Line 5287... | Line 5762... | ||
5287 | 5762 | ||
5288 | static void |
5763 | static void |
5289 | d_print_cast (struct d_print_info *dpi, int options, |
5764 | d_print_cast (struct d_print_info *dpi, int options, |
5290 | const struct demangle_component *dc) |
5765 | const struct demangle_component *dc) |
5291 | { |
- | |
5292 | if (d_left (dc)->type != DEMANGLE_COMPONENT_TEMPLATE) |
- | |
5293 | d_print_comp (dpi, options, d_left (dc)); |
- | |
5294 | else |
- | |
5295 | { |
- | |
5296 | struct d_print_mod *hold_dpm; |
5766 | { |
Line 5297... | Line 5767... | ||
5297 | struct d_print_template dpt; |
5767 | struct d_print_template dpt; |
5298 | 5768 | ||
5299 | /* It appears that for a templated cast operator, we need to put |
- | |
5300 | the template parameters in scope for the operator name, but |
- | |
5301 | not for the parameters. The effect is that we need to handle |
- | |
5302 | the template printing here. */ |
- | |
5303 | 5769 | /* For a cast operator, we need the template parameters from |
|
5304 | hold_dpm = dpi->modifiers; |
5770 | the enclosing template in scope for processing the type. */ |
5305 | dpi->modifiers = NULL; |
5771 | if (dpi->current_template != NULL) |
5306 | 5772 | { |
|
5307 | dpt.next = dpi->templates; |
5773 | dpt.next = dpi->templates; |
- | 5774 | dpi->templates = &dpt; |
|
Line -... | Line 5775... | ||
- | 5775 | dpt.template_decl = dpi->current_template; |
|
- | 5776 | } |
|
- | 5777 | ||
- | 5778 | if (d_left (dc)->type != DEMANGLE_COMPONENT_TEMPLATE) |
|
- | 5779 | { |
|
- | 5780 | d_print_comp (dpi, options, d_left (dc)); |
|
- | 5781 | if (dpi->current_template != NULL) |
|
- | 5782 | dpi->templates = dpt.next; |
|
5308 | dpi->templates = &dpt; |
5783 | } |
Line -... | Line 5784... | ||
- | 5784 | else |
|
- | 5785 | { |
|
- | 5786 | d_print_comp (dpi, options, d_left (d_left (dc))); |
|
- | 5787 | ||
5309 | dpt.template_decl = d_left (dc); |
5788 | /* For a templated cast operator, we need to remove the template |
Line 5310... | Line 5789... | ||
5310 | 5789 | parameters from scope after printing the operator name, |
|
5311 | d_print_comp (dpi, options, d_left (d_left (dc))); |
5790 | so we need to handle the template printing here. */ |
5312 | 5791 | if (dpi->current_template != NULL) |
|
Line 5319... | Line 5798... | ||
5319 | /* Avoid generating two consecutive '>' characters, to avoid |
5798 | /* Avoid generating two consecutive '>' characters, to avoid |
5320 | the C++ syntactic ambiguity. */ |
5799 | the C++ syntactic ambiguity. */ |
5321 | if (d_last_char (dpi) == '>') |
5800 | if (d_last_char (dpi) == '>') |
5322 | d_append_char (dpi, ' '); |
5801 | d_append_char (dpi, ' '); |
5323 | d_append_char (dpi, '>'); |
5802 | d_append_char (dpi, '>'); |
5324 | - | ||
5325 | dpi->modifiers = hold_dpm; |
- | |
5326 | } |
5803 | } |
5327 | } |
5804 | } |
Line 5328... | Line 5805... | ||
5328 | 5805 | ||
5329 | /* Initialize the information structure we use to pass around |
5806 | /* Initialize the information structure we use to pass around |
Line 5353... | Line 5830... | ||
5353 | di->did_subs = 0; |
5830 | di->did_subs = 0; |
Line 5354... | Line 5831... | ||
5354 | 5831 | ||
Line 5355... | Line 5832... | ||
5355 | di->last_name = NULL; |
5832 | di->last_name = NULL; |
- | 5833 | ||
- | 5834 | di->expansion = 0; |
|
5356 | 5835 | di->is_expression = 0; |
|
Line 5357... | Line 5836... | ||
5357 | di->expansion = 0; |
5836 | di->is_conversion = 0; |
5358 | } |
5837 | } |
5359 | 5838 | ||
Line 5423... | Line 5902... | ||
5423 | : DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS), |
5902 | : DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS), |
5424 | d_make_demangle_mangled_name (&di, d_str (&di)), |
5903 | d_make_demangle_mangled_name (&di, d_str (&di)), |
5425 | NULL); |
5904 | NULL); |
5426 | d_advance (&di, strlen (d_str (&di))); |
5905 | d_advance (&di, strlen (d_str (&di))); |
5427 | break; |
5906 | break; |
- | 5907 | default: |
|
- | 5908 | abort (); /* We have listed all the cases. */ |
|
5428 | } |
5909 | } |
Line 5429... | Line 5910... | ||
5429 | 5910 | ||
5430 | /* If DMGL_PARAMS is set, then if we didn't consume the entire |
5911 | /* If DMGL_PARAMS is set, then if we didn't consume the entire |
5431 | mangled string, then we didn't successfully demangle it. If |
5912 | mangled string, then we didn't successfully demangle it. If |