llvm::writeToOutput

Create an output stream for OutputFileName and pass it to Write.

Synopsis

Declared in <llvm/Support/raw_ostream.h>

Error
writeToOutput(
    StringRef OutputFileName,
    std::function<Error(raw_ostream&)> Write);

Description

The stream created is based on the specified OutputFileName: llvm::outs for "-", raw_null_ostream for "/dev/null", and raw_fd_ostream for other names. For raw_fd_ostream instances, the stream writes to a temporary file. The final output file is atomically replaced with the temporary file after the Write function is finished.

Return Value

Success, or the error from opening the file or from Write.

Parameters

NameDescription
OutputFileNamePath or special name ("-" / "/dev/null") to write.
WriteCallback that receives the stream and returns an Error.