summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp')
-rw-r--r--llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp16
1 files changed, 6 insertions, 10 deletions
diff --git a/llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp b/llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp
index 94533270c30..1779d783c80 100644
--- a/llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp
+++ b/llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp
@@ -56,21 +56,16 @@ public:
} // namespace
-std::vector<std::unique_ptr<MemoryBuffer>> OwningMBs;
-
// Opens a file. Path has to be resolved already.
-// Newly created memory buffers are owned by this driver.
-Optional<MemoryBufferRef> openFile(StringRef Path) {
+static std::unique_ptr<MemoryBuffer> openFile(const Twine &Path) {
ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> MB = MemoryBuffer::getFile(Path);
if (std::error_code EC = MB.getError()) {
llvm::errs() << "cannot open file " << Path << ": " << EC.message() << "\n";
- return None;
+ return nullptr;
}
- MemoryBufferRef MBRef = MB.get()->getMemBufferRef();
- OwningMBs.push_back(std::move(MB.get())); // take ownership
- return MBRef;
+ return std::move(*MB);
}
static MachineTypes getEmulation(StringRef S) {
@@ -82,7 +77,7 @@ static MachineTypes getEmulation(StringRef S) {
.Default(IMAGE_FILE_MACHINE_UNKNOWN);
}
-static std::string getImplibPath(std::string Path) {
+static std::string getImplibPath(StringRef Path) {
SmallString<128> Out = StringRef("lib");
Out.append(Path);
sys::path::replace_extension(Out, ".a");
@@ -122,7 +117,8 @@ int llvm::dlltoolDriverMain(llvm::ArrayRef<const char *> ArgsArr) {
return 1;
}
- Optional<MemoryBufferRef> MB = openFile(Args.getLastArg(OPT_d)->getValue());
+ std::unique_ptr<MemoryBuffer> MB =
+ openFile(Args.getLastArg(OPT_d)->getValue());
if (!MB)
return 1;
OpenPOWER on IntegriCloud