[PATCH] D83704: [llvm-readobj] Print help when executed with no input files
Elvina Yakubova via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 15 14:51:16 PDT 2020
Elvina updated this revision to Diff 278317.
Elvina added a comment.
Changed llvm-readobj's behavior as suggested, so now an error message is displayed if no input files are provided
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D83704/new/
https://reviews.llvm.org/D83704
Files:
llvm/docs/CommandGuide/llvm-readelf.rst
llvm/docs/CommandGuide/llvm-readobj.rst
llvm/test/tools/llvm-readobj/basic.test
llvm/tools/llvm-readobj/llvm-readobj.cpp
Index: llvm/tools/llvm-readobj/llvm-readobj.cpp
===================================================================
--- llvm/tools/llvm-readobj/llvm-readobj.cpp
+++ llvm/tools/llvm-readobj/llvm-readobj.cpp
@@ -689,6 +689,11 @@
}
cl::ParseCommandLineOptions(argc, argv, "LLVM Object Reader\n");
+
+ // Default to print error if no filename is specified.
+ if (opts::InputFilenames.empty()) {
+ error("No input files specified");
+ }
if (opts::All) {
opts::FileHeaders = true;
@@ -714,10 +719,6 @@
opts::SectionHeaders = true;
}
- // Default to stdin if no filename is specified.
- if (opts::InputFilenames.empty())
- opts::InputFilenames.push_back("-");
-
ScopedPrinter Writer(fouts());
for (const std::string &I : opts::InputFilenames)
dumpInput(I, Writer);
Index: llvm/test/tools/llvm-readobj/basic.test
===================================================================
--- llvm/test/tools/llvm-readobj/basic.test
+++ llvm/test/tools/llvm-readobj/basic.test
@@ -4,6 +4,11 @@
ENOENT: llvm-[[TOOL]]{{(\.exe)?}}: error: '{{.*}}.blah': {{[Nn]}}o such file or directory
+# Test case with no input file
+RUN: not llvm-readobj 2>&1 | FileCheck %s --check-prefix=NO-FILE
+RUN: not llvm-readelf 2>&1 | FileCheck %s --check-prefix=NO-FILE
+NO-FILE: error: No input files specified
+
# Test case where input file is too small to be a recognised object file.
RUN: touch %t.empty
RUN: not llvm-readobj %t.empty 2>&1 | FileCheck --check-prefix=EMPTY %s
Index: llvm/docs/CommandGuide/llvm-readobj.rst
===================================================================
--- llvm/docs/CommandGuide/llvm-readobj.rst
+++ llvm/docs/CommandGuide/llvm-readobj.rst
@@ -14,7 +14,7 @@
The :program:`llvm-readobj` tool displays low-level format-specific information
about one or more object files.
-If ``input`` is "``-``" or omitted, :program:`llvm-readobj` reads from standard
+If ``input`` is "``-``", :program:`llvm-readobj` reads from standard
input. Otherwise, it will read from the specified ``filenames``.
DIFFERENCES TO LLVM-READELF
Index: llvm/docs/CommandGuide/llvm-readelf.rst
===================================================================
--- llvm/docs/CommandGuide/llvm-readelf.rst
+++ llvm/docs/CommandGuide/llvm-readelf.rst
@@ -14,7 +14,7 @@
The :program:`llvm-readelf` tool displays low-level format-specific information
about one or more object files.
-If ``input`` is "``-``" or omitted, :program:`llvm-readelf` reads from standard
+If ``input`` is "``-``", :program:`llvm-readelf` reads from standard
input. Otherwise, it will read from the specified ``filenames``.
OPTIONS
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83704.278317.patch
Type: text/x-patch
Size: 2653 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200715/d11692ca/attachment.bin>
More information about the llvm-commits
mailing list