From b940b66c6032096d40dfd1859e2598749a30378c Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Tue, 6 Sep 2016 19:16:48 +0000 Subject: Add an c++ itanium demangler to llvm. This adds a copy of the demangler in libcxxabi. The code also has no dependencies on anything else in LLVM. To enforce that I added it as another library. That way a BUILD_SHARED_LIBS will fail if anyone adds an use of StringRef for example. The no llvm dependency combined with the fact that this has to build on linux, OS X and Windows required a few changes to the code. In particular: No constexpr. No alignas On OS X at least this library has only one global symbol: __ZN4llvm16itanium_demangleEPKcPcPmPi My current plan is: Commit something like this Change lld to use it Change lldb to use it as the fallback Add a few #ifdefs so that exactly the same file can be used in libcxxabi to export abi::__cxa_demangle. Once the fast demangler in lldb can handle any names this implementation can be replaced with it and we will have the one true demangler. llvm-svn: 280732 --- llvm/lib/Support/LLVMBuild.txt | 1 + llvm/lib/Support/Unix/Signals.inc | 10 ++-------- 2 files changed, 3 insertions(+), 8 deletions(-) (limited to 'llvm/lib/Support') diff --git a/llvm/lib/Support/LLVMBuild.txt b/llvm/lib/Support/LLVMBuild.txt index 5b88be0203e..4c751397041 100644 --- a/llvm/lib/Support/LLVMBuild.txt +++ b/llvm/lib/Support/LLVMBuild.txt @@ -19,3 +19,4 @@ type = Library name = Support parent = Libraries +required_libraries = Demangle diff --git a/llvm/lib/Support/Unix/Signals.inc b/llvm/lib/Support/Unix/Signals.inc index 961f32b4603..4661fd68657 100644 --- a/llvm/lib/Support/Unix/Signals.inc +++ b/llvm/lib/Support/Unix/Signals.inc @@ -14,6 +14,7 @@ #include "Unix.h" #include "llvm/ADT/STLExtras.h" +#include "llvm/Demangle/Demangle.h" #include "llvm/Support/Format.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/FileUtilities.h" @@ -33,9 +34,6 @@ #if HAVE_SYS_STAT_H #include #endif -#if HAVE_CXXABI_H -#include -#endif #if HAVE_DLFCN_H #include #endif @@ -443,12 +441,8 @@ void llvm::sys::PrintStackTrace(raw_ostream &OS) { if (dlinfo.dli_sname != nullptr) { OS << ' '; -# if HAVE_CXXABI_H int res; - char* d = abi::__cxa_demangle(dlinfo.dli_sname, nullptr, nullptr, &res); -# else - char* d = NULL; -# endif + char* d = itaniumDemangle(dlinfo.dli_sname, nullptr, nullptr, &res); if (!d) OS << dlinfo.dli_sname; else OS << d; free(d); -- cgit v1.2.3