Uni20
Asynchronous tensor and runtime library.
Loading...
Searching...
No Matches
src
uni20
common
demangle.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <cstdlib>
4
#include <string>
5
#include <typeinfo>
6
7
#if defined(__GNUG__)
8
#include <cxxabi.h>
9
#elif defined(_MSC_VER)
10
#include <DbgHelp.h>
11
#include <windows.h>
12
// link against Dbghelp.lib
13
#pragma comment(lib, "Dbghelp.lib")
14
#endif
15
16
namespace
uni20::demangle
17
{
18
22
inline
std::string
demangle
(
const
char
* name)
23
{
24
#if defined(__GNUG__)
25
int
status = 0;
26
char
* dem = abi::__cxa_demangle(name,
nullptr
,
nullptr
, &status);
27
std::string out = (status == 0 && dem) ? dem : name;
28
std::free(dem);
29
return
out;
30
#elif defined(_MSC_VER)
31
char
buffer[1024] = {};
32
// UNDNAME_COMPLETE gives full undecoration
33
if
(UnDecorateSymbolName(name, buffer,
sizeof
(buffer), UNDNAME_COMPLETE))
34
return
std::string(buffer);
35
else
36
return
name;
37
#else
38
return
name;
39
#endif
40
}
41
42
template
<
typename
T> std::string
demangle_type
() {
return
demangle
(
typeid
(T).name()); }
43
44
}
// namespace uni20::demangle
uni20::demangle
Definition
demangle.hpp:17
uni20::demangle::demangle_type
std::string demangle_type()
Definition
demangle.hpp:42
uni20::demangle::demangle
std::string demangle(const char *name)
Turn a compilerâmangled name into a humanâreadable one.
Definition
demangle.hpp:22
Generated by
1.9.8