1 //===- Strings.cpp -------------------------------------------------------===//
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "lld/Common/Strings.h"
11 #include "llvm/Demangle/Demangle.h"
16 // Returns the demangled C++ symbol name for Name.
17 Optional<std::string> lld::demangleItanium(StringRef Name) {
18 // itaniumDemangle can be used to demangle strings other than symbol
19 // names which do not necessarily start with "_Z". Name can be
20 // either a C or C++ symbol. Don't call itaniumDemangle if the name
21 // does not look like a C++ symbol name to avoid getting unexpected
22 // result for a C symbol that happens to match a mangled type name.
23 if (!Name.startswith("_Z"))
26 char *Buf = itaniumDemangle(Name.str().c_str(), nullptr, nullptr, nullptr);