summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2013-06-17 18:05:35 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2013-06-17 18:05:35 +0000
commit68c0efac35021516bf46b2793e56e0d9d804c9e8 (patch)
tree2c6ef13444d2f395b32a4e6b8aeecef992d2d4a6 /tools
parentd5bf07b4667c7381fcd375b186e95436b32b90e6 (diff)
downloadllvm-68c0efac35021516bf46b2793e56e0d9d804c9e8.tar.gz
llvm-68c0efac35021516bf46b2793e56e0d9d804c9e8.tar.bz2
llvm-68c0efac35021516bf46b2793e56e0d9d804c9e8.tar.xz
Don't use PathV1.h in LTOCodeGenerator.cpp
This patch also adds a simpler version of sys::fs::remove and a tool_output_file constructor for when we already have an open file. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184095 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r--tools/lto/LTOCodeGenerator.cpp31
1 files changed, 14 insertions, 17 deletions
diff --git a/tools/lto/LTOCodeGenerator.cpp b/tools/lto/LTOCodeGenerator.cpp
index 5383262847..1db296bbc3 100644
--- a/tools/lto/LTOCodeGenerator.cpp
+++ b/tools/lto/LTOCodeGenerator.cpp
@@ -30,10 +30,10 @@
#include "llvm/MC/SubtargetFeature.h"
#include "llvm/PassManager.h"
#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FileSystem.h"
#include "llvm/Support/FormattedStream.h"
#include "llvm/Support/Host.h"
#include "llvm/Support/MemoryBuffer.h"
-#include "llvm/Support/PathV1.h"
#include "llvm/Support/Signals.h"
#include "llvm/Support/TargetRegistry.h"
#include "llvm/Support/TargetSelect.h"
@@ -160,36 +160,33 @@ bool LTOCodeGenerator::writeMergedModules(const char *path,
bool LTOCodeGenerator::compile_to_file(const char** name, std::string& errMsg) {
// make unique temp .o file to put generated object file
- sys::PathWithStatus uniqueObjPath("lto-llvm.o");
- if (uniqueObjPath.createTemporaryFileOnDisk(false, &errMsg)) {
- uniqueObjPath.eraseFromDisk();
+ SmallString<128> Filename;
+ int FD;
+ error_code EC = sys::fs::unique_file("lto-llvm-%%%%%%%.o",
+ FD, Filename);
+ if (EC) {
+ errMsg = EC.message();
return true;
}
- sys::RemoveFileOnSignal(uniqueObjPath.str());
// generate object file
- bool genResult = false;
- tool_output_file objFile(uniqueObjPath.c_str(), errMsg);
- if (!errMsg.empty()) {
- uniqueObjPath.eraseFromDisk();
- return true;
- }
+ tool_output_file objFile(Filename.c_str(), FD);
- genResult = this->generateObjectFile(objFile.os(), errMsg);
+ bool genResult = generateObjectFile(objFile.os(), errMsg);
objFile.os().close();
if (objFile.os().has_error()) {
objFile.os().clear_error();
- uniqueObjPath.eraseFromDisk();
+ sys::fs::remove(Twine(Filename));
return true;
}
objFile.keep();
if (genResult) {
- uniqueObjPath.eraseFromDisk();
+ sys::fs::remove(Twine(Filename));
return true;
}
- _nativeObjectPath = uniqueObjPath.str();
+ _nativeObjectPath = Filename.c_str();
*name = _nativeObjectPath.c_str();
return false;
}
@@ -206,13 +203,13 @@ const void* LTOCodeGenerator::compile(size_t* length, std::string& errMsg) {
OwningPtr<MemoryBuffer> BuffPtr;
if (error_code ec = MemoryBuffer::getFile(name, BuffPtr, -1, false)) {
errMsg = ec.message();
- sys::Path(_nativeObjectPath).eraseFromDisk();
+ sys::fs::remove(_nativeObjectPath);
return NULL;
}
_nativeObjectFile = BuffPtr.take();
// remove temp files
- sys::Path(_nativeObjectPath).eraseFromDisk();
+ sys::fs::remove(_nativeObjectPath);
// return buffer, unless error
if (_nativeObjectFile == NULL)