Avoid using std::string and std::vector in the demangler. Instead use vectors/strings with storage allocated by the NodeFactory’s bump pointer allocator.
This brings another 35% speedup. Especially in the case the Demangle::Context is not reused for subsequent demanglings.
Explicitly specify the aliased type (IndexType) rather than the
underlying type (unsigned) when invoking `CreateNode` to disambiguate
overload when targeting Windows. NFC.
This makes the demangler about 10 times faster.
It also changes the lifetimes of nodes. Previously nodes were reference-counted.
Now the returned demangle node-tree is owned by the Demangler class and it’s lifetime ends with the lifetime of the Demangler.
Therefore the old (and already deprecated) global functions demangleSymbolAsNode and demangleTypeAsNode are no longer available.
Another change is that the demangling for reflection now only supports the new mangling (which should be no problem because
we are generating only new mangled names for reflection).
Instead of a global demangleSymbolAsNode, which returns a reference-counted NodePointer, there is now a Context class which owns the nodes.
So now demangleSymbolAsNode is a member of Context and the returned NodePointer is alive as long as the Context is alive.
This is still a NFC: the new ABI still maps to the old functions.
The purpose of this change is to let lldb adapt to the new API and then we can switch to the new implementation.
This is what ‘_Tt’ was in the old mangling.
Maybe we don’t need this eventually. But currently at least swift-ide-test relies on having a special mangling for such symbols
Use a new mangling scheme that describes the layout of compound boxes. For compatibility with reflection-based clients, continue to use the legacy mangling for single-field boxes when emitting reflection TypeRefs until we fully support reflection for the new box implementation.
Following classes provide symbol mangling for specific purposes:
*) Mangler: the base mangler class, just providing some basic utilities
*) ASTMangler: for mangling AST declarations
*) SpecializationMangler: to be used in the optimizer for mangling specialized function names
*) IRGenMangler: mangling all kind of symbols in IRGen
All those classes are not used yet, so it’s basically a NFC.
Another change is that some demangler node types are added (either because they were missing or the new demangler needs them).
Those new nodes also need to be handled in the old demangler, but this should also be a NFC as those nodes are not created by the old demangler.
My plan is to keep the old and new mangling implementation in parallel for some time. After that we can remove the old mangler.
Currently the new implementation is scoped in the NewMangling namespace. This namespace should be renamed after the old mangler is removed.