Index: llvm/trunk/test/tools/llvm-ar/invalid-object-file.test =================================================================== --- llvm/trunk/test/tools/llvm-ar/invalid-object-file.test +++ llvm/trunk/test/tools/llvm-ar/invalid-object-file.test @@ -0,0 +1,8 @@ +## Test that we get a proper error message with a file that is not a recognized object file. + +# RUN: rm -f %t.txt +# RUN: touch %t.txt +# RUN: not llvm-ar sc %t.txt 2>&1 > /dev/null | FileCheck %s -DFILE=%t.txt + +# CHECK: error: unable to load '[[FILE]]': file too small to be an archive +# CHECK-NOT: {{.}} Index: llvm/trunk/tools/llvm-ar/llvm-ar.cpp =================================================================== --- llvm/trunk/tools/llvm-ar/llvm-ar.cpp +++ llvm/trunk/tools/llvm-ar/llvm-ar.cpp @@ -927,8 +927,7 @@ if (!EC) { Error Err = Error::success(); object::Archive Archive(Buf.get()->getMemBufferRef(), Err); - EC = errorToErrorCode(std::move(Err)); - failIfError(EC, "error loading '" + ArchiveName + "': " + EC.message()); + failIfError(std::move(Err), "unable to load '" + ArchiveName + "'"); if (Archive.isThin()) CompareFullPath = true; performOperation(Operation, &Archive, std::move(Buf.get()), NewMembers);