[PATCH] D46547: [llvm-objcopy] Fix the exit code

Alexander Shaposhnikov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 8 10:16:40 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL331776: [llvm-objcopy] Fix exit code (authored by alexshap, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D46547?vs=145546&id=145719#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D46547

Files:
  llvm/trunk/test/tools/llvm-objcopy/help-message.test
  llvm/trunk/tools/llvm-objcopy/llvm-objcopy.cpp


Index: llvm/trunk/tools/llvm-objcopy/llvm-objcopy.cpp
===================================================================
--- llvm/trunk/tools/llvm-objcopy/llvm-objcopy.cpp
+++ llvm/trunk/tools/llvm-objcopy/llvm-objcopy.cpp
@@ -409,8 +409,13 @@
   unsigned MissingArgumentIndex, MissingArgumentCount;
   llvm::opt::InputArgList InputArgs =
       T.ParseArgs(ArgsArr, MissingArgumentIndex, MissingArgumentCount);
-
-  if (InputArgs.size() == 0 || InputArgs.hasArg(OBJCOPY_help)) {
+  
+  if (InputArgs.size() == 0) {
+    T.PrintHelp(errs(), "llvm-objcopy <input> [ <output> ]", "objcopy tool");
+    exit(1);
+  }
+  
+  if (InputArgs.hasArg(OBJCOPY_help)) {
     T.PrintHelp(outs(), "llvm-objcopy <input> [ <output> ]", "objcopy tool");
     exit(0);
   }
@@ -484,7 +489,12 @@
   llvm::opt::InputArgList InputArgs =
       T.ParseArgs(ArgsArr, MissingArgumentIndex, MissingArgumentCount);
 
-  if (InputArgs.size() == 0 || InputArgs.hasArg(STRIP_help)) {
+  if (InputArgs.size() == 0) {
+    T.PrintHelp(errs(), "llvm-strip <input> [ <output> ]", "strip tool");
+    exit(1);
+  }
+  
+  if (InputArgs.hasArg(STRIP_help)) {
     T.PrintHelp(outs(), "llvm-strip <input> [ <output> ]", "strip tool");
     exit(0);
   }
Index: llvm/trunk/test/tools/llvm-objcopy/help-message.test
===================================================================
--- llvm/trunk/test/tools/llvm-objcopy/help-message.test
+++ llvm/trunk/test/tools/llvm-objcopy/help-message.test
@@ -0,0 +1,8 @@
+# RUN: llvm-objcopy --help | FileCheck --check-prefix=CHECK-OBJCOPY %s
+# RUN: not llvm-objcopy 2>&1 | FileCheck --check-prefix=CHECK-OBJCOPY %s
+
+# RUN: llvm-strip --help | FileCheck --check-prefix=CHECK-STRIP %s
+# RUN: not llvm-strip 2>&1 | FileCheck --check-prefix=CHECK-STRIP %s
+
+# CHECK-OBJCOPY: USAGE: llvm-objcopy
+# CHECK-STRIP:   USAGE: llvm-strip


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46547.145719.patch
Type: text/x-patch
Size: 1840 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180508/17d56b43/attachment.bin>


More information about the llvm-commits mailing list