[llvm] r257561 - [llvm-objdump] Use report_error() and improve error coverage.
Davide Italiano via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 12 18:03:32 PST 2016
Author: davide
Date: Tue Jan 12 20:03:31 2016
New Revision: 257561
URL: http://llvm.org/viewvc/llvm-project?rev=257561&view=rev
Log:
[llvm-objdump] Use report_error() and improve error coverage.
Added:
llvm/trunk/test/tools/llvm-objdump/Inputs/malformed-macho.bin (with props)
llvm/trunk/test/tools/llvm-objdump/malformed-macho.test
Modified:
llvm/trunk/test/tools/llvm-objdump/malformed-archives.test
llvm/trunk/tools/llvm-objdump/MachODump.cpp
Added: llvm/trunk/test/tools/llvm-objdump/Inputs/malformed-macho.bin
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-objdump/Inputs/malformed-macho.bin?rev=257561&view=auto
==============================================================================
Binary file - no diff available.
Propchange: llvm/trunk/test/tools/llvm-objdump/Inputs/malformed-macho.bin
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Modified: llvm/trunk/test/tools/llvm-objdump/malformed-archives.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-objdump/malformed-archives.test?rev=257561&r1=257560&r2=257561&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-objdump/malformed-archives.test (original)
+++ llvm/trunk/test/tools/llvm-objdump/malformed-archives.test Tue Jan 12 20:03:31 2016
@@ -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
Added: llvm/trunk/test/tools/llvm-objdump/malformed-macho.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-objdump/malformed-macho.test?rev=257561&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-objdump/malformed-macho.test (added)
+++ llvm/trunk/test/tools/llvm-objdump/malformed-macho.test Tue Jan 12 20:03:31 2016
@@ -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
Modified: llvm/trunk/tools/llvm-objdump/MachODump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/MachODump.cpp?rev=257561&r1=257560&r2=257561&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objdump/MachODump.cpp (original)
+++ llvm/trunk/tools/llvm-objdump/MachODump.cpp Tue Jan 12 20:03:31 2016
@@ -1481,10 +1481,8 @@ void llvm::ParseInputMachO(StringRef Fil
// Attempt to open the binary.
ErrorOr<OwningBinary<Binary>> 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<Archive>(&Bin)) {
More information about the llvm-commits
mailing list