[PATCH] D83152: llvm-nm: add flag to suppress no symbols warning

Keith Smiley via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 7 16:20:52 PST 2021


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG64240f8138f5: llvm-nm: add flag to suppress no symbols warning (authored by keith).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83152

Files:
  llvm/docs/CommandGuide/llvm-nm.rst
  llvm/test/tools/llvm-nm/X86/nm-no-symbols.test
  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
@@ -117,6 +117,9 @@
 cl::alias PrintFileNameo("o", cl::desc("Alias for --print-file-name"),
                          cl::aliasopt(PrintFileName), cl::Grouping);
 
+cl::opt<bool> Quiet("quiet", cl::desc("Suppress 'no symbols' diagnostic"),
+                    cl::cat(NMCat));
+
 cl::opt<bool> DebugSyms("debug-syms",
                         cl::desc("Show all symbols, even debugger only"),
                         cl::cat(NMCat));
@@ -1861,7 +1864,7 @@
 
   CurrentFilename = Obj.getFileName();
 
-  if (Symbols.empty() && SymbolList.empty()) {
+  if (Symbols.empty() && SymbolList.empty() && !Quiet) {
     writeFileName(errs(), ArchiveName, ArchitectureName);
     errs() << "no symbols\n";
   }
Index: llvm/test/tools/llvm-nm/X86/nm-no-symbols.test
===================================================================
--- llvm/test/tools/llvm-nm/X86/nm-no-symbols.test
+++ llvm/test/tools/llvm-nm/X86/nm-no-symbols.test
@@ -9,3 +9,5 @@
   Machine:         EM_X86_64
 
 # CHECK: [[FILE]]: no symbols{{$}}
+
+# RUN: llvm-nm --quiet %t.o 2>&1 | count 0
Index: llvm/docs/CommandGuide/llvm-nm.rst
===================================================================
--- llvm/docs/CommandGuide/llvm-nm.rst
+++ llvm/docs/CommandGuide/llvm-nm.rst
@@ -204,6 +204,10 @@
 
  Show symbol size as well as address (not applicable for Mach-O).
 
+.. option:: --quiet
+
+ Suppress 'no symbols' diagnostic.
+
 .. option:: --radix=<RADIX>, -t
 
  Specify the radix of the symbol address(es). Values accepted are *d* (decimal),


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83152.328914.patch
Type: text/x-patch
Size: 1691 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210308/737c5d72/attachment.bin>


More information about the llvm-commits mailing list