LLVM: lib/Support/raw_ostream.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

15#include "llvm/Config/config.h"

27#include

28#include

29#include

30#include <sys/stat.h>

31

32

33# include <fcntl.h>

34

35#if defined(HAVE_UNISTD_H)

36# include <unistd.h>

37#endif

38

39#if defined(__CYGWIN__)

40#include <io.h>

41#endif

42

43#if defined(_MSC_VER)

44#include <io.h>

45#ifndef STDIN_FILENO

46# define STDIN_FILENO 0

47#endif

48#ifndef STDOUT_FILENO

49# define STDOUT_FILENO 1

50#endif

51#ifndef STDERR_FILENO

52# define STDERR_FILENO 2

53#endif

54#endif

55

56#ifdef _WIN32

60#endif

61

62using namespace llvm;

63

65

66

67 assert(OutBufCur == OutBufStart &&

68 "raw_ostream destructor called with non-empty buffer!");

69

70 if (BufferMode == BufferKind::InternalBuffer)

71 delete [] OutBufStart;

72}

73

75#ifdef _WIN32

76

77

78

79 return (16 * 1024);

80#else

81

82 return BUFSIZ;

83#endif

84}

85

94

95void raw_ostream::SetBufferAndMode(char *BufferStart, size_t Size,

96 BufferKind Mode) {

97 assert(((Mode == BufferKind::Unbuffered && !BufferStart && Size == 0) ||

98 (Mode != BufferKind::Unbuffered && BufferStart && Size != 0)) &&

99 "stream must be unbuffered or have at least one byte");

100

101

103

104 if (BufferMode == BufferKind::InternalBuffer)

105 delete [] OutBufStart;

106 OutBufStart = BufferStart;

107 OutBufEnd = OutBufStart+Size;

108 OutBufCur = OutBufStart;

109 BufferMode = Mode;

110

111 assert(OutBufStart <= OutBufEnd && "Invalid size!");

112}

113

118

123

128

133

138

142 else

144 return *this;

145}

146

148 for (int Idx = 0; Idx < 16; ++Idx) {

149 *this << format("%02" PRIX32, UUID[Idx]);

150 if (Idx == 3 || Idx == 5 || Idx == 7 || Idx == 9)

151 *this << "-";

152 }

153 return *this;

154}

155

156

158 bool UseHexEscapes) {

159 for (unsigned char c : Str) {

160 switch (c) {

161 case '\\':

162 *this << '\\' << '\\';

163 break;

164 case '\t':

165 *this << '\\' << 't';

166 break;

167 case '\n':

168 *this << '\\' << 'n';

169 break;

170 case '"':

171 *this << '\\' << '"';

172 break;

173 default:

175 *this << c;

176 break;

177 }

178

179

180 if (UseHexEscapes) {

181 *this << '\\' << 'x';

182 *this << hexdigit((c >> 4) & 0xF);

183 *this << hexdigit((c >> 0) & 0xF);

184 } else {

185

186 *this << '\\';

187 *this << char('0' + ((c >> 6) & 7));

188 *this << char('0' + ((c >> 3) & 7));

189 *this << char('0' + ((c >> 0) & 7));

190 }

191 }

192 }

193

194 return *this;

195}

196

201

206

207void raw_ostream::flush_nonempty() {

208 assert(OutBufCur > OutBufStart && "Invalid call to flush_nonempty.");

209 size_t Length = OutBufCur - OutBufStart;

210 OutBufCur = OutBufStart;

211 write_impl(OutBufStart, Length);

212}

213

215

218 if (BufferMode == BufferKind::Unbuffered) {

219 write_impl(reinterpret_cast<char *>(&C), 1);

220 return *this;

221 }

222

225 }

226

227 flush_nonempty();

228 }

229

230 *OutBufCur++ = C;

231 return *this;

232}

233

235

238 if (BufferMode == BufferKind::Unbuffered) {

239 write_impl(Ptr, Size);

240 return *this;

241 }

242

245 }

246

247 size_t NumBytes = OutBufEnd - OutBufCur;

248

249

250

251

253 assert(NumBytes != 0 && "undefined behavior");

