[PATCH] D110551: [llvm-objdump] Fix --prefix and --prefix-strip
Owen Reynolds via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 28 04:30:11 PDT 2021
gbreynoo updated this revision to Diff 375525.
gbreynoo added a comment.
Updated after Maskray's comment.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D110551/new/
https://reviews.llvm.org/D110551
Files:
llvm/test/tools/llvm-objdump/X86/source-interleave-prefix.test
llvm/tools/llvm-objdump/ObjdumpOpts.td
llvm/tools/llvm-objdump/llvm-objdump.cpp
Index: llvm/tools/llvm-objdump/llvm-objdump.cpp
===================================================================
--- llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -2560,8 +2560,8 @@
TripleName = InputArgs.getLastArgValue(OBJDUMP_triple_EQ).str();
UnwindInfo = InputArgs.hasArg(OBJDUMP_unwind_info);
Wide = InputArgs.hasArg(OBJDUMP_wide);
- Prefix = InputArgs.getLastArgValue(OBJDUMP_prefix).str();
- parseIntArg(InputArgs, OBJDUMP_prefix_strip, PrefixStrip);
+ Prefix = InputArgs.getLastArgValue(OBJDUMP_prefix_EQ).str();
+ parseIntArg(InputArgs, OBJDUMP_prefix_strip_EQ, PrefixStrip);
if (const opt::Arg *A = InputArgs.getLastArg(OBJDUMP_debug_vars_EQ)) {
DbgVariables = StringSwitch<DebugVarsFormat>(A->getValue())
.Case("ascii", DVASCII)
Index: llvm/tools/llvm-objdump/ObjdumpOpts.td
===================================================================
--- llvm/tools/llvm-objdump/ObjdumpOpts.td
+++ llvm/tools/llvm-objdump/ObjdumpOpts.td
@@ -180,12 +180,14 @@
HelpText<"Ignored for compatibility with GNU objdump">;
def : Flag<["-"], "w">, Alias<wide>;
-def prefix : Separate<["--"], "prefix">,
+def prefix_EQ : Joined<["--"], "prefix=">,
HelpText<"Add prefix to absolute paths">;
+def : Separate<["--"], "prefix">, Alias<prefix_EQ>;
-def prefix_strip : Separate<["--"], "prefix-strip">,
+def prefix_strip_EQ : Joined<["--"], "prefix-strip=">,
HelpText<"Strip out initial directories from absolute "
"paths. No effect without --prefix">;
+def : Separate<["--"], "prefix-strip">, Alias<prefix_strip_EQ>;
def debug_vars_EQ : Joined<["--"], "debug-vars=">,
Values<"unicode,ascii">;
Index: llvm/test/tools/llvm-objdump/X86/source-interleave-prefix.test
===================================================================
--- llvm/test/tools/llvm-objdump/X86/source-interleave-prefix.test
+++ llvm/test/tools/llvm-objdump/X86/source-interleave-prefix.test
@@ -83,9 +83,16 @@
; RUN: not llvm-objdump --prefix %p --prefix-strip '-1' --source %t-missing-prefix.o 2>&1 | \
; RUN: FileCheck %s --check-prefix=CHECK-INVALID-PREFIX-STRIP -DOPTION='-1'
-; CHECK-INVALID-PREFIX-STRIP: {{.*}}llvm-objdump{{.*}}: error: --prefix-strip: expected a non-negative integer, but got '[[OPTION]]'
+; CHECK-INVALID-PREFIX-STRIP: {{.*}}llvm-objdump{{.*}}: error: --prefix-strip=: expected a non-negative integer, but got '[[OPTION]]'
;; Test text value --prefix-strip. Reports an error.
; RUN: not llvm-objdump --prefix %p --prefix-strip foo --source %t-missing-prefix.o 2>&1 | \
; RUN: FileCheck %s --check-prefix=CHECK-INVALID-PREFIX-STRIP -DOPTION='foo'
+
+;; Test use of --prefix= and --prefix-strip=
+
+; RUN: sed -e "s,SRC_COMPDIR,/extra/Inputs,g" %p/Inputs/source-interleave.ll > %t-extra-path-prefix.ll
+; RUN: llc -o %t-extra-path-prefix.o -filetype=obj -mtriple=x86_64-pc-linux %t-extra-path-prefix.ll
+; RUN: llvm-objdump --prefix=%p --prefix-strip=1 --source %t-extra-path-prefix.o 2>&1 | \
+; RUN: FileCheck %s --check-prefix=CHECK-MISSING-PREFIX-FIX
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110551.375525.patch
Type: text/x-patch
Size: 3082 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210928/ced060ce/attachment.bin>
More information about the llvm-commits
mailing list