[PATCH] D49552: Add a Microsoft Demangler library and utility.

Zachary Turner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 19 09:15:30 PDT 2018


zturner created this revision.
zturner added reviewers: ruiu, rnk, compnerd, majnemer, pcc, smeenai, thakis.
Herald added subscribers: erik.pilkington, hiraditya, mgorny.

This patch picks up the work from https://reviews.llvm.org/D34667 and makes it (hopefully) suitable for an initial commit.  Changes from the initial revision:

1. More symbols can demangle correctly now than before.
2. Variable and function naming convention converted to LLVM conventions.
3. 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.
4. Added an `llvm-undname` utility.
5. Tests converted to using lit style tests and making use of `llvm-undname`
6. Removal of custom String classes (LLVMDemangle now has a `StringView` class which is shared by the itanium demangler, so I use that instead).
7. Undecorated names now try to intelligently add spaces between pointers and function parameters to make the output easier to read.
8. 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 //de//mangling 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%


https://reviews.llvm.org/D49552

Files:
  llvm/include/llvm/Demangle/Demangle.h
  llvm/lib/Demangle/CMakeLists.txt
  llvm/lib/Demangle/MicrosoftDemangle.cpp
  llvm/test/Demangle/ms-basic.test
  llvm/test/Demangle/ms-mangle.test
  llvm/test/Demangle/ms-windows.test
  llvm/tools/LLVMBuild.txt
  llvm/tools/llvm-undname/CMakeLists.txt
  llvm/tools/llvm-undname/LLVMBuild.txt
  llvm/tools/llvm-undname/llvm-undname.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49552.156285.patch
Type: text/x-patch
Size: 55670 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180719/c4d6ed45/attachment-0001.bin>


More information about the llvm-commits mailing list