254 size_t BytesToWrite = Size - (Size % NumBytes);

255 write_impl(Ptr, BytesToWrite);

256 size_t BytesRemaining = Size - BytesToWrite;

257 if (BytesRemaining > size_t(OutBufEnd - OutBufCur)) {

258

259 return write(Ptr + BytesToWrite, BytesRemaining);

260 }

261 copy_to_buffer(Ptr + BytesToWrite, BytesRemaining);

262 return *this;

263 }

264

265

266

267 copy_to_buffer(Ptr, NumBytes);

268 flush_nonempty();

269 return write(Ptr + NumBytes, Size - NumBytes);

270 }

271

272 copy_to_buffer(Ptr, Size);

273

274 return *this;

275}

276

277void raw_ostream::copy_to_buffer(const char *Ptr, size_t Size) {

278 assert(Size <= size_t(OutBufEnd - OutBufCur) && "Buffer overrun!");

279

280

281

282 switch (Size) {

283 case 4: OutBufCur[3] = Ptr[3]; [[fallthrough]];

284 case 3: OutBufCur[2] = Ptr[2]; [[fallthrough]];

285 case 2: OutBufCur[1] = Ptr[1]; [[fallthrough]];

286 case 1: OutBufCur[0] = Ptr[0]; [[fallthrough]];

287 case 0: break;

288 default:

289 memcpy(OutBufCur, Ptr, Size);

290 break;

291 }

292

293 OutBufCur += Size;

294}

295

296

298

299

300 size_t NextBufferSize = 127;

301 size_t BufferBytesLeft = OutBufEnd - OutBufCur;

302 if (BufferBytesLeft > 3) {

303 size_t BytesUsed = Fmt.print(OutBufCur, BufferBytesLeft);

304

305

306 if (BytesUsed <= BufferBytesLeft) {

307 OutBufCur += BytesUsed;

308 return *this;

309 }

310

311

312

313 NextBufferSize = BytesUsed;

314 }

315

316

317

318

320

321 while (true) {

322 V.resize(NextBufferSize);

323

324

325 size_t BytesUsed = Fmt.print(V.data(), NextBufferSize);

326

327

328 if (BytesUsed <= NextBufferSize)

329 return write(V.data(), BytesUsed);

330

331

332 assert(BytesUsed > NextBufferSize && "Didn't grow buffer!?");

333 NextBufferSize = BytesUsed;

334 }

335}

336

338 Obj.format(*this);

339 return *this;

340}

341

343 unsigned LeftIndent = 0;

344 unsigned RightIndent = 0;

345 const ssize_t Difference = FS.Width - FS.Str.size();

346 if (Difference > 0) {

347 switch (FS.Justify) {

349 break;

351 RightIndent = Difference;

352 break;

354 LeftIndent = Difference;

355 break;

357 LeftIndent = Difference / 2;

358 RightIndent = Difference - LeftIndent;

359 break;

360 }

361 }

363 (*this) << FS.Str;

365 return *this;

366}

367

369 if (FN.Hex) {

371 if (FN.Upper && FN.HexPrefix)

373 else if (FN.Upper && !FN.HexPrefix)

375 else if (!FN.Upper && FN.HexPrefix)

377 else

380 } else {

384 if (Buffer.size() < FN.Width)

386 (*this) << Buffer;

387 }

388 return *this;

389}

390

392 if (FB.Bytes.empty())

393 return *this;

394

395 size_t LineIndex = 0;

396 auto Bytes = FB.Bytes;

397 const size_t Size = Bytes.size();

400 if (FB.FirstByteOffset) {

401

402

403

404 size_t Lines = Size / FB.NumPerLine;

405 uint64_t MaxOffset = *FB.FirstByteOffset + Lines * FB.NumPerLine;

406 unsigned Power = 0;

407 if (MaxOffset > 0)

409 OffsetWidth = std::max<uint64_t>(4, llvm::alignTo(Power, 4) / 4);

410 }

411

412

413 unsigned NumByteGroups =

414 alignTo(FB.NumPerLine, FB.ByteGroupSize) / FB.ByteGroupSize;

