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

74

76

77

78 assert(OutBufCur == OutBufStart &&

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

80

81 if (BufferMode == BufferKind::InternalBuffer)

82 delete [] OutBufStart;

83}

84

86#ifdef _WIN32

87

88

89

90 return (16 * 1024);

91#else

92

93 return BUFSIZ;

94#endif

95}

96

98

101 else

102

104}

105

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

107 BufferKind Mode) {

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

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

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

111

112

114

115 if (BufferMode == BufferKind::InternalBuffer)

116 delete [] OutBufStart;

117 OutBufStart = BufferStart;

118 OutBufEnd = OutBufStart+Size;

119 OutBufCur = OutBufStart;

120 BufferMode = Mode;

121

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

123}

124

127 return *this;

128}

129

132 return *this;

133}

134

137 return *this;

138}

139

142 return *this;

143}

144

147 return *this;

148}

149

153 else

155 return *this;

156}

157

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

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

162 *this << "-";

163 }

164 return *this;

165}

166

167

169 bool UseHexEscapes) {

170 for (unsigned char c : Str) {

171 switch (c) {

172 case '\\':

173 *this << '\\' << '\\';

174 break;

175 case '\t':

176 *this << '\\' << 't';

177 break;

178 case '\n':

179 *this << '\\' << 'n';

180 break;

181 case '"':

182 *this << '\\' << '"';

183 break;

184 default:

185 if (isPrint(c)) {

186 *this << c;

187 break;

188 }

189

190

191 if (UseHexEscapes) {

192 *this << '\\' << 'x';

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

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

195 } else {

196

197 *this << '\\';

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

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

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

201 }

202 }

203 }

204

205 return *this;

206}

207

210 return *this;

211}

212

215 return *this;

216}

217

218void raw_ostream::flush_nonempty() {

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

220 size_t Length = OutBufCur - OutBufStart;

221 OutBufCur = OutBufStart;

222 write_impl(OutBufStart, Length);

223}

224

226

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

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

231 return *this;

232 }

233

236 }

237

238 flush_nonempty();

239 }

240

241 *OutBufCur++ = C;

242 return *this;

243}

244

246

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

251 return *this;

252 }

253

256 }

257

258 size_t NumBytes = OutBufEnd - OutBufCur;

259

260

261

262

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

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

266 write_impl(Ptr, BytesToWrite);

267 size_t BytesRemaining = Size - BytesToWrite;

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

269

270 return write(Ptr + BytesToWrite, BytesRemaining);

271 }

272 copy_to_buffer(Ptr + BytesToWrite, BytesRemaining);

273 return *this;

274 }

275

276

277

278 copy_to_buffer(Ptr, NumBytes);

279 flush_nonempty();

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

281 }

282

283 copy_to_buffer(Ptr, Size);

284

285 return *this;

286}

287

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

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

290

291

292

293 switch (Size) {

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

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

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

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

298 case 0: break;

299 default:

300 memcpy(OutBufCur, Ptr, Size);

301 break;

302 }

303

304 OutBufCur += Size;

305}

306

307

309

310

311 size_t NextBufferSize = 127;

312 size_t BufferBytesLeft = OutBufEnd - OutBufCur;

313 if (BufferBytesLeft > 3) {

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

315

316

317 if (BytesUsed <= BufferBytesLeft) {

318 OutBufCur += BytesUsed;

319 return *this;

320 }

321

322

323

324 NextBufferSize = BytesUsed;

325 }

326

327

328

329

331

332 while (true) {

333 V.resize(NextBufferSize);

334

335

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

337

338

339 if (BytesUsed <= NextBufferSize)

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

341

342

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

344 NextBufferSize = BytesUsed;

345 }

346}

347

350 return *this;

351}

352

354 unsigned LeftIndent = 0;

355 unsigned RightIndent = 0;

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

357 if (Difference > 0) {

358 switch (FS.Justify) {

360 break;

362 RightIndent = Difference;

363 break;

365 LeftIndent = Difference;

366 break;

368 LeftIndent = Difference / 2;

369 RightIndent = Difference - LeftIndent;

370 break;

371 }

372 }

374 (*this) << FS.Str;

376 return *this;

377}

378

380 if (FN.Hex) {

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

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

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

388 else

391 } else {

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

397 (*this) << Buffer;

398 }

