Printing (only) demangled C++ symbols in lld diagnostics?

Is there a specific reason why diagnostics like

ld.lld: error: undefined reference due to --no-allow-shlib-undefined: std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>::_M_replace_cold(char*, unsigned long, char const*, unsigned long, unsigned long)
>>> referenced by ../../lib/

only prints the demangled symbol? I think this needlessly hides information from the user.
Going from a mangled to a demangled symbol is easy for the user with c++filter. But going in the other direction isn’t even possible in general, as e.g. both _ZN1SD0Ev and _ZN1SD1Ev map to the same demangled S::~S().

1 Like

The symbol names are only dangled if -demangle is specified in the link command. Without -demangle, it would have printed _ZN1SD0Ev or _ZN1SD1Ev

1 Like

ah, and which is apparently the default (for better or worse); -Wl,-no-demangle to the rescue

1 Like

For methods, I find this mostly helpful, but I’ve been caught a few times when the error message says something like void foo(void) not found and I definitely have a foo symbol, but don’t notice that it’s actually looking for a _Z3foov symbol. It would be really nice if there was some visual indicator such as “C++ mangled symbol for void foo(void), pass -no-demangle to see mangled symbols” or similar in the error message.