415 unsigned BlockCharWidth = FB.NumPerLine * 2 + NumByteGroups - 1;

416

417 while (!Bytes.empty()) {

418 indent(FB.IndentLevel);

419

420 if (FB.FirstByteOffset) {

423 *this << ": ";

424 }

425

426 auto Line = Bytes.take_front(FB.NumPerLine);

427

428 size_t CharsPrinted = 0;

429

430 for (size_t I = 0; I < Line.size(); ++I, CharsPrinted += 2) {

431 if (I && (I % FB.ByteGroupSize) == 0) {

432 ++CharsPrinted;

433 *this << " ";

434 }

436 }

437

438 if (FB.ASCII) {

439

440

441 assert(BlockCharWidth >= CharsPrinted);

442 indent(BlockCharWidth - CharsPrinted + 2);

443 *this << "|";

444

445

446 for (uint8_t Byte : Line) {

448 *this << static_cast(Byte);

449 else

450 *this << '.';

451 }

452 *this << '|';

453 }

454

455 Bytes = Bytes.drop_front(Line.size());

456 LineIndex += Line.size();

457 if (LineIndex < Size)

458 *this << '\n';

459 }

460 return *this;

461}

462

463template

465 static const char Chars[] = {C, C, C, C, C, C, C, C, C, C, C, C, C, C, C, C,

466 C, C, C, C, C, C, C, C, C, C, C, C, C, C, C, C,

467 C, C, C, C, C, C, C, C, C, C, C, C, C, C, C, C,

468 C, C, C, C, C, C, C, C, C, C, C, C, C, C, C, C,

469 C, C, C, C, C, C, C, C, C, C, C, C, C, C, C, C};

470

471

472 if (NumChars < std::size(Chars))

473 return OS.write(Chars, NumChars);

474

475 while (NumChars) {

476 unsigned NumToWrite = std::min(NumChars, (unsigned)std::size(Chars) - 1);

477 OS.write(Chars, NumToWrite);

478 NumChars -= NumToWrite;

479 }

480 return OS;

481}

482

483

487

488

492

493bool raw_ostream::prepare_colors() {

494

495 if (!ColorEnabled)

496 return false;

497

498

499

501 return false;

502

505

506 return true;

507}

508

510 if (!prepare_colors())

511 return *this;

512

513 const char *colorcode =

517 if (colorcode)

518 write(colorcode, strlen(colorcode));

519 return *this;

520}

521

523 if (!prepare_colors())

524 return *this;

525

527 write(colorcode, strlen(colorcode));

528 return *this;

529}

530

532 if (!prepare_colors())

533 return *this;

534

536 write(colorcode, strlen(colorcode));

537 return *this;

538}

539

540void raw_ostream::anchor() {}

541

542

543

544

545

546

549

550

551

552

553

558 "Cannot make a raw_ostream from a read-only descriptor!");

559

560

561

562 if (Filename == "-") {

563 EC = std::error_code();

564

567 }

568

569 int FD;

572 else

574 if (EC)

575 return -1;

576

577 return FD;

578}

579

583

587

592

597

603

604

605

608 : raw_pwrite_stream(unbuffered, K), FD(fd), ShouldClose(shouldClose) {

609 if (FD < 0 ) {

610 ShouldClose = false;

611 return;

612 }

613

615

616

617

618

619

620

621

623 ShouldClose = false;

624

625#ifdef _WIN32

626

627 IsWindowsConsole =

628 ::GetFileType((HANDLE)::_get_osfhandle(fd)) == FILE_TYPE_CHAR;

629#endif

630

631

632 off_t loc = ::lseek(FD, 0, SEEK_CUR);

634 std::error_code EC = status(FD, Status);

636#ifdef _WIN32

637

638 SupportsSeeking = !EC && IsRegularFile;

639#else

640 SupportsSeeking = !EC && loc != (off_t)-1;

641#endif

642 if (!SupportsSeeking)

643 pos = 0;

644 else

645 pos = static_cast<uint64_t>(loc);

646}

647

649 if (FD >= 0) {

651 if (ShouldClose) {

654 }

655 }

656

657#ifdef __MINGW32__

658

659

