2018-04-09 13:52:39 +00:00
|
|
|
#include <common/demangle.h>
|
2017-12-08 01:34:52 +00:00
|
|
|
|
2019-03-12 19:20:32 +00:00
|
|
|
#if defined(__has_feature)
|
|
|
|
#if __has_feature(memory_sanitizer)
|
|
|
|
#define MEMORY_SANITIZER 1
|
|
|
|
#endif
|
|
|
|
#elif defined(__MEMORY_SANITIZER__)
|
|
|
|
#define MEMORY_SANITIZER 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if _MSC_VER || MEMORY_SANITIZER
|
2018-05-25 18:13:48 +00:00
|
|
|
|
2020-02-04 13:31:15 +00:00
|
|
|
DemangleResult tryDemangle(const char * name)
|
|
|
|
{
|
|
|
|
return DemangleResult{};
|
|
|
|
}
|
|
|
|
|
2018-05-25 18:13:48 +00:00
|
|
|
std::string demangle(const char * name, int & status)
|
|
|
|
{
|
|
|
|
status = 0;
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <cxxabi.h>
|
2017-12-08 01:34:52 +00:00
|
|
|
|
2020-02-04 13:31:15 +00:00
|
|
|
static DemangleResult tryDemangle(const char * name, int & status)
|
2017-12-08 01:34:52 +00:00
|
|
|
{
|
2020-02-05 10:24:24 +00:00
|
|
|
return DemangleResult(abi::__cxa_demangle(name, nullptr, nullptr, &status));
|
2020-02-03 19:50:08 +00:00
|
|
|
}
|
|
|
|
|
2020-02-04 13:31:15 +00:00
|
|
|
DemangleResult tryDemangle(const char * name)
|
2020-02-03 19:50:08 +00:00
|
|
|
{
|
|
|
|
int status = 0;
|
2020-02-04 13:31:15 +00:00
|
|
|
return tryDemangle(name, status);
|
2020-02-03 19:50:08 +00:00
|
|
|
}
|
2017-12-08 01:34:52 +00:00
|
|
|
|
2020-02-03 19:50:08 +00:00
|
|
|
std::string demangle(const char * name, int & status)
|
|
|
|
{
|
2020-02-04 13:31:15 +00:00
|
|
|
auto result = tryDemangle(name, status);
|
2020-02-05 10:24:24 +00:00
|
|
|
if (result)
|
2017-12-08 01:34:52 +00:00
|
|
|
{
|
2020-02-05 10:24:24 +00:00
|
|
|
return std::string(result.get());
|
2017-12-08 01:34:52 +00:00
|
|
|
}
|
|
|
|
|
2020-02-03 19:50:08 +00:00
|
|
|
return name;
|
2017-12-08 01:34:52 +00:00
|
|
|
}
|
2018-05-25 18:13:48 +00:00
|
|
|
|
2020-02-03 19:50:08 +00:00
|
|
|
|
2018-05-25 18:13:48 +00:00
|
|
|
#endif
|