#include "llvm/Support/raw_ostream.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Config/config.h"
#include "llvm/Support/AutoConvert.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Duration.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/NativeFormatting.h"
#include "llvm/Support/Process.h"
#include "llvm/Support/Program.h"
#include <algorithm>
#include <cerrno>
#include <cstdio>
#include <sys/stat.h>
#if defined(HAVE_FCNTL_H)
# include <fcntl.h>
#endif
#if defined(HAVE_UNISTD_H)
# include <unistd.h>
#endif
#if defined(__CYGWIN__)
#include <io.h>
#endif
#if defined(_MSC_VER)
#include <io.h>
#ifndef STDIN_FILENO
#define STDIN_FILENO …
#endif
#ifndef STDOUT_FILENO
#define STDOUT_FILENO …
#endif
#ifndef STDERR_FILENO
#define STDERR_FILENO …
#endif
#endif
#ifdef _WIN32
#include "llvm/Support/ConvertUTF.h"
#include "llvm/Support/Signals.h"
#include "llvm/Support/Windows/WindowsSupport.h"
#endif
usingnamespacellvm;
constexpr raw_ostream::Colors raw_ostream::BLACK;
constexpr raw_ostream::Colors raw_ostream::RED;
constexpr raw_ostream::Colors raw_ostream::GREEN;
constexpr raw_ostream::Colors raw_ostream::YELLOW;
constexpr raw_ostream::Colors raw_ostream::BLUE;
constexpr raw_ostream::Colors raw_ostream::MAGENTA;
constexpr raw_ostream::Colors raw_ostream::CYAN;
constexpr raw_ostream::Colors raw_ostream::WHITE;
constexpr raw_ostream::Colors raw_ostream::SAVEDCOLOR;
constexpr raw_ostream::Colors raw_ostream::RESET;
raw_ostream::~raw_ostream() { … }
size_t raw_ostream::preferred_buffer_size() const { … }
void raw_ostream::SetBuffered() { … }
void raw_ostream::SetBufferAndMode(char *BufferStart, size_t Size,
BufferKind Mode) { … }
raw_ostream &raw_ostream::operator<<(unsigned long N) { … }
raw_ostream &raw_ostream::operator<<(long N) { … }
raw_ostream &raw_ostream::operator<<(unsigned long long N) { … }
raw_ostream &raw_ostream::operator<<(long long N) { … }
raw_ostream &raw_ostream::write_hex(unsigned long long N) { … }
raw_ostream &raw_ostream::operator<<(Colors C) { … }
raw_ostream &raw_ostream::write_uuid(const uuid_t UUID) { … }
raw_ostream &raw_ostream::write_escaped(StringRef Str,
bool UseHexEscapes) { … }
raw_ostream &raw_ostream::operator<<(const void *P) { … }
raw_ostream &raw_ostream::operator<<(double N) { … }
void raw_ostream::flush_nonempty() { … }
raw_ostream &raw_ostream::write(unsigned char C) { … }
raw_ostream &raw_ostream::write(const char *Ptr, size_t Size) { … }
void raw_ostream::copy_to_buffer(const char *Ptr, size_t Size) { … }
raw_ostream &raw_ostream::operator<<(const format_object_base &Fmt) { … }
raw_ostream &raw_ostream::operator<<(const formatv_object_base &Obj) { … }
raw_ostream &raw_ostream::operator<<(const FormattedString &FS) { … }
raw_ostream &raw_ostream::operator<<(const FormattedNumber &FN) { … }
raw_ostream &raw_ostream::operator<<(const FormattedBytes &FB) { … }
template <char C>
static raw_ostream &write_padding(raw_ostream &OS, unsigned NumChars) { … }
raw_ostream &raw_ostream::indent(unsigned NumSpaces) { … }
raw_ostream &raw_ostream::write_zeros(unsigned NumZeros) { … }
bool raw_ostream::prepare_colors() { … }
raw_ostream &raw_ostream::changeColor(enum Colors colors, bool bold, bool bg) { … }
raw_ostream &raw_ostream::resetColor() { … }
raw_ostream &raw_ostream::reverseColor() { … }
void raw_ostream::anchor() { … }
void format_object_base::home() { … }
static int getFD(StringRef Filename, std::error_code &EC,
sys::fs::CreationDisposition Disp, sys::fs::FileAccess Access,
sys::fs::OpenFlags Flags) { … }
raw_fd_ostream::raw_fd_ostream(StringRef Filename, std::error_code &EC)
: … { … }
raw_fd_ostream::raw_fd_ostream(StringRef Filename, std::error_code &EC,
sys::fs::CreationDisposition Disp)
: … { … }
raw_fd_ostream::raw_fd_ostream(StringRef Filename, std::error_code &EC,
sys::fs::FileAccess Access)
: … { … }
raw_fd_ostream::raw_fd_ostream(StringRef Filename, std::error_code &EC,
sys::fs::OpenFlags Flags)
: … { … }
raw_fd_ostream::raw_fd_ostream(StringRef Filename, std::error_code &EC,
sys::fs::CreationDisposition Disp,
sys::fs::FileAccess Access,
sys::fs::OpenFlags Flags)
: … { … }
raw_fd_ostream::raw_fd_ostream(int fd, bool shouldClose, bool unbuffered,
OStreamKind K)
: … { … }
raw_fd_ostream::~raw_fd_ostream() { … }
#if defined(_WIN32)
static bool write_console_impl(int FD, StringRef Data) {
SmallVector<wchar_t, 256> WideText;
if (auto EC = sys::windows::UTF8ToUTF16(Data, WideText))
return false;
size_t MaxWriteSize = WideText.size();
if (!RunningWindows8OrGreater())
MaxWriteSize = 32767;
size_t WCharsWritten = 0;
do {
size_t WCharsToWrite =
std::min(MaxWriteSize, WideText.size() - WCharsWritten);
DWORD ActuallyWritten;
bool Success =
::WriteConsoleW((HANDLE)::_get_osfhandle(FD), &WideText[WCharsWritten],
WCharsToWrite, &ActuallyWritten,
nullptr);
if (!Success)
return false;
WCharsWritten += ActuallyWritten;
} while (WCharsWritten != WideText.size());
return true;
}
#endif
void raw_fd_ostream::write_impl(const char *Ptr, size_t Size) { … }
void raw_fd_ostream::close() { … }
uint64_t raw_fd_ostream::seek(uint64_t off) { … }
void raw_fd_ostream::pwrite_impl(const char *Ptr, size_t Size,
uint64_t Offset) { … }
size_t raw_fd_ostream::preferred_buffer_size() const { … }
bool raw_fd_ostream::is_displayed() const { … }
bool raw_fd_ostream::has_colors() const { … }
Expected<sys::fs::FileLocker> raw_fd_ostream::lock() { … }
Expected<sys::fs::FileLocker>
raw_fd_ostream::tryLockFor(Duration const& Timeout) { … }
void raw_fd_ostream::anchor() { … }
raw_fd_ostream &llvm::outs() { … }
raw_fd_ostream &llvm::errs() { … }
raw_ostream &llvm::nulls() { … }
raw_fd_stream::raw_fd_stream(StringRef Filename, std::error_code &EC)
: … { … }
raw_fd_stream::raw_fd_stream(int fd, bool shouldClose)
: … { … }
ssize_t raw_fd_stream::read(char *Ptr, size_t Size) { … }
bool raw_fd_stream::classof(const raw_ostream *OS) { … }
void raw_string_ostream::write_impl(const char *Ptr, size_t Size) { … }
uint64_t raw_svector_ostream::current_pos() const { … }
void raw_svector_ostream::write_impl(const char *Ptr, size_t Size) { … }
void raw_svector_ostream::pwrite_impl(const char *Ptr, size_t Size,
uint64_t Offset) { … }
bool raw_svector_ostream::classof(const raw_ostream *OS) { … }
raw_null_ostream::~raw_null_ostream() { … }
void raw_null_ostream::write_impl(const char *Ptr, size_t Size) { … }
uint64_t raw_null_ostream::current_pos() const { … }
void raw_null_ostream::pwrite_impl(const char *Ptr, size_t Size,
uint64_t Offset) { … }
void raw_pwrite_stream::anchor() { … }
void buffer_ostream::anchor() { … }
void buffer_unique_ostream::anchor() { … }
Error llvm::writeToOutput(StringRef OutputFileName,
std::function<Error(raw_ostream &)> Write) { … }