From patchwork Tue Oct 5 17:13:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Lu=C3=ADs_Ferreira?= X-Patchwork-Id: 45903 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 85A93385B80B for ; Tue, 5 Oct 2021 17:14:43 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from 2.mo560.mail-out.ovh.net (2.mo560.mail-out.ovh.net [188.165.53.149]) by sourceware.org (Postfix) with ESMTPS id B1AF5385840B for ; Tue, 5 Oct 2021 17:14:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B1AF5385840B Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=lsferreira.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=lsferreira.net Received: from player694.ha.ovh.net (unknown [10.108.1.15]) by mo560.mail-out.ovh.net (Postfix) with ESMTP id 663E720E49 for ; Tue, 5 Oct 2021 17:14:24 +0000 (UTC) Received: from lsferreira.net (252.131.62.94.rev.vodafone.pt [94.62.131.252]) (Authenticated sender: contact@lsferreira.net) by player694.ha.ovh.net (Postfix) with ESMTPSA id A014522D05358; Tue, 5 Oct 2021 17:14:22 +0000 (UTC) Authentication-Results: garm.ovh; auth=pass (GARM-97G0026e36e02b-25cf-4f5e-ae20-70f4c577e822, FE30037FE80C2E37D4FFB74244306D6B358E4563) smtp.auth=contact@lsferreira.net X-OVh-ClientIp: 94.62.131.252 From: =?utf-8?q?Lu=C3=ADs_Ferreira?= To: gcc-patches@gcc.gnu.org Subject: [PATCH] d-demangle: properly skip anonymous symbols Date: Tue, 5 Oct 2021 18:13:58 +0100 Message-Id: <20211005171358.1010162-1-contact@lsferreira.net> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 X-Ovh-Tracer-Id: 9795047714782836984 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvtddrudelgedgudduudcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecunecujfgurhephffvufffkffogggtgfesthekredtredtjeenucfhrhhomhepnfhuvohsucfhvghrrhgvihhrrgcuoegtohhnthgrtghtsehlshhfvghrrhgvihhrrgdrnhgvtheqnecuggftrfgrthhtvghrnhepgeetuddvgfejuedtgfelkefhfedthfeukeegtdduveffgffgieejhfetteethedunecuffhomhgrihhnpegulhgrnhhgrdhorhhgpdgrnhhonhihmhhouhhsrdhfohhonecukfhppedtrddtrddtrddtpdelgedriedvrddufedurddvhedvnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmohguvgepshhmthhpqdhouhhtpdhhvghlohepphhlrgihvghrieelgedrhhgrrdhovhhhrdhnvghtpdhinhgvtheptddrtddrtddrtddpmhgrihhlfhhrohhmpegtohhnthgrtghtsehlshhfvghrrhgvihhrrgdrnhgvthdprhgtphhtthhopehgtggtqdhprghttghhvghssehgtggtrdhgnhhurdhorhhg X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Lu=C3=ADs_Ferreira?= Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" This patch fixes a bug on the D demangler by parsing and skip anonymous symbols correctly, according the ABI specification. Furthermore, it also includes tests to cover anonymous symbols. The spec specifies [1] that a symbol name can be anonymous and multiple anonymous symbols are allowed. [1]: https://dlang.org/spec/abi.html#SymbolName ChangeLog: libiberty/ * d-demangle.c (dlang_parse_qualified): Handle anonymous symbols correctly. * testsuite/d-demangle-expected: New tests to cover anonymous symbols. Signed-off-by: Luís Ferreira --- libiberty/d-demangle.c | 13 +++++++++---- libiberty/testsuite/d-demangle-expected | 8 ++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/libiberty/d-demangle.c b/libiberty/d-demangle.c index 3adf7b562d1..682f73f9923 100644 --- a/libiberty/d-demangle.c +++ b/libiberty/d-demangle.c @@ -1650,13 +1650,18 @@ dlang_parse_qualified (string *decl, const char *mangled, size_t n = 0; do { + /* Skip over anonymous symbols. */ + if (*mangled == '0') + { + do mangled++; + while (*mangled == '0'); + + continue; + } + if (n++) string_append (decl, "."); - /* Skip over anonymous symbols. */ - while (*mangled == '0') - mangled++; - mangled = dlang_identifier (decl, mangled, info); /* Consume the encoded arguments. However if this is not followed by the diff --git a/libiberty/testsuite/d-demangle-expected b/libiberty/testsuite/d-demangle-expected index 44a3649c429..9459f600779 100644 --- a/libiberty/testsuite/d-demangle-expected +++ b/libiberty/testsuite/d-demangle-expected @@ -1450,3 +1450,11 @@ mod.func().nested!(int).nested() --format=dlang _D6mangle__T8fun21753VSQv6S21753S1f_DQBj10__lambda71MFNaNbNiNfZvZQCbQp mangle.fun21753!(mangle.S21753(mangle.__lambda71())).fun21753 +# +--format=dlang +_D8demangle9anonymous0Z +demangle.anonymous +# +--format=dlang +_D8demangle9anonymous03fooZ +demangle.anonymous.foo