399 return *this;

400}

401

403 if (FB.Bytes.empty())

404 return *this;

405

406 size_t LineIndex = 0;

407 auto Bytes = FB.Bytes;

408 const size_t Size = Bytes.size();

411 if (FB.FirstByteOffset) {

412

413

414

415 size_t Lines = Size / FB.NumPerLine;

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

417 unsigned Power = 0;

418 if (MaxOffset > 0)

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

421 }

422

423

424 unsigned NumByteGroups =

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

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

427

428 while (!Bytes.empty()) {

429 indent(FB.IndentLevel);

430

431 if (FB.FirstByteOffset) {

434 *this << ": ";

435 }

436

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

438

439 size_t CharsPrinted = 0;

440

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

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

443 ++CharsPrinted;

444 *this << " ";

445 }

447 }

448

449 if (FB.ASCII) {

450

451

452 assert(BlockCharWidth >= CharsPrinted);

453 indent(BlockCharWidth - CharsPrinted + 2);

454 *this << "|";

455

456

457 for (uint8_t Byte : Line) {

458 if (isPrint(Byte))

459 *this << static_cast(Byte);

460 else

461 *this << '.';

462 }

463 *this << '|';

464 }

465

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

467 LineIndex += Line.size();

468 if (LineIndex < Size)

469 *this << '\n';

470 }

471 return *this;

472}

473

474template

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

477 C, C, C, C, C, C, C, C, C, C, C, C, C, C, C, C,

478 C, C, C, C, C, C, C, C, C, C, C, C, C, C, C, C,

479 C, C, C, C, C, C, C, C, C, C, C, C, C, C, C, C,

480 C, C, C, C, C, C, C, C, C, C, C, C, C, C, C, C};

481

482

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

484 return OS.write(Chars, NumChars);

485

486 while (NumChars) {

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

488 OS.write(Chars, NumToWrite);

489 NumChars -= NumToWrite;

490 }

491 return OS;

492}

493

494

496 return write_padding<' '>(*this, NumSpaces);

497}

498

499

501 return write_padding<'\0'>(*this, NumZeros);

502}

503

504bool raw_ostream::prepare_colors() {

505

506 if (!ColorEnabled)

507 return false;

508

509

510

512 return false;

513

516

517 return true;

518}

519

521 if (!prepare_colors())

522 return *this;

523

524 const char *colorcode =

528 if (colorcode)

529 write(colorcode, strlen(colorcode));

530 return *this;

531}

532

534 if (!prepare_colors())

535 return *this;

536

538 write(colorcode, strlen(colorcode));

539 return *this;

540}

541

543 if (!prepare_colors())

544 return *this;

545

547 write(colorcode, strlen(colorcode));

548 return *this;

549}

550

551void raw_ostream::anchor() {}

552

553

554

555

556

557

559}

560

561

562

563

564

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

570

571

572

573 if (Filename == "-") {

574 EC = std::error_code();

575

577 return STDOUT_FILENO;

578 }

579

580 int FD;

583 else

585 if (EC)

586 return -1;

587

588 return FD;

589}

590

592 : raw_fd_ostream(Filename, EC, sys::fs::CD_CreateAlways, sys::fs::FA_Write,

593 sys::fs::OF_None) {}

594

597 : raw_fd_ostream(Filename, EC, Disp, sys::fs::FA_Write, sys::fs::OF_None) {}

598

602 sys::fs::OF_None) {}

603

606 : raw_fd_ostream(Filename, EC, sys::fs::CD_CreateAlways, sys::fs::FA_Write,

607 Flags) {}

608

614

615

616

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

620 if (FD < 0 ) {

621 ShouldClose = false;

622 return;

623 }

624

626

627

628

629

630

631

632

633 if (FD <= STDERR_FILENO)

634 ShouldClose = false;

635

636#ifdef _WIN32

637

638 IsWindowsConsole =

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

640#endif

641

642

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

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

647#ifdef _WIN32

648

649 SupportsSeeking = !EC && IsRegularFile;

650#else

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

652#endif

653 if (!SupportsSeeking)

654 pos = 0;

655 else

656 pos = static_cast<uint64_t>(loc);

657}

658

