ClickHouse/base/common/demangle.cpp

45 lines
730 B
C++
Raw Normal View History

#include <common/demangle.h>
2020-05-11 06:50:38 +00:00
#if defined(_MSC_VER)
2020-05-10 05:24:01 +00:00
DemangleResult tryDemangle(const char *)
2020-02-04 13:31:15 +00:00
{
return DemangleResult{};
}
std::string demangle(const char * name, int & status)
{
status = 0;
return name;
}
#else
#include <stdlib.h>
#include <cxxabi.h>
2020-02-04 13:31:15 +00:00
static DemangleResult tryDemangle(const char * name, int & status)
{
2020-02-05 10:24:24 +00:00
return DemangleResult(abi::__cxa_demangle(name, nullptr, nullptr, &status));
}
2020-02-04 13:31:15 +00:00
DemangleResult tryDemangle(const char * name)
{
int status = 0;
2020-02-04 13:31:15 +00:00
return tryDemangle(name, status);
}
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)
{
2020-02-05 10:24:24 +00:00
return std::string(result.get());
}
return name;
}
#endif