aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2020-05-08 13:58:56 -0700
committerReid Kleckner <rnk@google.com>2020-05-08 14:22:28 -0700
commit39772063f513ef24729ed9f20830e887d89459b6 (patch)
treec919f33d5455bc661dbeda2a1bc5c7704a63557b /llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
parent77ecf90c52641aadedf6bad7c8bea5b217b49729 (diff)
downloadllvm-39772063f513ef24729ed9f20830e887d89459b6.zip
llvm-39772063f513ef24729ed9f20830e887d89459b6.tar.gz
llvm-39772063f513ef24729ed9f20830e887d89459b6.tar.bz2
[COFF] Use Expected in COFFObjectFile creation
The constructor error out parameter was a bit awkward. Wrap it in a factory method which can return an error. Make the constructor private.
Diffstat (limited to 'llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp')
-rw-r--r--llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp b/llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
index d622c16..c409012 100644
--- a/llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
+++ b/llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
@@ -141,14 +141,14 @@ static void doList(opt::InputArgList& Args) {
static COFF::MachineTypes getCOFFFileMachine(MemoryBufferRef MB) {
std::error_code EC;
- object::COFFObjectFile Obj(MB, EC);
- if (EC) {
+ auto Obj = object::COFFObjectFile::create(MB);
+ if (!Obj) {
llvm::errs() << MB.getBufferIdentifier()
- << ": failed to open: " << EC.message() << '\n';
+ << ": failed to open: " << Obj.takeError() << '\n';
exit(1);
}
- uint16_t Machine = Obj.getMachine();
+ uint16_t Machine = (*Obj)->getMachine();
if (Machine != COFF::IMAGE_FILE_MACHINE_I386 &&
Machine != COFF::IMAGE_FILE_MACHINE_AMD64 &&
Machine != COFF::IMAGE_FILE_MACHINE_ARMNT &&