From 13f61005b8f8982f90b72fe8820e081a3f3b008b Mon Sep 17 00:00:00 2001 From: Davide Italiano Date: Wed, 13 Jan 2016 02:03:31 +0000 Subject: [PATCH] [llvm-objdump] Use report_error() and improve error coverage. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@257561 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../tools/llvm-objdump/Inputs/malformed-macho.bin | Bin 0 -> 843 bytes test/tools/llvm-objdump/malformed-archives.test | 2 +- test/tools/llvm-objdump/malformed-macho.test | 2 ++ tools/llvm-objdump/MachODump.cpp | 6 ++---- 4 files changed, 5 insertions(+), 5 deletions(-) create mode 100644 test/tools/llvm-objdump/Inputs/malformed-macho.bin create mode 100644 test/tools/llvm-objdump/malformed-macho.test diff --git a/test/tools/llvm-objdump/Inputs/malformed-macho.bin b/test/tools/llvm-objdump/Inputs/malformed-macho.bin new file mode 100644 index 0000000000000000000000000000000000000000..b8a3f153a8964bdc98eece04e5570ea4ea97fa54 GIT binary patch literal 843 zcmaJP$AL57`OfQ}IrrYby$Io(5cog|2V|H~$UO9n_#bk~e#7q> znukD10~}Y%wj7%YK&ezBlltP?+F*nFQSCKw*g7EEI)_lH+>zZVRS(%Y-cR?5aD12N zW9s$P1c-jMNo7?VH~hpz&WC-$Hul%th)_s_La`md6f?vw01oAR7a5#7W) zfqU{Q-R3~L>ArNkSE5hOn_(pJ==Nmi&OEr4R=Hd=TeU_xAEwYy_#S?YGRtw_@xJgm zhR>J@Os8U6*R^WllUN3j((PW{`FAlIz`@sDft|Byxcpgc%Bied@6ZizS&^)hLY t*vK?7;)u6_B=lxS!gv^!Y^f?#9dFGpcr0!eMN-A_{zO80m%L83;ZOSzTPFYj literal 0 HcmV?d00001 diff --git a/test/tools/llvm-objdump/malformed-archives.test b/test/tools/llvm-objdump/malformed-archives.test index e0f165d37ed..c477022e2e1 100644 --- a/test/tools/llvm-objdump/malformed-archives.test +++ b/test/tools/llvm-objdump/malformed-archives.test @@ -1,7 +1,7 @@ // These test checks that llvm-objdump will not crash with malformed Archive // files. So the check line is not all that important but the bug fixes to // make sure llvm-objdump is robust is what matters. -# RUN: llvm-objdump -macho -archive-headers \ +# RUN: not llvm-objdump -macho -archive-headers \ # RUN: %p/Inputs/libbogus1.a \ # RUN: 2>&1 | FileCheck -check-prefix=bogus1 %s diff --git a/test/tools/llvm-objdump/malformed-macho.test b/test/tools/llvm-objdump/malformed-macho.test new file mode 100644 index 00000000000..e96945d9112 --- /dev/null +++ b/test/tools/llvm-objdump/malformed-macho.test @@ -0,0 +1,2 @@ +RUN: not llvm-objdump -macho -s %p/Inputs/malformed-macho.bin 2>&1 | FileCheck %s -check-prefix=MALFORMED +MALFORMED: '{{.*}}': The file was not recognized as a valid object file diff --git a/tools/llvm-objdump/MachODump.cpp b/tools/llvm-objdump/MachODump.cpp index e486b1a0d6d..87b2b439d55 100644 --- a/tools/llvm-objdump/MachODump.cpp +++ b/tools/llvm-objdump/MachODump.cpp @@ -1481,10 +1481,8 @@ void llvm::ParseInputMachO(StringRef Filename) { // Attempt to open the binary. ErrorOr> BinaryOrErr = createBinary(Filename); - if (std::error_code EC = BinaryOrErr.getError()) { - errs() << "llvm-objdump: '" << Filename << "': " << EC.message() << ".\n"; - return; - } + if (std::error_code EC = BinaryOrErr.getError()) + report_error(Filename, EC); Binary &Bin = *BinaryOrErr.get().getBinary(); if (Archive *A = dyn_cast(&Bin)) { -- 2.34.1