AK: The <cxxabi.h> header is not available during Toolchain build

This will need some refinement, but basically since we build LibC
during the toolchain build, we don't have libstdc++ headers yet.
This commit is contained in:
Andreas Kling 2020-02-03 06:26:32 +01:00
parent 9dc78338ad
commit c600280dde
Notes: sideshowbarker 2024-07-19 09:41:13 +09:00

View File

@ -27,18 +27,25 @@
#pragma once
#include <AK/String.h>
#ifndef SERENITY_LIBC_BUILD
#include <cxxabi.h>
#endif
namespace AK {
inline String demangle(const StringView& name)
{
#ifdef SERENITY_LIBC_BUILD
return name;
#else
int status = 0;
auto* demangled_name = abi::__cxa_demangle(String(name).characters(), nullptr, nullptr, &status);
auto string = String(status == 0 ? demangled_name : name);
if (status == 0)
kfree(demangled_name);
return string;
#endif
}
}