serenity/AK/Demangle.h
Andrew Kaster c24fe710d7 AK: Turn off demangler in userland
For some reason, the default CXXFLAGS and such don't get us the
__cxa_demangle symbol in userland.
2020-01-01 17:48:41 +01:00

25 lines
422 B
C++

#pragma once
#include <AK/String.h>
#include <cxxabi.h>
namespace AK {
inline String demangle(const char* name)
{
#ifdef KERNEL
int status = 0;
auto* demangled_name = abi::__cxa_demangle(name, nullptr, nullptr, &status);
auto string = String(status == 0 ? demangled_name : name);
if (status == 0)
kfree(demangled_name);
return string;
#else
return name;
#endif
}
}
using AK::demangle;