660

661

662 if (FD == 2) return;

663#endif

664

665

666

667

668

671 error().message());

672}

673

674#if defined(_WIN32)

675

676

677

678

679

680

681

682

683

684

685

686

687

688

689static bool write_console_impl(int FD, StringRef Data) {

691

692

693 if (auto EC = sys::windows::UTF8ToUTF16(Data, WideText))

694 return false;

695

696

697

698 size_t MaxWriteSize = WideText.size();

700 MaxWriteSize = 32767;

701

702 size_t WCharsWritten = 0;

703 do {

704 size_t WCharsToWrite =

705 std::min(MaxWriteSize, WideText.size() - WCharsWritten);

706 DWORD ActuallyWritten;

708 ::WriteConsoleW((HANDLE)::_get_osfhandle(FD), &WideText[WCharsWritten],

709 WCharsToWrite, &ActuallyWritten,

710 nullptr);

711

712

713

714

716 return false;

717

718 WCharsWritten += ActuallyWritten;

719 } while (WCharsWritten != WideText.size());

720 return true;

721}

722#endif

723

724void raw_fd_ostream::write_impl(const char *Ptr, size_t Size) {

725 if (TiedStream)

726 TiedStream->flush();

727

728 assert(FD >= 0 && "File already closed.");

730

731#if defined(_WIN32)

732

733

734 if (IsWindowsConsole)

735 if (write_console_impl(FD, StringRef(Ptr, Size)))

736 return;

737#endif

738

739

740

741

742 size_t MaxWriteSize = INT32_MAX;

743

744#if defined(__linux__)

745

746

747 MaxWriteSize = 1024 * 1024 * 1024;

748#endif

749

750 do {

751 size_t ChunkSize = std::min(Size, MaxWriteSize);

752 ssize_t ret = ::write(FD, Ptr, ChunkSize);

753

754 if (ret < 0) {

755

756

757

758

759

760

761

762

763 if (errno == EINTR || errno == EAGAIN

764#ifdef EWOULDBLOCK

765 || errno == EWOULDBLOCK

766#endif

767 )

768 continue;

769

770#ifdef _WIN32

771

772 DWORD WinLastError = GetLastError();

773 if (WinLastError == ERROR_BROKEN_PIPE ||

774 (WinLastError == ERROR_NO_DATA && errno == EINVAL)) {

775 llvm::sys::CallOneShotPipeSignalHandler();

776 errno = EPIPE;

777 }

778#endif

779

781 break;

782 }

783

784

785

786

787 Ptr += ret;

789 } while (Size > 0);

790}

791

794 ShouldClose = false;

798 FD = -1;

799}

800

802 assert(SupportsSeeking && "Stream does not support seeking!");

804#ifdef _WIN32

805 pos = ::_lseeki64(FD, off, SEEK_SET);

806#else

807 pos = ::lseek(FD, off, SEEK_SET);

808#endif

811 return pos;

812}

813

814void raw_fd_ostream::pwrite_impl(const char *Ptr, size_t Size,

820}

821

823#if defined(_WIN32)

824

825

826

827

828

829 if (IsWindowsConsole)

830 return 0;

832#elif defined(__MVS__)

833

834

836#else

837 assert(FD >= 0 && "File not yet open!");

838 struct stat statbuf;

839 if (fstat(FD, &statbuf) != 0)

840 return 0;

841

842

843

844

845 if (S_ISCHR(statbuf.st_mode) && is_displayed())

846 return 0;

847

848 return statbuf.st_blksize;

849#endif

850}

851

855

857 if (!HasColors)

859 return *HasColors;

860}

861

868

876

877void raw_fd_ostream::anchor() {}

878

879

880

881

882

884

885 std::error_code EC;

886

887

888 static std::error_code EC1 = enableAutoConversion(STDOUT_FILENO);

890 (void)EC1;

891

894 return S;

895}

896

898

899 static std::error_code EC = enableAutoConversion(STDERR_FILENO);

901 (void)EC;

902

903

905 return S;

906}

907

908

913

914

915

916

917

920 sys::fs::FA_Write | sys::fs::FA_Read,

