This is an archive of the discontinued LLVM Phabricator instance.

[demangler] Avoid special-subst code duplication
ClosedPublic

Authored by urnathan on May 9 2022, 12:13 PM.

Details

Reviewers
MaskRay
dblaikie
Group Reviewers
Restricted Project
Commits
rG562ce1592456: [demangler] Avoid special-subst code duplication
Summary

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, and remain unchanged.

Diff Detail

Event Timeline

urnathan created this revision.May 9 2022, 12:13 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 9 2022, 12:13 PM
Herald added a subscriber: StephenFan. · View Herald Transcript
urnathan requested review of this revision.May 9 2022, 12:13 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 9 2022, 12:13 PM
urnathan updated this revision to Diff 428909.May 12 2022, 5:18 AM

Address CI issue

dblaikie accepted this revision.May 12 2022, 3:04 PM

Looks about right at a glance - thanks!

This revision is now accepted and ready to land.May 12 2022, 3:04 PM
MaskRay accepted this revision.May 12 2022, 3:37 PM
This revision was landed with ongoing or failed builds.May 13 2022, 4:35 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptMay 13 2022, 4:35 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript