[llvm] r185719 - Use sys::fs::createTemporaryFile.
Rafael Espindola
rafael.espindola at gmail.com
Fri Jul 5 13:14:52 PDT 2013
Author: rafael
Date: Fri Jul 5 15:14:52 2013
New Revision: 185719
URL: http://llvm.org/viewvc/llvm-project?rev=185719&view=rev
Log:
Use sys::fs::createTemporaryFile.
Modified:
llvm/trunk/lib/Support/GraphWriter.cpp
llvm/trunk/lib/Transforms/Instrumentation/DebugIR.cpp
llvm/trunk/tools/bugpoint/Miscompilation.cpp
llvm/trunk/tools/bugpoint/ToolRunner.cpp
llvm/trunk/tools/lto/LTOCodeGenerator.cpp
llvm/trunk/unittests/Support/Path.cpp
Modified: llvm/trunk/lib/Support/GraphWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/GraphWriter.cpp?rev=185719&r1=185718&r2=185719&view=diff
==============================================================================
--- llvm/trunk/lib/Support/GraphWriter.cpp (original)
+++ llvm/trunk/lib/Support/GraphWriter.cpp Fri Jul 5 15:14:52 2013
@@ -68,8 +68,7 @@ StringRef llvm::DOT::getColorString(unsi
std::string llvm::createGraphFilename(const Twine &Name, int &FD) {
FD = -1;
SmallString<128> Filename;
- error_code EC = sys::fs::unique_file(Twine(Name) + "-%%%%%%%.dot",
- FD, Filename);
+ error_code EC = sys::fs::createTemporaryFile(Name, "dot", FD, Filename);
if (EC) {
errs() << "Error: " << EC.message() << "\n";
return "";
Modified: llvm/trunk/lib/Transforms/Instrumentation/DebugIR.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/DebugIR.cpp?rev=185719&r1=185718&r2=185719&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/DebugIR.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/DebugIR.cpp Fri Jul 5 15:14:52 2013
@@ -504,10 +504,9 @@ bool DebugIR::updateExtension(StringRef
}
void DebugIR::generateFilename(OwningPtr<int> &fd) {
- StringRef FileModel("debug-ir-%s%s%s%s.ll");
SmallVector<char, 16> PathVec;
fd.reset(new int);
- sys::fs::unique_file(FileModel, *fd, PathVec);
+ sys::fs::createTemporaryFile("debug-ir", "ll", *fd, PathVec);
StringRef Path(PathVec.data(), PathVec.size());
Filename = sys::path::filename(Path);
sys::path::remove_filename(PathVec);
Modified: llvm/trunk/tools/bugpoint/Miscompilation.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/Miscompilation.cpp?rev=185719&r1=185718&r2=185719&view=diff
==============================================================================
--- llvm/trunk/tools/bugpoint/Miscompilation.cpp (original)
+++ llvm/trunk/tools/bugpoint/Miscompilation.cpp Fri Jul 5 15:14:52 2013
@@ -928,8 +928,8 @@ static bool TestCodeGenerator(BugDriver
SmallString<128> TestModuleBC;
int TestModuleFD;
- error_code EC = sys::fs::unique_file("bugpoint.test-%%%%%%%.bc", TestModuleFD,
- TestModuleBC);
+ error_code EC = sys::fs::createTemporaryFile("bugpoint.test", "bc",
+ TestModuleFD, TestModuleBC);
if (EC) {
errs() << BD.getToolName() << "Error making unique filename: "
<< EC.message() << "\n";
@@ -947,8 +947,8 @@ static bool TestCodeGenerator(BugDriver
// Make the shared library
SmallString<128> SafeModuleBC;
int SafeModuleFD;
- EC = sys::fs::unique_file("bugpoint.safe-%%%%%%%.bc", SafeModuleFD,
- SafeModuleBC);
+ EC = sys::fs::createTemporaryFile("bugpoint.safe", "bc", SafeModuleFD,
+ SafeModuleBC);
if (EC) {
errs() << BD.getToolName() << "Error making unique filename: "
<< EC.message() << "\n";
@@ -1022,8 +1022,8 @@ bool BugDriver::debugCodeGenerator(std::
SmallString<128> TestModuleBC;
int TestModuleFD;
- error_code EC = sys::fs::unique_file("bugpoint.test-%%%%%%%.bc", TestModuleFD,
- TestModuleBC);
+ error_code EC = sys::fs::createTemporaryFile("bugpoint.test", "bc",
+ TestModuleFD, TestModuleBC);
if (EC) {
errs() << getToolName() << "Error making unique filename: "
<< EC.message() << "\n";
@@ -1040,8 +1040,8 @@ bool BugDriver::debugCodeGenerator(std::
// Make the shared library
SmallString<128> SafeModuleBC;
int SafeModuleFD;
- EC = sys::fs::unique_file("bugpoint.safe-%%%%%%%.bc", SafeModuleFD,
- SafeModuleBC);
+ EC = sys::fs::createTemporaryFile("bugpoint.safe", "bc", SafeModuleFD,
+ SafeModuleBC);
if (EC) {
errs() << getToolName() << "Error making unique filename: "
<< EC.message() << "\n";
Modified: llvm/trunk/tools/bugpoint/ToolRunner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/ToolRunner.cpp?rev=185719&r1=185718&r2=185719&view=diff
==============================================================================
--- llvm/trunk/tools/bugpoint/ToolRunner.cpp (original)
+++ llvm/trunk/tools/bugpoint/ToolRunner.cpp Fri Jul 5 15:14:52 2013
@@ -141,8 +141,8 @@ static std::string ProcessFailure(String
// Rerun the compiler, capturing any error messages to print them.
SmallString<128> ErrorFilename;
int ErrorFD;
- error_code EC = sys::fs::unique_file("bugpoint.program_error_messages",
- ErrorFD, ErrorFilename);
+ error_code EC = sys::fs::createTemporaryFile(
+ "bugpoint.program_error_messages", "", ErrorFD, ErrorFilename);
if (EC) {
errs() << "Error making unique filename: " << EC.message() << "\n";
exit(1);
Modified: llvm/trunk/tools/lto/LTOCodeGenerator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOCodeGenerator.cpp?rev=185719&r1=185718&r2=185719&view=diff
==============================================================================
--- llvm/trunk/tools/lto/LTOCodeGenerator.cpp (original)
+++ llvm/trunk/tools/lto/LTOCodeGenerator.cpp Fri Jul 5 15:14:52 2013
@@ -162,8 +162,7 @@ bool LTOCodeGenerator::compile_to_file(c
// make unique temp .o file to put generated object file
SmallString<128> Filename;
int FD;
- error_code EC = sys::fs::unique_file("lto-llvm-%%%%%%%.o",
- FD, Filename);
+ error_code EC = sys::fs::createTemporaryFile("lto-llvm", "o", FD, Filename);
if (EC) {
errMsg = EC.message();
return true;
Modified: llvm/trunk/unittests/Support/Path.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/Path.cpp?rev=185719&r1=185718&r2=185719&view=diff
==============================================================================
--- llvm/trunk/unittests/Support/Path.cpp (original)
+++ llvm/trunk/unittests/Support/Path.cpp Fri Jul 5 15:14:52 2013
@@ -165,7 +165,7 @@ TEST_F(FileSystemTest, Unique) {
int FileDescriptor;
SmallString<64> TempPath;
ASSERT_NO_ERROR(
- fs::unique_file("%%-%%-%%-%%.temp", FileDescriptor, TempPath));
+ fs::createTemporaryFile("prefix", "temp", FileDescriptor, TempPath));
// The same file should return an identical unique id.
uint64_t F1, F2;
@@ -177,8 +177,8 @@ TEST_F(FileSystemTest, Unique) {
int FileDescriptor2;
SmallString<64> TempPath2;
ASSERT_NO_ERROR(
- fs::unique_file("%%-%%-%%-%%.temp", FileDescriptor2, TempPath2));
-
+ fs::createTemporaryFile("prefix", "temp", FileDescriptor2, TempPath2));
+
uint64_t D;
ASSERT_NO_ERROR(fs::getUniqueID(Twine(TempPath2), D));
ASSERT_NE(D, F1);
@@ -201,7 +201,7 @@ TEST_F(FileSystemTest, TempFiles) {
int FileDescriptor;
SmallString<64> TempPath;
ASSERT_NO_ERROR(
- fs::unique_file("%%-%%-%%-%%.temp", FileDescriptor, TempPath));
+ fs::createTemporaryFile("prefix", "temp", FileDescriptor, TempPath));
// Make sure it exists.
bool TempFileExists;
@@ -211,7 +211,7 @@ TEST_F(FileSystemTest, TempFiles) {
// Create another temp tile.
int FD2;
SmallString<64> TempPath2;
- ASSERT_NO_ERROR(fs::unique_file("%%-%%-%%-%%.temp", FD2, TempPath2));
+ ASSERT_NO_ERROR(fs::createTemporaryFile("prefix", "temp", FD2, TempPath2));
ASSERT_NE(TempPath.str(), TempPath2.str());
fs::file_status A, B;
@@ -369,7 +369,7 @@ TEST_F(FileSystemTest, Permissions) {
int FileDescriptor;
SmallString<64> TempPath;
ASSERT_NO_ERROR(
- fs::unique_file("%%-%%-%%-%%.temp", FileDescriptor, TempPath));
+ fs::createTemporaryFile("prefix", "temp", FileDescriptor, TempPath));
// Mark file as read-only
const fs::perms AllWrite = fs::owner_write|fs::group_write|fs::others_write;
@@ -396,7 +396,7 @@ TEST_F(FileSystemTest, FileMapping) {
int FileDescriptor;
SmallString<64> TempPath;
ASSERT_NO_ERROR(
- fs::unique_file("%%-%%-%%-%%.temp", FileDescriptor, TempPath));
+ fs::createTemporaryFile("prefix", "temp", FileDescriptor, TempPath));
// Map in temp file and add some content
error_code EC;
StringRef Val("hello there");
More information about the llvm-commits
mailing list