const std::string &NewPrefix);
/// Setup optimization remarks.
-Expected<std::unique_ptr<tool_output_file>>
+Expected<std::unique_ptr<ToolOutputFile>>
setupOptimizationRemarks(LLVMContext &Context, StringRef LTORemarksFilename,
bool LTOPassRemarksWithHotness, int Count = -1);
bool ShouldEmbedUselists = false;
bool ShouldRestoreGlobalsLinkage = false;
TargetMachine::CodeGenFileType FileType = TargetMachine::CGFT_ObjectFile;
- std::unique_ptr<tool_output_file> DiagnosticOutputFile;
+ std::unique_ptr<ToolOutputFile> DiagnosticOutputFile;
bool Freestanding = false;
};
}
//
//===----------------------------------------------------------------------===//
//
-// This file defines the tool_output_file class.
+// This file defines the ToolOutputFile class.
//
//===----------------------------------------------------------------------===//
/// This class contains a raw_fd_ostream and adds a few extra features commonly
/// needed for compiler-like tool output files:
/// - The file is automatically deleted if the process is killed.
-/// - The file is automatically deleted when the tool_output_file
+/// - The file is automatically deleted when the ToolOutputFile
/// object is destroyed unless the client calls keep().
-class tool_output_file {
+class ToolOutputFile {
/// This class is declared before the raw_fd_ostream so that it is constructed
/// before the raw_fd_ostream is constructed and destructed after the
/// raw_fd_ostream is destructed. It installs cleanups in its constructor and
public:
/// This constructor's arguments are passed to to raw_fd_ostream's
/// constructor.
- tool_output_file(StringRef Filename, std::error_code &EC,
- sys::fs::OpenFlags Flags);
+ ToolOutputFile(StringRef Filename, std::error_code &EC,
+ sys::fs::OpenFlags Flags);
- tool_output_file(StringRef Filename, int FD);
+ ToolOutputFile(StringRef Filename, int FD);
/// Return the contained raw_fd_ostream.
raw_fd_ostream &os() { return OS; }
return BackendProc->wait();
}
-Expected<std::unique_ptr<tool_output_file>>
+Expected<std::unique_ptr<ToolOutputFile>>
lto::setupOptimizationRemarks(LLVMContext &Context,
StringRef LTORemarksFilename,
bool LTOPassRemarksWithHotness, int Count) {
std::error_code EC;
auto DiagnosticFile =
- llvm::make_unique<tool_output_file>(Filename, EC, sys::fs::F_None);
+ llvm::make_unique<ToolOutputFile>(Filename, EC, sys::fs::F_None);
if (EC)
return errorCodeToError(EC);
Context.setDiagnosticsOutputFile(
}
static void
-finalizeOptimizationRemarks(std::unique_ptr<tool_output_file> DiagOutputFile) {
+finalizeOptimizationRemarks(std::unique_ptr<ToolOutputFile> DiagOutputFile) {
// Make sure we flush the diagnostic remarks file in case the linker doesn't
// call the global destructors before exiting.
if (!DiagOutputFile)
// create output file
std::error_code EC;
- tool_output_file Out(Path, EC, sys::fs::F_None);
+ ToolOutputFile Out(Path, EC, sys::fs::F_None);
if (EC) {
std::string ErrMsg = "could not open bitcode file for writing: ";
ErrMsg += Path;
}
// generate object file
- tool_output_file objFile(Filename, FD);
+ ToolOutputFile objFile(Filename, FD);
bool genResult = compileOptimized(&objFile.os());
objFile.os().close();
TmpArchiveFD, TmpArchive))
return errorCodeToError(EC);
- tool_output_file Output(TmpArchive, TmpArchiveFD);
+ ToolOutputFile Output(TmpArchive, TmpArchiveFD);
raw_fd_ostream &Out = Output.os();
if (Thin)
Out << "!<thin>\n";
-//===--- ToolOutputFile.cpp - Implement the tool_output_file class --------===//
+//===--- ToolOutputFile.cpp - Implement the ToolOutputFile class --------===//
//
// The LLVM Compiler Infrastructure
//
//
//===----------------------------------------------------------------------===//
//
-// This implements the tool_output_file class.
+// This implements the ToolOutputFile class.
//
//===----------------------------------------------------------------------===//
#include "llvm/Support/Signals.h"
using namespace llvm;
-tool_output_file::CleanupInstaller::CleanupInstaller(StringRef Filename)
+ToolOutputFile::CleanupInstaller::CleanupInstaller(StringRef Filename)
: Filename(Filename), Keep(false) {
// Arrange for the file to be deleted if the process is killed.
if (Filename != "-")
sys::RemoveFileOnSignal(Filename);
}
-tool_output_file::CleanupInstaller::~CleanupInstaller() {
+ToolOutputFile::CleanupInstaller::~CleanupInstaller() {
// Delete the file if the client hasn't told us not to.
if (!Keep && Filename != "-")
sys::fs::remove(Filename);
sys::DontRemoveFileOnSignal(Filename);
}
-tool_output_file::tool_output_file(StringRef Filename, std::error_code &EC,
- sys::fs::OpenFlags Flags)
+ToolOutputFile::ToolOutputFile(StringRef Filename, std::error_code &EC,
+ sys::fs::OpenFlags Flags)
: Installer(Filename), OS(Filename, EC, Flags) {
// If open fails, no cleanup is needed.
if (EC)
Installer.Keep = true;
}
-tool_output_file::tool_output_file(StringRef Filename, int FD)
+ToolOutputFile::ToolOutputFile(StringRef Filename, int FD)
: Installer(Filename), OS(FD, true) {}
return reportError(argv0, "the option -d must be used together with -o\n");
std::error_code EC;
- tool_output_file DepOut(DependFilename, EC, sys::fs::F_Text);
+ ToolOutputFile DepOut(DependFilename, EC, sys::fs::F_Text);
if (EC)
return reportError(argv0, "error opening " + DependFilename + ":" +
EC.message() + "\n");
return 1;
std::error_code EC;
- tool_output_file Out(OutputFilename, EC, sys::fs::F_Text);
+ ToolOutputFile Out(OutputFilename, EC, sys::fs::F_Text);
if (EC)
return reportError(argv0, "error opening " + OutputFilename + ":" +
EC.message() + "\n");
}
sys::RemoveFileOnSignal(Filename);
- tool_output_file BlocksToNotExtractFile(Filename.c_str(), FD);
+ ToolOutputFile BlocksToNotExtractFile(Filename.c_str(), FD);
for (std::vector<BasicBlock *>::const_iterator I = BBs.begin(), E = BBs.end();
I != E; ++I) {
BasicBlock *BB = *I;
/// writeProgramToFile - This writes the current "Program" to the named bitcode
/// file. If an error occurs, true is returned.
///
-static bool writeProgramToFileAux(tool_output_file &Out, const Module *M) {
+static bool writeProgramToFileAux(ToolOutputFile &Out, const Module *M) {
WriteBitcodeToFile(M, Out.os(), PreserveBitcodeUseListOrder);
Out.os().close();
if (!Out.os().has_error()) {
bool BugDriver::writeProgramToFile(const std::string &Filename, int FD,
const Module *M) const {
- tool_output_file Out(Filename, FD);
+ ToolOutputFile Out(Filename, FD);
return writeProgramToFileAux(Out, M);
}
bool BugDriver::writeProgramToFile(const std::string &Filename,
const Module *M) const {
std::error_code EC;
- tool_output_file Out(Filename, EC, sys::fs::F_None);
+ ToolOutputFile Out(Filename, EC, sys::fs::F_None);
if (!EC)
return writeProgramToFileAux(Out, M);
return true;
return 1;
}
- tool_output_file InFile(InputFilename, InputFD);
+ ToolOutputFile InFile(InputFilename, InputFD);
WriteBitcodeToFile(Program, InFile.os(), PreserveBitcodeUseListOrder);
InFile.os().close();
static int compileModule(char **, LLVMContext &);
-static std::unique_ptr<tool_output_file>
-GetOutputStream(const char *TargetName, Triple::OSType OS,
- const char *ProgName) {
+static std::unique_ptr<ToolOutputFile> GetOutputStream(const char *TargetName,
+ Triple::OSType OS,
+ const char *ProgName) {
// If we don't yet have an output filename, make one.
if (OutputFilename.empty()) {
if (InputFilename == "-")
sys::fs::OpenFlags OpenFlags = sys::fs::F_None;
if (!Binary)
OpenFlags |= sys::fs::F_Text;
- auto FDOut = llvm::make_unique<tool_output_file>(OutputFilename, EC,
- OpenFlags);
+ auto FDOut = llvm::make_unique<ToolOutputFile>(OutputFilename, EC, OpenFlags);
if (EC) {
errs() << EC.message() << '\n';
return nullptr;
if (PassRemarksHotnessThreshold)
Context.setDiagnosticsHotnessThreshold(PassRemarksHotnessThreshold);
- std::unique_ptr<tool_output_file> YamlFile;
+ std::unique_ptr<ToolOutputFile> YamlFile;
if (RemarksFilename != "") {
std::error_code EC;
- YamlFile = llvm::make_unique<tool_output_file>(RemarksFilename, EC,
- sys::fs::F_None);
+ YamlFile =
+ llvm::make_unique<ToolOutputFile>(RemarksFilename, EC, sys::fs::F_None);
if (EC) {
errs() << EC.message() << '\n';
return 1;
Options.FloatABIType = FloatABIForCalls;
// Figure out where we are going to send the output.
- std::unique_ptr<tool_output_file> Out =
+ std::unique_ptr<ToolOutputFile> Out =
GetOutputStream(TheTarget->getName(), TheTriple.getOS(), argv[0]);
if (!Out) return 1;
}
std::error_code EC;
- std::unique_ptr<tool_output_file> Out(
- new tool_output_file(OutputFilename, EC, sys::fs::F_None));
+ std::unique_ptr<ToolOutputFile> Out(
+ new ToolOutputFile(OutputFilename, EC, sys::fs::F_None));
if (EC) {
errs() << EC.message() << '\n';
exit(1);
error(InputPath, EC.message());
return;
}
- tool_output_file InputTOF{InputPath, InputFD};
+ ToolOutputFile InputTOF{InputPath, InputFD};
unsigned NumSymbols = 0;
for (const auto &Function : Coverage.getCoveredFunctions()) {
error(OutputPath, EC.message());
return;
}
- tool_output_file OutputTOF{OutputPath, OutputFD};
+ ToolOutputFile OutputTOF{OutputPath, OutputFD};
OutputTOF.os().close();
// Invoke the demangler.
}
std::error_code EC;
- std::unique_ptr<tool_output_file> Out(
- new tool_output_file(OutputFilename, EC, sys::fs::F_None));
+ std::unique_ptr<ToolOutputFile> Out(
+ new ToolOutputFile(OutputFilename, EC, sys::fs::F_None));
if (EC) {
errs() << EC.message() << '\n';
return 1;
Passes.add(createStripDeadPrototypesPass()); // Remove dead func decls
std::error_code EC;
- tool_output_file Out(OutputFilename, EC, sys::fs::F_None);
+ ToolOutputFile Out(OutputFilename, EC, sys::fs::F_None);
if (EC) {
errs() << EC.message() << '\n';
return 1;
if (DumpAsm) errs() << "Here's the assembly:\n" << *Composite;
std::error_code EC;
- tool_output_file Out(OutputFilename, EC, sys::fs::F_None);
+ ToolOutputFile Out(OutputFilename, EC, sys::fs::F_None);
if (EC) {
errs() << EC.message() << '\n';
return 1;
error("writing merged module failed.");
}
- std::list<tool_output_file> OSs;
+ std::list<ToolOutputFile> OSs;
std::vector<raw_pwrite_stream *> OSPtrs;
for (unsigned I = 0; I != Parallelism; ++I) {
std::string PartFilename = OutputFilename;
// Diagnostic messages should have been printed by the handler.
error("error compiling the code");
- for (tool_output_file &OS : OSs)
+ for (ToolOutputFile &OS : OSs)
OS.keep();
} else {
if (Parallelism != 1)
std::error_code EC;
const std::string OutputFilename = "-";
- auto Out = llvm::make_unique<tool_output_file>(OutputFilename, EC,
- sys::fs::F_None);
+ auto Out =
+ llvm::make_unique<ToolOutputFile>(OutputFilename, EC, sys::fs::F_None);
if (EC) {
errs() << EC.message() << '\n';
abort();
return TheTarget;
}
-static std::unique_ptr<tool_output_file> GetOutputStream() {
+static std::unique_ptr<ToolOutputFile> GetOutputStream() {
if (OutputFilename == "")
OutputFilename = "-";
std::error_code EC;
- auto Out = llvm::make_unique<tool_output_file>(OutputFilename, EC,
- sys::fs::F_None);
+ auto Out =
+ llvm::make_unique<ToolOutputFile>(OutputFilename, EC, sys::fs::F_None);
if (EC) {
errs() << EC.message() << '\n';
return nullptr;
FeaturesStr = Features.getString();
}
- std::unique_ptr<tool_output_file> Out = GetOutputStream();
+ std::unique_ptr<ToolOutputFile> Out = GetOutputStream();
if (!Out)
return 1;
}
std::error_code EC;
- std::unique_ptr<tool_output_file> Out(
- new tool_output_file(OutputFilename, EC, sys::fs::F_None));
+ std::unique_ptr<ToolOutputFile> Out(
+ new ToolOutputFile(OutputFilename, EC, sys::fs::F_None));
ExitOnErr(errorCodeToError(EC));
if (BinaryExtract) {
errs() << XarEC.message() << "\n";
return;
}
- tool_output_file XarFile(XarFilename, FD);
+ ToolOutputFile XarFile(XarFilename, FD);
raw_fd_ostream &XarOut = XarFile.os();
StringRef XarContents(sect, size);
XarOut << XarContents;
unsigned I = 0;
SplitModule(std::move(M), NumOutputs, [&](std::unique_ptr<Module> MPart) {
std::error_code EC;
- std::unique_ptr<tool_output_file> Out(new tool_output_file(
- OutputFilename + utostr(I++), EC, sys::fs::F_None));
+ std::unique_ptr<ToolOutputFile> Out(
+ new ToolOutputFile(OutputFilename + utostr(I++), EC, sys::fs::F_None));
if (EC) {
errs() << EC.message() << '\n';
exit(1);
IntroduceControlFlow(F, R);
// Figure out what stream we are supposed to write to...
- std::unique_ptr<tool_output_file> Out;
+ std::unique_ptr<ToolOutputFile> Out;
// Default to standard output.
if (OutputFilename.empty())
OutputFilename = "-";
std::error_code EC;
- Out.reset(new tool_output_file(OutputFilename, EC, sys::fs::F_None));
+ Out.reset(new ToolOutputFile(OutputFilename, EC, sys::fs::F_None));
if (EC) {
errs() << EC.message() << '\n';
return 1;
#endif
bool llvm::runPassPipeline(StringRef Arg0, Module &M, TargetMachine *TM,
- tool_output_file *Out,
- tool_output_file *ThinLTOLinkOut,
- tool_output_file *OptRemarkFile,
+ ToolOutputFile *Out, ToolOutputFile *ThinLTOLinkOut,
+ ToolOutputFile *OptRemarkFile,
StringRef PassPipeline, OutputKind OK,
VerifierKind VK,
bool ShouldPreserveAssemblyUseListOrder,
class LLVMContext;
class Module;
class TargetMachine;
-class tool_output_file;
+class ToolOutputFile;
namespace opt_tool {
enum OutputKind {
/// ThinLTOLinkOut is only used when OK is OK_OutputThinLTOBitcode, and can be
/// nullptr.
bool runPassPipeline(StringRef Arg0, Module &M, TargetMachine *TM,
- tool_output_file *Out, tool_output_file *ThinLinkOut,
- tool_output_file *OptRemarkFile, StringRef PassPipeline,
+ ToolOutputFile *Out, ToolOutputFile *ThinLinkOut,
+ ToolOutputFile *OptRemarkFile, StringRef PassPipeline,
opt_tool::OutputKind OK, opt_tool::VerifierKind VK,
bool ShouldPreserveAssemblyUseListOrder,
bool ShouldPreserveBitcodeUseListOrder,
if (PassRemarksHotnessThreshold)
Context.setDiagnosticsHotnessThreshold(PassRemarksHotnessThreshold);
- std::unique_ptr<tool_output_file> OptRemarkFile;
+ std::unique_ptr<ToolOutputFile> OptRemarkFile;
if (RemarksFilename != "") {
std::error_code EC;
- OptRemarkFile = llvm::make_unique<tool_output_file>(RemarksFilename, EC,
- sys::fs::F_None);
+ OptRemarkFile =
+ llvm::make_unique<ToolOutputFile>(RemarksFilename, EC, sys::fs::F_None);
if (EC) {
errs() << EC.message() << '\n';
return 1;
M->setDataLayout(ClDataLayout);
// Figure out what stream we are supposed to write to...
- std::unique_ptr<tool_output_file> Out;
- std::unique_ptr<tool_output_file> ThinLinkOut;
+ std::unique_ptr<ToolOutputFile> Out;
+ std::unique_ptr<ToolOutputFile> ThinLinkOut;
if (NoOutput) {
if (!OutputFilename.empty())
errs() << "WARNING: The -o (output filename) option is ignored when\n"
OutputFilename = "-";
std::error_code EC;
- Out.reset(new tool_output_file(OutputFilename, EC, sys::fs::F_None));
+ Out.reset(new ToolOutputFile(OutputFilename, EC, sys::fs::F_None));
if (EC) {
errs() << EC.message() << '\n';
return 1;
if (!ThinLinkBitcodeFile.empty()) {
ThinLinkOut.reset(
- new tool_output_file(ThinLinkBitcodeFile, EC, sys::fs::F_None));
+ new ToolOutputFile(ThinLinkBitcodeFile, EC, sys::fs::F_None));
if (EC) {
errs() << EC.message() << '\n';
return 1;
OutputFilename = "-";
std::error_code EC;
- Out = llvm::make_unique<tool_output_file>(OutputFilename, EC,
- sys::fs::F_None);
+ Out = llvm::make_unique<ToolOutputFile>(OutputFilename, EC,
+ sys::fs::F_None);
if (EC) {
errs() << EC.message() << '\n';
return 1;
OutputFilename = "-";
std::error_code EC;
- std::unique_ptr<tool_output_file> Out(
- new tool_output_file(OutputFilename, EC, sys::fs::F_None));
+ std::unique_ptr<ToolOutputFile> Out(
+ new ToolOutputFile(OutputFilename, EC, sys::fs::F_None));
if (EC)
error("yaml2obj: Error opening '" + OutputFilename + "': " + EC.message());