On Jul 12, 2010, at 9:06 AM, Bjorn Reese wrote:
> On 2010-07-10 19:32, Chris Lattner wrote:
>>
>> On Jul 10, 2010, at 8:47 AM, Bjorn Reese wrote:
>>
>>> If I use the "Hello World Pass" example from "Writing an LLVM Pass",
>>> then the C++ function names (from Function::getName) are mangled.
>>>
>>> Is it possible to get the demangled function name instead?
>>
>> You should be able to demangle it yourself. libstdc++ provides the __cxa_demangle function that will do this for you:
>>
http://idlebox.net/2008/0901-stacktrace-demangled/cxa_demangle.htt>>
>> LLVM doesn't provide any direct capabilities to do this.
>
> Is there any way to detect that the function names have been mangled
> by the C++ ABI rules (or that we are optimizing C++ code)?
Every mangling under the Itanium C++ ABI starts with _Z.
Of course it's still possible to declare a C function called, say,
int _ZN3foo3barEi(int x);
which would then have the same mangling as the C++ function
namespace foo { int bar(int x); }
That these collide is okay under the standard because names starting with
underscores are reserved for future use, so programs using them do so at
their own risk.
John.
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev