2021-12-05 17:54:36 +00:00
|
|
|
#include "Type.h"
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <memory>
|
|
|
|
#include <cxxabi.h>
|
|
|
|
|
|
|
|
std::string demangle(const char* name) {
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
int status = -4; // some arbitrary value to eliminate the compiler warning
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
// enable c++11 by passing the flag -std=c++11 to g++
|
|
|
|
std::unique_ptr<char, void(*)(void*)> res{
|
|
|
|
abi::__cxa_demangle(name, NULL, NULL, &status),
|
|
|
|
std::free
|
|
|
|
};
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
return (status == 0) ? res.get() : name;
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
// does nothing if not g++
|
|
|
|
std::string demangle(const char* name) {
|
2022-07-28 13:39:57 +00:00
|
|
|
return name;
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|