diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2016-09-06 19:16:48 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2016-09-06 19:16:48 +0000 |
commit | b940b66c6032096d40dfd1859e2598749a30378c (patch) | |
tree | 8bbfb87f1e7b0e4584ca5d6b4096e13827addaf9 /llvm/tools/llvm-cxxfilt | |
parent | 34ecf42bffe57ed1f4c45ac1ff0a3be2d5ed0dd1 (diff) | |
download | bcm5719-llvm-b940b66c6032096d40dfd1859e2598749a30378c.tar.gz bcm5719-llvm-b940b66c6032096d40dfd1859e2598749a30378c.zip |
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
Diffstat (limited to 'llvm/tools/llvm-cxxfilt')
-rw-r--r-- | llvm/tools/llvm-cxxfilt/CMakeLists.txt | 7 | ||||
-rw-r--r-- | llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp | 29 |
2 files changed, 36 insertions, 0 deletions
diff --git a/llvm/tools/llvm-cxxfilt/CMakeLists.txt b/llvm/tools/llvm-cxxfilt/CMakeLists.txt new file mode 100644 index 00000000000..4d0e5b01028 --- /dev/null +++ b/llvm/tools/llvm-cxxfilt/CMakeLists.txt @@ -0,0 +1,7 @@ +set(LLVM_LINK_COMPONENTS + Demangle + ) + +add_llvm_tool(llvm-cxxfilt + llvm-cxxfilt.cpp + ) diff --git a/llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp b/llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp new file mode 100644 index 00000000000..d2c1ba37420 --- /dev/null +++ b/llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp @@ -0,0 +1,29 @@ +//===-- llvm-c++filt.cpp --------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "llvm/Demangle/Demangle.h" + +#include <stdio.h> +#include <stdlib.h> + +using namespace llvm; + +int main(int argc, char **argv) { + for (int I = 1; I < argc; ++I) { + const char *Mangled = argv[I]; + int Status; + char *Demangled = itaniumDemangle(Mangled, nullptr, nullptr, &Status); + if (Demangled) + printf("%s\n", Demangled); + else + printf("%s\n", Mangled); + free(Demangled); + } + return 0; +} |