921 sys::fs::OF_None),

923 if (EC)

924 return;

925

927 EC = std::make_error_code(std::errc::invalid_argument);

928}

929

932

934 assert(get_fd() >= 0 && "File already closed.");

936 if (Ret >= 0)

938 else

940 return Ret;

941}

942

946

947

948

949

950

951void raw_string_ostream::write_impl(const char *Ptr, size_t Size) {

952 OS.append(Ptr, Size);

953}

954

955

956

957

958

959uint64_t raw_svector_ostream::current_pos() const { return OS.size(); }

960

961void raw_svector_ostream::write_impl(const char *Ptr, size_t Size) {

962 OS.append(Ptr, Ptr + Size);

963}

964

965void raw_svector_ostream::pwrite_impl(const char *Ptr, size_t Size,

967 memcpy(OS.data() + Offset, Ptr, Size);

968}

969

973

974

975

976

977

979#ifndef NDEBUG

980

981

982

984#endif

985}

986

987void raw_null_ostream::write_impl(const char *Ptr, size_t Size) {

988}

989

990uint64_t raw_null_ostream::current_pos() const {

991 return 0;

992}

993

994void raw_null_ostream::pwrite_impl(const char *Ptr, size_t Size,

996

997void raw_pwrite_stream::anchor() {}

998

999void buffer_ostream::anchor() {}

1000

1001void buffer_unique_ostream::anchor() {}

1002

1005 if (OutputFileName == "-")

1007

1008 if (OutputFileName == "/dev/null") {

1010 return Write(Out);

1011 }

1012

1016 if (!Temp)

1018

1020

1022 if (Error DiscardError = Temp->discard())

1023 return joinErrors(std::move(E), std::move(DiscardError));

1024 return E;

1025 }

1027

1028 return Temp->keep(OutputFileName);

1029}

assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")

#define LLVM_UNLIKELY(EXPR)

Provides a library for accessing information about this process and other processes on the operating ...

std::pair< llvm::MachO::Target, std::string > UUID

bool empty() const

empty - Check if the array is empty.

Lightweight error class with error context and mandatory checking.

Tagged union holding either a T or a Error.

Error takeError()

Take ownership of the stored error.

This is a helper class used for format_hex() and format_decimal().

This is a helper class for left_justify, right_justify, and center_justify.

SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...

This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.

StringRef - Represent a constant reference to a string, i.e.

Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...

This is a helper class used for handling formatted output.

virtual void home()

Definition raw_ostream.cpp:547

unsigned print(char *Buffer, unsigned BufferSize) const

Format the object into the specified buffer.

A raw_ostream that writes to a file descriptor.

bool is_displayed() const override

This function determines if this stream is connected to a "tty" or "console" window.

Definition raw_ostream.cpp:852

bool has_error() const

Return the value of the flag in this raw_fd_ostream indicating whether an output error has been encou...

std::error_code error() const

void close()

Manually flush the stream and close the file.

Definition raw_ostream.cpp:792

void inc_pos(uint64_t Delta)

Expected< sys::fs::FileLocker > lock()

Locks the underlying file.

Definition raw_ostream.cpp:862

~raw_fd_ostream() override

Definition raw_ostream.cpp:648

bool has_colors() const override

This function determines if this stream is displayed and supports colors.

Definition raw_ostream.cpp:856

bool isRegularFile() const

uint64_t seek(uint64_t off)

Flushes the stream and repositions the underlying file descriptor position to the offset specified fr...

Definition raw_ostream.cpp:801

int get_fd() const

Return the file descriptor.

Expected< sys::fs::FileLocker > tryLockFor(Duration const &Timeout)

Tries to lock the underlying file within the specified period.

Definition raw_ostream.cpp:870

raw_fd_ostream(StringRef Filename, std::error_code &EC)

Open the specified file for writing.

Definition raw_ostream.cpp:580

void error_detected(std::error_code EC)

Set the flag indicating that an output error has been encountered.

static LLVM_ABI bool classof(const raw_ostream *OS)

Check if OS is a pointer of type raw_fd_stream*.

Definition raw_ostream.cpp:943

