Convert most uses of PathV1.h in ToolRunner.cpp.
llvm-svn: 184210
This commit is contained in:
parent
8ca77852f4
commit
8ffbac96a8
|
@ -16,6 +16,7 @@
|
||||||
#include "llvm/Config/config.h" // for HAVE_LINK_R
|
#include "llvm/Config/config.h" // for HAVE_LINK_R
|
||||||
#include "llvm/Support/CommandLine.h"
|
#include "llvm/Support/CommandLine.h"
|
||||||
#include "llvm/Support/Debug.h"
|
#include "llvm/Support/Debug.h"
|
||||||
|
#include "llvm/Support/FileSystem.h"
|
||||||
#include "llvm/Support/FileUtilities.h"
|
#include "llvm/Support/FileUtilities.h"
|
||||||
#include "llvm/Support/PathV1.h"
|
#include "llvm/Support/PathV1.h"
|
||||||
#include "llvm/Support/Program.h"
|
#include "llvm/Support/Program.h"
|
||||||
|
@ -139,10 +140,12 @@ static std::string ProcessFailure(StringRef ProgPath, const char** Args,
|
||||||
OS << "\n";
|
OS << "\n";
|
||||||
|
|
||||||
// Rerun the compiler, capturing any error messages to print them.
|
// Rerun the compiler, capturing any error messages to print them.
|
||||||
sys::Path ErrorFilename("bugpoint.program_error_messages");
|
SmallString<128> ErrorFilename;
|
||||||
std::string ErrMsg;
|
int ErrorFD;
|
||||||
if (ErrorFilename.makeUnique(true, &ErrMsg)) {
|
error_code EC = sys::fs::unique_file("bugpoint.program_error_messages",
|
||||||
errs() << "Error making unique filename: " << ErrMsg << "\n";
|
ErrorFD, ErrorFilename);
|
||||||
|
if (EC) {
|
||||||
|
errs() << "Error making unique filename: " << EC.message() << "\n";
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
RunProgramWithTimeout(ProgPath, Args, "", ErrorFilename.str(),
|
RunProgramWithTimeout(ProgPath, Args, "", ErrorFilename.str(),
|
||||||
|
@ -158,7 +161,7 @@ static std::string ProcessFailure(StringRef ProgPath, const char** Args,
|
||||||
ErrorFile.close();
|
ErrorFile.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorFilename.eraseFromDisk();
|
sys::fs::remove(ErrorFilename.c_str());
|
||||||
return OS.str();
|
return OS.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,12 +246,14 @@ static std::string PrependMainExecutablePath(const std::string &ExeName,
|
||||||
// Check the directory that the calling program is in. We can do
|
// Check the directory that the calling program is in. We can do
|
||||||
// this if ProgramPath contains at least one / character, indicating that it
|
// this if ProgramPath contains at least one / character, indicating that it
|
||||||
// is a relative path to the executable itself.
|
// is a relative path to the executable itself.
|
||||||
sys::Path Result = sys::Path::GetMainExecutable(Argv0, MainAddr);
|
sys::Path Main = sys::Path::GetMainExecutable(Argv0, MainAddr);
|
||||||
Result.eraseComponent();
|
StringRef Result = sys::path::parent_path(Main.str());
|
||||||
|
|
||||||
if (!Result.isEmpty()) {
|
if (!Result.empty()) {
|
||||||
Result.appendComponent(ExeName);
|
SmallString<128> Storage = Result;
|
||||||
Result.appendSuffix(sys::Path::GetEXESuffix());
|
sys::path::append(Storage, ExeName);
|
||||||
|
sys::path::replace_extension(Storage, sys::Path::GetEXESuffix());
|
||||||
|
return Storage.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Result.str();
|
return Result.str();
|
||||||
|
@ -465,13 +470,15 @@ GCC::FileType LLC::OutputCode(const std::string &Bitcode,
|
||||||
std::string &OutputAsmFile, std::string &Error,
|
std::string &OutputAsmFile, std::string &Error,
|
||||||
unsigned Timeout, unsigned MemoryLimit) {
|
unsigned Timeout, unsigned MemoryLimit) {
|
||||||
const char *Suffix = (UseIntegratedAssembler ? ".llc.o" : ".llc.s");
|
const char *Suffix = (UseIntegratedAssembler ? ".llc.o" : ".llc.s");
|
||||||
sys::Path uniqueFile(Bitcode + Suffix);
|
|
||||||
std::string ErrMsg;
|
SmallString<128> UniqueFile;
|
||||||
if (uniqueFile.makeUnique(true, &ErrMsg)) {
|
error_code EC =
|
||||||
errs() << "Error making unique filename: " << ErrMsg << "\n";
|
sys::fs::unique_file(Bitcode + "-%%%%%%%" + Suffix, UniqueFile);
|
||||||
|
if (EC) {
|
||||||
|
errs() << "Error making unique filename: " << EC.message() << "\n";
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
OutputAsmFile = uniqueFile.str();
|
OutputAsmFile = UniqueFile.str();
|
||||||
std::vector<const char *> LLCArgs;
|
std::vector<const char *> LLCArgs;
|
||||||
LLCArgs.push_back(LLCPath.c_str());
|
LLCArgs.push_back(LLCPath.c_str());
|
||||||
|
|
||||||
|
@ -700,10 +707,12 @@ int GCC::ExecuteProgram(const std::string &ProgramFile,
|
||||||
GCCArgs.push_back("-x");
|
GCCArgs.push_back("-x");
|
||||||
GCCArgs.push_back("none");
|
GCCArgs.push_back("none");
|
||||||
GCCArgs.push_back("-o");
|
GCCArgs.push_back("-o");
|
||||||
sys::Path OutputBinary (ProgramFile+".gcc.exe");
|
|
||||||
std::string ErrMsg;
|
SmallString<128> OutputBinary;
|
||||||
if (OutputBinary.makeUnique(true, &ErrMsg)) {
|
error_code EC =
|
||||||
errs() << "Error making unique filename: " << ErrMsg << "\n";
|
sys::fs::unique_file(ProgramFile+ "-%%%%%%%.gcc.exe", OutputBinary);
|
||||||
|
if (EC) {
|
||||||
|
errs() << "Error making unique filename: " << EC.message() << "\n";
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
GCCArgs.push_back(OutputBinary.c_str()); // Output to the right file...
|
GCCArgs.push_back(OutputBinary.c_str()); // Output to the right file...
|
||||||
|
@ -809,13 +818,14 @@ int GCC::MakeSharedObject(const std::string &InputFile, FileType fileType,
|
||||||
std::string &OutputFile,
|
std::string &OutputFile,
|
||||||
const std::vector<std::string> &ArgsForGCC,
|
const std::vector<std::string> &ArgsForGCC,
|
||||||
std::string &Error) {
|
std::string &Error) {
|
||||||
sys::Path uniqueFilename(InputFile+LTDL_SHLIB_EXT);
|
SmallString<128> UniqueFilename;
|
||||||
std::string ErrMsg;
|
error_code EC = sys::fs::unique_file(InputFile + "-%%%%%%%" + LTDL_SHLIB_EXT,
|
||||||
if (uniqueFilename.makeUnique(true, &ErrMsg)) {
|
UniqueFilename);
|
||||||
errs() << "Error making unique filename: " << ErrMsg << "\n";
|
if (EC) {
|
||||||
|
errs() << "Error making unique filename: " << EC.message() << "\n";
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
OutputFile = uniqueFilename.str();
|
OutputFile = UniqueFilename.str();
|
||||||
|
|
||||||
std::vector<const char*> GCCArgs;
|
std::vector<const char*> GCCArgs;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue