2016-09-07 03:16:48 +08:00
|
|
|
//===-- 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"
|
2016-09-28 02:50:30 +08:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2016-11-14 04:43:38 +08:00
|
|
|
#include <cstdlib>
|
|
|
|
#include <iostream>
|
2016-09-07 03:16:48 +08:00
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
2016-11-14 04:43:38 +08:00
|
|
|
static void demangle(llvm::raw_ostream &OS, const char *Mangled) {
|
|
|
|
int Status;
|
|
|
|
char *Demangled = itaniumDemangle(Mangled, nullptr, nullptr, &Status);
|
|
|
|
OS << (Demangled ? Demangled : Mangled) << '\n';
|
|
|
|
free(Demangled);
|
|
|
|
}
|
|
|
|
|
2016-09-07 03:16:48 +08:00
|
|
|
int main(int argc, char **argv) {
|
2016-11-14 04:43:38 +08:00
|
|
|
if (argc == 1)
|
|
|
|
for (std::string Mangled; std::getline(std::cin, Mangled);)
|
|
|
|
demangle(llvm::outs(), Mangled.c_str());
|
|
|
|
else
|
|
|
|
for (int I = 1; I < argc; ++I)
|
|
|
|
demangle(llvm::outs(), argv[I]);
|
|
|
|
|
|
|
|
return EXIT_SUCCESS;
|
2016-09-07 03:16:48 +08:00
|
|
|
}
|