This patch picks up the work from D34667 and makes it (hopefully) suitable for an initial commit. Changes from the initial revision:
- More symbols can demangle correctly now than before.
- Variable and function naming convention converted to LLVM conventions.
- Removal of all usage of STL containers. This seems to be important due to its use in libcxxabi and potential future use in compiler-rt. I know it was a sticking point last time. I'm still making use of some type traits, but only because the itanium demangler is already doing so.
- Added an llvm-undname utility.
- Tests converted to using lit style tests and making use of llvm-undname
- Removal of custom String classes (LLVMDemangle now has a StringView class which is shared by the itanium demangler, so I use that instead).
- Undecorated names now try to intelligently add spaces between pointers and function parameters to make the output easier to read.
- Removal of all error messages. Previous code would try to return a message indicating specifically why an error occurred. This made use of std::string, which is now removed (see point number 3). Obviously it's possible to deal with dynamically allocated strings without C++, but I think for the purposes of an initial commit, this isn't necessary and just gets in the way of understanding the core logic.
There are still some limitations. There are certain things which I already know don't undecorate correctly. My testing strategy until now has been to go look at the comprehensive set of mangling tests we have in clang/test/CodeGenCXX/mangle-* and convert 100% of them to demangling tests. Currently I have all of Rui's initial tests passing, plus about 95% of the file mangle-ms.cpp. For the ones that still fail, I chose to left them in the test file with FIXME label rather than omitting it, because otherwise it would just get lost in mangle-ms.cpp and we would forget about it.
In subsequent patches I plan to go through and try to get more things working, adding more of the tests from clang/test/CodeGenCXX/mangle-*.cpp along the way until we have 100%