[LLVMdev] How to get the original function name in C++?
Jonathan Roelofs
jonathan at codesourcery.com
Thu Dec 11 07:31:56 PST 2014
This is called name mangling, and what you want is a demangler. c++filt is a
program that does this.
If you're looking for a library function you can call that will do this for you,
there's __cxa_demangle
https://mentorembedded.github.io/cxx-abi/abi.html#demangler which should be
provided by your c++ abi library. Clang might have a more convenient wrapper
around that or it's own separate implementation, but I'm not sure where that
would be.
Cheers,
Jon
On 12/11/14 4:52 AM, zy jj wrote:
> Hi, everyone!
> I'm new here trapped by a simple problem for days.
> When LLVM translates C++ source code to IR, it will add a prefix to the
> function name. For example:
> source code:
> int foo(){
> return 1;
> }
> IR form:
> define i32 @_Z3foov() #0 {
> entry:
> ret i32 1, !dbg !20
> }
> The getName() method returns _Z3foov, then how can I get foo? I know
> the debugging information is contained in metadata, but I've no idea on
> using it.
> Thanks a lot for any help.
>
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
--
Jon Roelofs
jonathan at codesourcery.com
CodeSourcery / Mentor Embedded
More information about the llvm-dev
mailing list