diff --git a/llvm/test/tools/llvm-nm/X86/nm-no-symbols.test b/llvm/test/tools/llvm-nm/X86/nm-no-symbols.test --- a/llvm/test/tools/llvm-nm/X86/nm-no-symbols.test +++ b/llvm/test/tools/llvm-nm/X86/nm-no-symbols.test @@ -9,3 +9,6 @@ Machine: EM_X86_64 # CHECK: [[FILE]]: no symbols{{$}} + +# RUN: llvm-nm %t.o 2>&1 | FileCheck %s -DFILE=%t.o --check-prefix=NO-WARNING --allow-empty +# NO-WARNING-NOT: {{.}} diff --git a/llvm/tools/llvm-nm/llvm-nm.cpp b/llvm/tools/llvm-nm/llvm-nm.cpp --- a/llvm/tools/llvm-nm/llvm-nm.cpp +++ b/llvm/tools/llvm-nm/llvm-nm.cpp @@ -155,6 +155,9 @@ cl::aliasopt(PrintSize), cl::Grouping); bool MachOPrintSizeWarning = false; +cl::opt Quiet("quiet", cl::desc("Suppress 'no symbols' diagnostic"), + cl::cat(NMCat)); + cl::opt SizeSort("size-sort", cl::desc("Sort symbols by size"), cl::cat(NMCat)); @@ -1846,7 +1849,7 @@ CurrentFilename = Obj.getFileName(); - if (Symbols.empty() && SymbolList.empty()) { + if (Symbols.empty() && SymbolList.empty() && !Quiet) { writeFileName(errs(), ArchiveName, ArchitectureName); errs() << "no symbols\n"; }