For this, add a few toString() calls when printing the "undefined symbol" diagnostics; toString() already does demangling on Windows hosts.
Also make lld::demangleMSVC() (called by toString(Symbol*)) call LLVM's microsoftDemangle() instead of UnDecorateSymbolName() so that it works on non-Windows hosts – this makes both updating tests easier and provides a better user experience for people doing cross-links.
Update microsoftDemangle() to work more like itaniumDemangle() after which appears to be modeled, so that lld::demangleItanium() and lld::demangleMSVC() can look alike:
- Use same method of initializing the output stream and its buffer
- Allow a nullptr Status pointer
- Don't print the mangled name on demangling error
- Write to N (if it is non-nullptr)
This doesn't yet do the right thing for symbols starting with __imp_, but that can be improved in a follow-up.