From: Fangrui Song Date: Fri, 20 Sep 2019 04:40:44 +0000 (+0000) Subject: [llvm-ar] Removes repetition in the error message X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a6465b89dbb7cb4039d8b773ab0ff451429493bb;p=llvm [llvm-ar] Removes repetition in the error message As per bug 40244, fixed an error where the error message was repeated. Differential Revision: https://reviews.llvm.org/D67038 Patch by Yu Jian (wyjw) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@372370 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/tools/llvm-ar/invalid-object-file.test b/test/tools/llvm-ar/invalid-object-file.test new file mode 100644 index 00000000000..d967d8763a9 --- /dev/null +++ b/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: {{.}} diff --git a/tools/llvm-ar/llvm-ar.cpp b/tools/llvm-ar/llvm-ar.cpp index 006d8ed74cf..65a86192091 100644 --- a/tools/llvm-ar/llvm-ar.cpp +++ b/tools/llvm-ar/llvm-ar.cpp @@ -927,8 +927,7 @@ static int performOperation(ArchiveOperation Operation, 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);