[PATCH] D118132: [demangler] stricter NestedName parsing

Nathan Sidwell via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 25 05:14:27 PST 2022


urnathan created this revision.
urnathan added reviewers: bruno, ChuanqiXu, aaron.ballman.
urnathan requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

The parsing of nested names is a little lax.  This corrects that.

1. The 'L' local name prefix cannot appear before a NestedName -- only

within it.  Let's remove that check from parseName, and then adjust
parseUnscopedName to allow it with or without the 'St' prefix.

2. In a nested name, a <template-param>, <decltype> or <substitution>

can only appear as the first element.  Let's enforce that.  Note I do
not remove these from the loop, to make the change easier to follow
(such a change will come later).

3. Given that, there's no need to special case 'St' outside of the

loop, handle it with the other 'S' elements.

4. There's no need to reset 'EndsWithTemplateArgs' after each

non-template-arg component.  Rather, always clear it and then set it
in the template-args case.

5. An template-args cannot immediately follow a template-args.

6. The parsing of a CDtor name with ABITags would attach the tags to

the NestedName node, rather than the CDTor node.  This is different to
how ABITags are attached to an unscopedName.  Make it consistent.

7. We remain with only CDTor and UnscopedName requireing construction

of a NestedName, so let's drop the PushComponent lambda.

8. Add some tests to catch the new rejected manglings.


https://reviews.llvm.org/D118132

Files:
  libcxxabi/src/demangle/ItaniumDemangle.h
  libcxxabi/test/test_demangle.pass.cpp
  llvm/include/llvm/Demangle/ItaniumDemangle.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118132.402863.patch
Type: text/x-patch
Size: 12780 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220125/3cea76e4/attachment.bin>


More information about the llvm-commits mailing list