Return an ErrorOr<Binary *> from createBinary.
I did write a version returning ErrorOr<OwningPtr<Binary> >, but it is too
cumbersome to use without std::move. I will keep the patch locally and submit
when we switch to c++11.
llvm-svn: 199326
diff --git a/llvm/tools/llvm-size/llvm-size.cpp b/llvm/tools/llvm-size/llvm-size.cpp
index 3de6605..cb805c2 100644
--- a/llvm/tools/llvm-size/llvm-size.cpp
+++ b/llvm/tools/llvm-size/llvm-size.cpp
@@ -244,11 +244,12 @@
}
// Attempt to open the binary.
- OwningPtr<Binary> binary;
- if (error_code ec = createBinary(file, binary)) {
- errs() << ToolName << ": " << file << ": " << ec.message() << ".\n";
+ ErrorOr<Binary *> BinaryOrErr = createBinary(file);
+ if (error_code EC = BinaryOrErr.getError()) {
+ errs() << ToolName << ": " << file << ": " << EC.message() << ".\n";
return;
}
+ OwningPtr<Binary> binary(BinaryOrErr.get());
if (Archive *a = dyn_cast<Archive>(binary.get())) {
// This is an archive. Iterate over each member and display its sizes.