This patch is not intended to be submitted as-is. I'm sending this out
now to get comments if there's anyone who has an opinion on the
implementation strategy.
So this is an initial patch for a Microsoft-style symbol demangler.
To give you an overview, I'll describe the code from 10,000 feet view.
- First of all, this demangler is not based on the exiting Itanium demangler which resides in the same directory. This is because the existing demangler seems too complicated to me and reported to be too slow.
I designed this demangler with a goal to reduce the number of memory allocations as possible. This hasn't yet optimized hard, because I don't want to do that until the feature is complete, but I think you can see it from the code. - Internally, all mangled symbols are converted to ASTs (or Types) and then converted to strings. This simplifies the code a lot. Particularly, constructing a string representing a C++ type is hard because you have to append new strings to both ends of an intermediate result. By using ASTs, you can eliminate that complexity.
I also believe that this is faster than constructing strings directly. - This demangler does not use any LLVM code. So, there's no use of StringRef, ArrayRef, etc. I had to write my own small String class, which is a bit silly, but this is intentional as this demangler is supposed to be used in other programs such as libcxxabi as well.
I don't ask you guys to do regular code review on this patch because the
patch is incomplete. Particularly, this patch
- does not provide a support for demanglign C++ special functions such as operator overloads, except the ctor and dtor, and
- does not provide a "proper" external function (whatever it means). The current microsoftDemangle function is provided just for testing.
I guess that this patch might be fun to read. Enjoy.
Isnt this effectively std::string_view or StringRef?