From patchwork Wed Jan 17 12:07:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Clifton X-Patchwork-Id: 188812 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:42cf:b0:101:a8e8:374 with SMTP id q15csp860931dye; Wed, 17 Jan 2024 04:07:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IGy+yDqi9aYDyGUA+66Xny5Je+qwEUOUdrQJgvZ0BE3d/G9JUS6i4Aay9jofWdO4DlJi+qt X-Received: by 2002:ad4:5d4e:0:b0:681:7567:86ee with SMTP id jk14-20020ad45d4e000000b00681756786eemr2339005qvb.71.1705493278971; Wed, 17 Jan 2024 04:07:58 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705493278; cv=pass; d=google.com; s=arc-20160816; b=rz9iHi0NALHNFxCgr8tojAVcnPdJQ7AHSOk16laUYvDZXAmqRtbbIceLFFwifexnVU CzatH+0eP9RRWxL737Lun9fhp2oC7skNUkFA5k9nyF4HM9QhW+rYcC0L971CCvrVKlU0 UE3PnfVcDMEChKDdDHPE+M35nN+fuTb4EiXeKMZ0ck6254P1F5u6jy656YL/28qqn9ZP lZpqdzIV3/7g4j2ZqSAEFeLy1sWuSPo7GOgiiuL78WcewVXHUqPZRZ67HA1uCRLutPvY fp4QjjY7M6yYgiXcw1Zeiuu75EmPRl0US8xLdIUNM2dC5esRG4F56LHKUgYY0kRWjsfd cltw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mime-version:message-id:date :subject:to:from:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=i5S7OOkyIQV7gCbhOqXzKBXXU+dL3IYww4Q1naN23Qc=; fh=NLxAvL/bDfPg4AGOtxqvQlND8vazkZrNzKLY8+LAbBY=; b=LtsdZa1KLZcdlMGCw2a6fD860DzTcO3vAU4Ya7bz8zN/TA37wi2UNR4h4UNuKX6aP7 8TDpcVquG/2DiFpJ+kZCvfIDcek3XPBnSk1HtanpEspELhfRRJLMIttTF/qXG5k8UxJI /i0TwBLgaNWu0XR1XD35Nqb/XmBVDkCtXQnvicWyd5nDVm3eXUT++4J2WLpUuZspuYHw /SzFz2lWDczzhI/hnFLAgOvZFv0udvT6hWc3OKU5UXxMEPJF24xDbPsRJv7PWjUrAX1L taMLS1GVlROyPo0AogjSEzVdLOWwzwSKOCOfUujh400rvs3V/JUQ7S9X/mNNFm+8VOyq EHTg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=A3eSfLUh; arc=pass (i=1); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id j1-20020a0c9cc1000000b006817ae41797si1040930qvf.391.2024.01.17.04.07.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jan 2024 04:07:58 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=A3eSfLUh; arc=pass (i=1); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A75343858402 for ; Wed, 17 Jan 2024 12:07:58 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 0E7313858D33 for ; Wed, 17 Jan 2024 12:07:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0E7313858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0E7313858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705493271; cv=none; b=MwdzWnFyNGrj8iQqlcwDQYYLHkATxcTl6Hm8ZdiHiNrz0SFfTMkZCEoqqQJ0OhLewy/C/mcN5irZW9IZu54d2RZyOxXNoU57623jLTIOVGeSvmfzqprmRJyU3d7DFYcgvEFzs5+u4utLWCNN32vf/BCzYEtgZ2VOOfVCE0mdGyg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705493271; c=relaxed/simple; bh=yZ/5+MmieswSWNKAa8soYuciJRXG/jbkmXSSeX7vwjQ=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=X9gHXnA392RPXKuDD3obIrNyRphIdp5GxDiBghJT5M+yremLhRSj7oLJsUPT6pfqcCgT96e3Kpkm6NBTk0m6D2kfnt8ftE4oQKglxyowz8dMcVUi7HvuEY9jCHTQK2r7Ff0j5GWdVcUuGFl+b+7vWqqymnNwo9tzmZPNZpj7mss= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705493269; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=i5S7OOkyIQV7gCbhOqXzKBXXU+dL3IYww4Q1naN23Qc=; b=A3eSfLUhicYkHQYhYm1xAlzGAve3SrApcNVmfW6vhG0zDAmLxMoSQkla6bMUbLMFQRzPck 8rsHzRX5DdWN6FGT6C0gLcpW3htsShMjC96Ww2ukSDLA49swWg1/qrJWcjawa65WBpuAmN uCuDfo+82gszrdxk9LRmCwVPsCGKrHI= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-94-P46_A-hjP-CM2YZ-43AgEw-1; Wed, 17 Jan 2024 07:07:48 -0500 X-MC-Unique: P46_A-hjP-CM2YZ-43AgEw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D5B58863E8A for ; Wed, 17 Jan 2024 12:07:47 +0000 (UTC) Received: from prancer.redhat.com (unknown [10.42.28.74]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6B8C12027042 for ; Wed, 17 Jan 2024 12:07:47 +0000 (UTC) From: Nick Clifton To: binutils@sourceware.org Subject: Commit: Bring in Date: Wed, 17 Jan 2024 12:07:46 +0000 Message-ID: <87frywmact.fsf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-10.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788339320379308574 X-GMAIL-MSGID: 1788339320379308574 Hi Guys, I am applying the attached patch to the mainline and 2.42 branch sources in order to update libiberty's demangling capabilities with support for the explicit object member function mangling, as used by Clang and gcc v14: https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=65388b28656d65595bdaf191df85af81c35ca638 https://github.com/itanium-cxx-abi/cxx-abi/issues/148 Cheers Nick From 65388b28656d65595bdaf191df85af81c35ca638 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Sat, 13 Jan 2024 10:23:53 +0100 Subject: [PATCH] c++, demangle: Implement https://github.com/itanium-cxx-abi/cxx-abi/issues/148 non-proposal The following patch attempts to implement what apparently clang++ implemented for explicit object member function mangling, but nobody actually proposed in patch form in https://github.com/itanium-cxx-abi/cxx-abi/issues/148 2024-01-13 Jakub Jelinek gcc/cp/ * mangle.cc (write_nested_name): Mangle explicit object member functions with H as per https://github.com/itanium-cxx-abi/cxx-abi/issues/148 non-proposal. gcc/testsuite/ * g++.dg/abi/mangle79.C: New test. include/ * demangle.h (enum demangle_component_type): Add DEMANGLE_COMPONENT_XOBJ_MEMBER_FUNCTION. libiberty/ * cp-demangle.c (FNQUAL_COMPONENT_CASE): Add case for DEMANGLE_COMPONENT_XOBJ_MEMBER_FUNCTION. (d_dump): Handle DEMANGLE_COMPONENT_XOBJ_MEMBER_FUNCTION. (d_nested_name): Parse H after N in nested name. (d_count_templates_scopes): Handle DEMANGLE_COMPONENT_XOBJ_MEMBER_FUNCTION. (d_print_mod): Likewise. (d_print_function_type): Likewise. * testsuite/demangle-expected: Add tests for explicit object member functions. --- gcc/cp/mangle.cc | 3 ++ gcc/testsuite/g++.dg/abi/mangle79.C | 61 +++++++++++++++++++++++++++ include/demangle.h | 2 + libiberty/cp-demangle.c | 39 ++++++++++++++--- libiberty/testsuite/demangle-expected | 9 ++++ 5 files changed, 107 insertions(+), 7 deletions(-) create mode 100644 gcc/testsuite/g++.dg/abi/mangle79.C diff --git a/include/demangle.h b/include/demangle.h index 6a03f4f4f93..49b84d4de88 100644 --- a/include/demangle.h +++ b/include/demangle.h @@ -314,6 +314,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. */ diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c index dee36173896..fc2cf64e6e0 100644 --- a/libiberty/cp-demangle.c +++ b/libiberty/cp-demangle.c @@ -581,6 +581,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 @@ -749,6 +750,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; @@ -1547,6 +1551,8 @@ d_name (struct d_info *di, int substable) /* ::= N [] [] E ::= N [] [] E + ::= N H E + ::= N H E */ static struct demangle_component * @@ -1559,13 +1565,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) @@ -4427,6 +4444,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: @@ -6521,6 +6539,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; @@ -6559,11 +6579,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) @@ -6586,7 +6608,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; @@ -6617,6 +6640,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)); diff --git a/libiberty/testsuite/demangle-expected b/libiberty/testsuite/demangle-expected index 0997e96ea43..0f7b97a6d0a 100644 --- a/libiberty/testsuite/demangle-expected +++ b/libiberty/testsuite/demangle-expected @@ -1700,3 +1700,12 @@ void f() requires C # requires after () _Z1fIiEvvQ1CIT_E void f() requires C + +_ZNH1S3fooES_ +S::foo(this S) + +_ZNH1S3barILi5EiEEvS_T0_ +void S::bar<5, int>(this S, int) + +_ZNH1S3bazERKS_ +S::baz(this S const&) -- 2.39.3