summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2017-11-16 21:53:51 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2017-11-16 21:53:51 +0000
commitf9b2c734345e83a99b4767fa8a6f452aff2cea68 (patch)
treec28f2fde03b9d6c32fb52a5b60409498cd392b60
parentb60bb6904b63fb254f39441939dc8fdc6e3e0c78 (diff)
downloadbcm5719-llvm-f9b2c734345e83a99b4767fa8a6f452aff2cea68.tar.gz
bcm5719-llvm-f9b2c734345e83a99b4767fa8a6f452aff2cea68.zip
Convert the last use of sys::fs::createUniqueFile in bugpoint.
llvm-svn: 318459
-rw-r--r--llvm/tools/bugpoint/ExecutionDriver.cpp22
1 files changed, 8 insertions, 14 deletions
diff --git a/llvm/tools/bugpoint/ExecutionDriver.cpp b/llvm/tools/bugpoint/ExecutionDriver.cpp
index 912eeb006c2..7562aa603bb 100644
--- a/llvm/tools/bugpoint/ExecutionDriver.cpp
+++ b/llvm/tools/bugpoint/ExecutionDriver.cpp
@@ -302,32 +302,26 @@ 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...
- 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()
+ auto File =
+ sys::fs::TempFile::create(OutputPrefix + "-test-program-%%%%%%%.bc");
+ if (!File) {
+ errs() << ToolName
+ << ": Error making unique filename: " << toString(File.takeError())
<< "!\n";
exit(1);
}
- BitcodeFile = UniqueFilename.str();
+ DiscardTemp Discard{*File};
+ BitcodeFile = File->TmpName;
- if (writeProgramToFile(BitcodeFile, UniqueFD, Program)) {
+ if (writeProgramToFile(File->FD, 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-%%%%%%%";
OpenPOWER on IntegriCloud