diff options
| author | 2018-04-06 14:26:03 +0000 | |
|---|---|---|
| committer | 2018-04-06 14:26:03 +0000 | |
| commit | bdabc2f19ffb9e20600dad6e8a300842a7bda50e (patch) | |
| tree | c50e7b2e5449b074651bb82a58517a8ebc4a8cf7 /gnu/llvm/tools/bugpoint/ExtractFunction.cpp | |
| parent | Print a 'p' flag for file descriptors that were opened after pledge(2). (diff) | |
| download | wireguard-openbsd-bdabc2f19ffb9e20600dad6e8a300842a7bda50e.tar.xz wireguard-openbsd-bdabc2f19ffb9e20600dad6e8a300842a7bda50e.zip | |
Import LLVM 6.0.1 release including clang, lld and lldb.
"where is the kaboom?" deraadt@
Diffstat (limited to 'gnu/llvm/tools/bugpoint/ExtractFunction.cpp')
| -rw-r--r-- | gnu/llvm/tools/bugpoint/ExtractFunction.cpp | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/gnu/llvm/tools/bugpoint/ExtractFunction.cpp b/gnu/llvm/tools/bugpoint/ExtractFunction.cpp index 72872e83f79..431dcedfe20 100644 --- a/gnu/llvm/tools/bugpoint/ExtractFunction.cpp +++ b/gnu/llvm/tools/bugpoint/ExtractFunction.cpp @@ -373,19 +373,17 @@ llvm::SplitFunctionsOutOfModule(Module *M, const std::vector<Function *> &F, std::unique_ptr<Module> BugDriver::extractMappedBlocksFromModule(const std::vector<BasicBlock *> &BBs, Module *M) { - SmallString<128> Filename; - int FD; - std::error_code EC = sys::fs::createUniqueFile( - OutputPrefix + "-extractblocks%%%%%%%", FD, Filename); - if (EC) { + auto Temp = sys::fs::TempFile::create(OutputPrefix + "-extractblocks%%%%%%%"); + if (!Temp) { outs() << "*** Basic Block extraction failed!\n"; - errs() << "Error creating temporary file: " << EC.message() << "\n"; + errs() << "Error creating temporary file: " << toString(Temp.takeError()) + << "\n"; EmitProgressBitcode(M, "basicblockextractfail", true); return nullptr; } - sys::RemoveFileOnSignal(Filename); + DiscardTemp Discard{*Temp}; - tool_output_file BlocksToNotExtractFile(Filename.c_str(), FD); + raw_fd_ostream OS(Temp->FD, /*shouldClose*/ false); for (std::vector<BasicBlock *>::const_iterator I = BBs.begin(), E = BBs.end(); I != E; ++I) { BasicBlock *BB = *I; @@ -393,28 +391,24 @@ BugDriver::extractMappedBlocksFromModule(const std::vector<BasicBlock *> &BBs, // off of. if (!BB->hasName()) BB->setName("tmpbb"); - BlocksToNotExtractFile.os() << BB->getParent()->getName() << " " - << BB->getName() << "\n"; + OS << BB->getParent()->getName() << " " << BB->getName() << "\n"; } - BlocksToNotExtractFile.os().close(); - if (BlocksToNotExtractFile.os().has_error()) { + OS.flush(); + if (OS.has_error()) { errs() << "Error writing list of blocks to not extract\n"; EmitProgressBitcode(M, "basicblockextractfail", true); - BlocksToNotExtractFile.os().clear_error(); + OS.clear_error(); return nullptr; } - BlocksToNotExtractFile.keep(); std::string uniqueFN = "--extract-blocks-file="; - uniqueFN += Filename.str(); + uniqueFN += Temp->TmpName; const char *ExtraArg = uniqueFN.c_str(); std::vector<std::string> PI; PI.push_back("extract-blocks"); std::unique_ptr<Module> Ret = runPassesOn(M, PI, 1, &ExtraArg); - sys::fs::remove(Filename.c_str()); - if (!Ret) { outs() << "*** Basic Block extraction failed, please report a bug!\n"; EmitProgressBitcode(M, "basicblockextractfail", true); |
