From 51c5a286bae5ad27ddc49602f44b7ea7253a4cc9 Mon Sep 17 00:00:00 2001 From: Reid Spencer Date: Wed, 23 Aug 2006 20:34:57 +0000 Subject: For PR797: Final removal of exceptions from lib/System and adjustment of users to accommodate. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29846 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/bugpoint/ExecutionDriver.cpp | 20 +++++++++++++++++--- tools/bugpoint/Miscompilation.cpp | 26 ++++++++++++++++++++++---- tools/bugpoint/OptimizerDriver.cpp | 14 +++++++++++--- tools/bugpoint/ToolRunner.cpp | 30 +++++++++++++++++++++++++----- 4 files changed, 75 insertions(+), 15 deletions(-) (limited to 'tools/bugpoint') diff --git a/tools/bugpoint/ExecutionDriver.cpp b/tools/bugpoint/ExecutionDriver.cpp index 93eef5dbc5..2f75f62338 100644 --- a/tools/bugpoint/ExecutionDriver.cpp +++ b/tools/bugpoint/ExecutionDriver.cpp @@ -161,7 +161,12 @@ bool BugDriver::initializeExecutionEnvironment() { void BugDriver::compileProgram(Module *M) { // Emit the program to a bytecode file... sys::Path BytecodeFile ("bugpoint-test-program.bc"); - BytecodeFile.makeUnique(); + std::string ErrMsg; + if (BytecodeFile.makeUnique(true,&ErrMsg)) { + std::cerr << ToolName << ": Error making unique filename: " << ErrMsg + << "\n"; + exit(1); + } if (writeProgramToFile(BytecodeFile.toString(), M)) { std::cerr << ToolName << ": Error emitting bytecode to file '" << BytecodeFile << "'!\n"; @@ -188,10 +193,15 @@ std::string BugDriver::executeProgram(std::string OutputFile, if (AI == 0) AI = Interpreter; assert(AI && "Interpreter should have been created already!"); bool CreatedBytecode = false; + std::string ErrMsg; if (BytecodeFile.empty()) { // Emit the program to a bytecode file... sys::Path uniqueFilename("bugpoint-test-program.bc"); - uniqueFilename.makeUnique(); + if (uniqueFilename.makeUnique(true, &ErrMsg)) { + std::cerr << ToolName << ": Error making unique filename: " + << ErrMsg << "!\n"; + exit(1); + } BytecodeFile = uniqueFilename.toString(); if (writeProgramToFile(BytecodeFile, Program)) { @@ -210,7 +220,11 @@ std::string BugDriver::executeProgram(std::string OutputFile, // Check to see if this is a valid output filename... sys::Path uniqueFile(OutputFile); - uniqueFile.makeUnique(); + if (uniqueFile.makeUnique(true, &ErrMsg)) { + std::cerr << ToolName << ": Error making unique filename: " + << ErrMsg << "\n"; + exit(1); + } OutputFile = uniqueFile.toString(); // Figure out which shared objects to run, if any. diff --git a/tools/bugpoint/Miscompilation.cpp b/tools/bugpoint/Miscompilation.cpp index 0fe14e34ae..7660a83d30 100644 --- a/tools/bugpoint/Miscompilation.cpp +++ b/tools/bugpoint/Miscompilation.cpp @@ -776,7 +776,12 @@ static bool TestCodeGenerator(BugDriver &BD, Module *Test, Module *Safe) { CleanupAndPrepareModules(BD, Test, Safe); sys::Path TestModuleBC("bugpoint.test.bc"); - TestModuleBC.makeUnique(); + std::string ErrMsg; + if (TestModuleBC.makeUnique(true, &ErrMsg)) { + std::cerr << BD.getToolName() << "Error making unique filename: " + << ErrMsg << "\n"; + exit(1); + } if (BD.writeProgramToFile(TestModuleBC.toString(), Test)) { std::cerr << "Error writing bytecode to `" << TestModuleBC << "'\nExiting."; exit(1); @@ -785,7 +790,11 @@ static bool TestCodeGenerator(BugDriver &BD, Module *Test, Module *Safe) { // Make the shared library sys::Path SafeModuleBC("bugpoint.safe.bc"); - SafeModuleBC.makeUnique(); + if (SafeModuleBC.makeUnique(true, &ErrMsg)) { + std::cerr << BD.getToolName() << "Error making unique filename: " + << ErrMsg << "\n"; + exit(1); + } if (BD.writeProgramToFile(SafeModuleBC.toString(), Safe)) { std::cerr << "Error writing bytecode to `" << SafeModuleBC << "'\nExiting."; @@ -836,7 +845,12 @@ bool BugDriver::debugCodeGenerator() { CleanupAndPrepareModules(*this, ToCodeGen, ToNotCodeGen); sys::Path TestModuleBC("bugpoint.test.bc"); - TestModuleBC.makeUnique(); + std::string ErrMsg; + if (TestModuleBC.makeUnique(true, &ErrMsg)) { + std::cerr << getToolName() << "Error making unique filename: " + << ErrMsg << "\n"; + exit(1); + } if (writeProgramToFile(TestModuleBC.toString(), ToCodeGen)) { std::cerr << "Error writing bytecode to `" << TestModuleBC << "'\nExiting."; @@ -846,7 +860,11 @@ bool BugDriver::debugCodeGenerator() { // Make the shared library sys::Path SafeModuleBC("bugpoint.safe.bc"); - SafeModuleBC.makeUnique(); + if (SafeModuleBC.makeUnique(true, &ErrMsg)) { + std::cerr << getToolName() << "Error making unique filename: " + << ErrMsg << "\n"; + exit(1); + } if (writeProgramToFile(SafeModuleBC.toString(), ToNotCodeGen)) { std::cerr << "Error writing bytecode to `" << SafeModuleBC << "'\nExiting."; diff --git a/tools/bugpoint/OptimizerDriver.cpp b/tools/bugpoint/OptimizerDriver.cpp index 4311200cc3..956faba41b 100644 --- a/tools/bugpoint/OptimizerDriver.cpp +++ b/tools/bugpoint/OptimizerDriver.cpp @@ -139,12 +139,21 @@ bool BugDriver::runPasses(const std::vector &Passes, // setup the output file name std::cout << std::flush; sys::Path uniqueFilename("bugpoint-output.bc"); - uniqueFilename.makeUnique(); + std::string ErrMsg; + if (uniqueFilename.makeUnique(true, &ErrMsg)) { + std::cerr << getToolName() << ": Error making unique filename: " + << ErrMsg << "\n"; + return(1); + } OutputFilename = uniqueFilename.toString(); // set up the input file name sys::Path inputFilename("bugpoint-input.bc"); - inputFilename.makeUnique(); + if (inputFilename.makeUnique(true, &ErrMsg)) { + std::cerr << getToolName() << ": Error making unique filename: " + << ErrMsg << "\n"; + return(1); + } std::ios::openmode io_mode = std::ios::out | std::ios::trunc | std::ios::binary; std::ofstream InFile(inputFilename.c_str(), io_mode); @@ -179,7 +188,6 @@ bool BugDriver::runPasses(const std::vector &Passes, args[n++] = 0; sys::Path prog(sys::Program::FindProgramByName(ToolName)); - std::string ErrMsg; int result = sys::Program::ExecuteAndWait(prog,args,0,0,Timeout,&ErrMsg); // If we are supposed to delete the bytecode file or if the passes crashed, diff --git a/tools/bugpoint/ToolRunner.cpp b/tools/bugpoint/ToolRunner.cpp index 8712baf353..589f5158d1 100644 --- a/tools/bugpoint/ToolRunner.cpp +++ b/tools/bugpoint/ToolRunner.cpp @@ -53,7 +53,11 @@ static void ProcessFailure(sys::Path ProgPath, const char** Args) { // Rerun the compiler, capturing any error messages to print them. sys::Path ErrorFilename("error_messages"); - ErrorFilename.makeUnique(); + std::string ErrMsg; + if (ErrorFilename.makeUnique(true, &ErrMsg)) { + std::cerr << "Error making unique filename: " << ErrMsg << "\n"; + exit(1); + } RunProgramWithTimeout(ProgPath, Args, sys::Path(""), ErrorFilename, ErrorFilename); // FIXME: check return code ? @@ -153,7 +157,11 @@ AbstractInterpreter *AbstractInterpreter::createLLI(const std::string &ProgPath, // void LLC::OutputAsm(const std::string &Bytecode, sys::Path &OutputAsmFile) { sys::Path uniqueFile(Bytecode+".llc.s"); - uniqueFile.makeUnique(); + std::string ErrMsg; + if (uniqueFile.makeUnique(true, &ErrMsg)) { + std::cerr << "Error making unique filename: " << ErrMsg << "\n"; + exit(1); + } OutputAsmFile = uniqueFile; std::vector LLCArgs; LLCArgs.push_back (LLCPath.c_str()); @@ -307,7 +315,11 @@ AbstractInterpreter *AbstractInterpreter::createJIT(const std::string &ProgPath, void CBE::OutputC(const std::string &Bytecode, sys::Path& OutputCFile) { sys::Path uniqueFile(Bytecode+".cbe.c"); - uniqueFile.makeUnique(); + std::string ErrMsg; + if (uniqueFile.makeUnique(true, &ErrMsg)) { + std::cerr << "Error making unique filename: " << ErrMsg << "\n"; + exit(1); + } OutputCFile = uniqueFile; std::vector LLCArgs; LLCArgs.push_back (LLCPath.c_str()); @@ -409,7 +421,11 @@ int GCC::ExecuteProgram(const std::string &ProgramFile, GCCArgs.push_back("none"); GCCArgs.push_back("-o"); sys::Path OutputBinary (ProgramFile+".gcc.exe"); - OutputBinary.makeUnique(); + std::string ErrMsg; + if (OutputBinary.makeUnique(true, &ErrMsg)) { + std::cerr << "Error making unique filename: " << ErrMsg << "\n"; + exit(1); + } GCCArgs.push_back(OutputBinary.c_str()); // Output to the right file... // Add any arguments intended for GCC. We locate them here because this is @@ -462,7 +478,11 @@ int GCC::MakeSharedObject(const std::string &InputFile, FileType fileType, std::string &OutputFile, const std::vector &ArgsForGCC) { sys::Path uniqueFilename(InputFile+LTDL_SHLIB_EXT); - uniqueFilename.makeUnique(); + std::string ErrMsg; + if (uniqueFilename.makeUnique(true, &ErrMsg)) { + std::cerr << "Error making unique filename: " << ErrMsg << "\n"; + exit(1); + } OutputFile = uniqueFilename.toString(); std::vector GCCArgs; -- cgit v1.2.3