[llvm-commits] CVS: llvm/tools/lto/lto.cpp
Devang Patel
dpatel at apple.com
Mon Oct 9 12:05:05 PDT 2006
Changes in directory llvm/tools/lto:
lto.cpp updated: 1.17 -> 1.18
---
Log message:
Use GetTemporaryDirectory. Fix http://llvm.org/bugs/show_bug.cgi?id=894
---
Diffs of the changes: (+15 -2)
lto.cpp | 17 +++++++++++++++--
1 files changed, 15 insertions(+), 2 deletions(-)
Index: llvm/tools/lto/lto.cpp
diff -u llvm/tools/lto/lto.cpp:1.17 llvm/tools/lto/lto.cpp:1.18
--- llvm/tools/lto/lto.cpp:1.17 Thu Sep 21 12:22:55 2006
+++ llvm/tools/lto/lto.cpp Mon Oct 9 14:04:51 2006
@@ -341,18 +341,28 @@
exportList[i] = allSymbols[name]->getName();
}
- sys::Path tmpAsmFilePath("/tmp/");
+
std::string ErrMsg;
+ sys::Path TempDir = sys::Path::GetTemporaryDirectory(&ErrMsg);
+ sys::Path tmpAsmFilePath(TempDir);
+ if (!tmpAsmFilePath.appendComponent("lto")) {
+ std::cerr << "lto: " << ErrMsg << "\n";
+ TempDir.eraseFromDisk(true);
+ return LTO_WRITE_FAILURE;
+ }
if (tmpAsmFilePath.createTemporaryFileOnDisk(&ErrMsg)) {
std::cerr << "lto: " << ErrMsg << "\n";
+ TempDir.eraseFromDisk(true);
return LTO_WRITE_FAILURE;
}
sys::RemoveFileOnSignal(tmpAsmFilePath);
std::ofstream asmFile(tmpAsmFilePath.c_str(), io_mode);
if (!asmFile.is_open() || asmFile.bad()) {
- if (tmpAsmFilePath.exists())
+ if (tmpAsmFilePath.exists()) {
tmpAsmFilePath.eraseFromDisk();
+ TempDir.eraseFromDisk(true);
+ }
return LTO_WRITE_FAILURE;
}
@@ -360,6 +370,7 @@
asmFile.close();
if (status != LTO_OPT_SUCCESS) {
tmpAsmFilePath.eraseFromDisk();
+ TempDir.eraseFromDisk(true);
return status;
}
@@ -374,6 +385,7 @@
const sys::Path gcc = FindExecutable("gcc", "/");
if (gcc.isEmpty()) {
tmpAsmFilePath.eraseFromDisk();
+ TempDir.eraseFromDisk(true);
return LTO_ASM_FAILURE;
}
@@ -390,6 +402,7 @@
sys::Program::ExecuteAndWait(gcc, &args[0], 0, 0, 1);
tmpAsmFilePath.eraseFromDisk();
+ TempDir.eraseFromDisk(true);
return LTO_OPT_SUCCESS;
}
More information about the llvm-commits
mailing list