#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Config/config.h"
+#include "llvm/Demangle/Demangle.h"
#include <algorithm>
-#ifdef HAVE_CXXABI_H
-#include <cxxabi.h>
-#endif
-
using namespace llvm;
using namespace lld;
using namespace lld::elf;
// Returns the demangled C++ symbol name for Name.
std::string elf::demangle(StringRef Name) {
-#if !defined(HAVE_CXXABI_H)
- return Name;
-#else
// __cxa_demangle can be used to demangle strings other than symbol
// names which do not necessarily start with "_Z". Name can be
// either a C or C++ symbol. Don't call __cxa_demangle if the name
if (!Name.startswith("_Z"))
return Name;
- char *Buf =
- abi::__cxa_demangle(Name.str().c_str(), nullptr, nullptr, nullptr);
+ char *Buf = itaniumDemangle(Name.str().c_str(), nullptr, nullptr, nullptr);
if (!Buf)
return Name;
std::string S(Buf);
free(Buf);
return S;
-#endif
}
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/Triple.h"
#include "llvm/Config/config.h"
+#include "llvm/Demangle/Demangle.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Errc.h"
#include "llvm/Support/Host.h"
#include "llvm/Support/Path.h"
#include <algorithm>
-#if defined(HAVE_CXXABI_H)
-#include <cxxabi.h>
-#endif
-
using lld::mach_o::ArchHandler;
using lld::mach_o::MachOFile;
using lld::mach_o::MachODylibFile;
if (!symbolName.startswith("__Z"))
return symbolName;
-#if defined(HAVE_CXXABI_H)
SmallString<256> symBuff;
StringRef nullTermSym = Twine(symbolName).toNullTerminatedStringRef(symBuff);
// Mach-O has extra leading underscore that needs to be removed.
const char *cstr = nullTermSym.data() + 1;
int status;
- char *demangled = abi::__cxa_demangle(cstr, nullptr, nullptr, &status);
+ char *demangled = llvm::itaniumDemangle(cstr, nullptr, nullptr, &status);
if (demangled) {
std::string result(demangled);
// __cxa_demangle() always uses a malloc'ed buffer to return the result.
free(demangled);
return result;
}
-#endif
return symbolName;
}