660 if (FD >= 0) {

662 if (ShouldClose) {

665 }

666 }

667

668#ifdef __MINGW32__

669

670

671

672

673 if (FD == 2) return;

674#endif

675

676

677

678

679

682 error().message(),

683 false);

684}

685

686#if defined(_WIN32)

687

688

689

690

691

692

693

694

695

696

697

698

699

700

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

703

704

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

706 return false;

707

708

709

710 size_t MaxWriteSize = WideText.size();

712 MaxWriteSize = 32767;

713

714 size_t WCharsWritten = 0;

715 do {

716 size_t WCharsToWrite =

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

718 DWORD ActuallyWritten;

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

721 WCharsToWrite, &ActuallyWritten,

722 nullptr);

723

724

725

726

728 return false;

729

730 WCharsWritten += ActuallyWritten;

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

732 return true;

733}

734#endif

735

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

737 if (TiedStream)

738 TiedStream->flush();

739

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

742

743#if defined(_WIN32)

744

745

746 if (IsWindowsConsole)

748 return;

749#endif

750

751

752

753

754 size_t MaxWriteSize = INT32_MAX;

755

756#if defined(__linux__)

757

758

759 MaxWriteSize = 1024 * 1024 * 1024;

760#endif

761

762 do {

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

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

765

766 if (ret < 0) {

767

768

769

770

771

772

773

774

775 if (errno == EINTR || errno == EAGAIN

776#ifdef EWOULDBLOCK

777 || errno == EWOULDBLOCK

778#endif

779 )

780 continue;

781

782#ifdef _WIN32

783

784 DWORD WinLastError = GetLastError();

785 if (WinLastError == ERROR_BROKEN_PIPE ||

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

787 llvm::sys::CallOneShotPipeSignalHandler();

788 errno = EPIPE;

789 }

790#endif

791

793 break;

794 }

795

796

797

798

799 Ptr += ret;

801 } while (Size > 0);

802}

803

806 ShouldClose = false;

810 FD = -1;

811}

812

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

816#ifdef _WIN32

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

818#else

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

820#endif

823 return pos;

824}

825

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

832}

833

834size_t raw_fd_ostream::preferred_buffer_size() const {

835#if defined(_WIN32)

836

837

838

839

840

841 if (IsWindowsConsole)

842 return 0;

844#elif defined(__MVS__)

845

846

848#else

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

850 struct stat statbuf;

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

852 return 0;

853

854

855

856

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

858 return 0;

859

860 return statbuf.st_blksize;

861#endif

862}

863

866}

867

869 if (!HasColors)

871 return *HasColors;

872}

873

876 if (!EC)

879}

880

884 if (!EC)

887}

888

889void raw_fd_ostream::anchor() {}

890

891

892

893

894

896

897 std::error_code EC;

898#ifdef __MVS__

899 EC = enablezOSAutoConversion(STDOUT_FILENO);

901#endif

904 return S;

905}

906

908

909#ifdef __MVS__

910 std::error_code EC = enablezOSAutoConversion(STDERR_FILENO);

912#endif

914 return S;

915}

916

917

920 return S;

921}

922

923

924

925

926

929 sys::fs::FA_Write | sys::fs::FA_Read,

930 sys::fs::OF_None),

932 if (EC)

933 return;

934

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

937}

938

941

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

945 if (Ret >= 0)

947 else

949 return Ret;

950}

951

954}

955

956

957

958

959

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

962}

963

964

965

966

967

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

969

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

972}

973

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

977}

978

981}

982

983

984

985

986

988#ifndef NDEBUG

989

990

991

993#endif

994}

995

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

997}

998

999uint64_t raw_null_ostream::current_pos() const {

1000 return 0;

1001}

1002

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

1005

1006void raw_pwrite_stream::anchor() {}

1007

1008void buffer_ostream::anchor() {}

1009

1010void buffer_unique_ostream::anchor() {}

1011

1014 if (OutputFileName == "-")

1016

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

1019 return Write(Out);

1020 }

1021

1025 if (!Temp)

1027

1029

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

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

1033 return E;

1034 }

1036

1037 return Temp->keep(OutputFileName);

1038}

static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")

#define LLVM_UNLIKELY(EXPR)

Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx

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

