LLVM  16.0.0git
LibDriver.cpp
Go to the documentation of this file.
1 //===- LibDriver.cpp - lib.exe-compatible driver --------------------------===//
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 // Defines an interface to a lib.exe-compatible driver that also understands
10 // bitcode files. Used by llvm-lib and lld-link /lib.
11 //
12 //===----------------------------------------------------------------------===//
13 
15 #include "llvm/ADT/STLExtras.h"
16 #include "llvm/ADT/StringSet.h"
17 #include "llvm/BinaryFormat/COFF.h"
21 #include "llvm/Object/COFF.h"
23 #include "llvm/Option/Arg.h"
24 #include "llvm/Option/ArgList.h"
25 #include "llvm/Option/Option.h"
27 #include "llvm/Support/Path.h"
28 #include "llvm/Support/Process.h"
31 
32 using namespace llvm;
33 
34 namespace {
35 
36 enum {
37  OPT_INVALID = 0,
38 #define OPTION(_1, _2, ID, _4, _5, _6, _7, _8, _9, _10, _11, _12) OPT_##ID,
39 #include "Options.inc"
40 #undef OPTION
41 };
42 
43 #define PREFIX(NAME, VALUE) const char *const NAME[] = VALUE;
44 #include "Options.inc"
45 #undef PREFIX
46 
47 static const opt::OptTable::Info InfoTable[] = {
48 #define OPTION(X1, X2, ID, KIND, GROUP, ALIAS, X7, X8, X9, X10, X11, X12) \
49  {X1, X2, X10, X11, OPT_##ID, opt::Option::KIND##Class, \
50  X9, X8, OPT_##GROUP, OPT_##ALIAS, X7, X12},
51 #include "Options.inc"
52 #undef OPTION
53 };
54 
55 class LibOptTable : public opt::OptTable {
56 public:
57  LibOptTable() : OptTable(InfoTable, true) {}
58 };
59 
60 }
61 
62 static std::string getDefaultOutputPath(const NewArchiveMember &FirstMember) {
63  SmallString<128> Val = StringRef(FirstMember.Buf->getBufferIdentifier());
64  sys::path::replace_extension(Val, ".lib");
65  return std::string(Val.str());
66 }
67 
68 static std::vector<StringRef> getSearchPaths(opt::InputArgList *Args,
69  StringSaver &Saver) {
70  std::vector<StringRef> Ret;
71  // Add current directory as first item of the search path.
72  Ret.push_back("");
73 
74  // Add /libpath flags.
75  for (auto *Arg : Args->filtered(OPT_libpath))
76  Ret.push_back(Arg->getValue());
77 
78  // Add $LIB.
80  if (!EnvOpt)
81  return Ret;
82  StringRef Env = Saver.save(*EnvOpt);
83  while (!Env.empty()) {
84  StringRef Path;
85  std::tie(Path, Env) = Env.split(';');
86  Ret.push_back(Path);
87  }
88  return Ret;
89 }
90 
91 static std::string findInputFile(StringRef File, ArrayRef<StringRef> Paths) {
92  for (StringRef Dir : Paths) {
93  SmallString<128> Path = Dir;
94  sys::path::append(Path, File);
95  if (sys::fs::exists(Path))
96  return std::string(Path);
97  }
98  return "";
99 }
100 
101 static void fatalOpenError(llvm::Error E, Twine File) {
102  if (!E)
103  return;
104  handleAllErrors(std::move(E), [&](const llvm::ErrorInfoBase &EIB) {
105  llvm::errs() << "error opening '" << File << "': " << EIB.message() << '\n';
106  exit(1);
107  });
108 }
109 
111  // lib.exe prints the contents of the first archive file.
112  std::unique_ptr<MemoryBuffer> B;
113  for (auto *Arg : Args.filtered(OPT_INPUT)) {
114  // Create or open the archive object.
116  Arg->getValue(), /*IsText=*/false, /*RequiresNullTerminator=*/false);
117  fatalOpenError(errorCodeToError(MaybeBuf.getError()), Arg->getValue());
118 
119  if (identify_magic(MaybeBuf.get()->getBuffer()) == file_magic::archive) {
120  B = std::move(MaybeBuf.get());
121  break;
122  }
123  }
124 
125  // lib.exe doesn't print an error if no .lib files are passed.
126  if (!B)
127  return;
128 
129  Error Err = Error::success();
130  object::Archive Archive(B.get()->getMemBufferRef(), Err);
131  fatalOpenError(std::move(Err), B->getBufferIdentifier());
132 
133  for (auto &C : Archive.children(Err)) {
134  Expected<StringRef> NameOrErr = C.getName();
135  fatalOpenError(NameOrErr.takeError(), B->getBufferIdentifier());
136  StringRef Name = NameOrErr.get();
137  llvm::outs() << Name << '\n';
138  }
139  fatalOpenError(std::move(Err), B->getBufferIdentifier());
140 }
141 
143  std::error_code EC;
144  auto Obj = object::COFFObjectFile::create(MB);
145  if (!Obj)
146  return Obj.takeError();
147 
148  uint16_t Machine = (*Obj)->getMachine();
154  "unknown machine: " + std::to_string(Machine));
155  }
156 
157  return static_cast<COFF::MachineTypes>(Machine);
158 }
159 
162  if (!TripleStr)
163  return TripleStr.takeError();
164 
165  switch (Triple(*TripleStr).getArch()) {
166  case Triple::x86:
168  case Triple::x86_64:
170  case Triple::arm:
172  case Triple::aarch64:
174  default:
176  "unknown arch in target triple: " + *TripleStr);
177  }
178 }
179 
180 static void appendFile(std::vector<NewArchiveMember> &Members,
181  COFF::MachineTypes &LibMachine,
182  std::string &LibMachineSource, MemoryBufferRef MB) {
184 
189  << ": not a COFF object, bitcode, archive, import library or "
190  "resource file\n";
191  exit(1);
192  }
193 
194  // If a user attempts to add an archive to another archive, llvm-lib doesn't
195  // handle the first archive file as a single file. Instead, it extracts all
196  // members from the archive and add them to the second archive. This behavior
197  // is for compatibility with Microsoft's lib command.
198  if (Magic == file_magic::archive) {
199  Error Err = Error::success();
200  object::Archive Archive(MB, Err);
202 
203  for (auto &C : Archive.children(Err)) {
204  Expected<MemoryBufferRef> ChildMB = C.getMemoryBufferRef();
205  if (!ChildMB) {
206  handleAllErrors(ChildMB.takeError(), [&](const ErrorInfoBase &EIB) {
207  llvm::errs() << MB.getBufferIdentifier() << ": " << EIB.message()
208  << "\n";
209  });
210  exit(1);
211  }
212 
213  appendFile(Members, LibMachine, LibMachineSource, *ChildMB);
214  }
215 
217  return;
218  }
219 
220  // Check that all input files have the same machine type.
221  // Mixing normal objects and LTO bitcode files is fine as long as they
222  // have the same machine type.
223  // Doing this here duplicates the header parsing work that writeArchive()
224  // below does, but it's not a lot of work and it's a bit awkward to do
225  // in writeArchive() which needs to support many tools, can't assume the
226  // input is COFF, and doesn't have a good way to report errors.
228  Expected<COFF::MachineTypes> MaybeFileMachine =
230  : getBitcodeFileMachine(MB);
231  if (!MaybeFileMachine) {
232  handleAllErrors(MaybeFileMachine.takeError(),
233  [&](const ErrorInfoBase &EIB) {
234  llvm::errs() << MB.getBufferIdentifier() << ": "
235  << EIB.message() << "\n";
236  });
237  exit(1);
238  }
239  COFF::MachineTypes FileMachine = *MaybeFileMachine;
240 
241  // FIXME: Once lld-link rejects multiple resource .obj files:
242  // Call convertResToCOFF() on .res files and add the resulting
243  // COFF file to the .lib output instead of adding the .res file, and remove
244  // this check. See PR42180.
245  if (FileMachine != COFF::IMAGE_FILE_MACHINE_UNKNOWN) {
246  if (LibMachine == COFF::IMAGE_FILE_MACHINE_UNKNOWN) {
247  LibMachine = FileMachine;
248  LibMachineSource =
249  (" (inferred from earlier file '" + MB.getBufferIdentifier() + "')")
250  .str();
251  } else if (LibMachine != FileMachine) {
252  llvm::errs() << MB.getBufferIdentifier() << ": file machine type "
253  << machineToStr(FileMachine)
254  << " conflicts with library machine type "
255  << machineToStr(LibMachine) << LibMachineSource << '\n';
256  exit(1);
257  }
258  }
259  }
260 
261  Members.emplace_back(MB);
262 }
263 
266  StringSaver Saver(Alloc);
267 
268  // Parse command line arguments.
269  SmallVector<const char *, 20> NewArgs(ArgsArr.begin(), ArgsArr.end());
271  ArgsArr = NewArgs;
272 
273  LibOptTable Table;
274  unsigned MissingIndex;
275  unsigned MissingCount;
277  Table.ParseArgs(ArgsArr.slice(1), MissingIndex, MissingCount);
278  if (MissingCount) {
279  llvm::errs() << "missing arg value for \""
280  << Args.getArgString(MissingIndex) << "\", expected "
281  << MissingCount
282  << (MissingCount == 1 ? " argument.\n" : " arguments.\n");
283  return 1;
284  }
285  for (auto *Arg : Args.filtered(OPT_UNKNOWN))
286  llvm::errs() << "ignoring unknown argument: " << Arg->getAsString(Args)
287  << "\n";
288 
289  // Handle /help
290  if (Args.hasArg(OPT_help)) {
291  Table.printHelp(outs(), "llvm-lib [options] file...", "LLVM Lib");
292  return 0;
293  }
294 
295  // Parse /ignore:
296  llvm::StringSet<> IgnoredWarnings;
297  for (auto *Arg : Args.filtered(OPT_ignore))
298  IgnoredWarnings.insert(Arg->getValue());
299 
300  // If no input files and not told otherwise, silently do nothing to match
301  // lib.exe
302  if (!Args.hasArgNoClaim(OPT_INPUT) && !Args.hasArg(OPT_llvmlibempty)) {
303  if (!IgnoredWarnings.contains("emptyoutput")) {
304  llvm::errs() << "warning: no input files, not writing output file\n";
305  llvm::errs() << " pass /llvmlibempty to write empty .lib file,\n";
306  llvm::errs() << " pass /ignore:emptyoutput to suppress warning\n";
307  if (Args.hasFlag(OPT_WX, OPT_WX_no, false)) {
308  llvm::errs() << "treating warning as error due to /WX\n";
309  return 1;
310  }
311  }
312  return 0;
313  }
314 
315  if (Args.hasArg(OPT_lst)) {
316  doList(Args);
317  return 0;
318  }
319 
320  std::vector<StringRef> SearchPaths = getSearchPaths(&Args, Saver);
321 
323  std::string LibMachineSource;
324  if (auto *Arg = Args.getLastArg(OPT_machine)) {
325  LibMachine = getMachineType(Arg->getValue());
326  if (LibMachine == COFF::IMAGE_FILE_MACHINE_UNKNOWN) {
327  llvm::errs() << "unknown /machine: arg " << Arg->getValue() << '\n';
328  return 1;
329  }
330  LibMachineSource =
331  std::string(" (from '/machine:") + Arg->getValue() + "' flag)";
332  }
333 
334  std::vector<std::unique_ptr<MemoryBuffer>> MBs;
335  StringSet<> Seen;
336  std::vector<NewArchiveMember> Members;
337 
338  // Create a NewArchiveMember for each input file.
339  for (auto *Arg : Args.filtered(OPT_INPUT)) {
340  // Find a file
341  std::string Path = findInputFile(Arg->getValue(), SearchPaths);
342  if (Path.empty()) {
343  llvm::errs() << Arg->getValue() << ": no such file or directory\n";
344  return 1;
345  }
346 
347  // Input files are uniquified by pathname. If you specify the exact same
348  // path more than once, all but the first one are ignored.
349  //
350  // Note that there's a loophole in the rule; you can prepend `.\` or
351  // something like that to a path to make it look different, and they are
352  // handled as if they were different files. This behavior is compatible with
353  // Microsoft lib.exe.
354  if (!Seen.insert(Path).second)
355  continue;
356 
357  // Open a file.
359  Path, /*IsText=*/false, /*RequiresNullTerminator=*/false);
360  fatalOpenError(errorCodeToError(MOrErr.getError()), Path);
361  MemoryBufferRef MBRef = (*MOrErr)->getMemBufferRef();
362 
363  // Append a file.
364  appendFile(Members, LibMachine, LibMachineSource, MBRef);
365 
366  // Take the ownership of the file buffer to keep the file open.
367  MBs.push_back(std::move(*MOrErr));
368  }
369 
370  // Create an archive file.
371  std::string OutputPath;
372  if (auto *Arg = Args.getLastArg(OPT_out)) {
373  OutputPath = Arg->getValue();
374  } else if (!Members.empty()) {
375  OutputPath = getDefaultOutputPath(Members[0]);
376  } else {
377  llvm::errs() << "no output path given, and cannot infer with no inputs\n";
378  return 1;
379  }
380  // llvm-lib uses relative paths for both regular and thin archives, unlike
381  // standard GNU ar, which only uses relative paths for thin archives and
382  // basenames for regular archives.
383  for (NewArchiveMember &Member : Members) {
384  if (sys::path::is_relative(Member.MemberName)) {
385  Expected<std::string> PathOrErr =
386  computeArchiveRelativePath(OutputPath, Member.MemberName);
387  if (PathOrErr)
388  Member.MemberName = Saver.save(*PathOrErr);
389  }
390  }
391 
392  if (Error E =
393  writeArchive(OutputPath, Members,
394  /*WriteSymtab=*/true, object::Archive::K_GNU,
395  /*Deterministic*/ true, Args.hasArg(OPT_llvmlibthin))) {
396  handleAllErrors(std::move(E), [&](const ErrorInfoBase &EI) {
397  llvm::errs() << OutputPath << ": " << EI.message() << "\n";
398  });
399  return 1;
400  }
401 
402  return 0;
403 }
llvm::NewArchiveMember
Definition: ArchiveWriter.h:20
llvm::opt::OptTable
Provide access to the Option info table.
Definition: OptTable.h:40
Option.h
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::machineToStr
StringRef machineToStr(COFF::MachineTypes MT)
Definition: WindowsMachineFlag.cpp:32
llvm::opt::InputArgList
Definition: ArgList.h:383
llvm::file_magic
file_magic - An "enum class" enumeration of file types based on magic (the first N bytes of the file)...
Definition: Magic.h:20
llvm::object::Archive::children
iterator_range< child_iterator > children(Error &Err, bool SkipInternal=true) const
Definition: Archive.h:347
llvm::getMachineType
COFF::MachineTypes getMachineType(StringRef S)
Definition: WindowsMachineFlag.cpp:22
llvm::Triple::x86
@ x86
Definition: Triple.h:85
llvm::NewArchiveMember::Buf
std::unique_ptr< MemoryBuffer > Buf
Definition: ArchiveWriter.h:21
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1182
Path.h
llvm::Error::success
static ErrorSuccess success()
Create a success value.
Definition: Error.h:329
doList
static void doList(opt::InputArgList &Args)
Definition: LibDriver.cpp:110
llvm::COFF::IMAGE_FILE_MACHINE_AMD64
@ IMAGE_FILE_MACHINE_AMD64
Definition: COFF.h:97
llvm::COFF::IMAGE_FILE_MACHINE_UNKNOWN
@ IMAGE_FILE_MACHINE_UNKNOWN
Definition: COFF.h:95
llvm::Triple
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
COFF.h
llvm::object::Archive::K_GNU
@ K_GNU
Definition: Archive.h:339
LibDriver.h
true
basic Basic Alias true
Definition: BasicAliasAnalysis.cpp:1877
llvm::Triple::x86_64
@ x86_64
Definition: Triple.h:86
llvm::COFF::IMAGE_FILE_MACHINE_ARMNT
@ IMAGE_FILE_MACHINE_ARMNT
Definition: COFF.h:99
llvm::Optional< std::string >
getBitcodeFileMachine
static Expected< COFF::MachineTypes > getBitcodeFileMachine(MemoryBufferRef MB)
Definition: LibDriver.cpp:160
llvm::errs
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
Definition: raw_ostream.cpp:891
llvm::StringSet::insert
std::pair< typename Base::iterator, bool > insert(StringRef key)
Definition: StringSet.h:34
llvm::MipsISD::Ret
@ Ret
Definition: MipsISelLowering.h:119
llvm::Expected
Tagged union holding either a T or a Error.
Definition: APFloat.h:41
STLExtras.h
llvm::MemoryBufferRef
Definition: MemoryBufferRef.h:22
getSearchPaths
static std::vector< StringRef > getSearchPaths(opt::InputArgList *Args, StringSaver &Saver)
Definition: LibDriver.cpp:68
llvm::file_magic::bitcode
@ bitcode
Bitcode file.
Definition: Magic.h:23
llvm::sys::path::append
void append(SmallVectorImpl< char > &path, const Twine &a, const Twine &b="", const Twine &c="", const Twine &d="")
Append to path.
Definition: Path.cpp:456
Arg
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
Definition: AMDGPULibCalls.cpp:186
CommandLine.h
llvm::MemoryBuffer::getFile
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFile(const Twine &Filename, bool IsText=false, bool RequiresNullTerminator=true, bool IsVolatile=false)
Open the specified file as a MemoryBuffer, returning a new MemoryBuffer if successful,...
Definition: MemoryBuffer.cpp:239
llvm::COFF::IMAGE_FILE_MACHINE_I386
@ IMAGE_FILE_MACHINE_I386
Definition: COFF.h:103
llvm::object::Archive
Definition: Archive.h:159
Process.h
ArchiveWriter.h
Magic.h
llvm::outs
raw_fd_ostream & outs()
This returns a reference to a raw_fd_ostream for standard output.
Definition: raw_ostream.cpp:883
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
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:92
llvm::writeArchive
Error writeArchive(StringRef ArcName, ArrayRef< NewArchiveMember > NewMembers, bool WriteSymtab, object::Archive::Kind Kind, bool Deterministic, bool Thin, std::unique_ptr< MemoryBuffer > OldArchiveBuf=nullptr)
Definition: ArchiveWriter.cpp:823
WindowsMachineFlag.h
llvm::ErrorOr::getError
std::error_code getError() const
Definition: ErrorOr.h:153
llvm::StringSet::contains
bool contains(StringRef key) const
Check if the set contains the given key.
Definition: StringSet.h:51
B
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
llvm::cl::TokenizeWindowsCommandLine
void TokenizeWindowsCommandLine(StringRef Source, StringSaver &Saver, SmallVectorImpl< const char * > &NewArgv, bool MarkEOLs=false)
Tokenizes a string of Windows command line arguments, which may contain quotes and escaped quotes.
Definition: CommandLine.cpp:1046
llvm::Triple::getArch
ArchType getArch() const
Get the parsed architecture type of this triple.
Definition: Triple.h:346
llvm::ArrayRef::slice
ArrayRef< T > slice(size_t N, size_t M) const
slice(n, m) - Chop off the first N elements of the array, and keep M elements in the array.
Definition: ArrayRef.h:194
llvm::ErrorInfoBase
Base class for error info classes.
Definition: Error.h:46
findInputFile
static std::string findInputFile(StringRef File, ArrayRef< StringRef > Paths)
Definition: LibDriver.cpp:91
llvm::ErrorInfoBase::message
virtual std::string message() const
Return the error message as a string.
Definition: Error.h:54
llvm::SmallString< 128 >
fatalOpenError
static void fatalOpenError(llvm::Error E, Twine File)
Definition: LibDriver.cpp:101
llvm::file_magic::coff_import_library
@ coff_import_library
COFF import library.
Definition: Magic.h:47
StringSaver.h
llvm::StringRef::empty
constexpr bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:134
llvm::sys::fs::exists
bool exists(const basic_file_status &status)
Does file exist?
Definition: Path.cpp:1077
Alloc
llvm::sys::path::replace_extension
void replace_extension(SmallVectorImpl< char > &path, const Twine &extension, Style style=Style::native)
Replace the file extension of path with extension.
Definition: Path.cpp:480
llvm::BumpPtrAllocatorImpl
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:63
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::file_magic::coff_object
@ coff_object
COFF object file.
Definition: Magic.h:46
llvm::object::COFFObjectFile::create
static Expected< std::unique_ptr< COFFObjectFile > > create(MemoryBufferRef Object)
Definition: COFFObjectFile.cpp:760
llvm::cl::ExpandResponseFiles
bool ExpandResponseFiles(StringSaver &Saver, TokenizerCallback Tokenizer, SmallVectorImpl< const char * > &Argv, bool MarkEOLs, bool RelativeNames, bool ExpandBasePath, llvm::Optional< llvm::StringRef > CurrentDir, llvm::vfs::FileSystem &FS)
Expand response files on a command line recursively using the given StringSaver and tokenization stra...
Definition: CommandLine.cpp:1222
llvm::sys::Process::GetEnv
static Optional< std::string > GetEnv(StringRef name)
llvm::libDriverMain
int libDriverMain(ArrayRef< const char * > ARgs)
Definition: LibDriver.cpp:264
llvm::MemoryBufferRef::getBuffer
StringRef getBuffer() const
Definition: MemoryBufferRef.h:32
getDefaultOutputPath
static std::string getDefaultOutputPath(const NewArchiveMember &FirstMember)
Definition: LibDriver.cpp:62
llvm::StringSaver
Saves strings in the provided stable storage and returns a StringRef with a stable character pointer.
Definition: StringSaver.h:21
llvm::computeArchiveRelativePath
Expected< std::string > computeArchiveRelativePath(StringRef From, StringRef To)
Definition: ArchiveWriter.cpp:629
llvm::StringSet
StringSet - A wrapper for StringMap that provides set-like functionality.
Definition: StringSet.h:23
Arg.h
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
llvm::Triple::arm
@ arm
Definition: Triple.h:49
appendFile
static void appendFile(std::vector< NewArchiveMember > &Members, COFF::MachineTypes &LibMachine, std::string &LibMachineSource, MemoryBufferRef MB)
Definition: LibDriver.cpp:180
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
llvm::msf::Magic
static const char Magic[]
Definition: MSFCommon.h:23
llvm::getBitcodeTargetTriple
Expected< std::string > getBitcodeTargetTriple(MemoryBufferRef Buffer)
Read the header of the specified bitcode buffer and extract just the triple information.
Definition: BitcodeReader.cpp:7915
llvm::Expected::get
reference get()
Returns a reference to the stored T value.
Definition: Error.h:567
llvm::COFF::IMAGE_FILE_MACHINE_ARM64
@ IMAGE_FILE_MACHINE_ARM64
Definition: COFF.h:100
StringSet.h
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
llvm::createStringError
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
Definition: Error.h:1239
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:50
ArgList.h
llvm::inconvertibleErrorCode
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
Definition: Error.cpp:79
uint16_t
llvm::ArrayRef::begin
iterator begin() const
Definition: ArrayRef.h:152
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:155
llvm::file_magic::archive
@ archive
ar style archive file
Definition: Magic.h:24
llvm::COFF::MachineTypes
MachineTypes
Definition: COFF.h:92
llvm::SmallString::str
StringRef str() const
Explicit conversion to StringRef.
Definition: SmallString.h:260
llvm::Expected::takeError
Error takeError()
Take ownership of the stored error.
Definition: Error.h:597
getCOFFFileMachine
static Expected< COFF::MachineTypes > getCOFFFileMachine(MemoryBufferRef MB)
Definition: LibDriver.cpp:142
Machine
COFF::MachineTypes Machine
Definition: COFFYAML.cpp:370
COFF.h
llvm::ErrorOr::get
reference get()
Definition: ErrorOr.h:150
exit
declare void exit(i32) noreturn nounwind This compiles into
Definition: README.txt:1072
llvm::ErrorOr
Represents either an error or a value T.
Definition: ErrorOr.h:56
llvm::to_string
std::string to_string(const T &Value)
Definition: ScopedPrinter.h:85
llvm::StringSaver::save
StringRef save(const char *S)
Definition: StringSaver.h:28
llvm::MemoryBufferRef::getBufferIdentifier
StringRef getBufferIdentifier() const
Definition: MemoryBufferRef.h:33
llvm::opt::OptTable::Info
Entry for a single option instance in the option data table.
Definition: OptTable.h:43
llvm::AMDGPU::HSAMD::Kernel::Key::Args
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
Definition: AMDGPUMetadata.h:394
BitcodeReader.h
raw_ostream.h
llvm::identify_magic
file_magic identify_magic(StringRef magic)
Identify the type of a binary file based on how magical it is.
Definition: Magic.cpp:33
llvm::file_magic::windows_resource
@ windows_resource
Windows compiled resource file (.res)
Definition: Magic.h:49
llvm::sys::path::is_relative
bool is_relative(const Twine &path, Style style=Style::native)
Is path relative?
Definition: Path.cpp:699
llvm::handleAllErrors
void handleAllErrors(Error E, HandlerTs &&... Handlers)
Behaves the same as handleErrors, except that by contract all errors must be handled by the given han...
Definition: Error.h:966
llvm::StringRef::split
std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
Definition: StringRef.h:689
llvm::ArrayRef::end
iterator end() const
Definition: ArrayRef.h:153
llvm::Triple::aarch64
@ aarch64
Definition: Triple.h:51