diff --git a/llvm/lib/Object/ArchiveWriter.cpp b/llvm/lib/Object/ArchiveWriter.cpp --- a/llvm/lib/Object/ArchiveWriter.cpp +++ b/llvm/lib/Object/ArchiveWriter.cpp @@ -598,8 +598,8 @@ if (NeedSymbols) { Expected> SymbolsOrErr = getSymbols(Buf, SymNames, HasObject); - if (auto E = SymbolsOrErr.takeError()) - return std::move(E); + if (!SymbolsOrErr) + return createFileError(M.MemberName, SymbolsOrErr.takeError()); Symbols = std::move(*SymbolsOrErr); } diff --git a/llvm/test/Object/archive-malformed-object.test b/llvm/test/Object/archive-malformed-object.test --- a/llvm/test/Object/archive-malformed-object.test +++ b/llvm/test/Object/archive-malformed-object.test @@ -10,13 +10,13 @@ # RUN: %python -c "with open('input.bc', 'a') as f: f.truncate(10)" # RUN: not llvm-ar rc bad.a input.bc 2>&1 | FileCheck %s --check-prefix=ERR1 -# ERR1: error: bad.a: Invalid bitcode signature +# ERR1: error: bad.a: 'input.bc': Invalid bitcode signature ## Non-bitcode malformed file. # RUN: yaml2obj input.yaml -o input.o # RUN: not llvm-ar rc bad.a input.o 2>&1 | FileCheck %s --check-prefix=ERR2 -# ERR2: error: bad.a: section header table goes past the end of the file: e_shoff = 0x9999 +# ERR2: error: bad.a: 'input.o': section header table goes past the end of the file: e_shoff = 0x9999 ## Don't emit an error if the symbol table is not required. # RUN: llvm-ar rcS good.a input.o input.bc