LLVM  14.0.0git
raw_ostream.cpp
Go to the documentation of this file.
1 //===--- raw_ostream.cpp - Implement the raw_ostream classes --------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This implements support for bulk buffered stream output.
10 //
11 //===----------------------------------------------------------------------===//
12 
14 #include "llvm/ADT/STLExtras.h"
15 #include "llvm/ADT/StringExtras.h"
16 #include "llvm/Config/config.h"
17 #include "llvm/Support/Compiler.h"
18 #include "llvm/Support/Duration.h"
21 #include "llvm/Support/Format.h"
25 #include "llvm/Support/Process.h"
26 #include "llvm/Support/Program.h"
27 #include <algorithm>
28 #include <cerrno>
29 #include <cstdio>
30 #include <sys/stat.h>
31 
32 // <fcntl.h> may provide O_BINARY.
33 #if defined(HAVE_FCNTL_H)
34 # include <fcntl.h>
35 #endif
36 
37 #if defined(HAVE_UNISTD_H)
38 # include <unistd.h>
39 #endif
40 
41 #if defined(__CYGWIN__)
42 #include <io.h>
43 #endif
44 
45 #if defined(_MSC_VER)
46 #include <io.h>
47 #ifndef STDIN_FILENO
48 # define STDIN_FILENO 0
49 #endif
50 #ifndef STDOUT_FILENO
51 # define STDOUT_FILENO 1
52 #endif
53 #ifndef STDERR_FILENO
54 # define STDERR_FILENO 2
55 #endif
56 #endif
57 
58 #ifdef _WIN32
61 #endif
62 
63 using namespace llvm;
64 
75 
77  // raw_ostream's subclasses should take care to flush the buffer
78  // in their destructors.
79  assert(OutBufCur == OutBufStart &&
80  "raw_ostream destructor called with non-empty buffer!");
81 
82  if (BufferMode == BufferKind::InternalBuffer)
83  delete [] OutBufStart;
84 }
85 
87  // BUFSIZ is intended to be a reasonable default.
88  return BUFSIZ;
89 }
90 
92  // Ask the subclass to determine an appropriate buffer size.
93  if (size_t Size = preferred_buffer_size())
95  else
96  // It may return 0, meaning this stream should be unbuffered.
97  SetUnbuffered();
98 }
99 
100 void raw_ostream::SetBufferAndMode(char *BufferStart, size_t Size,
101  BufferKind Mode) {
102  assert(((Mode == BufferKind::Unbuffered && !BufferStart && Size == 0) ||
103  (Mode != BufferKind::Unbuffered && BufferStart && Size != 0)) &&
104  "stream must be unbuffered or have at least one byte");
105  // Make sure the current buffer is free of content (we can't flush here; the
106  // child buffer management logic will be in write_impl).
107  assert(GetNumBytesInBuffer() == 0 && "Current buffer is non-empty!");
108 
109  if (BufferMode == BufferKind::InternalBuffer)
110  delete [] OutBufStart;
111  OutBufStart = BufferStart;
112  OutBufEnd = OutBufStart+Size;
113  OutBufCur = OutBufStart;
114  BufferMode = Mode;
115 
116  assert(OutBufStart <= OutBufEnd && "Invalid size!");
117 }
118 
120  write_integer(*this, static_cast<uint64_t>(N), 0, IntegerStyle::Integer);
121  return *this;
122 }
123 
125  write_integer(*this, static_cast<int64_t>(N), 0, IntegerStyle::Integer);
126  return *this;
127 }
128 
129 raw_ostream &raw_ostream::operator<<(unsigned long long N) {
130  write_integer(*this, static_cast<uint64_t>(N), 0, IntegerStyle::Integer);
131  return *this;
132 }
133 
135  write_integer(*this, static_cast<int64_t>(N), 0, IntegerStyle::Integer);
136  return *this;
137 }
138 
139 raw_ostream &raw_ostream::write_hex(unsigned long long N) {
141  return *this;
142 }
143 
145  if (C == Colors::RESET)
146  resetColor();
147  else
148  changeColor(C);
149  return *this;
150 }
151 
153  for (int Idx = 0; Idx < 16; ++Idx) {
154  *this << format("%02" PRIX32, UUID[Idx]);
155  if (Idx == 3 || Idx == 5 || Idx == 7 || Idx == 9)
156  *this << "-";
157  }
158  return *this;
159 }
160 
161 
163  bool UseHexEscapes) {
164  for (unsigned char c : Str) {
165  switch (c) {
166  case '\\':
167  *this << '\\' << '\\';
168  break;
169  case '\t':
170  *this << '\\' << 't';
171  break;
172  case '\n':
173  *this << '\\' << 'n';
174  break;
175  case '"':
176  *this << '\\' << '"';
177  break;
178  default:
179  if (isPrint(c)) {
180  *this << c;
181  break;
182  }
183 
184  // Write out the escaped representation.
185  if (UseHexEscapes) {
186  *this << '\\' << 'x';
187  *this << hexdigit((c >> 4) & 0xF);
188  *this << hexdigit((c >> 0) & 0xF);
189  } else {
190  // Always use a full 3-character octal escape.
191  *this << '\\';
192  *this << char('0' + ((c >> 6) & 7));
193  *this << char('0' + ((c >> 3) & 7));
194  *this << char('0' + ((c >> 0) & 7));
195  }
196  }
197  }
198 
199  return *this;
200 }
201 
203  llvm::write_hex(*this, (uintptr_t)P, HexPrintStyle::PrefixLower);
204  return *this;
205 }
206 
209  return *this;
210 }
211 
212 void raw_ostream::flush_nonempty() {
213  assert(OutBufCur > OutBufStart && "Invalid call to flush_nonempty.");
214  size_t Length = OutBufCur - OutBufStart;
215  OutBufCur = OutBufStart;
216  flush_tied_then_write(OutBufStart, Length);
217 }
218 
220  // Group exceptional cases into a single branch.
221  if (LLVM_UNLIKELY(OutBufCur >= OutBufEnd)) {
222  if (LLVM_UNLIKELY(!OutBufStart)) {
223  if (BufferMode == BufferKind::Unbuffered) {
224  flush_tied_then_write(reinterpret_cast<char *>(&C), 1);
225  return *this;
226  }
227  // Set up a buffer and start over.
228  SetBuffered();
229  return write(C);
230  }
231 
232  flush_nonempty();
233  }
234 
235  *OutBufCur++ = C;
236  return *this;
237 }
238 
239 raw_ostream &raw_ostream::write(const char *Ptr, size_t Size) {
240  // Group exceptional cases into a single branch.
241  if (LLVM_UNLIKELY(size_t(OutBufEnd - OutBufCur) < Size)) {
242  if (LLVM_UNLIKELY(!OutBufStart)) {
243  if (BufferMode == BufferKind::Unbuffered) {
244  flush_tied_then_write(Ptr, Size);
245  return *this;
246  }
247  // Set up a buffer and start over.
248  SetBuffered();
249  return write(Ptr, Size);
250  }
251 
252  size_t NumBytes = OutBufEnd - OutBufCur;
253 
254  // If the buffer is empty at this point we have a string that is larger
255  // than the buffer. Directly write the chunk that is a multiple of the
256  // preferred buffer size and put the remainder in the buffer.
257  if (LLVM_UNLIKELY(OutBufCur == OutBufStart)) {
258  assert(NumBytes != 0 && "undefined behavior");
259  size_t BytesToWrite = Size - (Size % NumBytes);
260  flush_tied_then_write(Ptr, BytesToWrite);
261  size_t BytesRemaining = Size - BytesToWrite;
262  if (BytesRemaining > size_t(OutBufEnd - OutBufCur)) {
263  // Too much left over to copy into our buffer.
264  return write(Ptr + BytesToWrite, BytesRemaining);
265  }
266  copy_to_buffer(Ptr + BytesToWrite, BytesRemaining);
267  return *this;
268  }
269 
270  // We don't have enough space in the buffer to fit the string in. Insert as
271  // much as possible, flush and start over with the remainder.
272  copy_to_buffer(Ptr, NumBytes);
273  flush_nonempty();
274  return write(Ptr + NumBytes, Size - NumBytes);
275  }
276 
277  copy_to_buffer(Ptr, Size);
278 
279  return *this;
280 }
281 
282 void raw_ostream::copy_to_buffer(const char *Ptr, size_t Size) {
283  assert(Size <= size_t(OutBufEnd - OutBufCur) && "Buffer overrun!");
284 
285  // Handle short strings specially, memcpy isn't very good at very short
286  // strings.
287  switch (Size) {
288  case 4: OutBufCur[3] = Ptr[3]; LLVM_FALLTHROUGH;
289  case 3: OutBufCur[2] = Ptr[2]; LLVM_FALLTHROUGH;
290  case 2: OutBufCur[1] = Ptr[1]; LLVM_FALLTHROUGH;
291  case 1: OutBufCur[0] = Ptr[0]; LLVM_FALLTHROUGH;
292  case 0: break;
293  default:
294  memcpy(OutBufCur, Ptr, Size);
295  break;
296  }
297 
298  OutBufCur += Size;
299 }
300 
301 void raw_ostream::flush_tied_then_write(const char *Ptr, size_t Size) {
302  if (TiedStream)
303  TiedStream->flush();
304  write_impl(Ptr, Size);
305 }
306 
307 // Formatted output.
309  // If we have more than a few bytes left in our output buffer, try
310  // formatting directly onto its end.
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  // Common case is that we have plenty of space.
317  if (BytesUsed <= BufferBytesLeft) {
318  OutBufCur += BytesUsed;
319  return *this;
320  }
321 
322  // Otherwise, we overflowed and the return value tells us the size to try
323  // again with.
324  NextBufferSize = BytesUsed;
325  }
326 
327  // If we got here, we didn't have enough space in the output buffer for the
328  // string. Try printing into a SmallVector that is resized to have enough
329  // space. Iterate until we win.
331 
332  while (true) {
333  V.resize(NextBufferSize);
334 
335  // Try formatting into the SmallVector.
336  size_t BytesUsed = Fmt.print(V.data(), NextBufferSize);
337 
338  // If BytesUsed fit into the vector, we win.
339  if (BytesUsed <= NextBufferSize)
340  return write(V.data(), BytesUsed);
341 
342  // Otherwise, try again with a new size.
343  assert(BytesUsed > NextBufferSize && "Didn't grow buffer!?");
344  NextBufferSize = BytesUsed;
345  }
346 }
347 
349  Obj.format(*this);
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  }
373  indent(LeftIndent);
374  (*this) << FS.Str;
375  indent(RightIndent);
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
390  llvm::write_hex(*this, FN.HexValue, Style, FN.Width);
391  } else {
392  llvm::SmallString<16> Buffer;
393  llvm::raw_svector_ostream Stream(Buffer);
394  llvm::write_integer(Stream, FN.DecValue, 0, IntegerStyle::Integer);
395  if (Buffer.size() < FN.Width)
396  indent(FN.Width - Buffer.size());
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();
410  uint64_t OffsetWidth = 0;
411  if (FB.FirstByteOffset.hasValue()) {
412  // Figure out how many nibbles are needed to print the largest offset
413  // represented by this data set, so that we can align the offset field
414  // to the right width.
415  size_t Lines = Size / FB.NumPerLine;
416  uint64_t MaxOffset = *FB.FirstByteOffset + Lines * FB.NumPerLine;
417  unsigned Power = 0;
418  if (MaxOffset > 0)
419  Power = llvm::Log2_64_Ceil(MaxOffset);
420  OffsetWidth = std::max<uint64_t>(4, llvm::alignTo(Power, 4) / 4);
421  }
422 
423  // The width of a block of data including all spaces for group separators.
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.hasValue()) {
432  uint64_t Offset = FB.FirstByteOffset.getValue();
433  llvm::write_hex(*this, Offset + LineIndex, HPS, OffsetWidth);
434  *this << ": ";
435  }
436 
437  auto Line = Bytes.take_front(FB.NumPerLine);
438 
439  size_t CharsPrinted = 0;
440  // Print the hex bytes for this line in groups
441  for (size_t I = 0; I < Line.size(); ++I, CharsPrinted += 2) {
442  if (I && (I % FB.ByteGroupSize) == 0) {
443  ++CharsPrinted;
444  *this << " ";
445  }
446  llvm::write_hex(*this, Line[I], HPS, 2);
447  }
448 
449  if (FB.ASCII) {
450  // Print any spaces needed for any bytes that we didn't print on this
451  // line so that the ASCII bytes are correctly aligned.
452  assert(BlockCharWidth >= CharsPrinted);
453  indent(BlockCharWidth - CharsPrinted + 2);
454  *this << "|";
455 
456  // Print the ASCII char values for each byte on this line
457  for (uint8_t Byte : Line) {
458  if (isPrint(Byte))
459  *this << static_cast<char>(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 
474 template <char C>
475 static raw_ostream &write_padding(raw_ostream &OS, unsigned NumChars) {
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  // Usually the indentation is small, handle it with a fastpath.
483  if (NumChars < array_lengthof(Chars))
484  return OS.write(Chars, NumChars);
485 
486  while (NumChars) {
487  unsigned NumToWrite = std::min(NumChars,
488  (unsigned)array_lengthof(Chars)-1);
489  OS.write(Chars, NumToWrite);
490  NumChars -= NumToWrite;
491  }
492  return OS;
493 }
494 
495 /// indent - Insert 'NumSpaces' spaces.
496 raw_ostream &raw_ostream::indent(unsigned NumSpaces) {
497  return write_padding<' '>(*this, NumSpaces);
498 }
499 
500 /// write_zeros - Insert 'NumZeros' nulls.
502  return write_padding<'\0'>(*this, NumZeros);
503 }
504 
505 bool raw_ostream::prepare_colors() {
506  // Colors were explicitly disabled.
507  if (!ColorEnabled)
508  return false;
509 
510  // Colors require changing the terminal but this stream is not going to a
511  // terminal.
513  return false;
514 
516  flush();
517 
518  return true;
519 }
520 
521 raw_ostream &raw_ostream::changeColor(enum Colors colors, bool bold, bool bg) {
522  if (!prepare_colors())
523  return *this;
524 
525  const char *colorcode =
526  (colors == SAVEDCOLOR)
528  : sys::Process::OutputColor(static_cast<char>(colors), bold, bg);
529  if (colorcode)
530  write(colorcode, strlen(colorcode));
531  return *this;
532 }
533 
535  if (!prepare_colors())
536  return *this;
537 
538  if (const char *colorcode = sys::Process::ResetColor())
539  write(colorcode, strlen(colorcode));
540  return *this;
541 }
542 
544  if (!prepare_colors())
545  return *this;
546 
547  if (const char *colorcode = sys::Process::OutputReverse())
548  write(colorcode, strlen(colorcode));
549  return *this;
550 }
551 
552 void raw_ostream::anchor() {}
553 
554 //===----------------------------------------------------------------------===//
555 // Formatted Output
556 //===----------------------------------------------------------------------===//
557 
558 // Out of line virtual method.
560 }
561 
562 //===----------------------------------------------------------------------===//
563 // raw_fd_ostream
564 //===----------------------------------------------------------------------===//
565 
566 static int getFD(StringRef Filename, std::error_code &EC,
568  sys::fs::OpenFlags Flags) {
569  assert((Access & sys::fs::FA_Write) &&
570  "Cannot make a raw_ostream from a read-only descriptor!");
571 
572  // Handle "-" as stdout. Note that when we do this, we consider ourself
573  // the owner of stdout and may set the "binary" flag globally based on Flags.
574  if (Filename == "-") {
575  EC = std::error_code();
576  // Change stdout's text/binary mode based on the Flags.
577  sys::ChangeStdoutMode(Flags);
578  return STDOUT_FILENO;
579  }
580 
581  int FD;
582  if (Access & sys::fs::FA_Read)
583  EC = sys::fs::openFileForReadWrite(Filename, FD, Disp, Flags);
584  else
585  EC = sys::fs::openFileForWrite(Filename, FD, Disp, Flags);
586  if (EC)
587  return -1;
588 
589  return FD;
590 }
591 
592 raw_fd_ostream::raw_fd_ostream(StringRef Filename, std::error_code &EC)
593  : raw_fd_ostream(Filename, EC, sys::fs::CD_CreateAlways, sys::fs::FA_Write,
594  sys::fs::OF_None) {}
595 
596 raw_fd_ostream::raw_fd_ostream(StringRef Filename, std::error_code &EC,
598  : raw_fd_ostream(Filename, EC, Disp, sys::fs::FA_Write, sys::fs::OF_None) {}
599 
600 raw_fd_ostream::raw_fd_ostream(StringRef Filename, std::error_code &EC,
601  sys::fs::FileAccess Access)
602  : raw_fd_ostream(Filename, EC, sys::fs::CD_CreateAlways, Access,
603  sys::fs::OF_None) {}
604 
605 raw_fd_ostream::raw_fd_ostream(StringRef Filename, std::error_code &EC,
606  sys::fs::OpenFlags Flags)
607  : raw_fd_ostream(Filename, EC, sys::fs::CD_CreateAlways, sys::fs::FA_Write,
608  Flags) {}
609 
610 raw_fd_ostream::raw_fd_ostream(StringRef Filename, std::error_code &EC,
612  sys::fs::FileAccess Access,
613  sys::fs::OpenFlags Flags)
614  : raw_fd_ostream(getFD(Filename, EC, Disp, Access, Flags), true) {}
615 
616 /// FD is the file descriptor that this writes to. If ShouldClose is true, this
617 /// closes the file when the stream is destroyed.
618 raw_fd_ostream::raw_fd_ostream(int fd, bool shouldClose, bool unbuffered,
619  OStreamKind K)
620  : raw_pwrite_stream(unbuffered, K), FD(fd), ShouldClose(shouldClose) {
621  if (FD < 0 ) {
622  ShouldClose = false;
623  return;
624  }
625 
626  enable_colors(true);
627 
628  // Do not attempt to close stdout or stderr. We used to try to maintain the
629  // property that tools that support writing file to stdout should not also
630  // write informational output to stdout, but in practice we were never able to
631  // maintain this invariant. Many features have been added to LLVM and clang
632  // (-fdump-record-layouts, optimization remarks, etc) that print to stdout, so
633  // users must simply be aware that mixed output and remarks is a possibility.
634  if (FD <= STDERR_FILENO)
635  ShouldClose = false;
636 
637 #ifdef _WIN32
638  // Check if this is a console device. This is not equivalent to isatty.
639  IsWindowsConsole =
640  ::GetFileType((HANDLE)::_get_osfhandle(fd)) == FILE_TYPE_CHAR;
641 #endif
642 
643  // Get the starting position.
644  off_t loc = ::lseek(FD, 0, SEEK_CUR);
646  std::error_code EC = status(FD, Status);
647  IsRegularFile = Status.type() == sys::fs::file_type::regular_file;
648 #ifdef _WIN32
649  // MSVCRT's _lseek(SEEK_CUR) doesn't return -1 for pipes.
650  SupportsSeeking = !EC && IsRegularFile;
651 #else
652  SupportsSeeking = !EC && loc != (off_t)-1;
653 #endif
654  if (!SupportsSeeking)
655  pos = 0;
656  else
657  pos = static_cast<uint64_t>(loc);
658 }
659 
661  if (FD >= 0) {
662  flush();
663  if (ShouldClose) {
664  if (auto EC = sys::Process::SafelyCloseFileDescriptor(FD))
665  error_detected(EC);
666  }
667  }
668 
669 #ifdef __MINGW32__
670  // On mingw, global dtors should not call exit().
671  // report_fatal_error() invokes exit(). We know report_fatal_error()
672  // might not write messages to stderr when any errors were detected
673  // on FD == 2.
674  if (FD == 2) return;
675 #endif
676 
677  // If there are any pending errors, report them now. Clients wishing
678  // to avoid report_fatal_error calls should check for errors with
679  // has_error() and clear the error flag with clear_error() before
680  // destructing raw_ostream objects which may have errors.
681  if (has_error())
682  report_fatal_error(Twine("IO failure on output stream: ") +
683  error().message(),
684  /*gen_crash_diag=*/false);
685 }
686 
687 #if defined(_WIN32)
688 // The most reliable way to print unicode in a Windows console is with
689 // WriteConsoleW. To use that, first transcode from UTF-8 to UTF-16. This
690 // assumes that LLVM programs always print valid UTF-8 to the console. The data
691 // might not be UTF-8 for two major reasons:
692 // 1. The program is printing binary (-filetype=obj -o -), in which case it
693 // would have been gibberish anyway.
694 // 2. The program is printing text in a semi-ascii compatible codepage like
695 // shift-jis or cp1252.
696 //
697 // Most LLVM programs don't produce non-ascii text unless they are quoting
698 // user source input. A well-behaved LLVM program should either validate that
699 // the input is UTF-8 or transcode from the local codepage to UTF-8 before
700 // quoting it. If they don't, this may mess up the encoding, but this is still
701 // probably the best compromise we can make.
702 static bool write_console_impl(int FD, StringRef Data) {
703  SmallVector<wchar_t, 256> WideText;
704 
705  // Fall back to ::write if it wasn't valid UTF-8.
706  if (auto EC = sys::windows::UTF8ToUTF16(Data, WideText))
707  return false;
708 
709  // On Windows 7 and earlier, WriteConsoleW has a low maximum amount of data
710  // that can be written to the console at a time.
711  size_t MaxWriteSize = WideText.size();
713  MaxWriteSize = 32767;
714 
715  size_t WCharsWritten = 0;
716  do {
717  size_t WCharsToWrite =
718  std::min(MaxWriteSize, WideText.size() - WCharsWritten);
719  DWORD ActuallyWritten;
720  bool Success =
721  ::WriteConsoleW((HANDLE)::_get_osfhandle(FD), &WideText[WCharsWritten],
722  WCharsToWrite, &ActuallyWritten,
723  /*Reserved=*/nullptr);
724 
725  // The most likely reason for WriteConsoleW to fail is that FD no longer
726  // points to a console. Fall back to ::write. If this isn't the first loop
727  // iteration, something is truly wrong.
728  if (!Success)
729  return false;
730 
731  WCharsWritten += ActuallyWritten;
732  } while (WCharsWritten != WideText.size());
733  return true;
734 }
735 #endif
736 
737 void raw_fd_ostream::write_impl(const char *Ptr, size_t Size) {
738  assert(FD >= 0 && "File already closed.");
739  pos += Size;
740 
741 #if defined(_WIN32)
742  // If this is a Windows console device, try re-encoding from UTF-8 to UTF-16
743  // and using WriteConsoleW. If that fails, fall back to plain write().
744  if (IsWindowsConsole)
745  if (write_console_impl(FD, StringRef(Ptr, Size)))
746  return;
747 #endif
748 
749  // The maximum write size is limited to INT32_MAX. A write
750  // greater than SSIZE_MAX is implementation-defined in POSIX,
751  // and Windows _write requires 32 bit input.
752  size_t MaxWriteSize = INT32_MAX;
753 
754 #if defined(__linux__)
755  // It is observed that Linux returns EINVAL for a very large write (>2G).
756  // Make it a reasonably small value.
757  MaxWriteSize = 1024 * 1024 * 1024;
758 #endif
759 
760  do {
761  size_t ChunkSize = std::min(Size, MaxWriteSize);
762  ssize_t ret = ::write(FD, Ptr, ChunkSize);
763 
764  if (ret < 0) {
765  // If it's a recoverable error, swallow it and retry the write.
766  //
767  // Ideally we wouldn't ever see EAGAIN or EWOULDBLOCK here, since
768  // raw_ostream isn't designed to do non-blocking I/O. However, some
769  // programs, such as old versions of bjam, have mistakenly used
770  // O_NONBLOCK. For compatibility, emulate blocking semantics by
771  // spinning until the write succeeds. If you don't want spinning,
772  // don't use O_NONBLOCK file descriptors with raw_ostream.
773  if (errno == EINTR || errno == EAGAIN
774 #ifdef EWOULDBLOCK
775  || errno == EWOULDBLOCK
776 #endif
777  )
778  continue;
779 
780  // Otherwise it's a non-recoverable error. Note it and quit.
781  error_detected(std::error_code(errno, std::generic_category()));
782  break;
783  }
784 
785  // The write may have written some or all of the data. Update the
786  // size and buffer pointer to reflect the remainder that needs
787  // to be written. If there are no bytes left, we're done.
788  Ptr += ret;
789  Size -= ret;
790  } while (Size > 0);
791 }
792 
794  assert(ShouldClose);
795  ShouldClose = false;
796  flush();
797  if (auto EC = sys::Process::SafelyCloseFileDescriptor(FD))
798  error_detected(EC);
799  FD = -1;
800 }
801 
803  assert(SupportsSeeking && "Stream does not support seeking!");
804  flush();
805 #ifdef _WIN32
806  pos = ::_lseeki64(FD, off, SEEK_SET);
807 #elif defined(HAVE_LSEEK64)
808  pos = ::lseek64(FD, off, SEEK_SET);
809 #else
810  pos = ::lseek(FD, off, SEEK_SET);
811 #endif
812  if (pos == (uint64_t)-1)
813  error_detected(std::error_code(errno, std::generic_category()));
814  return pos;
815 }
816 
817 void raw_fd_ostream::pwrite_impl(const char *Ptr, size_t Size,
818  uint64_t Offset) {
819  uint64_t Pos = tell();
820  seek(Offset);
821  write(Ptr, Size);
822  seek(Pos);
823 }
824 
825 size_t raw_fd_ostream::preferred_buffer_size() const {
826 #if defined(_WIN32)
827  // Disable buffering for console devices. Console output is re-encoded from
828  // UTF-8 to UTF-16 on Windows, and buffering it would require us to split the
829  // buffer on a valid UTF-8 codepoint boundary. Terminal buffering is disabled
830  // below on most other OSs, so do the same thing on Windows and avoid that
831  // complexity.
832  if (IsWindowsConsole)
833  return 0;
835 #elif !defined(__minix)
836  // Minix has no st_blksize.
837  assert(FD >= 0 && "File not yet open!");
838  struct stat statbuf;
839  if (fstat(FD, &statbuf) != 0)
840  return 0;
841 
842  // If this is a terminal, don't use buffering. Line buffering
843  // would be a more traditional thing to do, but it's not worth
844  // the complexity.
845  if (S_ISCHR(statbuf.st_mode) && is_displayed())
846  return 0;
847  // Return the preferred block size.
848  return statbuf.st_blksize;
849 #else
851 #endif
852 }
853 
856 }
857 
859  if (!HasColors)
861  return *HasColors;
862 }
863 
865  std::error_code EC = sys::fs::lockFile(FD);
866  if (!EC)
867  return sys::fs::FileLocker(FD);
868  return errorCodeToError(EC);
869 }
870 
873  std::error_code EC = sys::fs::tryLockFile(FD, Timeout.getDuration());
874  if (!EC)
875  return sys::fs::FileLocker(FD);
876  return errorCodeToError(EC);
877 }
878 
879 void raw_fd_ostream::anchor() {}
880 
881 //===----------------------------------------------------------------------===//
882 // outs(), errs(), nulls()
883 //===----------------------------------------------------------------------===//
884 
886  // Set buffer settings to model stdout behavior.
887  std::error_code EC;
888  static raw_fd_ostream S("-", EC, sys::fs::OF_None);
889  assert(!EC);
890  return S;
891 }
892 
894  // Set standard error to be unbuffered and tied to outs() by default.
895  static raw_fd_ostream S(STDERR_FILENO, false, true);
896  return S;
897 }
898 
899 /// nulls() - This returns a reference to a raw_ostream which discards output.
901  static raw_null_ostream S;
902  return S;
903 }
904 
905 //===----------------------------------------------------------------------===//
906 // File Streams
907 //===----------------------------------------------------------------------===//
908 
909 raw_fd_stream::raw_fd_stream(StringRef Filename, std::error_code &EC)
910  : raw_fd_ostream(getFD(Filename, EC, sys::fs::CD_CreateAlways,
911  sys::fs::FA_Write | sys::fs::FA_Read,
912  sys::fs::OF_None),
913  true, false, OStreamKind::OK_FDStream) {
914  if (EC)
915  return;
916 
917  if (!isRegularFile())
918  EC = std::make_error_code(std::errc::invalid_argument);
919 }
920 
921 ssize_t raw_fd_stream::read(char *Ptr, size_t Size) {
922  assert(get_fd() >= 0 && "File already closed.");
923  ssize_t Ret = ::read(get_fd(), (void *)Ptr, Size);
924  if (Ret >= 0)
925  inc_pos(Ret);
926  else
927  error_detected(std::error_code(errno, std::generic_category()));
928  return Ret;
929 }
930 
932  return OS->get_kind() == OStreamKind::OK_FDStream;
933 }
934 
935 //===----------------------------------------------------------------------===//
936 // raw_string_ostream
937 //===----------------------------------------------------------------------===//
938 
939 void raw_string_ostream::write_impl(const char *Ptr, size_t Size) {
940  OS.append(Ptr, Size);
941 }
942 
943 //===----------------------------------------------------------------------===//
944 // raw_svector_ostream
945 //===----------------------------------------------------------------------===//
946 
947 uint64_t raw_svector_ostream::current_pos() const { return OS.size(); }
948 
949 void raw_svector_ostream::write_impl(const char *Ptr, size_t Size) {
950  OS.append(Ptr, Ptr + Size);
951 }
952 
953 void raw_svector_ostream::pwrite_impl(const char *Ptr, size_t Size,
954  uint64_t Offset) {
955  memcpy(OS.data() + Offset, Ptr, Size);
956 }
957 
958 //===----------------------------------------------------------------------===//
959 // raw_null_ostream
960 //===----------------------------------------------------------------------===//
961 
963 #ifndef NDEBUG
964  // ~raw_ostream asserts that the buffer is empty. This isn't necessary
965  // with raw_null_ostream, but it's better to have raw_null_ostream follow
966  // the rules than to change the rules just for raw_null_ostream.
967  flush();
968 #endif
969 }
970 
971 void raw_null_ostream::write_impl(const char *Ptr, size_t Size) {
972 }
973 
974 uint64_t raw_null_ostream::current_pos() const {
975  return 0;
976 }
977 
978 void raw_null_ostream::pwrite_impl(const char *Ptr, size_t Size,
979  uint64_t Offset) {}
980 
981 void raw_pwrite_stream::anchor() {}
982 
983 void buffer_ostream::anchor() {}
984 
985 void buffer_unique_ostream::anchor() {}
986 
988  std::function<Error(raw_ostream &)> Write) {
989  if (OutputFileName == "-")
990  return Write(outs());
991 
992  if (OutputFileName == "/dev/null") {
993  raw_null_ostream Out;
994  return Write(Out);
995  }
996 
999  sys::fs::TempFile::create(OutputFileName + ".temp-stream-%%%%%%", Mode);
1000  if (!Temp)
1001  return createFileError(OutputFileName, Temp.takeError());
1002 
1003  raw_fd_ostream Out(Temp->FD, false);
1004 
1005  if (Error E = Write(Out)) {
1006  if (Error DiscardError = Temp->discard())
1007  return joinErrors(std::move(E), std::move(DiscardError));
1008  return E;
1009  }
1010  Out.flush();
1011 
1012  return Temp->keep(OutputFileName);
1013 }
llvm::Check::Size
@ Size
Definition: FileCheck.h:73
llvm::sys::fs::FA_Read
@ FA_Read
Definition: FileSystem.h:752
llvm::RunningWindows8OrGreater
bool RunningWindows8OrGreater()
Determines if the program is running on Windows 8 or newer.
llvm::alignTo
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
Definition: Alignment.h:148
llvm::raw_ostream::tell
uint64_t tell() const
tell - Return the current offset with the file.
Definition: raw_ostream.h:136
llvm::sys::fs::openFileForWrite
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...
Definition: FileSystem.h:1065
llvm::sys::fs::CreationDisposition
CreationDisposition
Definition: FileSystem.h:729
MathExtras.h
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AllocatorList.h:22
llvm::raw_fd_ostream::close
void close()
Manually flush the stream and close the file.
Definition: raw_ostream.cpp:793
llvm::lltok::Error
@ Error
Definition: LLToken.h:21
llvm::raw_ostream::SetBuffered
void SetBuffered()
Set the stream to be buffered, with an automatically determined buffer size.
Definition: raw_ostream.cpp:91
llvm::raw_ostream::SetUnbuffered
void SetUnbuffered()
Set the stream to be unbuffered.
Definition: raw_ostream.h:174
llvm::HexPrintStyle::Upper
@ Upper
FileSystem.h
llvm::sys::fs::OF_None
@ OF_None
Definition: FileSystem.h:757
llvm::X86AS::FS
@ FS
Definition: X86.h:188
llvm::raw_ostream::get_kind
OStreamKind get_kind() const
Definition: raw_ostream.h:138
llvm::sys::fs::FA_Write
@ FA_Write
Definition: FileSystem.h:753
llvm::sys::ChangeStdoutMode
std::error_code ChangeStdoutMode(fs::OpenFlags Flags)
llvm::raw_ostream::is_displayed
virtual bool is_displayed() const
This function determines if this stream is connected to a "tty" or "console" window.
Definition: raw_ostream.h:324
llvm::raw_ostream::write_zeros
raw_ostream & write_zeros(unsigned NumZeros)
write_zeros - Insert 'NumZeros' nulls.
Definition: raw_ostream.cpp:501
P
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
Definition: README-SSE.txt:411
llvm::raw_ostream::~raw_ostream
virtual ~raw_ostream()
Definition: raw_ostream.cpp:76
NativeFormatting.h
llvm::raw_ostream::OStreamKind::OK_FDStream
@ OK_FDStream
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1176
ErrorHandling.h
llvm::FormattedNumber
This is a helper class used for format_hex() and format_decimal().
Definition: Format.h:164
llvm::raw_ostream::write_escaped
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:162
llvm::raw_fd_ostream::raw_fd_ostream
raw_fd_ostream(StringRef Filename, std::error_code &EC)
Open the specified file for writing.
Definition: raw_ostream.cpp:592
llvm::raw_ostream::GREEN
static constexpr Colors GREEN
Definition: raw_ostream.h:113
WindowsSupport.h
true
basic Basic Alias true
Definition: BasicAliasAnalysis.cpp:1886
llvm::sys::fs::file_type::regular_file
@ regular_file
llvm::formatv_object_base::format
void format(raw_ostream &S) const
Definition: FormatVariadic.h:85
ret
to esp esp setne al movzbw ax esp setg cl movzbw cx cmove cx cl jne LBB1_2 esp ret(also really horrible code on ppc). This is due to the expand code for 64-bit compares. GCC produces multiple branches
Offset
uint64_t Offset
Definition: ELFObjHandler.cpp:80
llvm::raw_ostream::OStreamKind
OStreamKind
Definition: raw_ostream.h:57
llvm::sys::fs::FileAccess
FileAccess
Definition: FileSystem.h:751
llvm::errs
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
Definition: raw_ostream.cpp:893
llvm::MipsISD::Ret
@ Ret
Definition: MipsISelLowering.h:116
llvm::raw_ostream::RED
static constexpr Colors RED
Definition: raw_ostream.h:112
llvm::raw_ostream::Colors::RESET
@ RESET
llvm::sys::locale::isPrint
bool isPrint(int c)
Definition: Locale.cpp:13
llvm::Expected
Tagged union holding either a T or a Error.
Definition: APFloat.h:42
STLExtras.h
Format.h
llvm::nulls
raw_ostream & nulls()
This returns a reference to a raw_ostream which simply discards output.
Definition: raw_ostream.cpp:900
Duration.h
llvm::raw_fd_ostream::tryLockFor
LLVM_NODISCARD Expected< sys::fs::FileLocker > tryLockFor(Duration const &Timeout)
Tries to lock the underlying file within the specified period.
Definition: raw_ostream.cpp:872
llvm::sys::fs::all_write
@ all_write
Definition: FileSystem.h:101
llvm::Data
@ Data
Definition: SIMachineScheduler.h:55
endif
__FakeVCSRevision h endif() endif() set(generated_files "$
Definition: CMakeLists.txt:16
llvm::ArrayRef::empty
bool empty() const
empty - Check if the array is empty.
Definition: ArrayRef.h:158
llvm::raw_fd_ostream::has_colors
bool has_colors() const override
This function determines if this stream is displayed and supports colors.
Definition: raw_ostream.cpp:858
llvm::raw_ostream::MAGENTA
static constexpr Colors MAGENTA
Definition: raw_ostream.h:116
llvm::Optional::hasValue
constexpr bool hasValue() const
Definition: Optional.h:288
llvm::raw_fd_stream::classof
static bool classof(const raw_ostream *OS)
Check if OS is a pointer of type raw_fd_stream*.
Definition: raw_ostream.cpp:931
llvm::raw_ostream::changeColor
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:521
Process.h
llvm::raw_ostream::preferred_buffer_size
virtual size_t preferred_buffer_size() const
Return an efficient buffer size for the underlying output mechanism.
Definition: raw_ostream.cpp:86
llvm::outs
raw_fd_ostream & outs()
This returns a reference to a raw_fd_ostream for standard output.
Definition: raw_ostream.cpp:885
getFD
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:566
llvm::format_object_base
This is a helper class used for handling formatted output.
Definition: Format.h:38
llvm::raw_fd_ostream::has_error
bool has_error() const
Return the value of the flag in this raw_fd_ostream indicating whether an output error has been encou...
Definition: raw_ostream.h:535
llvm::FormattedString::JustifyRight
@ JustifyRight
Definition: Format.h:131
llvm::createFileError
Error createFileError(const Twine &F, Error E)
Concatenate a source file path and/or name with an Error.
Definition: Error.h:1320
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
llvm::SmallVectorImpl::append
void append(in_iter in_start, in_iter in_end)
Add the specified range to the end of the SmallVector.
Definition: SmallVector.h:656
llvm::raw_fd_ostream::inc_pos
void inc_pos(uint64_t Delta)
Definition: raw_ostream.h:483
llvm::raw_fd_ostream::get_fd
int get_fd() const
Return the file descriptor.
Definition: raw_ostream.h:480
llvm::writeToOutput
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:987
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::errorCodeToError
Error errorCodeToError(std::error_code EC)
Helper for converting an std::error_code to a Error.
Definition: Error.cpp:90
write_padding
static raw_ostream & write_padding(raw_ostream &OS, unsigned NumChars)
Definition: raw_ostream.cpp:475
llvm::Duration
Definition: Duration.h:20
false
Definition: StackSlotColoring.cpp:142
llvm::raw_null_ostream::~raw_null_ostream
~raw_null_ostream() override
Definition: raw_ostream.cpp:962
llvm::raw_ostream::write
raw_ostream & write(unsigned char C)
Definition: raw_ostream.cpp:219
llvm::report_fatal_error
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Definition: Error.cpp:143
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:54
llvm::SmallVectorImpl::resize
void resize(size_type N)
Definition: SmallVector.h:608
llvm::raw_ostream::flush
void flush()
Definition: raw_ostream.h:187
llvm::raw_ostream::GetNumBytesInBuffer
size_t GetNumBytesInBuffer() const
Definition: raw_ostream.h:179
llvm::raw_fd_ostream::error_detected
void error_detected(std::error_code EC)
Set the flag indicating that an output error has been encountered.
Definition: raw_ostream.h:477
llvm::sys::fs::FileLocker
RAII class that facilitates file locking.
Definition: FileSystem.h:1226
llvm::raw_ostream::WHITE
static constexpr Colors WHITE
Definition: raw_ostream.h:118
c
the resulting code requires compare and branches when and if the revised code is with conditional branches instead of More there is a byte word extend before each where there should be only and the condition codes are not remembered when the same two values are compared twice More LSR enhancements i8 and i32 load store addressing modes are identical int int c
Definition: README.txt:418
FormatVariadic.h
llvm::array_lengthof
constexpr size_t array_lengthof(T(&)[N])
Find the length of an array.
Definition: STLExtras.h:1435
llvm::raw_fd_ostream::seek
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:802
llvm::sys::fs::openFileForReadWrite
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...
Definition: FileSystem.h:1106
llvm::raw_ostream::enable_colors
virtual void enable_colors(bool enable)
Definition: raw_ostream.h:332
llvm::SmallString< 16 >
llvm::sys::Process::OutputBold
static const char * OutputBold(bool bg)
Same as OutputColor, but only enables the bold attribute.
llvm::format_object_base::print
unsigned print(char *Buffer, unsigned BufferSize) const
Format the object into the specified buffer.
Definition: Format.h:54
llvm::sys::Process::SafelyCloseFileDescriptor
static std::error_code SafelyCloseFileDescriptor(int FD)
llvm::FormattedString::JustifyLeft
@ JustifyLeft
Definition: Format.h:131
llvm::sys::fs::file_status
Represents the result of a call to sys::fs::status().
Definition: FileSystem.h:226
llvm::sys::Process::FileDescriptorHasColors
static bool FileDescriptorHasColors(int fd)
This function determines if the given file descriptor is displayd and supports colors.
llvm::sys::Process::ResetColor
static const char * ResetColor()
Resets the terminals colors, or returns an escape sequence to do so.
uint64_t
llvm::sys::fs::lockFile
std::error_code lockFile(int FD)
Lock the file.
llvm::raw_pwrite_stream
An abstract base class for streams implementations that also support a pwrite operation.
Definition: raw_ostream.h:418
llvm::Duration::getDuration
std::chrono::milliseconds getDuration() const
Definition: Duration.h:24
move
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
Definition: README.txt:546
llvm::sys::Process::OutputColor
static const char * OutputColor(char c, bool bold, bool bg)
This function returns the colorcode escape sequences.
llvm::HexPrintStyle::PrefixLower
@ PrefixLower
I
#define I(x, y, z)
Definition: MD5.cpp:58
StringExtras.h
llvm::joinErrors
Error joinErrors(Error E1, Error E2)
Concatenate errors.
Definition: Error.h:426
llvm::AMDGPU::SDWA::DWORD
@ DWORD
Definition: SIDefines.h:659
llvm::raw_fd_stream::read
ssize_t read(char *Ptr, size_t Size)
This reads the Size bytes into a buffer pointed by Ptr.
Definition: raw_ostream.cpp:921
llvm::Log2_64_Ceil
unsigned Log2_64_Ceil(uint64_t Value)
Return the ceil log base 2 of the specified value, 64 if the value is zero.
Definition: MathExtras.h:615
llvm::HexStyle::Style
Style
Definition: MCInstPrinter.h:32
message
message(STATUS "Targeting ${t}") add_subdirectory($
Definition: CMakeLists.txt:33
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
memcpy
<%struct.s * > cast struct s *S to sbyte *< sbyte * > sbyte uint cast struct s *agg result to sbyte *< sbyte * > sbyte uint cast struct s *memtmp to sbyte *< sbyte * > sbyte uint ret void llc ends up issuing two memcpy or custom lower memcpy(of small size) to be ldmia/stmia. I think option 2 is better but the current register allocator cannot allocate a chunk of registers at a time. A feasible temporary solution is to use specific physical registers at the lowering time for small(<
llvm::IntegerStyle::Integer
@ Integer
Mode
SI Whole Quad Mode
Definition: SIWholeQuadMode.cpp:262
function
print Print MemDeps of function
Definition: MemDepPrinter.cpp:83
UUID
std::pair< llvm::MachO::Target, std::string > UUID
Definition: TextStubCommon.h:23
llvm::sys::fs::CD_CreateAlways
@ CD_CreateAlways
CD_CreateAlways - When opening a file:
Definition: FileSystem.h:733
llvm::FloatStyle::Exponent
@ Exponent
Status
Definition: SIModeRegister.cpp:28
llvm::raw_ostream::CYAN
static constexpr Colors CYAN
Definition: raw_ostream.h:117
llvm::raw_null_ostream
A raw_ostream that discards all output.
Definition: raw_ostream.h:695
llvm::write_hex
void write_hex(raw_ostream &S, uint64_t N, HexPrintStyle Style, Optional< size_t > Width=None)
Definition: NativeFormatting.cpp:132
llvm::raw_ostream::reverseColor
virtual raw_ostream & reverseColor()
Reverses the foreground and background colors.
Definition: raw_ostream.cpp:543
llvm::raw_fd_ostream::error
std::error_code error() const
Definition: raw_ostream.h:529
llvm::min
Expected< ExpressionValue > min(const ExpressionValue &Lhs, const ExpressionValue &Rhs)
Definition: FileCheck.cpp:357
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
llvm::raw_fd_ostream::is_displayed
bool is_displayed() const override
This function determines if this stream is connected to a "tty" or "console" window.
Definition: raw_ostream.cpp:854
Compiler.h
S
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Definition: README.txt:210
llvm::format
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
Definition: Format.h:124
LLVM_FALLTHROUGH
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
Definition: Compiler.h:287
llvm::raw_fd_ostream
A raw_ostream that writes to a file descriptor.
Definition: raw_ostream.h:444
llvm::FormattedBytes
Definition: Format.h:215
llvm::raw_ostream::operator<<
raw_ostream & operator<<(char C)
Definition: raw_ostream.h:192
llvm::sys::Process::OutputReverse
static const char * OutputReverse()
This function returns the escape sequence to reverse forground and background colors.
llvm::HexPrintStyle::PrefixUpper
@ PrefixUpper
ConvertUTF.h
llvm::make_error_code
std::error_code make_error_code(BitcodeError E)
Definition: BitcodeReader.h:270
llvm::FormattedString::JustifyNone
@ JustifyNone
Definition: Format.h:131
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:83
llvm::FormattedString::JustifyCenter
@ JustifyCenter
Definition: Format.h:131
llvm::raw_ostream::RESET
static constexpr Colors RESET
Definition: raw_ostream.h:120
llvm::sys::fs::all_exe
@ all_exe
Definition: FileSystem.h:102
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:155
Success
#define Success
Definition: AArch64Disassembler.cpp:266
llvm::HexPrintStyle
HexPrintStyle
Definition: NativeFormatting.h:22
llvm::HexPrintStyle::Lower
@ Lower
llvm::sys::fs::OpenFlags
OpenFlags
Definition: FileSystem.h:756
llvm::write_double
void write_double(raw_ostream &S, double D, FloatStyle Style, Optional< size_t > Precision=None)
Definition: NativeFormatting.cpp:162
llvm::sys::Process::FileDescriptorIsDisplayed
static bool FileDescriptorIsDisplayed(int fd)
This function determines if the given file descriptor is connected to a "tty" or "console" window.
llvm::raw_ostream::SAVEDCOLOR
static constexpr Colors SAVEDCOLOR
Definition: raw_ostream.h:119
llvm::raw_fd_ostream::~raw_fd_ostream
~raw_fd_ostream() override
Definition: raw_ostream.cpp:660
llvm::write_integer
void write_integer(raw_ostream &S, unsigned int N, size_t MinDigits, IntegerStyle Style)
Definition: NativeFormatting.cpp:102
llvm::sys::fs::all_read
@ all_read
Definition: FileSystem.h:100
llvm::raw_fd_ostream::lock
LLVM_NODISCARD Expected< sys::fs::FileLocker > lock()
Locks the underlying file.
Definition: raw_ostream.cpp:864
llvm::raw_fd_stream::raw_fd_stream
raw_fd_stream(StringRef Filename, std::error_code &EC)
Open the specified file for reading/writing/seeking.
Definition: raw_ostream.cpp:909
llvm::sys::Process::ColorNeedsFlush
static bool ColorNeedsFlush()
Whether changing colors requires the output to be flushed.
llvm::raw_ostream::SetBufferSize
void SetBufferSize(size_t Size)
Set the stream to be buffered, using the specified buffer size.
Definition: raw_ostream.h:156
llvm::Expected::takeError
Error takeError()
Take ownership of the stored error.
Definition: Error.h:597
llvm::FormattedString
This is a helper class for left_justify, right_justify, and center_justify.
Definition: Format.h:129
llvm::raw_ostream::indent
raw_ostream & indent(unsigned NumSpaces)
indent - Insert 'NumSpaces' spaces.
Definition: raw_ostream.cpp:496
llvm::sys::fs::status
std::error_code status(const Twine &path, file_status &result, bool follow=true)
Get file status as if by POSIX stat().
llvm::raw_ostream::BLACK
static constexpr Colors BLACK
Definition: raw_ostream.h:111
N
#define N
Program.h
llvm::raw_ostream::Colors
Colors
Definition: raw_ostream.h:98
llvm::raw_svector_ostream
A raw_ostream that writes to an SmallVector or SmallString.
Definition: raw_ostream.h:662
llvm::raw_ostream::resetColor
virtual raw_ostream & resetColor()
Resets the colors to terminal defaults.
Definition: raw_ostream.cpp:534
llvm::formatv_object_base
Definition: FormatVariadic.h:66
llvm::raw_ostream::BLUE
static constexpr Colors BLUE
Definition: raw_ostream.h:115
llvm::raw_ostream::uuid_t
uint8_t[16] uuid_t
Output a formatted UUID with dash separators.
Definition: raw_ostream.h:273
llvm::sys::fs::TempFile::create
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...
Definition: Path.cpp:1324
llvm::raw_ostream::YELLOW
static constexpr Colors YELLOW
Definition: raw_ostream.h:114
LLVM_UNLIKELY
#define LLVM_UNLIKELY(EXPR)
Definition: Compiler.h:227
raw_ostream.h
llvm::format_object_base::home
virtual void home()
Definition: raw_ostream.cpp:559
llvm::raw_fd_ostream::isRegularFile
bool isRegularFile() const
Definition: raw_ostream.h:519
llvm::raw_ostream::write_uuid
raw_ostream & write_uuid(const uuid_t UUID)
Definition: raw_ostream.cpp:152
llvm::sys::fs::tryLockFile
std::error_code tryLockFile(int FD, std::chrono::milliseconds Timeout=std::chrono::milliseconds(0))
Try to locks the file during the specified time.
llvm::Optional::getValue
constexpr const T & getValue() const LLVM_LVALUE_FUNCTION
Definition: Optional.h:282
llvm::raw_ostream::write_hex
raw_ostream & write_hex(unsigned long long N)
Output N in hexadecimal, without any prefix or padding.
Definition: raw_ostream.cpp:139