diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2004-12-16 23:01:34 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2004-12-16 23:01:34 +0000 |
commit | 9ac141823d6180f8a49299c55ed8fc8b9a8310a3 (patch) | |
tree | cde8d6c57374e93a57189a4edd44e847c63ebec4 /lib/Support/ToolRunner.cpp | |
parent | a2f7ed7035b38a13c65c04fa3b626197bd9d360a (diff) |
For PR351:
* Make the OutputC and OutputAsm functions work with sys::Path for the output
file name instead of using std::string.
* Get rid of extraneous "toString" calls.
* Change "removeFile" to sys::Path::destroyFile()
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19000 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/ToolRunner.cpp')
-rw-r--r-- | lib/Support/ToolRunner.cpp | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/lib/Support/ToolRunner.cpp b/lib/Support/ToolRunner.cpp index 5f6336e672..fd9c2b3031 100644 --- a/lib/Support/ToolRunner.cpp +++ b/lib/Support/ToolRunner.cpp @@ -44,7 +44,7 @@ static void ProcessFailure(std::string ProgPath, const char** Args) { ErrorFile.close(); } - removeFile(ErrorFilename.toString()); + ErrorFilename.destroyFile(); throw ToolExecutionError(OS.str()); } @@ -123,10 +123,10 @@ AbstractInterpreter *AbstractInterpreter::createLLI(const std::string &ProgPath, //===----------------------------------------------------------------------===// // LLC Implementation of AbstractIntepreter interface // -void LLC::OutputAsm(const std::string &Bytecode, std::string &OutputAsmFile) { +void LLC::OutputAsm(const std::string &Bytecode, sys::Path &OutputAsmFile) { sys::Path uniqueFile(Bytecode+".llc.s"); uniqueFile.makeUnique(); - OutputAsmFile = uniqueFile.toString(); + OutputAsmFile = uniqueFile; std::vector<const char *> LLCArgs; LLCArgs.push_back (LLCPath.c_str()); @@ -152,9 +152,9 @@ void LLC::OutputAsm(const std::string &Bytecode, std::string &OutputAsmFile) { } void LLC::compileProgram(const std::string &Bytecode) { - std::string OutputAsmFile; + sys::Path OutputAsmFile; OutputAsm(Bytecode, OutputAsmFile); - removeFile(OutputAsmFile); + OutputAsmFile.destroyFile(); } int LLC::ExecuteProgram(const std::string &Bytecode, @@ -164,12 +164,12 @@ int LLC::ExecuteProgram(const std::string &Bytecode, const std::vector<std::string> &SharedLibs, unsigned Timeout) { - std::string OutputAsmFile; + sys::Path OutputAsmFile; OutputAsm(Bytecode, OutputAsmFile); FileRemover OutFileRemover(OutputAsmFile); // Assuming LLC worked, compile the result with GCC and run it. - return gcc->ExecuteProgram(OutputAsmFile, Args, GCC::AsmFile, + return gcc->ExecuteProgram(OutputAsmFile.toString(), Args, GCC::AsmFile, InputFile, OutputFile, SharedLibs, Timeout); } @@ -266,11 +266,10 @@ AbstractInterpreter *AbstractInterpreter::createJIT(const std::string &ProgPath, return 0; } -void CBE::OutputC(const std::string &Bytecode, - std::string &OutputCFile) { +void CBE::OutputC(const std::string &Bytecode, sys::Path& OutputCFile) { sys::Path uniqueFile(Bytecode+".cbe.c"); uniqueFile.makeUnique(); - OutputCFile = uniqueFile.toString(); + OutputCFile = uniqueFile; std::vector<const char *> LLCArgs; LLCArgs.push_back (LLCPath.c_str()); @@ -297,9 +296,9 @@ void CBE::OutputC(const std::string &Bytecode, } void CBE::compileProgram(const std::string &Bytecode) { - std::string OutputCFile; + sys::Path OutputCFile; OutputC(Bytecode, OutputCFile); - removeFile(OutputCFile); + OutputCFile.destroyFile(); } int CBE::ExecuteProgram(const std::string &Bytecode, @@ -308,12 +307,12 @@ int CBE::ExecuteProgram(const std::string &Bytecode, const std::string &OutputFile, const std::vector<std::string> &SharedLibs, unsigned Timeout) { - std::string OutputCFile; + sys::Path OutputCFile; OutputC(Bytecode, OutputCFile); FileRemover CFileRemove(OutputCFile); - return gcc->ExecuteProgram(OutputCFile, Args, GCC::CFile, + return gcc->ExecuteProgram(OutputCFile.toString(), Args, GCC::CFile, InputFile, OutputFile, SharedLibs, Timeout); } @@ -398,7 +397,7 @@ int GCC::ExecuteProgram(const std::string &ProgramFile, std::cerr << "\n"; ); - FileRemover OutputBinaryRemover(OutputBinary.toString()); + FileRemover OutputBinaryRemover(OutputBinary); return RunProgramWithTimeout(OutputBinary.toString(), &ProgramArgs[0], InputFile, OutputFile, OutputFile, Timeout); } |