[demangler] Avoid special-subst code duplication
authorNathan Sidwell <nathan@acm.org>
Mon, 28 Mar 2022 19:55:45 +0000 (12:55 -0700)
committerNathan Sidwell <nathan@acm.org>
Fri, 13 May 2022 11:35:29 +0000 (04:35 -0700)
commit562ce15924560d14f7062173cbdc6a9cd778e2eb
tree1dc7982e3b76bc36e8f3aa8352689da725f13264
parent89d4904541106172e307efc98fbed5d8a86c4342
[demangler] Avoid special-subst code duplication

We need to expand special substitutions in four different ways.  This
refactors to only have one conversion from enum to string, and derive
the other 3 needs off that.

The SpecialSubstitution node is derived from the
ExpandedSpecialSubstitution.  While this may seem unintuitive, it
works out quite well, as SpecialSubstitution can then use the former'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).

Expansion tests were added in D123134, and remain unchanged.

Reviewed By: MaskRay, dblaikie

Differential Revision: https://reviews.llvm.org/D125257
libcxxabi/src/demangle/ItaniumDemangle.h
llvm/include/llvm/Demangle/ItaniumDemangle.h