[PATCH] D132418: [tools][llvm-lipo] Fix off-by-one error in command-line argument parsing
Alexander Shaposhnikov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 23 12:52:39 PDT 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdde23bf98ecb: [tools][llvm-lipo] Fix off-by-one error in command-line argument parsing (authored by alexander-shaposhnikov).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D132418/new/
https://reviews.llvm.org/D132418
Files:
llvm/test/tools/llvm-lipo/replace-invalid-input.test
llvm/test/tools/llvm-lipo/segalign-invalid-input.test
llvm/tools/llvm-lipo/llvm-lipo.cpp
Index: llvm/tools/llvm-lipo/llvm-lipo.cpp
===================================================================
--- llvm/tools/llvm-lipo/llvm-lipo.cpp
+++ llvm/tools/llvm-lipo/llvm-lipo.cpp
@@ -183,9 +183,7 @@
C.InputFiles.push_back({None, Arg->getValue()});
for (auto Arg : InputArgs.filtered(LIPO_arch)) {
validateArchitectureName(Arg->getValue(0));
- if (!Arg->getValue(1))
- reportError(
- "arch is missing an argument: expects -arch arch_type file_name");
+ assert(Arg->getValue(1) && "file_name is missing");
C.InputFiles.push_back({StringRef(Arg->getValue(0)), Arg->getValue(1)});
}
@@ -294,10 +292,7 @@
case LIPO_replace:
for (auto Action : ActionArgs) {
- if (!Action->getValue(1))
- reportError(
- "replace is missing an argument: expects -replace arch_type "
- "file_name");
+ assert(Action->getValue(1) && "file_name is missing");
validateArchitectureName(Action->getValue(0));
C.ReplacementFiles.push_back(
{StringRef(Action->getValue(0)), Action->getValue(1)});
@@ -725,7 +720,7 @@
int main(int argc, char **argv) {
InitLLVM X(argc, argv);
- Config C = parseLipoOptions(makeArrayRef(argv + 1, argc));
+ Config C = parseLipoOptions(makeArrayRef(argv + 1, argc - 1));
LLVMContext LLVMCtx;
SmallVector<OwningBinary<Binary>, 1> InputBinaries =
readInputBinaries(LLVMCtx, C.InputFiles);
Index: llvm/test/tools/llvm-lipo/segalign-invalid-input.test
===================================================================
--- llvm/test/tools/llvm-lipo/segalign-invalid-input.test
+++ llvm/test/tools/llvm-lipo/segalign-invalid-input.test
@@ -2,7 +2,7 @@
# RUN: yaml2obj %p/Inputs/armv7-slice.yaml -o %t-armv7.o
# RUN: not llvm-lipo %t-armv7.o %t-arm64.o -create -o %t.o -segalign a 2>&1 | FileCheck --check-prefix=MISSING_ARG %s
-# MISSING_ARG: error: segalign is missing an argument: expects -segalign arch_type alignment_value
+# MISSING_ARG: error: missing argument to -segalign option
# RUN: not llvm-lipo %t-armv7.o %t-arm64.o -o %t.o -segalign arm64 10 2>&1 | FileCheck --check-prefix=MISSING_ACTION %s
# MISSING_ACTION: error: at least one action should be specified
Index: llvm/test/tools/llvm-lipo/replace-invalid-input.test
===================================================================
--- llvm/test/tools/llvm-lipo/replace-invalid-input.test
+++ llvm/test/tools/llvm-lipo/replace-invalid-input.test
@@ -3,7 +3,7 @@
# RUN: yaml2obj %p/Inputs/i386-x86_64-universal.yaml -o %t-universal.o
# RUN: not llvm-lipo %t-universal.o -replace %t-32.o 2>&1 | FileCheck --check-prefix=MISSING_ARG %s
-# MISSING_ARG: error: replace is missing an argument: expects -replace arch_type file_name
+# MISSING_ARG: error: missing argument to -replace option
# RUN: not llvm-lipo %t-universal.o -replace i386 %t-32.o 2>&1 | FileCheck --check-prefix=OUTPUT_FILE %s
# OUTPUT_FILE: error: replace expects a single output file to be specified
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132418.454932.patch
Type: text/x-patch
Size: 2989 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220823/8e937a40/attachment.bin>
More information about the llvm-commits
mailing list