repr
0.1
Reconstructable string representations and more
Toggle main menu visibility
Main Page
Installation
Usage
Customization
Extending
FAQ
CI Results
Test
Benchmark
API Documentation
Namespace List
Namespace List
Namespace Members
All
_
a
c
d
e
f
g
i
l
m
n
o
p
r
s
t
u
v
w
Functions
_
a
c
d
e
f
g
i
l
m
n
o
r
s
t
u
v
w
Variables
Typedefs
Enumerations
Concept List
Class List
Class List
Class Index
Class Hierarchy
Class Members
All
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
~
Functions
_
a
c
e
f
g
i
l
m
n
o
p
r
s
t
v
w
~
Variables
a
b
c
d
e
f
g
i
k
l
m
n
o
p
q
r
s
t
u
v
Typedefs
a
c
d
e
f
g
h
l
m
p
r
s
t
u
v
w
Enumerations
Enumerator
Related Symbols
File List
File List
File Members
All
_
l
n
o
r
u
Variables
Macros
_
l
o
r
u
Examples
Source Code
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
Concepts
Loading...
Searching...
No Matches
demangle.h
Go to the documentation of this file.
#pragma once
#include <
string
>
#include <
string_view
>
#include <
librepr/feature.h
>
#include <
librepr/macro/util.h
>
#include <
librepr/macro/platform.h
>
#include <
librepr/util/string/util.h
>
#if USING(LIBREPR_PLATFORM_WINDOWS)
#include "
detail/undecorate.h
"
#include "
detail/denoise.h
"
#elif __has_include(<cxxabi.h>)
#include <cxxabi.h>
#include <
memory
>
#else
#error No available demangling method!
#endif
namespace
librepr
{
[[
nodiscard
]]
inline
std::string
demangle
(
std::string_view
mangled
) {
#if USING(LIBREPR_PLATFORM_WINDOWS)
detail::DemangleBuffer
buffer{};
auto
count = detail::undecorate_name(
mangled
.data(), buffer);
if
(count == 0) [[
unlikely
]] {
// Demangling failed...
return
mangled
.data();
}
if
constexpr
(!detail::msvc::has_rawname) {
// Check if the symbol was obtained with __FUNCDNAME__
if
(
mangled
.starts_with(
"??$get_mangled_name"
)) [[
likely
]] {
using namespace
detail;
std::string_view
snip
{ buffer.data(), count };
snip
.remove_prefix(strsize(
"char const * librepr::get_mangled_name<"
));
snip
.remove_suffix(strsize(
">(void)"
));
return
denoise_name(
snip
);
}
}
return
std::string
(buffer.data(), count);
#else
struct
FreeDeleter
{
void
operator()(
void
* ptr)
const
{
std::free
(ptr); }
};
auto
const
demangled
=
std::unique_ptr<char, FreeDeleter>
{
abi::__cxa_demangle(
mangled
.data(),
nullptr
,
nullptr
,
nullptr
)
};
return
std::string
{
demangled
?
demangled
.get() :
mangled
};
#endif
}
[[
nodiscard
]]
inline
std::string
demangle
(
std::string_view
mangled
) {
…
}
}
// namespace librepr
include
librepr
name
demangle.h
Generated by
1.9.8, using the excellent
Doxygen Awesome
Theme