LLVM_ABI raw_fd_stream(StringRef Filename, std::error_code &EC)

Open the specified file for reading/writing/seeking.

Definition raw_ostream.cpp:918

LLVM_ABI ssize_t read(char *Ptr, size_t Size)

This reads the Size bytes into a buffer pointed by Ptr.

Definition raw_ostream.cpp:933

A raw_ostream that discards all output.

~raw_null_ostream() override

Definition raw_ostream.cpp:978

This class implements an extremely fast bulk output stream that can only output to a stream.

raw_ostream & write_zeros(unsigned NumZeros)

write_zeros - Insert 'NumZeros' nulls.

Definition raw_ostream.cpp:489

raw_ostream(bool unbuffered=false, OStreamKind K=OStreamKind::OK_OStream)

uint64_t tell() const

tell - Return the current offset with the file.

void SetBufferSize(size_t Size)

Set the stream to be buffered, using the specified buffer size.

virtual raw_ostream & changeColor(enum Colors Color, bool Bold=false, bool BG=false)

Changes the foreground color of text that will be output from this point forward.

Definition raw_ostream.cpp:509

raw_ostream & write_hex(unsigned long long N)

Output N in hexadecimal, without any prefix or padding.

Definition raw_ostream.cpp:134

virtual raw_ostream & resetColor()

Resets the colors to terminal defaults.

Definition raw_ostream.cpp:522

raw_ostream & write_uuid(const uuid_t UUID)

Definition raw_ostream.cpp:147

raw_ostream & operator<<(char C)

virtual ~raw_ostream()

Definition raw_ostream.cpp:64

raw_ostream & write_escaped(StringRef Str, bool UseHexEscapes=false)

Output Str, turning '\', '\t', ' ', '"', and anything that doesn't satisfy llvm::isPrint into an esca...

Definition raw_ostream.cpp:157

virtual raw_ostream & reverseColor()

Reverses the foreground and background colors.

Definition raw_ostream.cpp:531

virtual size_t preferred_buffer_size() const

Return an efficient buffer size for the underlying output mechanism.

Definition raw_ostream.cpp:74

raw_ostream & write(unsigned char C)

Definition raw_ostream.cpp:214

void SetUnbuffered()

Set the stream to be unbuffered.

virtual bool is_displayed() const

This function determines if this stream is connected to a "tty" or "console" window.

raw_ostream & indent(unsigned NumSpaces)

indent - Insert 'NumSpaces' spaces.

Definition raw_ostream.cpp:484

static constexpr Colors SAVEDCOLOR

uint8_t[16] uuid_t

Output a formatted UUID with dash separators.

virtual void enable_colors(bool enable)

size_t GetNumBytesInBuffer() const

OStreamKind get_kind() const

void SetBuffered()

Set the stream to be buffered, with an automatically determined buffer size.

Definition raw_ostream.cpp:86

raw_pwrite_stream(bool Unbuffered=false, OStreamKind K=OStreamKind::OK_OStream)

A raw_ostream that writes to an SmallVector or SmallString.

static bool classof(const raw_ostream *OS)

Definition raw_ostream.cpp:970

static LLVM_ABI std::error_code SafelyCloseFileDescriptor(int FD)

static LLVM_ABI bool ColorNeedsFlush()

Whether changing colors requires the output to be flushed.

static LLVM_ABI const char * ResetColor()

Resets the terminals colors, or returns an escape sequence to do so.

static LLVM_ABI bool FileDescriptorIsDisplayed(int fd)

This function determines if the given file descriptor is connected to a "tty" or "console" window.

static LLVM_ABI const char * OutputColor(char c, bool bold, bool bg)

This function returns the colorcode escape sequences.

static LLVM_ABI const char * OutputBold(bool bg)

Same as OutputColor, but only enables the bold attribute.

static LLVM_ABI bool FileDescriptorHasColors(int fd)

This function determines if the given file descriptor is displayd and supports colors.

static LLVM_ABI const char * OutputReverse()

This function returns the escape sequence to reverse forground and background colors.

RAII class that facilitates file locking.

static LLVM_ABI Expected< TempFile > create(const Twine &Model, unsigned Mode=all_read|all_write, OpenFlags ExtraFlags=OF_None)