static cl::opt< RegAllocEvictionAdvisorAnalysis::AdvisorMode > Mode("regalloc-enable-advisor", cl::Hidden, cl::init(RegAllocEvictionAdvisorAnalysis::AdvisorMode::Default), cl::desc("Enable regalloc advisor mode"), cl::values(clEnumValN(RegAllocEvictionAdvisorAnalysis::AdvisorMode::Default, "default", "Default"), clEnumValN(RegAllocEvictionAdvisorAnalysis::AdvisorMode::Release, "release", "precompiled"), clEnumValN(RegAllocEvictionAdvisorAnalysis::AdvisorMode::Development, "development", "for training")))

assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())

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

bool empty() const

empty - Check if the array is empty.

std::chrono::milliseconds getDuration() const

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.

unsigned print(char *Buffer, unsigned BufferSize) const

Format the object into the specified buffer.

void format(raw_ostream &S) const

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.

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.

void inc_pos(uint64_t Delta)

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

Locks the underlying file.

~raw_fd_ostream() override

bool has_colors() const override

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

bool isRegularFile() const

uint64_t seek(uint64_t off)

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

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.

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

Open the specified file for writing.

void error_detected(std::error_code EC)

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

static bool classof(const raw_ostream *OS)

Check if OS is a pointer of type raw_fd_stream*.

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

Open the specified file for reading/writing/seeking.

ssize_t read(char *Ptr, size_t Size)

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

A raw_ostream that discards all output.

~raw_null_ostream() override

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

static constexpr Colors YELLOW

raw_ostream & write_zeros(unsigned NumZeros)

write_zeros - Insert 'NumZeros' nulls.

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.

static constexpr Colors CYAN

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.

raw_ostream & write_hex(unsigned long long N)

Output N in hexadecimal, without any prefix or padding.

virtual raw_ostream & resetColor()

Resets the colors to terminal defaults.

raw_ostream & write_uuid(const uuid_t UUID)

raw_ostream & operator<<(char C)

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

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

virtual raw_ostream & reverseColor()

Reverses the foreground and background colors.

static constexpr Colors BLUE

virtual size_t preferred_buffer_size() const

Return an efficient buffer size for the underlying output mechanism.

raw_ostream & write(unsigned char C)

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.

static constexpr Colors RESET

uint8_t[16] uuid_t

Output a formatted UUID with dash separators.

static constexpr Colors MAGENTA

virtual void enable_colors(bool enable)

static constexpr Colors SAVEDCOLOR

size_t GetNumBytesInBuffer() const

static constexpr Colors BLACK

static constexpr Colors GREEN

static constexpr Colors RED

OStreamKind get_kind() const

void SetBuffered()

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

static constexpr Colors WHITE

An abstract base class for streams implementations that also support a pwrite operation.

A raw_ostream that writes to an SmallVector or SmallString.

static bool classof(const raw_ostream *OS)

static std::error_code SafelyCloseFileDescriptor(int FD)

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

This function returns the colorcode escape sequences.

static bool FileDescriptorIsDisplayed(int fd)

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

static const char * OutputBold(bool bg)

Same as OutputColor, but only enables the bold attribute.

static bool FileDescriptorHasColors(int fd)

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

static const char * OutputReverse()

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

static const char * ResetColor()

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

static bool ColorNeedsFlush()

Whether changing colors requires the output to be flushed.

RAII class that facilitates file locking.

static 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...

std::error_code tryLockFile(int FD, std::chrono::milliseconds Timeout=std::chrono::milliseconds(0))

Try to locks the file during the specified time.

std::error_code lockFile(int FD)

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...

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

This is an optimization pass for GlobalISel generic memory operations.

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.

raw_fd_ostream & outs()

This returns a reference to a raw_fd_ostream for standard output.

bool RunningWindows8OrGreater()

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

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

Error joinErrors(Error E1, Error E2)

Concatenate errors.

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

void report_fatal_error(Error Err, bool gen_crash_diag=true)

Report a serious error, calling any installed error handler.

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

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

raw_ostream & nulls()

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

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

These are helper functions used to produce formatted output.

raw_fd_ostream & errs()

This returns a reference to a raw_ostream for standard error.

uint64_t alignTo(uint64_t Size, Align A)

Returns a multiple of A needed to store Size bytes.

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

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

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.

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

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