[lld] r305730 - Have writeCOFFWriter return Expected<unique_ptr>.
Eric Beckmann via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 19 11:49:05 PDT 2017
Author: ecbeckmann
Date: Mon Jun 19 13:49:05 2017
New Revision: 305730
URL: http://llvm.org/viewvc/llvm-project?rev=305730&view=rev
Log:
Have writeCOFFWriter return Expected<unique_ptr>.
Summary: Have writeCOFFWriter return Expected<unique_ptr> instead of requiring being passed an uninitialized unique_ptr.
Reviewers: zturner, ruiu
Subscribers: hiraditya, llvm-commits
Differential Revision: https://reviews.llvm.org/D34307
Modified:
lld/trunk/COFF/DriverUtils.cpp
Modified: lld/trunk/COFF/DriverUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/DriverUtils.cpp?rev=305730&r1=305729&r2=305730&view=diff
==============================================================================
--- lld/trunk/COFF/DriverUtils.cpp (original)
+++ lld/trunk/COFF/DriverUtils.cpp Mon Jun 19 13:49:05 2017
@@ -604,12 +604,11 @@ convertResToCOFF(const std::vector<Memor
fatal(EC, "failed to parse .res file");
}
- std::unique_ptr<MemoryBuffer> MB;
- if (auto EC =
- llvm::object::writeWindowsResourceCOFF(MB, Config->Machine, Parser))
- fatal(EC, "failed to write resources to buffer");
-
- return MB;
+ Expected<std::unique_ptr<MemoryBuffer>> E =
+ llvm::object::writeWindowsResourceCOFF(Config->Machine, Parser);
+ if (!E)
+ fatal(errorToErrorCode(E.takeError()), "failed to write .res to COFF");
+ return std::move(E.get());
}
// Run MSVC link.exe for given in-memory object files.
More information about the llvm-commits
mailing list