I'm currently working on https://bugs.llvm.org/show_bug.cgi?id=40054. In order to avoid duplication of the demangling code in llvm-objdump, this change moves that code into the demangler library ready for reuse in llvm-readobj. The new function in the library provides memory management via std::string, and also calls both the Itanium and Microsoft demanglers, as per the old behaviour. One minor change is that the microsoftDemangle function will always be called if the input string does not start with "_Z", since the pre-existing "?" check is unnecessary (the microsoftDemangle function does this same check).
One aspect I'm uncertain on is the usage of std::string in Demangle.h. If this is an issue, I would welcome suggestions for an alternative location for this function.
MangledName