Skip to content

Commit

Permalink
AK: The <cxxabi.h> header is not available during Toolchain build
Browse files Browse the repository at this point in the history
This will need some refinement, but basically since we build LibC
during the toolchain build, we don't have libstdc++ headers yet.
  • Loading branch information
awesomekling committed Feb 3, 2020
1 parent 9dc7833 commit c600280
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions AK/Demangle.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

}
Expand Down

0 comments on commit c600280

Please sign in to comment.