LLVM  5.0.0
ArchiveWriter.cpp
Go to the documentation of this file.
1 //===- ArchiveWriter.cpp - ar File Format implementation --------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines the writeArchive function.
11 //
12 //===----------------------------------------------------------------------===//
13 
15 #include "llvm/ADT/ArrayRef.h"
16 #include "llvm/ADT/StringRef.h"
18 #include "llvm/IR/LLVMContext.h"
19 #include "llvm/Object/Archive.h"
20 #include "llvm/Object/ObjectFile.h"
23 #include "llvm/Support/Errc.h"
25 #include "llvm/Support/Format.h"
26 #include "llvm/Support/Path.h"
29 
30 #if !defined(_MSC_VER) && !defined(__MINGW32__)
31 #include <unistd.h>
32 #else
33 #include <io.h>
34 #endif
35 
36 using namespace llvm;
37 
39  : Buf(MemoryBuffer::getMemBuffer(BufRef, false)),
40  MemberName(BufRef.getBufferIdentifier()) {}
41 
44  bool Deterministic) {
46  if (!BufOrErr)
47  return BufOrErr.takeError();
48 
50  assert(M.IsNew == false);
51  M.Buf = MemoryBuffer::getMemBuffer(*BufOrErr, false);
52  M.MemberName = M.Buf->getBufferIdentifier();
53  if (!Deterministic) {
54  auto ModTimeOrErr = OldMember.getLastModified();
55  if (!ModTimeOrErr)
56  return ModTimeOrErr.takeError();
57  M.ModTime = ModTimeOrErr.get();
58  Expected<unsigned> UIDOrErr = OldMember.getUID();
59  if (!UIDOrErr)
60  return UIDOrErr.takeError();
61  M.UID = UIDOrErr.get();
62  Expected<unsigned> GIDOrErr = OldMember.getGID();
63  if (!GIDOrErr)
64  return GIDOrErr.takeError();
65  M.GID = GIDOrErr.get();
66  Expected<sys::fs::perms> AccessModeOrErr = OldMember.getAccessMode();
67  if (!AccessModeOrErr)
68  return AccessModeOrErr.takeError();
69  M.Perms = AccessModeOrErr.get();
70  }
71  return std::move(M);
72 }
73 
75  bool Deterministic) {
76  sys::fs::file_status Status;
77  int FD;
78  if (auto EC = sys::fs::openFileForRead(FileName, FD))
79  return errorCodeToError(EC);
80  assert(FD != -1);
81 
82  if (auto EC = sys::fs::status(FD, Status))
83  return errorCodeToError(EC);
84 
85  // Opening a directory doesn't make sense. Let it fail.
86  // Linux cannot open directories with open(2), although
87  // cygwin and *bsd can.
90 
91  ErrorOr<std::unique_ptr<MemoryBuffer>> MemberBufferOrErr =
92  MemoryBuffer::getOpenFile(FD, FileName, Status.getSize(), false);
93  if (!MemberBufferOrErr)
94  return errorCodeToError(MemberBufferOrErr.getError());
95 
96  if (close(FD) != 0)
97  return errorCodeToError(std::error_code(errno, std::generic_category()));
98 
100  M.IsNew = true;
101  M.Buf = std::move(*MemberBufferOrErr);
102  M.MemberName = M.Buf->getBufferIdentifier();
103  if (!Deterministic) {
104  M.ModTime = std::chrono::time_point_cast<std::chrono::seconds>(
105  Status.getLastModificationTime());
106  M.UID = Status.getUser();
107  M.GID = Status.getGroup();
108  M.Perms = Status.permissions();
109  }
110  return std::move(M);
111 }
112 
113 template <typename T>
114 static void printWithSpacePadding(raw_fd_ostream &OS, T Data, unsigned Size,
115  bool MayTruncate = false) {
116  uint64_t OldPos = OS.tell();
117  OS << Data;
118  unsigned SizeSoFar = OS.tell() - OldPos;
119  if (Size > SizeSoFar) {
120  OS.indent(Size - SizeSoFar);
121  } else if (Size < SizeSoFar) {
122  assert(MayTruncate && "Data doesn't fit in Size");
123  // Some of the data this is used for (like UID) can be larger than the
124  // space available in the archive format. Truncate in that case.
125  OS.seek(OldPos + Size);
126  }
127 }
128 
130  switch (Kind) {
132  return false;
135  return true;
139  break;
140  }
141  llvm_unreachable("not supported for writting");
142 }
143 
145  uint32_t Val) {
146  if (isBSDLike(Kind))
148  else
150 }
151 
154  unsigned UID, unsigned GID, unsigned Perms, unsigned Size) {
155  printWithSpacePadding(Out, sys::toTimeT(ModTime), 12);
156  printWithSpacePadding(Out, UID, 6, true);
157  printWithSpacePadding(Out, GID, 6, true);
158  printWithSpacePadding(Out, format("%o", Perms), 8);
159  printWithSpacePadding(Out, Size, 10);
160  Out << "`\n";
161 }
162 
163 static void
166  unsigned UID, unsigned GID, unsigned Perms,
167  unsigned Size) {
168  printWithSpacePadding(Out, Twine(Name) + "/", 16);
169  printRestOfMemberHeader(Out, ModTime, UID, GID, Perms, Size);
170 }
171 
172 static void
175  unsigned UID, unsigned GID, unsigned Perms,
176  unsigned Size) {
177  uint64_t PosAfterHeader = Out.tell() + 60 + Name.size();
178  // Pad so that even 64 bit object files are aligned.
179  unsigned Pad = OffsetToAlignment(PosAfterHeader, 8);
180  unsigned NameWithPadding = Name.size() + Pad;
181  printWithSpacePadding(Out, Twine("#1/") + Twine(NameWithPadding), 16);
182  printRestOfMemberHeader(Out, ModTime, UID, GID, Perms,
183  NameWithPadding + Size);
184  Out << Name;
185  assert(PosAfterHeader == Out.tell());
186  while (Pad--)
187  Out.write(uint8_t(0));
188 }
189 
190 static bool useStringTable(bool Thin, StringRef Name) {
191  return Thin || Name.size() >= 16 || Name.contains('/');
192 }
193 
194 static void
196  StringRef Name,
197  std::vector<unsigned>::iterator &StringMapIndexIter,
199  unsigned UID, unsigned GID, unsigned Perms, unsigned Size) {
200  if (isBSDLike(Kind))
201  return printBSDMemberHeader(Out, Name, ModTime, UID, GID, Perms, Size);
202  if (!useStringTable(Thin, Name))
203  return printGNUSmallMemberHeader(Out, Name, ModTime, UID, GID, Perms, Size);
204  Out << '/';
205  printWithSpacePadding(Out, *StringMapIndexIter++, 15);
206  printRestOfMemberHeader(Out, ModTime, UID, GID, Perms, Size);
207 }
208 
209 // Compute the relative path from From to To.
210 static std::string computeRelativePath(StringRef From, StringRef To) {
212  return To;
213 
214  StringRef DirFrom = sys::path::parent_path(From);
215  auto FromI = sys::path::begin(DirFrom);
216  auto ToI = sys::path::begin(To);
217  while (*FromI == *ToI) {
218  ++FromI;
219  ++ToI;
220  }
221 
222  SmallString<128> Relative;
223  for (auto FromE = sys::path::end(DirFrom); FromI != FromE; ++FromI)
224  sys::path::append(Relative, "..");
225 
226  for (auto ToE = sys::path::end(To); ToI != ToE; ++ToI)
227  sys::path::append(Relative, *ToI);
228 
229 #ifdef LLVM_ON_WIN32
230  // Replace backslashes with slashes so that the path is portable between *nix
231  // and Windows.
232  std::replace(Relative.begin(), Relative.end(), '\\', '/');
233 #endif
234 
235  return Relative.str();
236 }
237 
238 static void writeStringTable(raw_fd_ostream &Out, StringRef ArcName,
240  std::vector<unsigned> &StringMapIndexes,
241  bool Thin) {
242  unsigned StartOffset = 0;
243  for (const NewArchiveMember &M : Members) {
244  StringRef Path = M.Buf->getBufferIdentifier();
245  StringRef Name = M.MemberName;
246  if (!useStringTable(Thin, Name))
247  continue;
248  if (StartOffset == 0) {
249  printWithSpacePadding(Out, "//", 58);
250  Out << "`\n";
251  StartOffset = Out.tell();
252  }
253  StringMapIndexes.push_back(Out.tell() - StartOffset);
254 
255  if (Thin) {
256  if (M.IsNew)
257  Out << computeRelativePath(ArcName, Path);
258  else
259  Out << M.Buf->getBufferIdentifier();
260  } else
261  Out << Name;
262 
263  Out << "/\n";
264  }
265  if (StartOffset == 0)
266  return;
267  if (Out.tell() % 2)
268  Out << '\n';
269  int Pos = Out.tell();
270  Out.seek(StartOffset - 12);
271  printWithSpacePadding(Out, Pos - StartOffset, 10);
272  Out.seek(Pos);
273 }
274 
275 static sys::TimePoint<std::chrono::seconds> now(bool Deterministic) {
276  using namespace std::chrono;
277 
278  if (!Deterministic)
279  return time_point_cast<seconds>(system_clock::now());
280  return sys::TimePoint<seconds>();
281 }
282 
283 // Returns the offset of the first reference to a member offset.
284 static ErrorOr<unsigned>
287  std::vector<unsigned> &MemberOffsetRefs, bool Deterministic) {
288  unsigned HeaderStartOffset = 0;
289  unsigned BodyStartOffset = 0;
290  SmallString<128> NameBuf;
291  raw_svector_ostream NameOS(NameBuf);
293  for (unsigned MemberNum = 0, N = Members.size(); MemberNum < N; ++MemberNum) {
294  MemoryBufferRef MemberBuffer = Members[MemberNum].Buf->getMemBufferRef();
297  MemberBuffer, llvm::file_magic::unknown, &Context);
298  if (!ObjOrErr) {
299  // FIXME: check only for "not an object file" errors.
300  consumeError(ObjOrErr.takeError());
301  continue;
302  }
303  object::SymbolicFile &Obj = *ObjOrErr.get();
304 
305  if (!HeaderStartOffset) {
306  HeaderStartOffset = Out.tell();
307  if (isBSDLike(Kind))
308  printBSDMemberHeader(Out, "__.SYMDEF", now(Deterministic), 0, 0, 0, 0);
309  else
310  printGNUSmallMemberHeader(Out, "", now(Deterministic), 0, 0, 0, 0);
311  BodyStartOffset = Out.tell();
312  print32(Out, Kind, 0); // number of entries or bytes
313  }
314 
315  for (const object::BasicSymbolRef &S : Obj.symbols()) {
316  uint32_t Symflags = S.getFlags();
318  continue;
319  if (!(Symflags & object::SymbolRef::SF_Global))
320  continue;
321  if (Symflags & object::SymbolRef::SF_Undefined &&
322  !(Symflags & object::SymbolRef::SF_Indirect))
323  continue;
324 
325  unsigned NameOffset = NameOS.tell();
326  if (auto EC = S.printName(NameOS))
327  return EC;
328  NameOS << '\0';
329  MemberOffsetRefs.push_back(MemberNum);
330  if (isBSDLike(Kind))
331  print32(Out, Kind, NameOffset);
332  print32(Out, Kind, 0); // member offset
333  }
334  }
335 
336  if (HeaderStartOffset == 0)
337  return 0;
338 
339  // ld64 prefers the cctools type archive which pads its string table to a
340  // boundary of sizeof(int32_t).
341  if (isBSDLike(Kind))
342  for (unsigned P = OffsetToAlignment(NameOS.tell(), sizeof(int32_t)); P--;)
343  NameOS << '\0';
344 
345  StringRef StringTable = NameOS.str();
346  if (isBSDLike(Kind))
347  print32(Out, Kind, StringTable.size()); // byte count of the string table
348  Out << StringTable;
349  // If there are no symbols, emit an empty symbol table, to satisfy Solaris
350  // tools, older versions of which expect a symbol table in a non-empty
351  // archive, regardless of whether there are any symbols in it.
352  if (StringTable.size() == 0)
353  print32(Out, Kind, 0);
354 
355  // ld64 requires the next member header to start at an offset that is
356  // 4 bytes aligned.
357  unsigned Pad = OffsetToAlignment(Out.tell(), 4);
358  while (Pad--)
359  Out.write(uint8_t(0));
360 
361  // Patch up the size of the symbol table now that we know how big it is.
362  unsigned Pos = Out.tell();
363  const unsigned MemberHeaderSize = 60;
364  Out.seek(HeaderStartOffset + 48); // offset of the size field.
365  printWithSpacePadding(Out, Pos - MemberHeaderSize - HeaderStartOffset, 10);
366 
367  // Patch up the number of symbols.
368  Out.seek(BodyStartOffset);
369  unsigned NumSyms = MemberOffsetRefs.size();
370  if (isBSDLike(Kind))
371  print32(Out, Kind, NumSyms * 8);
372  else
373  print32(Out, Kind, NumSyms);
374 
375  Out.seek(Pos);
376  return BodyStartOffset + 4;
377 }
378 
379 std::pair<StringRef, std::error_code>
381  std::vector<NewArchiveMember> &NewMembers,
382  bool WriteSymtab, object::Archive::Kind Kind,
383  bool Deterministic, bool Thin,
384  std::unique_ptr<MemoryBuffer> OldArchiveBuf) {
385  assert((!Thin || !isBSDLike(Kind)) && "Only the gnu format has a thin mode");
386  SmallString<128> TmpArchive;
387  int TmpArchiveFD;
388  if (auto EC = sys::fs::createUniqueFile(ArcName + ".temp-archive-%%%%%%%.a",
389  TmpArchiveFD, TmpArchive))
390  return std::make_pair(ArcName, EC);
391 
392  tool_output_file Output(TmpArchive, TmpArchiveFD);
393  raw_fd_ostream &Out = Output.os();
394  if (Thin)
395  Out << "!<thin>\n";
396  else
397  Out << "!<arch>\n";
398 
399  std::vector<unsigned> MemberOffsetRefs;
400 
401  unsigned MemberReferenceOffset = 0;
402  if (WriteSymtab) {
403  ErrorOr<unsigned> MemberReferenceOffsetOrErr = writeSymbolTable(
404  Out, Kind, NewMembers, MemberOffsetRefs, Deterministic);
405  if (auto EC = MemberReferenceOffsetOrErr.getError())
406  return std::make_pair(ArcName, EC);
407  MemberReferenceOffset = MemberReferenceOffsetOrErr.get();
408  }
409 
410  std::vector<unsigned> StringMapIndexes;
411  if (!isBSDLike(Kind))
412  writeStringTable(Out, ArcName, NewMembers, StringMapIndexes, Thin);
413 
414  std::vector<unsigned>::iterator StringMapIndexIter = StringMapIndexes.begin();
415  std::vector<unsigned> MemberOffset;
416  for (const NewArchiveMember &M : NewMembers) {
417  MemoryBufferRef File = M.Buf->getMemBufferRef();
418  unsigned Padding = 0;
419 
420  unsigned Pos = Out.tell();
421  MemberOffset.push_back(Pos);
422 
423  // ld64 expects the members to be 8-byte aligned for 64-bit content and at
424  // least 4-byte aligned for 32-bit content. Opt for the larger encoding
425  // uniformly. This matches the behaviour with cctools and ensures that ld64
426  // is happy with archives that we generate.
427  if (Kind == object::Archive::K_DARWIN)
428  Padding = OffsetToAlignment(M.Buf->getBufferSize(), 8);
429 
430  printMemberHeader(Out, Kind, Thin, M.MemberName, StringMapIndexIter,
431  M.ModTime, M.UID, M.GID, M.Perms,
432  M.Buf->getBufferSize() + Padding);
433 
434  if (!Thin)
435  Out << File.getBuffer();
436 
437  while (Padding--)
438  Out << '\n';
439  if (Out.tell() % 2)
440  Out << '\n';
441  }
442 
443  if (MemberReferenceOffset) {
444  Out.seek(MemberReferenceOffset);
445  for (unsigned MemberNum : MemberOffsetRefs) {
446  if (isBSDLike(Kind))
447  Out.seek(Out.tell() + 4); // skip over the string offset
448  print32(Out, Kind, MemberOffset[MemberNum]);
449  }
450  }
451 
452  Output.keep();
453  Out.close();
454 
455  // At this point, we no longer need whatever backing memory
456  // was used to generate the NewMembers. On Windows, this buffer
457  // could be a mapped view of the file we want to replace (if
458  // we're updating an existing archive, say). In that case, the
459  // rename would still succeed, but it would leave behind a
460  // temporary file (actually the original file renamed) because
461  // a file cannot be deleted while there's a handle open on it,
462  // only renamed. So by freeing this buffer, this ensures that
463  // the last open handle on the destination file, if any, is
464  // closed before we attempt to rename.
465  OldArchiveBuf.reset();
466 
467  sys::fs::rename(TmpArchive, ArcName);
468  return std::make_pair("", std::error_code());
469 }
const_iterator end(StringRef path)
Get end iterator over path.
Definition: Path.cpp:243
std::error_code getError() const
Definition: ErrorOr.h:172
Represents either an error or a value T.
Definition: ErrorOr.h:69
LLVM_ATTRIBUTE_ALWAYS_INLINE std::time_t toTimeT(TimePoint<> TP)
Convert a TimePoint to std::time_t.
Definition: Chrono.h:37
LLVMContext & Context
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
Definition: Path.cpp:234
std::error_code createUniqueFile(const Twine &Model, int &ResultFD, SmallVectorImpl< char > &ResultPath, unsigned Mode=all_read|all_write)
Create a uniquely named file.
Definition: Path.cpp:751
std::error_code openFileForRead(const Twine &Name, int &ResultFD, SmallVectorImpl< char > *RealPath=nullptr)
static Expected< std::unique_ptr< SymbolicFile > > createSymbolicFile(MemoryBufferRef Object, llvm::file_magic Type, LLVMContext *Context)
static void printMemberHeader(raw_fd_ostream &Out, object::Archive::Kind Kind, bool Thin, StringRef Name, std::vector< unsigned >::iterator &StringMapIndexIter, const sys::TimePoint< std::chrono::seconds > &ModTime, unsigned UID, unsigned GID, unsigned Perms, unsigned Size)
Expected< unsigned > getGID() const
Definition: Archive.h:126
uint64_t seek(uint64_t off)
Flushes the stream and repositions the underlying file descriptor position to the offset specified fr...
static std::unique_ptr< MemoryBuffer > getMemBuffer(StringRef InputData, StringRef BufferName="", bool RequiresNullTerminator=true)
Open the specified memory range as a MemoryBuffer.
raw_ostream & indent(unsigned NumSpaces)
indent - Insert 'NumSpaces' spaces.
raw_fd_ostream & os()
Return the contained raw_fd_ostream.
A raw_ostream that writes to an SmallVector or SmallString.
Definition: raw_ostream.h:490
Error takeError()
Take ownership of the stored error.
Definition: Error.h:764
file_status - Represents the result of a call to stat and friends.
Definition: FileSystem.h:146
static void print32(raw_ostream &Out, object::Archive::Kind Kind, uint32_t Val)
void append(SmallVectorImpl< char > &path, const Twine &a, const Twine &b="", const Twine &c="", const Twine &d="")
Append to path.
Definition: Path.cpp:465
static void printBSDMemberHeader(raw_fd_ostream &Out, StringRef Name, const sys::TimePoint< std::chrono::seconds > &ModTime, unsigned UID, unsigned GID, unsigned Perms, unsigned Size)
std::pair< StringRef, std::error_code > writeArchive(StringRef ArcName, std::vector< NewArchiveMember > &NewMembers, bool WriteSymtab, object::Archive::Kind Kind, bool Deterministic, bool Thin, std::unique_ptr< MemoryBuffer > OldArchiveBuf=nullptr)
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
std::error_code make_error_code(BitcodeError E)
bool is_absolute(const Twine &path, Style style=Style::native)
Is path absolute?
Definition: Path.cpp:673
Tagged union holding either a T or a Error.
Definition: CachePruning.h:23
uint64_t tell() const
tell - Return the current offset with the file.
Definition: raw_ostream.h:98
static ErrorOr< unsigned > writeSymbolTable(raw_fd_ostream &Out, object::Archive::Kind Kind, ArrayRef< NewArchiveMember > Members, std::vector< unsigned > &MemberOffsetRefs, bool Deterministic)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:33
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
Definition: StringRef.h:138
size_t size() const
size - Get the array size.
Definition: ArrayRef.h:149
const char * Name
static bool isBSDLike(object::Archive::Kind Kind)
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool contains(StringRef Other) const
Return true if the given string is a substring of *this, and false otherwise.
Definition: StringRef.h:448
format_object< Ts...> format(const char *Fmt, const Ts &...Vals)
These are helper functions used to produce formatted output.
Definition: Format.h:124
Expected< sys::fs::perms > getAccessMode() const
Definition: Archive.h:128
Function Alias Analysis false
#define P(N)
static void printRestOfMemberHeader(raw_fd_ostream &Out, const sys::TimePoint< std::chrono::seconds > &ModTime, unsigned UID, unsigned GID, unsigned Perms, unsigned Size)
Expected< unsigned > getUID() const
Definition: Archive.h:125
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:68
std::error_code status(const Twine &path, file_status &result, bool follow=true)
Get file status as if by POSIX stat().
Error errorCodeToError(std::error_code EC)
Helper for converting an std::error_code to a Error.
Definition: Error.cpp:78
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
Definition: SmallVector.h:115
static sys::TimePoint< std::chrono::seconds > now(bool Deterministic)
This class contains a raw_fd_ostream and adds a few extra features commonly needed for compiler-like ...
StringRef parent_path(StringRef path, Style style=Style::native)
Get parent path.
Definition: Path.cpp:476
perms permissions() const
Definition: FileSystem.h:207
static void write(bool isBE, void *P, T V)
void consumeError(Error Err)
Consume a Error without doing anything.
Definition: Error.h:593
raw_ostream & write(unsigned char C)
std::error_code rename(const Twine &from, const Twine &to)
Rename from to to.
StringRef getBuffer() const
Definition: MemoryBuffer.h:169
static bool useStringTable(bool Thin, StringRef Name)
const size_t N
StringRef str()
Return a StringRef for the vector contents.
Definition: raw_ostream.h:515
reference get()
Returns a reference to the stored T value.
Definition: Error.h:744
static Expected< NewArchiveMember > getOldMember(const object::Archive::Child &OldMember, bool Deterministic)
This interface provides simple read-only access to a block of memory, and provides simple methods for...
Definition: MemoryBuffer.h:40
Expected< sys::TimePoint< std::chrono::seconds > > getLastModified() const
Definition: Archive.h:117
StringRef str() const
Explicit conversion to StringRef.
Definition: SmallString.h:267
basic_symbol_iterator_range symbols() const
Definition: SymbolicFile.h:160
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
llvm_unreachable("Unknown RegBank!")
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
Definition: SmallVector.h:119
A raw_ostream that writes to a file descriptor.
Definition: raw_ostream.h:357
void keep()
Indicate that the tool's job wrt this output file has been successful and the file should not be dele...
static void printGNUSmallMemberHeader(raw_fd_ostream &Out, StringRef Name, const sys::TimePoint< std::chrono::seconds > &ModTime, unsigned UID, unsigned GID, unsigned Perms, unsigned Size)
static void writeStringTable(raw_fd_ostream &Out, StringRef ArcName, ArrayRef< NewArchiveMember > Members, std::vector< unsigned > &StringMapIndexes, bool Thin)
This is a value type class that represents a single symbol in the list of symbols in the object file...
Definition: SymbolicFile.h:99
TimePoint getLastModificationTime() const
static Expected< NewArchiveMember > getFile(StringRef FileName, bool Deterministic)
void close()
Manually flush the stream and close the file.
const unsigned Kind
static std::string computeRelativePath(StringRef From, StringRef To)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static void printWithSpacePadding(raw_fd_ostream &OS, T Data, unsigned Size, bool MayTruncate=false)
uint64_t OffsetToAlignment(uint64_t Value, uint64_t Align)
Returns the offset to the next integer (mod 2**64) that is greater than or equal to Value and is a mu...
Definition: MathExtras.h:714
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:44
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
static Expected< std::string > replace(StringRef S, StringRef From, StringRef To)
static ErrorOr< std::unique_ptr< MemoryBuffer > > getOpenFile(int FD, const Twine &Filename, uint64_t FileSize, bool RequiresNullTerminator=true, bool IsVolatile=false)
Given an already-open file descriptor, read the file and return a MemoryBuffer.
std::unique_ptr< MemoryBuffer > Buf
Definition: ArchiveWriter.h:24
file_type type() const
Definition: FileSystem.h:206
Unrecognized file.
Definition: Magic.h:23
sys::TimePoint< std::chrono::seconds > ModTime
Definition: ArchiveWriter.h:26
Expected< MemoryBufferRef > getMemoryBufferRef() const
Definition: Archive.cpp:504
reference get()
Definition: ErrorOr.h:169
std::chrono::time_point< std::chrono::system_clock, D > TimePoint
A time point on the system clock.
Definition: Chrono.h:34