summaryrefslogtreecommitdiff
path: root/tools/llvm-objdump
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2014-01-21 23:06:54 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2014-01-21 23:06:54 +0000
commit3d218156f8eb62693c2ab31029859096a3b2e4a2 (patch)
tree3834b59659e0cb303b49970ec2bc14101ddb537c /tools/llvm-objdump
parentdcaab3b6818ff5421c7880527ce5f4f13b7daaee (diff)
downloadllvm-3d218156f8eb62693c2ab31029859096a3b2e4a2.tar.gz
llvm-3d218156f8eb62693c2ab31029859096a3b2e4a2.tar.bz2
llvm-3d218156f8eb62693c2ab31029859096a3b2e4a2.tar.xz
Be a bit more consistent about using ErrorOr when constructing Binary objects.
The constructors of classes deriving from Binary normally take an error_code as an argument to the constructor. My original intent was to change them to have a trivial constructor and move the initial parsing logic to a static method returning an ErrorOr. I changed my mind because: * A constructor with an error_code out parameter is extremely convenient from the implementation side. We can incrementally construct the object and give up when we find an error. * It is very efficient when constructing on the stack or when there is no error. The only inefficient case is where heap allocating and an error is found (we have to free the memory). The result is that this is a much smaller patch. It just standardizes the create* helpers to return an ErrorOr. Almost no functionality change: The only difference is that this found that we were trying to read past the end of COFF import library but ignoring the error. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199770 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-objdump')
-rw-r--r--tools/llvm-objdump/MachODump.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/tools/llvm-objdump/MachODump.cpp b/tools/llvm-objdump/MachODump.cpp
index 86923fd1d7..52c786f305 100644
--- a/tools/llvm-objdump/MachODump.cpp
+++ b/tools/llvm-objdump/MachODump.cpp
@@ -207,8 +207,8 @@ void llvm::DisassembleInputMachO(StringRef Filename) {
return;
}
- OwningPtr<MachOObjectFile> MachOOF(static_cast<MachOObjectFile*>(
- ObjectFile::createMachOObjectFile(Buff.take())));
+ OwningPtr<MachOObjectFile> MachOOF(static_cast<MachOObjectFile *>(
+ ObjectFile::createMachOObjectFile(Buff.take()).get()));
DisassembleInputMachO2(Filename, MachOOF.get());
}
@@ -297,7 +297,7 @@ static void DisassembleInputMachO2(StringRef Filename,
errs() << "llvm-objdump: " << Filename << ": " << ec.message() << '\n';
return;
}
- DbgObj = ObjectFile::createMachOObjectFile(Buf.take());
+ DbgObj = ObjectFile::createMachOObjectFile(Buf.take()).get();
}
// Setup the DIContext