summaryrefslogtreecommitdiff
path: root/tools/llvm-cxxfilt
diff options
context:
space:
mode:
authorSaleem Abdulrasool <compnerd@compnerd.org>2017-01-20 04:25:26 +0000
committerSaleem Abdulrasool <compnerd@compnerd.org>2017-01-20 04:25:26 +0000
commit81cf2fa17ae698248ffe12408ee8939e4892b3c1 (patch)
treee06a545b83c6f48a10db5c5446fd6c302f8ba876 /tools/llvm-cxxfilt
parent440f273c40cd5a4dbdaf81910c4f5dfc51435bff (diff)
llvm-cxxfilt: support `-t` to demangle types
By default c++filt demangles functions, though you can optionally pass `-t` to have it decode types as well, behaving nearly identical to `__cxa_demangle`. Add support for this mode. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292576 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-cxxfilt')
-rw-r--r--tools/llvm-cxxfilt/llvm-cxxfilt.cpp23
1 files changed, 18 insertions, 5 deletions
diff --git a/tools/llvm-cxxfilt/llvm-cxxfilt.cpp b/tools/llvm-cxxfilt/llvm-cxxfilt.cpp
index 1e2797ba333..525cea28ff3 100644
--- a/tools/llvm-cxxfilt/llvm-cxxfilt.cpp
+++ b/tools/llvm-cxxfilt/llvm-cxxfilt.cpp
@@ -8,29 +8,42 @@
//===----------------------------------------------------------------------===//
#include "llvm/Demangle/Demangle.h"
+#include "llvm/Support/CommandLine.h"
#include "llvm/Support/raw_ostream.h"
#include <cstdlib>
#include <iostream>
using namespace llvm;
+static cl::opt<bool>
+ Types("types",
+ cl::desc("attempt to demangle types as well as function names"),
+ cl::init(false));
+static cl::alias TypesShort("t", cl::desc("alias for --types"),
+ cl::aliasopt(Types));
+
+static cl::list<std::string>
+Decorated(cl::Positional, cl::desc("<mangled>"), cl::ZeroOrMore);
+
static void demangle(llvm::raw_ostream &OS, const std::string &Mangled) {
int Status;
char *Demangled = nullptr;
- if ((Mangled.size() >= 2 && Mangled.compare(0, 2, "_Z")) ||
- (Mangled.size() >= 4 && Mangled.compare(0, 4, "___Z")))
+ if (Types || ((Mangled.size() >= 2 && Mangled.compare(0, 2, "_Z")) ||
+ (Mangled.size() >= 4 && Mangled.compare(0, 4, "___Z"))))
Demangled = itaniumDemangle(Mangled.c_str(), nullptr, nullptr, &Status);
OS << (Demangled ? Demangled : Mangled) << '\n';
free(Demangled);
}
int main(int argc, char **argv) {
- if (argc == 1)
+ cl::ParseCommandLineOptions(argc, argv, "llvm symbol table dumper\n");
+
+ if (Decorated.empty())
for (std::string Mangled; std::getline(std::cin, Mangled);)
demangle(llvm::outs(), Mangled);
else
- for (int I = 1; I < argc; ++I)
- demangle(llvm::outs(), argv[I]);
+ for (const auto &Symbol : Decorated)
+ demangle(llvm::outs(), Symbol);
return EXIT_SUCCESS;
}