reland: [Demangle] make llvm::demangle take std::string_view rather than const std::string&
As suggested by @erichkeane in
https://reviews.llvm.org/D141451#inline-1429549
There's potential for a lot more cleanups around these APIs. This is
just a start.
Callers need to be more careful about sub-expressions producing strings
that don't outlast the expression using `llvm::demangle`. Add a
release note.
Differential Revision: https://reviews.llvm.org/D149104
diff --git a/lld/ELF/Symbols.cpp b/lld/ELF/Symbols.cpp
index 62a8a3c..840385a 100644
--- a/lld/ELF/Symbols.cpp
+++ b/lld/ELF/Symbols.cpp
@@ -45,9 +45,7 @@
// Returns a symbol for an error message.
static std::string maybeDemangleSymbol(StringRef symName) {
- if (elf::config->demangle)
- return demangle(symName.str());
- return symName.str();
+ return elf::config->demangle ? demangle(symName.str()) : symName.str();
}
std::string lld::toString(const elf::Symbol &sym) {