mirror of
https://github.com/RPCS3/llvm.git
synced 2024-11-25 12:49:50 +00:00
llvm-cxxfilt: support reading from stdin
`c++filt` when given no arguments runs as a REPL, decoding each line as a decorated name. Unify the test structure to be more uniform, with the tests for llvm-cxxfilt living under test/tools/llvm-cxxfilt. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@286777 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
38feb36e4a
commit
a5627e5c59
@ -1 +0,0 @@
|
||||
config.suffixes = ['.test']
|
10
test/tools/llvm-cxxfilt/noargs.test
Normal file
10
test/tools/llvm-cxxfilt/noargs.test
Normal file
@ -0,0 +1,10 @@
|
||||
RUN: sed -n 's/^STDIN: //p' %s | llvm-cxxfilt | FileCheck %s
|
||||
|
||||
STDIN: _Znw
|
||||
STDIN: _Znwj
|
||||
STDIN: _Znwm
|
||||
|
||||
CHECK: operator new
|
||||
CHECK: operator new(unsigned int)
|
||||
CHECK: operator new(unsigned long)
|
||||
|
@ -9,18 +9,25 @@
|
||||
|
||||
#include "llvm/Demangle/Demangle.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
|
||||
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);
|
||||
llvm::outs() << (Demangled ? Demangled : Mangled) << '\n';
|
||||
free(Demangled);
|
||||
}
|
||||
return 0;
|
||||
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);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user