ClickHouse/libs/libcommon/src/demangle.cpp

41 lines
671 B
C++
Raw Normal View History

#include <common/demangle.h>
2018-12-28 05:08:44 +00:00
#if _MSC_VER || (defined(__has_feature) && __has_feature(memory_sanitizer))
std::string demangle(const char * name, int & status)
{
status = 0;
return name;
}
#else
#include <stdlib.h>
#include <cxxabi.h>
std::string demangle(const char * name, int & status)
{
std::string res;
char * demangled_str = abi::__cxa_demangle(name, 0, 0, &status);
if (demangled_str)
{
try
{
res = demangled_str;
}
catch (...)
{
free(demangled_str);
throw;
}
free(demangled_str);
}
else
res = name;
return res;
}
#endif