* [PATCH] d-demangle: properly skip anonymous symbols
@ 2021-10-05 17:13 Luís Ferreira
2021-10-05 17:34 ` Luís Ferreira
2021-10-05 17:53 ` Luís Ferreira
0 siblings, 2 replies; 4+ messages in thread
From: Luís Ferreira @ 2021-10-05 17:13 UTC (permalink / raw)
To: gcc-patches; +Cc: Luís Ferreira
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
--
2.33.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] d-demangle: properly skip anonymous symbols
2021-10-05 17:13 [PATCH] d-demangle: properly skip anonymous symbols Luís Ferreira
@ 2021-10-05 17:34 ` Luís Ferreira
2021-10-05 17:53 ` Luís Ferreira
1 sibling, 0 replies; 4+ messages in thread
From: Luís Ferreira @ 2021-10-05 17:34 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 2702 bytes --]
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.
--
Sincerely,
Luís Ferreira @ lsferreira.net
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] d-demangle: properly skip anonymous symbols
2021-10-05 17:13 [PATCH] d-demangle: properly skip anonymous symbols Luís Ferreira
2021-10-05 17:34 ` Luís Ferreira
@ 2021-10-05 17:53 ` Luís Ferreira
2021-10-17 22:39 ` Jeff Law
1 sibling, 1 reply; 4+ messages in thread
From: Luís Ferreira @ 2021-10-05 17:53 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 2768 bytes --]
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.
--
Sincerely,
Luís Ferreira @ lsferreira.net
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] d-demangle: properly skip anonymous symbols
2021-10-05 17:53 ` Luís Ferreira
@ 2021-10-17 22:39 ` Jeff Law
0 siblings, 0 replies; 4+ messages in thread
From: Jeff Law @ 2021-10-17 22:39 UTC (permalink / raw)
To: Luís Ferreira, gcc-patches
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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-10-17 22:39 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-05 17:13 [PATCH] d-demangle: properly skip anonymous symbols Luís Ferreira
2021-10-05 17:34 ` Luís Ferreira
2021-10-05 17:53 ` Luís Ferreira
2021-10-17 22:39 ` Jeff Law
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).