Fix demangling of namespaced type arguments #220
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
Demangler
breaks up a mangled identifier into a list of "scopes":This does not work when the idenfitier is for a template with a namespaced type argument:
The problem is that, when splitting the demangled name into scopes, it ignores the meaning of
<
and>
characters, instead treating them as part of the name. The most hygienic solution is to replace the list of scopes with a more complex structure that can also hold type arguments.As this would require significant changes to the
Demangler
, and theDemangler
is used in a few places where the effect of such changes would be unclear. I've opted for a quick and dirty solution for now.The list of scopes will still contain broken names, exactly as shown in the example above. When converting this list of scopes into a javascript name, the templates are removed after joining the scopes together instead of before.
cleanupTemplates
used to assume that the template parameters, if any, are at the end of the string passed tocleanupTemplates
. This was true before because>
is always at the end of a type name, or it is followed by::
. But now, becausecleanupTemplates
is only called after joining the scopes back together, it can also be passed strings with multiple template parameters, or where the template parameters are not at the end of the string.cleanupTemplates
is updated to handle these cases as well, splicing out template parameters from the middle of the string instead of just at the end.Side note: this whole class is a mess, half of the functions aren't even used anywhere.