[PATCH] D50586: [Demangle] Add itaniumFindTypesInMangledName()

Pavel Labath via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 11 00:32:52 PDT 2018


labath added a comment.

I've recently ran into another case where I've needed to modify a mangled name.

In short, the problem was that clang does not bother emitting complete object constructors (C1) when they are linkonce_odr, this causes a problem for us in expression evaluation, since it's then never possible to construct these objects in the expression. After my attempts to get clang (https://reviews.llvm.org/D46685)  to emit these C1 symbols always resulted in code size regressions, we started looking at ways to fix this elsewhere. One of the possibilities was to substitute the C1 for the C2 version when we know they are identical. However, for this to work, I'd need a) to know whether a symbol is C1 or C2; b) modify the symbol from C1 to C2.

Doing things this way, would require adding more hooks to the demangler, which does not seem particularly nice. OTOH, exposing the AST would allow other interesting uses too. (For example, sometimes the mangled name actually contains more information than debug info -- debug info will describe a template function as `foo<int>(int)`, but it will not tell you whether the `int` argument is actually the template parameter of the function, or if it's just a static type. This currently causes problems for us when trying to round-trip these functions into clang AST. If we could understand the structure of the mangled name (which preserves this kind of information), we could do a better job at supporting these functions).

I've put up my work so far at https://reviews.llvm.org/D50599. It is still very WIP, but I believe it's enough to show the general direction of where I'm heading with this. Unfortunately,  I don't think I'll have the time in the next 2-3 weeks to complete that patch, but I wanted to show a possible alternative to the approach taken here (and see if it's even worth trying to complete that patch).


https://reviews.llvm.org/D50586





More information about the llvm-commits mailing list