[PATCH] D60134: [llvm-nm]Add support for --no-demangle
James Henderson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 2 09:01:34 PDT 2019
jhenderson created this revision.
jhenderson added reviewers: grimar, rupprecht, Sunil_Srivastava, mattd.
Herald added a subscriber: erik.pilkington.
Herald added a project: LLVM.
GNU nm has --no-demangle, so llvm-nm should too. It disables the --demangle switch.
Repository:
rL LLVM
https://reviews.llvm.org/D60134
Files:
test/tools/llvm-nm/X86/demangle.ll
tools/llvm-nm/llvm-nm.cpp
Index: tools/llvm-nm/llvm-nm.cpp
===================================================================
--- tools/llvm-nm/llvm-nm.cpp
+++ tools/llvm-nm/llvm-nm.cpp
@@ -127,6 +127,8 @@
cl::opt<bool> Demangle("demangle", cl::desc("Demangle C++ symbol names"));
cl::alias DemangleC("C", cl::desc("Alias for --demangle"), cl::aliasopt(Demangle),
cl::Grouping);
+cl::opt<bool> NoDemangle("no-demangle", cl::init(false),
+ cl::desc("Don't demangle symbol names"));
cl::opt<bool> ReverseSort("reverse-sort", cl::desc("Sort in reverse order"));
cl::alias ReverseSortr("r", cl::desc("Alias for --reverse-sort"),
@@ -2077,6 +2079,10 @@
InitLLVM X(argc, argv);
cl::ParseCommandLineOptions(argc, argv, "llvm symbol table dumper\n");
+ // If both --demangle and --no-demangle are specified then pick the last one.
+ if (NoDemangle.getPosition() > Demangle.getPosition())
+ Demangle = !NoDemangle;
+
// llvm-nm only reads binary files.
if (error(sys::ChangeStdinToBinary()))
return 1;
Index: test/tools/llvm-nm/X86/demangle.ll
===================================================================
--- test/tools/llvm-nm/X86/demangle.ll
+++ test/tools/llvm-nm/X86/demangle.ll
@@ -1,5 +1,6 @@
; 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 --no-demangle | FileCheck --check-prefix="MANGLED" %s
; RUN: llvm-nm -C %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 -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 -C --no-demangle %t.o | FileCheck --check-prefix="MANGLED" %s
+; RUN: llvm-nm --no-demangle -C %t.o | FileCheck --check-prefix="DEMANGLED" %s
+
define i32 @_Z3fooi(i32) #0 {
entry:
ret i32 1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60134.193307.patch
Type: text/x-patch
Size: 2193 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190402/7723de1d/attachment.bin>
More information about the llvm-commits
mailing list