lldb-dev thread: http://lists.llvm.org/pipermail/lldb-dev/2018-January/013186.html
Currently, the demangler in ItaniumDemangler works by parsing the mangled name into an AST-like format, then traverses that AST to produce the demangled name. Some users (LLDB) consume this demangled name by writing custom parsers. This is redundant (in a very hot section, AFAIK), as the name has to be printed and the re-parsed. For large demangled names with many (potentially nested) <template-param>s and substitutions, the demangler has to produce a massive symbol that LLDB has to dig through in order to find the small amount of information that it needs. Just parsing to an AST expands no substitutions, and should run in about O(strlen of the mangled name).
This patch adds a partial demangling API that parses the mangled name into the AST-like format without printing and provides some functions to access interesting information from that AST. If LLDB used this instead of char*s to investigate the demangled name, it would be cleaner and save time. (AFAIK, I've never touched lldb!)
I've put this patch up super early, I still want to add more tests and make it more robust. I'm hoping that this would be a good place to find out if this is what the LLDB people actually want. Does anyone have any thoughts?
Thanks for taking a look!
Erik