Hi, 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? Regards, Blackbox dev team -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130509/0ed811f7/attachment.html>
No, the LLVM Mangler class really only does low-level manglings like '_' prefixing, stdcall mangling on Windows, and escaping funny symbols. The Clang mangler, however, does what you want. But, you'll need to feed it a clang AST in order to get a name out. Depending on the parameters of your function, this may be easy or hard. On Thu, May 9, 2013 at 8:38 AM, B B <blackbox.dev.ml at gmail.com> wrote:> Hi, > 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? > > Regards, > Blackbox dev team > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >
Hi,> 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: class A; void foo(A*); // _Z3fooP1A class Different; typedef Different A; void foo(A*); // _Z3fooP9Different Tim.
> The Clang mangler, however, does what you want. But, you'll need to > feed it a clang AST in order to get a name out. Depending on the > parameters of your function, this may be easy or hard.By the way, does anyone know of a project which *does* call into Clang's mangling framework from outside? I'd be interested to know purely out of curiosity. Cheers. Tim.
Reasonably Related Threads
- [LLVMdev] C++ Name mangling
- [LLVMdev] C++ Name mangling
- VC C++ demangler
- [LLVMdev] Where does LLVM mangle characters from llvm-ir names while generating native code?
- [LLVMdev] Where does LLVM mangle characters from llvm-ir names while generating native code?