1
1
mirror of https://github.com/rui314/mold.git synced 2024-09-20 17:39:56 +03:00
mold/demangle.cc
2021-12-10 16:24:54 +09:00

25 lines
439 B
C++

#include "mold.h"
#include <cstdlib>
#include <cxxabi.h>
namespace mold {
std::string_view demangle(std::string_view name) {
if (name.starts_with("_Z")) {
static thread_local char *buf;
static thread_local size_t buflen;
int status;
char *p = abi::__cxa_demangle(std::string(name).c_str(), buf, &buflen, &status);
if (status == 0) {
buf = p;
return p;
}
}
return name;
}
} // namespace mold