[PATCH] D120731: [llvm] add -o flag to llvm-bitcode-strip
Richard Howell via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 3 07:34:19 PST 2022
rmaz updated this revision to Diff 412718.
rmaz added a comment.
update test
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D120731/new/
https://reviews.llvm.org/D120731
Files:
llvm/test/tools/llvm-objcopy/MachO/bitcode-strip.test
llvm/tools/llvm-objcopy/BitcodeStripOpts.td
llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
Index: llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
===================================================================
--- llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
+++ llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
@@ -1207,7 +1207,12 @@
"llvm-bitcode-strip expects a single input file");
assert(!Positional.empty());
Config.InputFilename = Positional[0];
- Config.OutputFilename = Positional[0];
+
+ if (!InputArgs.hasArg(BITCODE_STRIP_output)) {
+ return createStringError(errc::invalid_argument,
+ "-o is a required argument");
+ }
+ Config.OutputFilename = InputArgs.getLastArgValue(BITCODE_STRIP_output);
DC.CopyConfigs.push_back(std::move(ConfigMgr));
return std::move(DC);
Index: llvm/tools/llvm-objcopy/BitcodeStripOpts.td
===================================================================
--- llvm/tools/llvm-objcopy/BitcodeStripOpts.td
+++ llvm/tools/llvm-objcopy/BitcodeStripOpts.td
@@ -17,8 +17,11 @@
def h : Flag<["-"], "h">, Alias<help>;
def version : Flag<["--"], "version">,
- HelpText<"Print the version and exit.">;
+ HelpText<"Print the version and exit">;
def V : Flag<["-"], "V">,
Alias<version>,
HelpText<"Alias for --version">;
+
+def output : JoinedOrSeparate<["-"], "o">, HelpText<"Write output to <file>">,
+ MetaVarName<"<file>">;
Index: llvm/test/tools/llvm-objcopy/MachO/bitcode-strip.test
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-objcopy/MachO/bitcode-strip.test
@@ -0,0 +1,44 @@
+## Test output flag is required.
+# RUN: yaml2obj %s -o %t
+# RUN: not llvm-bitcode-strip %t 2>&1 | FileCheck --check-prefix=MISSING-ARG %s
+# RUN: llvm-bitcode-strip %t -o %t2
+# RUN: cmp %t %t2
+
+# MISSING-ARG: llvm-bitcode-strip: error: -o is a required argument
+
+--- !mach-o
+FileHeader:
+ magic: 0xFEEDFACF
+ cputype: 0x01000007
+ cpusubtype: 0x00000003
+ filetype: 0x00000001
+ ncmds: 1
+ sizeofcmds: 152
+ flags: 0x00002000
+ reserved: 0x00000000
+LoadCommands:
+ - cmd: LC_SEGMENT_64
+ cmdsize: 152
+ segname: __TEXT
+ vmaddr: 0
+ vmsize: 4
+ fileoff: 184
+ filesize: 4
+ maxprot: 7
+ initprot: 7
+ nsects: 1
+ flags: 0
+ Sections:
+ - sectname: __text
+ segname: __TEXT
+ addr: 0x0000000000000000
+ content: 'AABBCCDD'
+ size: 4
+ offset: 184
+ align: 0
+ reloff: 0x00000000
+ nreloc: 0
+ flags: 0x80000400
+ reserved1: 0x00000000
+ reserved2: 0x00000000
+ reserved3: 0x00000000
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120731.412718.patch
Type: text/x-patch
Size: 2906 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220303/ee04bae7/attachment.bin>
More information about the llvm-commits
mailing list