Message ID | 20211005171358.1010162-1-contact@lsferreira.net |
---|---|
State | New |
Headers |
Return-Path: <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> 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 <patchwork@sourceware.org>; 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 <gcc-patches@gcc.gnu.org>; 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 <gcc-patches@gcc.gnu.org>; 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?= <contact@lsferreira.net> 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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> Cc: =?utf-8?q?Lu=C3=ADs_Ferreira?= <contact@lsferreira.net> Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> |
Series |
d-demangle: properly skip anonymous symbols
|
|
Commit Message
Luís Ferreira
Oct. 5, 2021, 5:13 p.m. UTC
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 <contact@lsferreira.net>
---
libiberty/d-demangle.c | 13 +++++++++----
libiberty/testsuite/d-demangle-expected | 8 ++++++++
2 files changed, 17 insertions(+), 4 deletions(-)
Comments
On Tue, 2021-10-05 at 18:13 +0100, Luís Ferreira wrote: > 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 <contact@lsferreira.net> > --- > 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__lambda71MFNaNbNiNfZvZQCb > Qp > mangle.fun21753!(mangle.S21753(mangle.__lambda71())).fun21753 > +# > +--format=dlang > +_D8demangle9anonymous0Z > +demangle.anonymous > +# > +--format=dlang > +_D8demangle9anonymous03fooZ > +demangle.anonymous.foo I can't create an issue on bugzilla for this patch, since I don't have an account. I'm going to create one right now. On the meanwhile, feel free to review it.
On Tue, 2021-10-05 at 18:13 +0100, Luís Ferreira wrote: > 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 <contact@lsferreira.net> > --- > 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 Updated ChangeLog: ChangeLog: libiberty/ PR bugzilla_component/102618 * d-demangle.c (dlang_parse_qualified): Handle anonymous symbols correctly. * testsuite/d-demangle-expected: New tests to cover anonymous symbols.
On 10/5/2021 11:53 AM, Luís Ferreira wrote: > On Tue, 2021-10-05 at 18:13 +0100, Luís Ferreira wrote: >> 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. Thanks. I fixed a whitespace nit and installed this patch. Jeff
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