[LLVMdev] C++ Name mangling
t.p.northover at gmail.com
Thu May 9 05:53:47 PDT 2013
> I'm trying to find a solution to the following problem: I need to generate a
> mangled name for given C++ function. Could I use llvm Mangler class for it?
I'm afraid not. That's for much lower level things like platforms
which add a leading '_' to every global symbol.
In principle the LLVM code that actually handles this is under Clang:
lib/AST/ItaniumMangle.cpp (for UNIX-like platforms) and
lib/AST/MicrosoftMangle.cpp (still incomplete, I believe). But
actually using them outside Clang would be very difficult. You'd
basically have to artificially create a Clang AST describing the
function you want to mangle (including all of its surrounding context
like the types it uses and so on) to feed in.
And even deciding on that context is much trickier than it first
appears. The following two functions are different, for example:
void foo(A*); // _Z3fooP1A
typedef Different A;
void foo(A*); // _Z3fooP9Different
More information about the llvm-dev