]> granicus.if.org Git - llvm/commitdiff
[llvm-ar] Removes repetition in the error message
authorFangrui Song <maskray@google.com>
Fri, 20 Sep 2019 04:40:44 +0000 (04:40 +0000)
committerFangrui Song <maskray@google.com>
Fri, 20 Sep 2019 04:40:44 +0000 (04:40 +0000)
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

test/tools/llvm-ar/invalid-object-file.test [new file with mode: 0644]
tools/llvm-ar/llvm-ar.cpp

diff --git a/test/tools/llvm-ar/invalid-object-file.test b/test/tools/llvm-ar/invalid-object-file.test
new file mode 100644 (file)
index 0000000..d967d87
--- /dev/null
@@ -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 006d8ed74cf29575c5d3c224338ca3976f98e98d..65a8619209117c811d650492ffe7794e550ef0cc 100644 (file)
@@ -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);