[llvm] 9072183 - [llvm-objdump] Fix --prefix and --prefix-strip
via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 7 07:54:32 PDT 2021
Author: gbreynoo
Date: 2021-10-07T15:53:45+01:00
New Revision: 9072183cb6346926fefa0c0d24cdc31cf028dcc8
URL: https://github.com/llvm/llvm-project/commit/9072183cb6346926fefa0c0d24cdc31cf028dcc8
DIFF: https://github.com/llvm/llvm-project/commit/9072183cb6346926fefa0c0d24cdc31cf028dcc8.diff
LOG: [llvm-objdump] Fix --prefix and --prefix-strip
In the command guide --prefix and --prefix-strip is used in the form
--prefix=<prefix> however currently it is used in the form --prefix
<prefix>. This change fixes these options to match the command guide.
Differential Revision: https://reviews.llvm.org/D110551
Added:
Modified:
llvm/test/tools/llvm-objdump/X86/source-interleave-prefix.test
llvm/tools/llvm-objdump/ObjdumpOpts.td
Removed:
################################################################################
diff --git a/llvm/test/tools/llvm-objdump/X86/source-interleave-prefix.test b/llvm/test/tools/llvm-objdump/X86/source-interleave-prefix.test
index e26db49e6d22b..746add22f96e5 100644
--- a/llvm/test/tools/llvm-objdump/X86/source-interleave-prefix.test
+++ b/llvm/test/tools/llvm-objdump/X86/source-interleave-prefix.test
@@ -89,3 +89,10 @@
; 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
diff --git a/llvm/tools/llvm-objdump/ObjdumpOpts.td b/llvm/tools/llvm-objdump/ObjdumpOpts.td
index 1b19733c65d07..19c7c11f0597a 100644
--- a/llvm/tools/llvm-objdump/ObjdumpOpts.td
+++ b/llvm/tools/llvm-objdump/ObjdumpOpts.td
@@ -1,5 +1,12 @@
include "llvm/Option/OptParser.td"
+multiclass Eq<string name, string help> {
+ def NAME : Separate<["--"], name>;
+ def NAME #_eq : Joined<["--"], name #"=">,
+ Alias<!cast<Separate>(NAME)>,
+ HelpText<help>;
+}
+
def help : Flag<["--"], "help">,
HelpText<"Display available options (--help-hidden for more)">;
@@ -180,12 +187,12 @@ def wide : Flag<["--"], "wide">,
HelpText<"Ignored for compatibility with GNU objdump">;
def : Flag<["-"], "w">, Alias<wide>;
-def prefix : Separate<["--"], "prefix">,
- HelpText<"Add prefix to absolute paths">;
-
-def prefix_strip : Separate<["--"], "prefix-strip">,
- HelpText<"Strip out initial directories from absolute "
- "paths. No effect without --prefix">;
+defm prefix : Eq<"prefix", "Add prefix to absolute paths">,
+ MetaVarName<"prefix">;
+defm prefix_strip
+ : Eq<"prefix-strip", "Strip out initial directories from absolute "
+ "paths. No effect without --prefix">,
+ MetaVarName<"prefix">;
def debug_vars_EQ : Joined<["--"], "debug-vars=">,
Values<"unicode,ascii">;
More information about the llvm-commits
mailing list