[PATCH] D125257: [demangler] Avoid special-subst code duplication

Nathan Sidwell via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 9 12:13:21 PDT 2022


urnathan created this revision.
urnathan added reviewers: MaskRay, dblaikie.
Herald added a subscriber: StephenFan.
Herald added a project: All.
urnathan requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

We need to expand special substitutions names in four different ways, and were doing it with 4 different switch blocks. This refactors the demangler to only have one conversion from enum to string, and derive the other 3 needs off that.

If we base the SpecialSubstitution node from the ExpandedSpecialSubstitution, this reuse becomes simpler.  While this may seem the wrong derivation, it works out quite well, as the SpecialSubstitution can then use the later's getBaseName and remove an unneeded 'basic_' prefix, for those substitutions that are instantiations (to known typedef).

Similarly all those instantiations use the same set of template arguments (with 'basic_string', getting an additional 'allocator' arg). There's no need to write each one separately.

Expansion tests were added in D123134 <https://reviews.llvm.org/D123134>, and remain unchanged.


https://reviews.llvm.org/D125257

Files:
  libcxxabi/src/demangle/ItaniumDemangle.h
  llvm/include/llvm/Demangle/ItaniumDemangle.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125257.428154.patch
Type: text/x-patch
Size: 9940 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220509/6c87e41b/attachment.bin>


More information about the llvm-commits mailing list