[PATCH] D34667: [Demangler] [DO NOT SUBMIT] Initial patch for Microsoft demangler.

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 26 22:51:45 PDT 2017


ruiu created this revision.
Herald added subscribers: hiraditya, mgorny.

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.


https://reviews.llvm.org/D34667

Files:
  llvm/include/llvm/Demangle/Demangle.h
  llvm/lib/Demangle/CMakeLists.txt
  llvm/lib/Demangle/MicrosoftDemangle.cpp
  llvm/unittests/CMakeLists.txt
  llvm/unittests/Demangle/CMakeLists.txt
  llvm/unittests/Demangle/MicrosoftDemangleTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34667.104093.patch
Type: text/x-patch
Size: 23964 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170627/8a1369eb/attachment.bin>


More information about the llvm-commits mailing list