diff options
author | Don Hinton <hintonda@gmail.com> | 2018-09-18 18:39:27 +0000 |
---|---|---|
committer | Don Hinton <hintonda@gmail.com> | 2018-09-18 18:39:27 +0000 |
commit | 3863d54a486b5d902b2bb95644a9878124830104 (patch) | |
tree | b4ddedde426ddaec157d457f983861ad41fec78e | |
parent | 405c1a12723d1a9aebc3283aee6d6472b7a84e7f (diff) | |
download | bcm5719-llvm-3863d54a486b5d902b2bb95644a9878124830104.tar.gz bcm5719-llvm-3863d54a486b5d902b2bb95644a9878124830104.zip |
[bugpoint] Revert r318459
Summary: Revert r318459 which introduced a TempFile scoping bug.
Differential Revision: https://reviews.llvm.org/D51836
llvm-svn: 342503
-rw-r--r-- | llvm/tools/bugpoint/ExecutionDriver.cpp | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/llvm/tools/bugpoint/ExecutionDriver.cpp b/llvm/tools/bugpoint/ExecutionDriver.cpp index 773bad69fae..690a48de35a 100644 --- a/llvm/tools/bugpoint/ExecutionDriver.cpp +++ b/llvm/tools/bugpoint/ExecutionDriver.cpp @@ -299,26 +299,32 @@ Expected<std::string> BugDriver::executeProgram(const Module &Program, if (!AI) AI = Interpreter; assert(AI && "Interpreter should have been created already!"); + bool CreatedBitcode = false; if (BitcodeFile.empty()) { // Emit the program to a bitcode file... - auto File = - sys::fs::TempFile::create(OutputPrefix + "-test-program-%%%%%%%.bc"); - if (!File) { - errs() << ToolName - << ": Error making unique filename: " << toString(File.takeError()) + SmallString<128> UniqueFilename; + int UniqueFD; + std::error_code EC = sys::fs::createUniqueFile( + OutputPrefix + "-test-program-%%%%%%%.bc", UniqueFD, UniqueFilename); + if (EC) { + errs() << ToolName << ": Error making unique filename: " << EC.message() << "!\n"; exit(1); } - DiscardTemp Discard{*File}; - BitcodeFile = File->TmpName; + BitcodeFile = UniqueFilename.str(); - if (writeProgramToFile(File->FD, Program)) { + if (writeProgramToFile(BitcodeFile, UniqueFD, Program)) { errs() << ToolName << ": Error emitting bitcode to file '" << BitcodeFile << "'!\n"; exit(1); } + CreatedBitcode = true; } + // Remove the temporary bitcode file when we are done. + std::string BitcodePath(BitcodeFile); + FileRemover BitcodeFileRemover(BitcodePath, CreatedBitcode && !SaveTemps); + if (OutputFile.empty()) OutputFile = OutputPrefix + "-execution-output-%%%%%%%"; |