On 10 Jun 2014, at 03:44, Ed Maste <[email protected]> wrote:

> I had the same issue in LLVM, and as hacky as it seems, the solution
> is to check that the name starts with "_Z" before passing it to
> __cxa_demangle.
> 
> For reference the LLVM review for the change is here:
> http://reviews.llvm.org/D2552
> 
> I didn't get around to testing it on Linux; since you have a test
> application ready it would be interesting to see the result of
> __cxa_demangle("f") there.

If you know that the thing that you are demangling is a symbol name, then you 
can use the _Z check, which isn't really a hack - it's a marker added to 
identify C++ symbols.  Note that, if you're writing portable code, you need to 
remember that some systems prepend an underscore to all compiler-generated 
symbols, so you may also need to check for __Z and trim the leading _.

The __cxa_demangle() function has to handle things that are not just symbols 
(types and so on) and so can't do this test itself.  Its most common use is 
generating a human-friendly error for an uncaught exception, where it is just 
parsing a type encoding.

The demangler that we ship is from libelftc.  It also fails on a number of 
C++11 types and doesn't handle some complex template cases.  

David

_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
To unsubscribe, send any mail to "[email protected]"

Reply via email to