mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-10-06 14:57:41 +00:00
Add a version of unique_file that return just the file name.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184206 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
21a78d149f
commit
8ee23f00c7
@ -509,6 +509,10 @@ error_code unique_file(const Twine &model, int &result_fd,
|
|||||||
SmallVectorImpl<char> &result_path,
|
SmallVectorImpl<char> &result_path,
|
||||||
bool makeAbsolute = true, unsigned mode = 0600);
|
bool makeAbsolute = true, unsigned mode = 0600);
|
||||||
|
|
||||||
|
/// @brief Simpler version for clients that don't want an open file.
|
||||||
|
error_code unique_file(const Twine &Model, SmallVectorImpl<char> &ResultPath,
|
||||||
|
bool MakeAbsolute = true, unsigned Mode = 0600);
|
||||||
|
|
||||||
/// @brief Canonicalize path.
|
/// @brief Canonicalize path.
|
||||||
///
|
///
|
||||||
/// Sets result to the file system's idea of what path is. The result is always
|
/// Sets result to the file system's idea of what path is. The result is always
|
||||||
|
@ -18,8 +18,11 @@
|
|||||||
#include <cctype>
|
#include <cctype>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#ifdef __APPLE__
|
|
||||||
|
#if !defined(_MSC_VER) && !defined(__MINGW32__)
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#else
|
||||||
|
#include <io.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@ -622,6 +625,14 @@ bool is_relative(const Twine &path) {
|
|||||||
|
|
||||||
namespace fs {
|
namespace fs {
|
||||||
|
|
||||||
|
error_code unique_file(const Twine &Model, SmallVectorImpl<char> &ResultPath,
|
||||||
|
bool MakeAbsolute, unsigned Mode) {
|
||||||
|
int FD;
|
||||||
|
error_code Ret = unique_file(Model, FD, ResultPath, MakeAbsolute, Mode);
|
||||||
|
close(FD);
|
||||||
|
return Ret;
|
||||||
|
}
|
||||||
|
|
||||||
error_code make_absolute(SmallVectorImpl<char> &path) {
|
error_code make_absolute(SmallVectorImpl<char> &path) {
|
||||||
StringRef p(path.data(), path.size());
|
StringRef p(path.data(), path.size());
|
||||||
|
|
||||||
|
@ -21,12 +21,6 @@
|
|||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
#if !defined(_MSC_VER) && !defined(__MINGW32__)
|
|
||||||
#include <unistd.h>
|
|
||||||
#else
|
|
||||||
#include <io.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@ -338,15 +332,13 @@ std::string BugDriver::executeProgram(const Module *Program,
|
|||||||
|
|
||||||
// Check to see if this is a valid output filename...
|
// Check to see if this is a valid output filename...
|
||||||
SmallString<128> UniqueFile;
|
SmallString<128> UniqueFile;
|
||||||
int UniqueFD;
|
error_code EC = sys::fs::unique_file(OutputFile, UniqueFile);
|
||||||
error_code EC = sys::fs::unique_file(OutputFile, UniqueFD, UniqueFile);
|
|
||||||
if (EC) {
|
if (EC) {
|
||||||
errs() << ToolName << ": Error making unique filename: "
|
errs() << ToolName << ": Error making unique filename: "
|
||||||
<< EC.message() << "\n";
|
<< EC.message() << "\n";
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
OutputFile = UniqueFile.str();
|
OutputFile = UniqueFile.str();
|
||||||
close(UniqueFD);
|
|
||||||
|
|
||||||
// Figure out which shared objects to run, if any.
|
// Figure out which shared objects to run, if any.
|
||||||
std::vector<std::string> SharedObjs(AdditionalSOs);
|
std::vector<std::string> SharedObjs(AdditionalSOs);
|
||||||
|
@ -34,12 +34,6 @@
|
|||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
#if !defined(_MSC_VER) && !defined(__MINGW32__)
|
|
||||||
#include <unistd.h>
|
|
||||||
#else
|
|
||||||
#include <io.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
@ -130,16 +124,14 @@ bool BugDriver::runPasses(Module *Program,
|
|||||||
// setup the output file name
|
// setup the output file name
|
||||||
outs().flush();
|
outs().flush();
|
||||||
SmallString<128> UniqueFilename;
|
SmallString<128> UniqueFilename;
|
||||||
int UniqueFD;
|
error_code EC =
|
||||||
error_code EC = sys::fs::unique_file(OutputPrefix + "-output-%%%%%%%.bc",
|
sys::fs::unique_file(OutputPrefix + "-output-%%%%%%%.bc", UniqueFilename);
|
||||||
UniqueFD, UniqueFilename);
|
|
||||||
if (EC) {
|
if (EC) {
|
||||||
errs() << getToolName() << ": Error making unique filename: "
|
errs() << getToolName() << ": Error making unique filename: "
|
||||||
<< EC.message() << "\n";
|
<< EC.message() << "\n";
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
OutputFilename = UniqueFilename.str();
|
OutputFilename = UniqueFilename.str();
|
||||||
close(UniqueFD); // We only want the filename.
|
|
||||||
|
|
||||||
// set up the input file name
|
// set up the input file name
|
||||||
SmallString<128> InputFilename;
|
SmallString<128> InputFilename;
|
||||||
|
Loading…
Reference in New Issue
Block a user