I know how to demangle C++ names.
But I would like to do the opposite – calling into C++ functions and classes.
Yesterday I searched the internet for this and found only one solution at stackoverflow requiring one to dynamically run g++ and filter the created assembler code.
There ought to be an easier way!
Of course one could compile an example C++ implementation using the -emit-llvm option.
But I’ve got multiple implementations, which only differ by the integer type used (char, short, int, int64_t).
So how does clang do it?
Clang does the whole implementation itself in ItaniumMangle.cpp (or the Microsoft equivalent). Both the LLVM-adjacent projects I know that do C++ interop (LLDB and Swift) link against Clang in some way and get it to mangle names for them.
1 Like