This creates a temporary file with createUniqueFile and schedules it for deletion with sys::RemoveFil...

Represents the result of a call to sys::fs::status().

@ C

The default llvm calling convention, compatible with C.

std::error_code openFileForReadWrite(const Twine &Name, int &ResultFD, CreationDisposition Disp, OpenFlags Flags, unsigned Mode=0666)

Opens the file with the given name in a write-only or read-write mode, returning its open file descri...

LLVM_ABI std::error_code lockFile(int FD, LockKind Kind=LockKind::Exclusive)

Lock the file.

std::error_code openFileForWrite(const Twine &Name, int &ResultFD, CreationDisposition Disp=CD_CreateAlways, OpenFlags Flags=OF_None, unsigned Mode=0666)

Opens the file with the given name in a write-only or read-write mode, returning its open file descri...

LLVM_ABI std::error_code tryLockFile(int FD, std::chrono::milliseconds Timeout=std::chrono::milliseconds(0), LockKind Kind=LockKind::Exclusive)

Try to locks the file during the specified time.

LLVM_ABI std::error_code ChangeStdoutMode(fs::OpenFlags Flags)

This is an optimization pass for GlobalISel generic memory operations.

LLVM_ABI bool RunningWindows8OrGreater()

Determines if the program is running on Windows 8 or newer.

Error createFileError(const Twine &F, Error E)

Concatenate a source file path and/or name with an Error.

unsigned Log2_64_Ceil(uint64_t Value)

Return the ceil log base 2 of the specified value, 64 if the value is zero.

LLVM_ABI raw_fd_ostream & outs()

This returns a reference to a raw_fd_ostream for standard output.

Definition raw_ostream.cpp:883

LLVM_ABI void write_integer(raw_ostream &S, unsigned int N, size_t MinDigits, IntegerStyle Style)

Error joinErrors(Error E1, Error E2)

Concatenate errors.

char hexdigit(unsigned X, bool LowerCase=false)

hexdigit - Return the hexadecimal character for the given number X (which should be less than 16).

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

This helper creates an output stream and then passes it to Write.

Definition raw_ostream.cpp:1003

LLVM_ABI raw_ostream & nulls()

This returns a reference to a raw_ostream which simply discards output.

Definition raw_ostream.cpp:909

format_object< Ts... > format(const char *Fmt, const Ts &... Vals)

These are helper functions used to produce formatted output.

@ Success

The lock was released successfully.

@ Timeout

Reached timeout while waiting for the owner to release the lock.

LLVM_ABI raw_fd_ostream & errs()

This returns a reference to a raw_ostream for standard error.

Definition raw_ostream.cpp:897

FunctionAddr VTableAddr uintptr_t uintptr_t Data

uint64_t alignTo(uint64_t Size, Align A)

Returns a multiple of A needed to store Size bytes.

LLVM_ABI void write_hex(raw_ostream &S, uint64_t N, HexPrintStyle Style, std::optional< size_t > Width=std::nullopt)

LLVM_ABI void write_double(raw_ostream &S, double D, FloatStyle Style, std::optional< size_t > Precision=std::nullopt)

bool isPrint(char C)

Checks whether character C is printable.

LLVM_ABI Error write(MCStreamer &Out, ArrayRef< std::string > Inputs, OnCuIndexOverflow OverflowOptValue, Dwarf64StrOffsetsPromotion StrOffsetsOptValue)

LLVM_ABI Error errorCodeToError(std::error_code EC)

Helper for converting an std::error_code to a Error.

std::error_code errnoAsErrorCode()

Helper to get errno as an std::error_code.

LLVM_ABI void reportFatalUsageError(Error Err)

Report a fatal error that does not indicate a bug in LLVM.

static int getFD(StringRef Filename, std::error_code &EC, sys::fs::CreationDisposition Disp, sys::fs::FileAccess Access, sys::fs::OpenFlags Flags)

Definition raw_ostream.cpp:554

static raw_ostream & write_padding(raw_ostream &OS, unsigned NumChars)

Definition raw_ostream.cpp:464