[PATCH] D64290: [tools] [llvm-nm] Default to reading from stdin not a.out

Alex Brachet via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 8 06:07:43 PDT 2019


abrachet updated this revision to Diff 208385.
abrachet added a comment.

Removed test case. Added documentation.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64290/new/

https://reviews.llvm.org/D64290

Files:
  llvm/docs/CommandGuide/llvm-nm.rst
  llvm/tools/llvm-nm/llvm-nm.cpp


Index: llvm/tools/llvm-nm/llvm-nm.cpp
===================================================================
--- llvm/tools/llvm-nm/llvm-nm.cpp
+++ llvm/tools/llvm-nm/llvm-nm.cpp
@@ -34,6 +34,7 @@
 #include "llvm/Support/Format.h"
 #include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Process.h"
 #include "llvm/Support/Program.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/TargetSelect.h"
@@ -1751,6 +1752,12 @@
 }
 
 static void dumpSymbolNamesFromFile(std::string &Filename) {
+  if (Filename == "-" && sys::Process::StandardInIsUserInput()) {
+    WithColor::warning(outs(), ToolName) << "can't read from keyboard input.\n";
+    cl::PrintHelpMessage();
+    HadError = true;
+    return;
+  }
   ErrorOr<std::unique_ptr<MemoryBuffer>> BufferOrErr =
       MemoryBuffer::getFileOrSTDIN(Filename);
   if (error(BufferOrErr.getError(), Filename))
@@ -2082,7 +2089,7 @@
   if (OutputFormat == sysv || SizeSort)
     PrintSize = true;
   if (InputFilenames.empty())
-    InputFilenames.push_back("a.out");
+    InputFilenames.push_back("-");
   if (InputFilenames.size() > 1)
     MultipleFiles = true;
 
Index: llvm/docs/CommandGuide/llvm-nm.rst
===================================================================
--- llvm/docs/CommandGuide/llvm-nm.rst
+++ llvm/docs/CommandGuide/llvm-nm.rst
@@ -14,9 +14,8 @@
 The :program:`llvm-nm` utility lists the names of symbols from the LLVM bitcode
 files, object files, or :program:`ar` archives containing them, named on the
 command line.  Each symbol is listed along with some simple information about
-its provenance.  If no filename is specified, *a.out* is used as the input.
-If *-* is used as a filename, :program:`llvm-nm` will read a file from its
-standard input stream.
+its provenance.  If no filename is specified, or *-* is used as a filename,
+:program:`llvm-nm` will process a file on its standard input stream.
 
 :program:`llvm-nm`'s default output format is the traditional BSD :program:`nm`
 output format.  Each such output record consists of an (optional) 8-digit


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64290.208385.patch
Type: text/x-patch
Size: 2090 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190708/19890000/attachment.bin>


More information about the llvm-commits mailing list