summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Support/GraphWriter.cpp3
-rw-r--r--lib/Transforms/Instrumentation/DebugIR.cpp3
-rw-r--r--tools/bugpoint/Miscompilation.cpp16
-rw-r--r--tools/bugpoint/ToolRunner.cpp4
-rw-r--r--tools/lto/LTOCodeGenerator.cpp3
-rw-r--r--unittests/Support/Path.cpp14
6 files changed, 20 insertions, 23 deletions
diff --git a/lib/Support/GraphWriter.cpp b/lib/Support/GraphWriter.cpp
index 20214c71d6..64d21642e8 100644
--- a/lib/Support/GraphWriter.cpp
+++ b/lib/Support/GraphWriter.cpp
@@ -68,8 +68,7 @@ StringRef llvm::DOT::getColorString(unsigned ColorNumber) {
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 "";
diff --git a/lib/Transforms/Instrumentation/DebugIR.cpp b/lib/Transforms/Instrumentation/DebugIR.cpp
index f4109eff4f..b5bdc7560b 100644
--- a/lib/Transforms/Instrumentation/DebugIR.cpp
+++ b/lib/Transforms/Instrumentation/DebugIR.cpp
@@ -504,10 +504,9 @@ bool DebugIR::updateExtension(StringRef NewExtension) {
}
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);
diff --git a/tools/bugpoint/Miscompilation.cpp b/tools/bugpoint/Miscompilation.cpp
index 73b5cd1fe8..5574303321 100644
--- a/tools/bugpoint/Miscompilation.cpp
+++ b/tools/bugpoint/Miscompilation.cpp
@@ -928,8 +928,8 @@ static bool TestCodeGenerator(BugDriver &BD, Module *Test, Module *Safe,
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 &BD, Module *Test, Module *Safe,
// 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::string *Error) {
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::string *Error) {
// 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";
diff --git a/tools/bugpoint/ToolRunner.cpp b/tools/bugpoint/ToolRunner.cpp
index a9a4a9d27f..bec00364d7 100644
--- a/tools/bugpoint/ToolRunner.cpp
+++ b/tools/bugpoint/ToolRunner.cpp
@@ -141,8 +141,8 @@ static std::string ProcessFailure(StringRef ProgPath, const char** Args,
// 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);
diff --git a/tools/lto/LTOCodeGenerator.cpp b/tools/lto/LTOCodeGenerator.cpp
index 88f2a0f27e..022a04c178 100644
--- a/tools/lto/LTOCodeGenerator.cpp
+++ b/tools/lto/LTOCodeGenerator.cpp
@@ -162,8 +162,7 @@ bool LTOCodeGenerator::compile_to_file(const char** name, std::string& errMsg) {
// 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;
diff --git a/unittests/Support/Path.cpp b/unittests/Support/Path.cpp
index ce335ccc6b..4fc02be5e3 100644
--- a/unittests/Support/Path.cpp
+++ b/unittests/Support/Path.cpp
@@ -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");