mirror of
https://github.com/RPCSX/llvm.git
synced 2025-02-18 12:09:38 +00:00
Use sys::fs::createTemporaryFile.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185719 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
e11874f6c5
commit
1276b39613
@ -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 "";
|
||||
|
@ -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);
|
||||
|
@ -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";
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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");
|
||||
|
Loading…
x
Reference in New Issue
Block a user