Index: clang/test/CodeGen/thinlto_backend.ll =================================================================== --- clang/test/CodeGen/thinlto_backend.ll +++ clang/test/CodeGen/thinlto_backend.ll @@ -25,7 +25,7 @@ ; be empty file. ; RUN: opt -o %t5.o %s ; RUN: %clang -target x86_64-unknown-linux-gnu -O2 -o %t4.o -x ir %t5.o -c -fthinlto-index=%t.thinlto.bc -; RUN: llvm-nm %t4.o | FileCheck %s -check-prefix=NO-SYMBOLS +; RUN: llvm-nm %t4.o 2>&1 | FileCheck %s -check-prefix=NO-SYMBOLS ; NO-SYMBOLS: no symbols ; Ensure f2 was imported. Check for all 3 flavors of -save-temps[=cwd|obj]. Index: lld/test/ELF/lto/thinlto-obj-path.ll =================================================================== --- lld/test/ELF/lto/thinlto-obj-path.ll +++ lld/test/ELF/lto/thinlto-obj-path.ll @@ -7,7 +7,7 @@ ; RUN: rm -f %t4.o ; RUN: ld.lld --plugin-opt=thinlto-index-only --plugin-opt=obj-path=%t4.o -shared %t1.o %t2.o -o %t3 ; RUN: llvm-readobj -h %t4.o | FileCheck %s -; RUN: llvm-nm %t4.o | FileCheck %s -check-prefix=NO-SYMBOLS +; RUN: llvm-nm %t4.o 2>&1 | FileCheck %s -check-prefix=NO-SYMBOLS ; NO-SYMBOLS: no symbols ; CHECK: Format: ELF64-x86-64 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) {