diff --git a/lib/Support/ToolRunner.cpp b/lib/Support/ToolRunner.cpp index fd9c2b30317..a07046a0d06 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 *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 << "" << 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 << "" << 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); } diff --git a/tools/bugpoint/ToolRunner.cpp b/tools/bugpoint/ToolRunner.cpp index fd9c2b30317..a07046a0d06 100644 --- a/tools/bugpoint/ToolRunner.cpp +++ b/tools/bugpoint/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 *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 << "" << 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 << "" << 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); }