aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2004-12-19 18:00:21 +0000
committerReid Spencer <rspencer@reidspencer.com>2004-12-19 18:00:21 +0000
commitb31baa88a5e6869ccac71aef53a672bb87a029c3 (patch)
tree369439d24ebaa69bf77a3f5df35dd968bba73d60 /lib
parenta434805014809e46ff955565bf89cdc2590fb4e6 (diff)
downloadexternal_llvm-b31baa88a5e6869ccac71aef53a672bb87a029c3.zip
external_llvm-b31baa88a5e6869ccac71aef53a672bb87a029c3.tar.gz
external_llvm-b31baa88a5e6869ccac71aef53a672bb87a029c3.tar.bz2
For PR351:
* Pass sys::Path instead of std::string for paths * Correct the types of arguments passed to RunProgramWithTimeout due to its interface using sys::Path instead of std::string * Replace "/dev/null" (not portable) with empty string which sys::Program::ExecuteAndWait recognizes as "redirect to bit bucket" git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19041 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Support/ToolRunner.cpp51
1 files changed, 27 insertions, 24 deletions
diff --git a/lib/Support/ToolRunner.cpp b/lib/Support/ToolRunner.cpp
index fd9c2b3..a07046a 100644
--- a/lib/Support/ToolRunner.cpp
+++ b/lib/Support/ToolRunner.cpp
@@ -22,7 +22,7 @@ using namespace llvm;
ToolExecutionError::~ToolExecutionError() throw() { }
-static void ProcessFailure(std::string ProgPath, const char** Args) {
+static void ProcessFailure(sys::Path ProgPath, const char** Args) {
std::ostringstream OS;
OS << "\nError running tool:\n ";
for (const char **Arg = Args; *Arg; ++Arg)
@@ -32,8 +32,8 @@ static void ProcessFailure(std::string ProgPath, const char** Args) {
// Rerun the compiler, capturing any error messages to print them.
sys::Path ErrorFilename("error_messages");
ErrorFilename.makeUnique();
- RunProgramWithTimeout(ProgPath, Args, "/dev/null", ErrorFilename.c_str(),
- ErrorFilename.c_str());
+ RunProgramWithTimeout(ProgPath, Args, sys::Path(""), ErrorFilename,
+ ErrorFilename);
// Print out the error messages generated by GCC if possible...
std::ifstream ErrorFile(ErrorFilename.c_str());
@@ -102,8 +102,9 @@ int LLI::ExecuteProgram(const std::string &Bytecode,
std::cerr << " " << LLIArgs[i];
std::cerr << "\n";
);
- return RunProgramWithTimeout(LLIPath, &LLIArgs[0],
- InputFile, OutputFile, OutputFile, Timeout);
+ return RunProgramWithTimeout(sys::Path(LLIPath), &LLIArgs[0],
+ sys::Path(InputFile), sys::Path(OutputFile), sys::Path(OutputFile),
+ Timeout);
}
// LLI create method - Try to find the LLI executable
@@ -146,9 +147,9 @@ void LLC::OutputAsm(const std::string &Bytecode, sys::Path &OutputAsmFile) {
std::cerr << " " << LLCArgs[i];
std::cerr << "\n";
);
- if (RunProgramWithTimeout(LLCPath, &LLCArgs[0], "/dev/null", "/dev/null",
- "/dev/null"))
- ProcessFailure(LLCPath, &LLCArgs[0]);
+ if (RunProgramWithTimeout(sys::Path(LLCPath), &LLCArgs[0],
+ sys::Path(), sys::Path(), sys::Path()))
+ ProcessFailure(sys::Path(LLCPath), &LLCArgs[0]);
}
void LLC::compileProgram(const std::string &Bytecode) {
@@ -248,8 +249,9 @@ int JIT::ExecuteProgram(const std::string &Bytecode,
std::cerr << "\n";
);
DEBUG(std::cerr << "\nSending output to " << OutputFile << "\n");
- return RunProgramWithTimeout(LLIPath, &JITArgs[0],
- InputFile, OutputFile, OutputFile, Timeout);
+ return RunProgramWithTimeout(sys::Path(LLIPath), &JITArgs[0],
+ sys::Path(InputFile), sys::Path(OutputFile), sys::Path(OutputFile),
+ Timeout);
}
/// createJIT - Try to find the LLI executable
@@ -290,8 +292,8 @@ void CBE::OutputC(const std::string &Bytecode, sys::Path& OutputCFile) {
std::cerr << " " << LLCArgs[i];
std::cerr << "\n";
);
- if (RunProgramWithTimeout(LLCPath, &LLCArgs[0], "/dev/null", "/dev/null",
- "/dev/null"))
+ if (RunProgramWithTimeout(LLCPath, &LLCArgs[0], sys::Path(), sys::Path(),
+ sys::Path()))
ProcessFailure(LLCPath, &LLCArgs[0]);
}
@@ -321,14 +323,14 @@ int CBE::ExecuteProgram(const std::string &Bytecode,
CBE *AbstractInterpreter::createCBE(const std::string &ProgramPath,
std::string &Message,
const std::vector<std::string> *Args) {
- std::string LLCPath = FindExecutable("llc", ProgramPath).toString();
- if (LLCPath.empty()) {
+ sys::Path LLCPath = FindExecutable("llc", ProgramPath);
+ if (LLCPath.isEmpty()) {
Message =
"Cannot find `llc' in executable directory or PATH!\n";
return 0;
}
- Message = "Found llc: " + LLCPath + "\n";
+ Message = "Found llc: " + LLCPath.toString() + "\n";
GCC *gcc = GCC::create(ProgramPath, Message);
if (!gcc) {
std::cerr << Message << "\n";
@@ -376,8 +378,8 @@ int GCC::ExecuteProgram(const std::string &ProgramFile,
GCCArgs.push_back(0); // NULL terminator
std::cout << "<gcc>" << std::flush;
- if (RunProgramWithTimeout(GCCPath, &GCCArgs[0], "/dev/null", "/dev/null",
- "/dev/null")) {
+ if (RunProgramWithTimeout(GCCPath, &GCCArgs[0], sys::Path(), sys::Path(),
+ sys::Path())) {
ProcessFailure(GCCPath, &GCCArgs[0]);
exit(1);
}
@@ -398,8 +400,9 @@ int GCC::ExecuteProgram(const std::string &ProgramFile,
);
FileRemover OutputBinaryRemover(OutputBinary);
- return RunProgramWithTimeout(OutputBinary.toString(), &ProgramArgs[0],
- InputFile, OutputFile, OutputFile, Timeout);
+ return RunProgramWithTimeout(OutputBinary, &ProgramArgs[0],
+ sys::Path(InputFile), sys::Path(OutputFile), sys::Path(OutputFile),
+ Timeout);
}
int GCC::MakeSharedObject(const std::string &InputFile, FileType fileType,
@@ -431,8 +434,8 @@ int GCC::MakeSharedObject(const std::string &InputFile, FileType fileType,
};
std::cout << "<gcc>" << std::flush;
- if (RunProgramWithTimeout(GCCPath, GCCArgs, "/dev/null", "/dev/null",
- "/dev/null")) {
+ if (RunProgramWithTimeout(GCCPath, GCCArgs, sys::Path(), sys::Path(),
+ sys::Path())) {
ProcessFailure(GCCPath, GCCArgs);
return 1;
}
@@ -442,12 +445,12 @@ int GCC::MakeSharedObject(const std::string &InputFile, FileType fileType,
/// create - Try to find the `gcc' executable
///
GCC *GCC::create(const std::string &ProgramPath, std::string &Message) {
- std::string GCCPath = FindExecutable("gcc", ProgramPath).toString();
- if (GCCPath.empty()) {
+ sys::Path GCCPath = FindExecutable("gcc", ProgramPath);
+ if (GCCPath.isEmpty()) {
Message = "Cannot find `gcc' in executable directory or PATH!\n";
return 0;
}
- Message = "Found gcc: " + GCCPath + "\n";
+ Message = "Found gcc: " + GCCPath.toString() + "\n";
return new GCC(GCCPath);
}