Index: llvm/test/Object/nm-shared-object.test =================================================================== --- llvm/test/Object/nm-shared-object.test +++ llvm/test/Object/nm-shared-object.test @@ -30,5 +30,6 @@ ERROR: File format has no dynamic symbol table. -RUN: llvm-nm -D %p/Inputs/trivial-object-test.elf-i386 | FileCheck %s -check-prefix=NO-SYMBOLS +RUN: llvm-nm -D %p/Inputs/trivial-object-test.elf-i386 2>&1 \ +RUN: | FileCheck %s -check-prefix=NO-SYMBOLS NO-SYMBOLS: no symbols Index: llvm/test/ThinLTO/X86/empty-module.ll =================================================================== --- llvm/test/ThinLTO/X86/empty-module.ll +++ llvm/test/ThinLTO/X86/empty-module.ll @@ -3,7 +3,7 @@ ; RUN: rm -f %t2.0 ; RUN: llvm-lto2 run %t.bc -r %t.bc,foo,pl -o %t2 -thinlto-distributed-indexes ; RUN: llvm-readobj -h %t2.0 | FileCheck %s -; RUN: llvm-nm %t2.0 | FileCheck %s -check-prefix=NO-SYMBOLS +; RUN: llvm-nm %t2.0 2>&1 | FileCheck %s -check-prefix=NO-SYMBOLS ; NO-SYMBOLS: no symbols ; CHECK: Format: ELF64-x86-64 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 @@ -1,6 +1,6 @@ # RUN: yaml2obj %s > %t.o -# RUN: llvm-nm %t.o | FileCheck %s -# RUN: llvm-nm --print-file-name %t.o | FileCheck %s --check-prefix=CHECK-PRINT-FILE-NAME +# RUN: llvm-nm %t.o 2>&1 | FileCheck %s +# RUN: llvm-nm --print-file-name %t.o 2>&1 | FileCheck %s --check-prefix=CHECK-PRINT-FILE-NAME !ELF FileHeader: Index: llvm/tools/llvm-nm/llvm-nm.cpp =================================================================== --- llvm/tools/llvm-nm/llvm-nm.cpp +++ llvm/tools/llvm-nm/llvm-nm.cpp @@ -757,22 +757,22 @@ } } - auto writeFileName = [&]() { + auto writeFileName = [&](raw_ostream &S) { if (!ArchitectureName.empty()) - outs() << "(for architecture " << ArchitectureName << "):"; + S << "(for architecture " << ArchitectureName << "):"; if (OutputFormat == posix && !ArchiveName.empty()) - outs() << ArchiveName << "[" << CurrentFilename << "]: "; + S << ArchiveName << "[" << CurrentFilename << "]: "; else { if (!ArchiveName.empty()) - outs() << ArchiveName << ":"; - outs() << CurrentFilename << ": "; + S << ArchiveName << ":"; + S << CurrentFilename << ": "; } }; if (SymbolList.empty()) { if (PrintFileName) - writeFileName(); - outs() << "no symbols\n"; + writeFileName(errs()); + errs() << "no symbols\n"; } for (SymbolListT::iterator I = SymbolList.begin(), E = SymbolList.end(); @@ -797,7 +797,7 @@ (Weak && NoWeakSymbols)) continue; if (PrintFileName) - writeFileName(); + writeFileName(outs()); if ((JustSymbolName || (UndefinedOnly && MachO && OutputFormat != darwin)) && OutputFormat != posix) {