From: Mark Wielaard Date: Wed, 3 Apr 2024 21:13:02 +0000 (+0200) Subject: Update libiberty demangler X-Git-Tag: VALGRIND_3_23_0~67 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=31224ab9d54224d1e732e677d128ab0ed884d92d;p=thirdparty%2Fvalgrind.git Update libiberty demangler Update the libiberty demangler using the auxprogs/update-demangler script to gcc git commit ca2f7c84927f85b95f0f48f82b93f1460c372db4. This update includes: * c++: mangle noexcept-expr [PR70790] * c++: Fix templated convertion operator demangling * c++: constrained hidden friends [PR109751] * c++: mangle function template constraints * Update copyright years. * c++, demangle: Implement https://github.com/itanium-cxx-abi/cxx-abi/issues/148 non-proposal * libiberty: Invoke D demangler when --format=auto --- diff --git a/auxprogs/update-demangler b/auxprogs/update-demangler index efdcf322e7..9b62fffca5 100755 --- a/auxprogs/update-demangler +++ b/auxprogs/update-demangler @@ -17,8 +17,8 @@ set -e #--------------------------------------------------------------------- # You need to modify these revision numbers for your update. -old_gcc_revision=d3b2ead595467166c849950ecd3710501a5094d9 # the revision of the previous update -new_gcc_revision=1719fa40c4ee4def60a2ce2f27e17f8168cf28ba # the revision for this update +old_gcc_revision=1719fa40c4ee4def60a2ce2f27e17f8168cf28ba # the revision of the previous update +new_gcc_revision=ca2f7c84927f85b95f0f48f82b93f1460c372db4 # the revision for this update # Unless the organization of demangler related files has changed, no # changes below this line should be necessary. diff --git a/coregrind/m_demangle/ansidecl.h b/coregrind/m_demangle/ansidecl.h index 39375e1715..653d91869e 100644 --- a/coregrind/m_demangle/ansidecl.h +++ b/coregrind/m_demangle/ansidecl.h @@ -1,5 +1,5 @@ /* Compiler compatibility macros - Copyright (C) 1991-2023 Free Software Foundation, Inc. + Copyright (C) 1991-2024 Free Software Foundation, Inc. This file is part of the GNU C Library. This program is free software; you can redistribute it and/or modify diff --git a/coregrind/m_demangle/cp-demangle.c b/coregrind/m_demangle/cp-demangle.c index 870f27bb84..b1a8d87e59 100644 --- a/coregrind/m_demangle/cp-demangle.c +++ b/coregrind/m_demangle/cp-demangle.c @@ -1,5 +1,5 @@ /* Demangler for g++ V3 ABI. - Copyright (C) 2003-2023 Free Software Foundation, Inc. + Copyright (C) 2003-2024 Free Software Foundation, Inc. Written by Ian Lance Taylor . This file is part of the libiberty library, which is part of GCC. @@ -598,6 +598,7 @@ static char *d_demangle (const char *, int, size_t *); case DEMANGLE_COMPONENT_CONST_THIS: \ case DEMANGLE_COMPONENT_REFERENCE_THIS: \ case DEMANGLE_COMPONENT_RVALUE_REFERENCE_THIS: \ + case DEMANGLE_COMPONENT_XOBJ_MEMBER_FUNCTION: \ case DEMANGLE_COMPONENT_TRANSACTION_SAFE: \ case DEMANGLE_COMPONENT_NOEXCEPT: \ case DEMANGLE_COMPONENT_THROW_SPEC @@ -766,6 +767,9 @@ d_dump (struct demangle_component *dc, int indent) case DEMANGLE_COMPONENT_RVALUE_REFERENCE_THIS: printf ("rvalue reference this\n"); break; + case DEMANGLE_COMPONENT_XOBJ_MEMBER_FUNCTION: + printf ("explicit object parameter\n"); + break; case DEMANGLE_COMPONENT_TRANSACTION_SAFE: printf ("transaction_safe this\n"); break; @@ -1010,6 +1014,7 @@ d_make_comp (struct d_info *di, enum demangle_component_type type, case DEMANGLE_COMPONENT_VECTOR_TYPE: case DEMANGLE_COMPONENT_CLONE: case DEMANGLE_COMPONENT_MODULE_ENTITY: + case DEMANGLE_COMPONENT_CONSTRAINTS: if (left == NULL || right == NULL) return NULL; break; @@ -1053,6 +1058,7 @@ d_make_comp (struct d_info *di, enum demangle_component_type type, case DEMANGLE_COMPONENT_TEMPLATE_NON_TYPE_PARM: case DEMANGLE_COMPONENT_TEMPLATE_TEMPLATE_PARM: case DEMANGLE_COMPONENT_TEMPLATE_PACK_PARM: + case DEMANGLE_COMPONENT_FRIEND: if (left == NULL) return NULL; break; @@ -1361,6 +1367,22 @@ is_ctor_dtor_or_conversion (struct demangle_component *dc) } } +/* [ Q ] */ + +static struct demangle_component * +d_maybe_constraints (struct d_info *di, struct demangle_component *dc) +{ + if (d_peek_char (di) == 'Q') + { + d_advance (di, 1); + struct demangle_component *expr = d_expression (di); + if (expr == NULL) + return NULL; + dc = d_make_comp (di, DEMANGLE_COMPONENT_CONSTRAINTS, dc, expr); + } + return dc; +} + /* ::= <(function) name> ::= <(data) name> ::= @@ -1414,21 +1436,21 @@ d_encoding (struct d_info *di, int top_level) struct demangle_component *ftype; ftype = d_bare_function_type (di, has_return_type (dc)); - if (ftype) - { - /* If this is a non-top-level local-name, clear the - return type, so it doesn't confuse the user by - being confused with the return type of whaever - this is nested within. */ - if (!top_level && dc->type == DEMANGLE_COMPONENT_LOCAL_NAME - && ftype->type == DEMANGLE_COMPONENT_FUNCTION_TYPE) - d_left (ftype) = NULL; - - dc = d_make_comp (di, DEMANGLE_COMPONENT_TYPED_NAME, - dc, ftype); - } - else - dc = NULL; + if (!ftype) + return NULL; + + /* If this is a non-top-level local-name, clear the + return type, so it doesn't confuse the user by + being confused with the return type of whaever + this is nested within. */ + if (!top_level && dc->type == DEMANGLE_COMPONENT_LOCAL_NAME + && ftype->type == DEMANGLE_COMPONENT_FUNCTION_TYPE) + d_left (ftype) = NULL; + + ftype = d_maybe_constraints (di, ftype); + + dc = d_make_comp (di, DEMANGLE_COMPONENT_TYPED_NAME, + dc, ftype); } } } @@ -1546,6 +1568,8 @@ d_name (struct d_info *di, int substable) /* ::= N [] [] E ::= N [] [] E + ::= N H E + ::= N H E */ static struct demangle_component * @@ -1558,13 +1582,24 @@ d_nested_name (struct d_info *di) if (! d_check_char (di, 'N')) return NULL; - pret = d_cv_qualifiers (di, &ret, 1); - if (pret == NULL) - return NULL; + if (d_peek_char (di) == 'H') + { + d_advance (di, 1); + di->expansion += sizeof "this"; + pret = &ret; + rqual = d_make_comp (di, DEMANGLE_COMPONENT_XOBJ_MEMBER_FUNCTION, + NULL, NULL); + } + else + { + pret = d_cv_qualifiers (di, &ret, 1); + if (pret == NULL) + return NULL; - /* Parse the ref-qualifier now and then attach it - once we have something to attach it to. */ - rqual = d_ref_qualifier (di, NULL); + /* Parse the ref-qualifier now and then attach it + once we have something to attach it to. */ + rqual = d_ref_qualifier (di, NULL); + } *pret = d_prefix (di, 1); if (*pret == NULL) @@ -1698,6 +1733,7 @@ d_maybe_module_name (struct d_info *di, struct demangle_component **name) /* ::= [] [] ::= [] [] ::= [] [] + ::= [] F [] ::= [] [] ::= [] DC + E [] ::= L [] @@ -1709,11 +1745,18 @@ d_unqualified_name (struct d_info *di, struct demangle_component *scope, { struct demangle_component *ret; char peek; + int member_like_friend = 0; if (!d_maybe_module_name (di, &module)) return NULL; peek = d_peek_char (di); + if (peek == 'F') + { + member_like_friend = 1; + d_advance (di, 1); + peek = d_peek_char (di); + } if (IS_DIGIT (peek)) ret = d_source_name (di); else if (IS_LOWER (peek)) @@ -1790,6 +1833,8 @@ d_unqualified_name (struct d_info *di, struct demangle_component *scope, ret = d_make_comp (di, DEMANGLE_COMPONENT_MODULE_ENTITY, ret, module); if (d_peek_char (di) == 'B') ret = d_abi_tags (di, ret); + if (member_like_friend) + ret = d_make_comp (di, DEMANGLE_COMPONENT_FRIEND, ret, NULL); if (scope) ret = d_make_comp (di, DEMANGLE_COMPONENT_QUAL_NAME, scope, ret); @@ -1964,6 +2009,7 @@ const struct demangle_operator_info cplus_demangle_operators[] = { "ng", NL ("-"), 1 }, { "nt", NL ("!"), 1 }, { "nw", NL ("new"), 3 }, + { "nx", NL ("noexcept"), 1 }, { "oR", NL ("|="), 2 }, { "oo", NL ("||"), 2 }, { "or", NL ("|"), 2 }, @@ -3028,7 +3074,7 @@ d_parmlist (struct d_info *di) struct demangle_component *type; char peek = d_peek_char (di); - if (peek == '\0' || peek == 'E' || peek == '.') + if (peek == '\0' || peek == 'E' || peek == '.' || peek == 'Q') break; if ((peek == 'R' || peek == 'O') && d_peek_next_char (di) == 'E') @@ -3264,7 +3310,7 @@ d_template_args (struct d_info *di) return d_template_args_1 (di); } -/* * E */ +/* * [Q ] E */ static struct demangle_component * d_template_args_1 (struct d_info *di) @@ -3300,13 +3346,17 @@ d_template_args_1 (struct d_info *di) return NULL; pal = &d_right (*pal); - if (d_peek_char (di) == 'E') - { - d_advance (di, 1); - break; - } + char peek = d_peek_char (di); + if (peek == 'E' || peek == 'Q') + break; } + al = d_maybe_constraints (di, al); + + if (d_peek_char (di) != 'E') + return NULL; + d_advance (di, 1); + di->last_name = hold_last_name; return al; @@ -4411,6 +4461,7 @@ d_count_templates_scopes (struct d_print_info *dpi, case DEMANGLE_COMPONENT_CONST_THIS: case DEMANGLE_COMPONENT_REFERENCE_THIS: case DEMANGLE_COMPONENT_RVALUE_REFERENCE_THIS: + case DEMANGLE_COMPONENT_XOBJ_MEMBER_FUNCTION: case DEMANGLE_COMPONENT_TRANSACTION_SAFE: case DEMANGLE_COMPONENT_NOEXCEPT: case DEMANGLE_COMPONENT_THROW_SPEC: @@ -4447,6 +4498,7 @@ d_count_templates_scopes (struct d_print_info *dpi, case DEMANGLE_COMPONENT_PACK_EXPANSION: case DEMANGLE_COMPONENT_TAGGED_NAME: case DEMANGLE_COMPONENT_CLONE: + case DEMANGLE_COMPONENT_CONSTRAINTS: recurse_left_right: /* PR 89394 - Check for too much recursion. */ if (dpi->recursion > DEMANGLE_RECURSION_LIMIT) @@ -4475,6 +4527,7 @@ d_count_templates_scopes (struct d_print_info *dpi, case DEMANGLE_COMPONENT_GLOBAL_CONSTRUCTORS: case DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS: case DEMANGLE_COMPONENT_MODULE_ENTITY: + case DEMANGLE_COMPONENT_FRIEND: d_count_templates_scopes (dpi, d_left (dc)); break; @@ -5221,6 +5274,22 @@ d_print_comp_inner (struct d_print_info *dpi, int options, dpt.next = dpi->templates; dpi->templates = &dpt; dpt.template_decl = typed_name; + + /* Constraints are mangled as part of the template argument list, + so they wrap the _TEMPLATE_ARGLIST. But + d_lookup_template_argument expects the RHS of _TEMPLATE to be + the _ARGLIST, and constraints need to refer to these args. So + move the _CONSTRAINTS out of the _TEMPLATE and onto the type. + This will result in them being printed after the () like a + trailing requires-clause, but that seems like our best option + given that we aren't printing a template-head. */ + struct demangle_component *tnr = d_right (typed_name); + if (tnr->type == DEMANGLE_COMPONENT_CONSTRAINTS) + { + d_right (typed_name) = d_left (tnr); + d_left (tnr) = d_right (dc); + d_right (dc) = tnr; + } } d_print_comp (dpi, options, d_right (dc)); @@ -5869,8 +5938,8 @@ d_print_comp_inner (struct d_print_info *dpi, int options, if (code && !strcmp (code, "gs")) /* Avoid parens after '::'. */ d_print_comp (dpi, options, operand); - else if (code && !strcmp (code, "st")) - /* Always print parens for sizeof (type). */ + else if (code && (!strcmp (code, "st") || !strcmp (code, "nx"))) + /* Always print parens for sizeof (type) and noexcept(expr). */ { d_append_char (dpi, '('); d_print_comp (dpi, options, operand); @@ -6229,6 +6298,11 @@ d_print_comp_inner (struct d_print_info *dpi, int options, d_append_char (dpi, ']'); return; + case DEMANGLE_COMPONENT_FRIEND: + d_print_comp (dpi, options, d_left (dc)); + d_append_string (dpi, "[friend]"); + return; + case DEMANGLE_COMPONENT_TEMPLATE_HEAD: { d_append_char (dpi, '<'); @@ -6263,6 +6337,12 @@ d_print_comp_inner (struct d_print_info *dpi, int options, d_append_string (dpi, "..."); return; + case DEMANGLE_COMPONENT_CONSTRAINTS: + d_print_comp (dpi, options, d_left (dc)); + d_append_string (dpi, " requires "); + d_print_comp (dpi, options, d_right (dc)); + return; + default: d_print_error (dpi); return; @@ -6492,6 +6572,8 @@ d_print_mod (struct d_print_info *dpi, int options, case DEMANGLE_COMPONENT_RVALUE_REFERENCE: d_append_string (dpi, "&&"); return; + case DEMANGLE_COMPONENT_XOBJ_MEMBER_FUNCTION: + return; case DEMANGLE_COMPONENT_COMPLEX: d_append_string (dpi, " _Complex"); return; @@ -6530,11 +6612,13 @@ d_print_function_type (struct d_print_info *dpi, int options, { int need_paren; int need_space; + int xobj_memfn; struct d_print_mod *p; struct d_print_mod *hold_modifiers; need_paren = 0; need_space = 0; + xobj_memfn = 0; for (p = mods; p != NULL; p = p->next) { if (p->printed) @@ -6557,7 +6641,8 @@ d_print_function_type (struct d_print_info *dpi, int options, need_space = 1; need_paren = 1; break; - FNQUAL_COMPONENT_CASE: + case DEMANGLE_COMPONENT_XOBJ_MEMBER_FUNCTION: + xobj_memfn = 1; break; default: break; @@ -6588,6 +6673,8 @@ d_print_function_type (struct d_print_info *dpi, int options, d_append_char (dpi, ')'); d_append_char (dpi, '('); + if (xobj_memfn) + d_append_string (dpi, "this "); if (d_right (dc) != NULL) d_print_comp (dpi, options, d_right (dc)); @@ -6692,32 +6779,10 @@ d_print_conversion (struct d_print_info *dpi, int options, dpt.template_decl = dpi->current_template; } - if (d_left (dc)->type != DEMANGLE_COMPONENT_TEMPLATE) - { - d_print_comp (dpi, options, d_left (dc)); - if (dpi->current_template != NULL) - dpi->templates = dpt.next; - } - else - { - d_print_comp (dpi, options, d_left (d_left (dc))); - - /* For a templated cast operator, we need to remove the template - parameters from scope after printing the operator name, - so we need to handle the template printing here. */ - if (dpi->current_template != NULL) - dpi->templates = dpt.next; + d_print_comp (dpi, options, d_left (dc)); - if (d_last_char (dpi) == '<') - d_append_char (dpi, ' '); - d_append_char (dpi, '<'); - d_print_comp (dpi, options, d_right (d_left (dc))); - /* Avoid generating two consecutive '>' characters, to avoid - the C++ syntactic ambiguity. */ - if (d_last_char (dpi) == '>') - d_append_char (dpi, ' '); - d_append_char (dpi, '>'); - } + if (dpi->current_template != NULL) + dpi->templates = dpt.next; } /* Initialize the information structure we use to pass around diff --git a/coregrind/m_demangle/cp-demangle.h b/coregrind/m_demangle/cp-demangle.h index 8563f91602..7640a4fb60 100644 --- a/coregrind/m_demangle/cp-demangle.h +++ b/coregrind/m_demangle/cp-demangle.h @@ -1,5 +1,5 @@ /* Internal demangler interface for g++ V3 ABI. - Copyright (C) 2003-2023 Free Software Foundation, Inc. + Copyright (C) 2003-2024 Free Software Foundation, Inc. Written by Ian Lance Taylor . This file is part of the libiberty library, which is part of GCC. diff --git a/coregrind/m_demangle/cplus-dem.c b/coregrind/m_demangle/cplus-dem.c index 7259d8516c..cbe6973615 100644 --- a/coregrind/m_demangle/cplus-dem.c +++ b/coregrind/m_demangle/cplus-dem.c @@ -1,5 +1,5 @@ /* Demangler for GNU C++ - Copyright (C) 1989-2023 Free Software Foundation, Inc. + Copyright (C) 1989-2024 Free Software Foundation, Inc. Written by James Clark (jjc@jclark.uucp) Rewritten by Fred Fish (fnf@cygnus.com) for ARM and Lucid demangling Modified by Satish Pai (pai@apollo.hp.com) for HP demangling @@ -204,7 +204,7 @@ ML_(cplus_demangle) (const char *mangled, int options) if (GNAT_DEMANGLING) return ada_demangle (mangled, options); - if (DLANG_DEMANGLING) + if (DLANG_DEMANGLING || AUTO_DEMANGLING) { ret = dlang_demangle (mangled, options); if (ret) diff --git a/coregrind/m_demangle/d-demangle.c b/coregrind/m_demangle/d-demangle.c index a390284b19..9a6a893324 100644 --- a/coregrind/m_demangle/d-demangle.c +++ b/coregrind/m_demangle/d-demangle.c @@ -1,5 +1,5 @@ /* Demangler for the D programming language - Copyright (C) 2014-2023 Free Software Foundation, Inc. + Copyright (C) 2014-2024 Free Software Foundation, Inc. Written by Iain Buclaw (ibuclaw@gdcproject.org) This file is part of the libiberty library. diff --git a/coregrind/m_demangle/demangle.h b/coregrind/m_demangle/demangle.h index 3ab23d838b..a518153472 100644 --- a/coregrind/m_demangle/demangle.h +++ b/coregrind/m_demangle/demangle.h @@ -1,5 +1,5 @@ /* Defs for interface to demanglers. - Copyright (C) 1992-2023 Free Software Foundation, Inc. + Copyright (C) 1992-2024 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License @@ -316,6 +316,8 @@ enum demangle_component_type /* C++11: An rvalue reference modifying a member function. The one subtree is the type which is being referenced. */ DEMANGLE_COMPONENT_RVALUE_REFERENCE_THIS, + /* C++23: A member function with explict object parameter. */ + DEMANGLE_COMPONENT_XOBJ_MEMBER_FUNCTION, /* A vendor qualifier. The left subtree is the type which is being qualified, and the right subtree is the name of the qualifier. */ @@ -450,6 +452,8 @@ enum demangle_component_type DEMANGLE_COMPONENT_TRANSACTION_SAFE, /* A cloned function. */ DEMANGLE_COMPONENT_CLONE, + /* A member-like friend function. */ + DEMANGLE_COMPONENT_FRIEND, DEMANGLE_COMPONENT_NOEXCEPT, DEMANGLE_COMPONENT_THROW_SPEC, @@ -466,6 +470,8 @@ enum demangle_component_type DEMANGLE_COMPONENT_TEMPLATE_TEMPLATE_PARM, DEMANGLE_COMPONENT_TEMPLATE_PACK_PARM, + DEMANGLE_COMPONENT_CONSTRAINTS, + /* A builtin type with argument. This holds the builtin type information. */ DEMANGLE_COMPONENT_EXTENDED_BUILTIN_TYPE diff --git a/coregrind/m_demangle/dyn-string.c b/coregrind/m_demangle/dyn-string.c index 94ec0479a1..c16f269dde 100644 --- a/coregrind/m_demangle/dyn-string.c +++ b/coregrind/m_demangle/dyn-string.c @@ -1,5 +1,5 @@ /* An abstract string datatype. - Copyright (C) 1998-2023 Free Software Foundation, Inc. + Copyright (C) 1998-2024 Free Software Foundation, Inc. Contributed by Mark Mitchell (mark@markmitchell.com). This file is part of GNU CC. @@ -60,7 +60,7 @@ Boston, MA 02110-1301, USA. */ /* Performs in-place initialization of a dyn_string struct. This function can be used with a dyn_string struct on the stack or - embedded in another object. The contents of of the string itself + embedded in another object. The contents of the string itself are still dynamically allocated. The string initially is capable of holding at least SPACE characeters, including the terminating NUL. If SPACE is 0, it will silently be increated to 1. diff --git a/coregrind/m_demangle/dyn-string.h b/coregrind/m_demangle/dyn-string.h index 20750d2cdc..9052780c96 100644 --- a/coregrind/m_demangle/dyn-string.h +++ b/coregrind/m_demangle/dyn-string.h @@ -1,5 +1,5 @@ /* An abstract string datatype. - Copyright (C) 1998-2023 Free Software Foundation, Inc. + Copyright (C) 1998-2024 Free Software Foundation, Inc. Contributed by Mark Mitchell (mark@markmitchell.com). This file is part of GCC. diff --git a/coregrind/m_demangle/rust-demangle.c b/coregrind/m_demangle/rust-demangle.c index 405e439512..4024813c20 100644 --- a/coregrind/m_demangle/rust-demangle.c +++ b/coregrind/m_demangle/rust-demangle.c @@ -1,5 +1,5 @@ /* Demangler for the Rust programming language - Copyright (C) 2016-2023 Free Software Foundation, Inc. + Copyright (C) 2016-2024 Free Software Foundation, Inc. Written by David Tolnay (dtolnay@gmail.com). Rewritten by Eduard-Mihai Burtescu (eddyb@lyken.rs) for v0 support. diff --git a/coregrind/m_demangle/safe-ctype.c b/coregrind/m_demangle/safe-ctype.c index 44e4428ce4..32654ef1e2 100644 --- a/coregrind/m_demangle/safe-ctype.c +++ b/coregrind/m_demangle/safe-ctype.c @@ -1,6 +1,6 @@ /* replacement macros. - Copyright (C) 2000-2023 Free Software Foundation, Inc. + Copyright (C) 2000-2024 Free Software Foundation, Inc. Contributed by Zack Weinberg . This file is part of the libiberty library. diff --git a/coregrind/m_demangle/safe-ctype.h b/coregrind/m_demangle/safe-ctype.h index b3d62ec7d2..fa9c85af4b 100644 --- a/coregrind/m_demangle/safe-ctype.h +++ b/coregrind/m_demangle/safe-ctype.h @@ -1,6 +1,6 @@ /* replacement macros. - Copyright (C) 2000-2023 Free Software Foundation, Inc. + Copyright (C) 2000-2024 Free Software Foundation, Inc. Contributed by Zack Weinberg . This file is part of the libiberty library.