forked from OSchip/llvm-project
[llvm-nm]Add support for --no-demangle
GNU nm has --no-demangle, so llvm-nm should too. It disables the --demangle switch. The patch also allows --demangle to be specified multiple times (the last of all --no-demangle/--demangle switches takes precedence). Reviewed by: grimar, rupprecht, mattd Differential Revision: https://reviews.llvm.org/D60134 llvm-svn: 357575
This commit is contained in:
parent
fee435702d
commit
ef93be84d3
|
@ -1,5 +1,6 @@
|
||||||
; RUN: llc -filetype=obj -mtriple=x86_64-pc-linux -o %t.o %s
|
; RUN: llc -filetype=obj -mtriple=x86_64-pc-linux -o %t.o %s
|
||||||
; RUN: llvm-nm %t.o | FileCheck --check-prefix="MANGLED" %s
|
; RUN: llvm-nm %t.o | FileCheck --check-prefix="MANGLED" %s
|
||||||
|
; RUN: llvm-nm %t.o --no-demangle | FileCheck --check-prefix="MANGLED" %s
|
||||||
; RUN: llvm-nm -C %t.o | FileCheck --check-prefix="DEMANGLED" %s
|
; RUN: llvm-nm -C %t.o | FileCheck --check-prefix="DEMANGLED" %s
|
||||||
; RUN: llvm-nm --demangle %t.o | FileCheck --check-prefix="DEMANGLED" %s
|
; RUN: llvm-nm --demangle %t.o | FileCheck --check-prefix="DEMANGLED" %s
|
||||||
|
|
||||||
|
@ -11,6 +12,12 @@
|
||||||
; RUN: llvm-nm %t.coff | FileCheck --check-prefix="COFF-MANGLED" %s
|
; RUN: llvm-nm %t.coff | FileCheck --check-prefix="COFF-MANGLED" %s
|
||||||
; RUN: llvm-nm -C %t.coff | FileCheck --check-prefix="COFF-DEMANGLED" %s
|
; RUN: llvm-nm -C %t.coff | FileCheck --check-prefix="COFF-DEMANGLED" %s
|
||||||
|
|
||||||
|
; Show that the last of --no-demangle/--demangle wins:
|
||||||
|
; RUN: llvm-nm --demangle --no-demangle %t.o | FileCheck --check-prefix="MANGLED" %s
|
||||||
|
; RUN: llvm-nm --no-demangle --demangle %t.o | FileCheck --check-prefix="DEMANGLED" %s
|
||||||
|
; RUN: llvm-nm --no-demangle --demangle --no-demangle %t.o | FileCheck --check-prefix="MANGLED" %s
|
||||||
|
; RUN: llvm-nm --demangle --no-demangle --demangle %t.o | FileCheck --check-prefix="DEMANGLED" %s
|
||||||
|
|
||||||
define i32 @_Z3fooi(i32) #0 {
|
define i32 @_Z3fooi(i32) #0 {
|
||||||
entry:
|
entry:
|
||||||
ret i32 1
|
ret i32 1
|
||||||
|
|
|
@ -124,9 +124,12 @@ cl::opt<bool> NoSort("no-sort", cl::desc("Show symbols in order encountered"));
|
||||||
cl::alias NoSortp("p", cl::desc("Alias for --no-sort"), cl::aliasopt(NoSort),
|
cl::alias NoSortp("p", cl::desc("Alias for --no-sort"), cl::aliasopt(NoSort),
|
||||||
cl::Grouping);
|
cl::Grouping);
|
||||||
|
|
||||||
cl::opt<bool> Demangle("demangle", cl::desc("Demangle C++ symbol names"));
|
cl::opt<bool> Demangle("demangle", cl::ZeroOrMore,
|
||||||
cl::alias DemangleC("C", cl::desc("Alias for --demangle"), cl::aliasopt(Demangle),
|
cl::desc("Demangle C++ symbol names"));
|
||||||
cl::Grouping);
|
cl::alias DemangleC("C", cl::desc("Alias for --demangle"),
|
||||||
|
cl::aliasopt(Demangle), cl::Grouping);
|
||||||
|
cl::opt<bool> NoDemangle("no-demangle", cl::init(false), cl::ZeroOrMore,
|
||||||
|
cl::desc("Don't demangle symbol names"));
|
||||||
|
|
||||||
cl::opt<bool> ReverseSort("reverse-sort", cl::desc("Sort in reverse order"));
|
cl::opt<bool> ReverseSort("reverse-sort", cl::desc("Sort in reverse order"));
|
||||||
cl::alias ReverseSortr("r", cl::desc("Alias for --reverse-sort"),
|
cl::alias ReverseSortr("r", cl::desc("Alias for --reverse-sort"),
|
||||||
|
@ -2106,6 +2109,10 @@ int main(int argc, char **argv) {
|
||||||
if (InputFilenames.size() > 1)
|
if (InputFilenames.size() > 1)
|
||||||
MultipleFiles = true;
|
MultipleFiles = true;
|
||||||
|
|
||||||
|
// If both --demangle and --no-demangle are specified then pick the last one.
|
||||||
|
if (NoDemangle.getPosition() > Demangle.getPosition())
|
||||||
|
Demangle = !NoDemangle;
|
||||||
|
|
||||||
for (unsigned i = 0; i < ArchFlags.size(); ++i) {
|
for (unsigned i = 0; i < ArchFlags.size(); ++i) {
|
||||||
if (ArchFlags[i] == "all") {
|
if (ArchFlags[i] == "all") {
|
||||||
ArchAll = true;
|
ArchAll = true;
|
||||||
|
|
Loading…
Reference in New Issue