1#include <common/demangle.h>
2
3#if defined(__has_feature)
4 #if __has_feature(memory_sanitizer)
5 #define MEMORY_SANITIZER 1
6 #endif
7#elif defined(__MEMORY_SANITIZER__)
8 #define MEMORY_SANITIZER 1
9#endif
10
11#if _MSC_VER || MEMORY_SANITIZER
12
13std::string demangle(const char * name, int & status)
14{
15 status = 0;
16 return name;
17}
18
19#else
20
21#include <stdlib.h>
22#include <cxxabi.h>
23
24std::string demangle(const char * name, int & status)
25{
26 std::string res;
27
28 char * demangled_str = abi::__cxa_demangle(name, 0, 0, &status);
29 if (demangled_str)
30 {
31 try
32 {
33 res = demangled_str;
34 }
35 catch (...)
36 {
37 free(demangled_str);
38 throw;
39 }
40 free(demangled_str);
41 }
42 else
43 res = name;
44
45 return res;
46}
47
48#endif
49