38 #define OPTION(_1, _2, ID, _4, _5, _6, _7, _8, _9, _10, _11, _12) OPT_##ID, 39 #include "Options.inc" 43 #define PREFIX(NAME, VALUE) const char *const NAME[] = VALUE; 44 #include "Options.inc" 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" 57 LibOptTable() : OptTable(InfoTable,
true) {}
65 return Arg->getValue();
73 std::vector<StringRef>
Ret;
79 Ret.push_back(
Arg->getValue());
86 while (!Env.
empty()) {
88 std::tie(Path, Env) = Env.
split(
';');
115 std::unique_ptr<MemoryBuffer>
B;
123 B = std::move(MaybeBuf.
get());
136 for (
auto &
C : Archive.children(Err)) {
150 <<
": failed to open: " << EC.message() <<
'\n';
171 <<
": failed to get target triple from bitcode\n";
186 <<
": unknown arch in target triple " << *TripleStr <<
'\n';
191 static void appendFile(std::vector<NewArchiveMember> &Members,
199 <<
": not a COFF object, bitcode, archive or resource file\n";
222 appendFile(Members, LibMachine, LibMachineSource, *ChildMB);
247 LibMachine = FileMachine;
251 }
else if (LibMachine != FileMachine) {
254 <<
" conflicts with library machine type " 255 <<
machineToStr(LibMachine) << LibMachineSource <<
'\n';
261 Members.emplace_back(MB);
274 unsigned MissingIndex;
275 unsigned MissingCount;
277 Table.ParseArgs(ArgsArr.
slice(1), MissingIndex, MissingCount);
282 << (MissingCount == 1 ?
" argument.\n" :
" arguments.\n");
286 llvm::errs() <<
"ignoring unknown argument: " <<
Arg->getAsString(Args)
290 if (Args.
hasArg(OPT_help)) {
291 Table.PrintHelp(
outs(),
"llvm-lib [options] file...",
"LLVM Lib");
299 if (Args.
hasArg(OPT_lst)) {
304 std::vector<StringRef> SearchPaths =
getSearchPaths(&Args, Saver);
307 std::string LibMachineSource;
311 llvm::errs() <<
"unknown /machine: arg " <<
Arg->getValue() <<
'\n';
315 std::string(
" (from '/machine:") +
Arg->getValue() +
"' flag)";
318 std::vector<std::unique_ptr<MemoryBuffer>> MBs;
320 std::vector<NewArchiveMember> Members;
327 llvm::errs() <<
Arg->getValue() <<
": no such file or directory\n";
338 if (!Seen.
insert(Path).second)
348 appendFile(Members, LibMachine, LibMachineSource, MBRef);
351 MBs.push_back(std::move(*MOrErr));
364 Member.MemberName = Saver.
save(*PathOrErr);
371 true, Args.
hasArg(OPT_llvmlibthin))) {
static COFF::MachineTypes getCOFFFileMachine(MemoryBufferRef MB)
Represents either an error or a value T.
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
LLVM_NODISCARD std::string str() const
str - Get the contents as an std::string.
This class represents lattice values for constants.
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
static std::string findInputFile(StringRef File, ArrayRef< StringRef > Paths)
Windows compiled resource file (.res)
virtual std::string message() const
Return the error message as a string.
iterator_range< filtered_iterator< sizeof...(OptSpecifiers)> > filtered(OptSpecifiers ...Ids) const
Error takeError()
Take ownership of the stored error.
Base class for error info classes.
Error writeArchive(StringRef ArcName, ArrayRef< NewArchiveMember > NewMembers, bool WriteSymtab, object::Archive::Kind Kind, bool Deterministic, bool Thin, std::unique_ptr< MemoryBuffer > OldArchiveBuf=nullptr)
void append(SmallVectorImpl< char > &path, const Twine &a, const Twine &b="", const Twine &c="", const Twine &d="")
Append to path.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
StringRef getBuffer() const
file_magic identify_magic(StringRef magic)
Identify the type of a binary file based on how magical it is.
bool ExpandResponseFiles(StringSaver &Saver, TokenizerCallback Tokenizer, SmallVectorImpl< const char *> &Argv, bool MarkEOLs=false, bool RelativeNames=false, llvm::vfs::FileSystem &FS= *llvm::vfs::getRealFileSystem(), llvm::Optional< llvm::StringRef > CurrentDir=llvm::None)
Expand response files on a command line recursively using the given StringSaver and tokenization stra...
StringRef machineToStr(COFF::MachineTypes MT)
Tagged union holding either a T or a Error.
void TokenizeWindowsCommandLine(StringRef Source, StringSaver &Saver, SmallVectorImpl< const char *> &NewArgv, bool MarkEOLs=false)
Tokenizes a Windows command line which may contain quotes and escaped quotes.
LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
StringRef str() const
Explicit conversion to StringRef.
static std::vector< StringRef > getSearchPaths(opt::InputArgList *Args, StringSaver &Saver)
ArchType getArch() const
getArch - Get the parsed architecture type of this triple.
bool hasArg(OptSpecifiers ...Ids) const
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
COFF::MachineTypes Machine
raw_ostream & outs()
This returns a reference to a raw_ostream for standard output.
bool hasArgNoClaim(OptSpecifiers ...Ids) const
hasArg - Does the arg list contain any option matching Id.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static void fatalOpenError(llvm::Error E, Twine File)
Allocate memory in an ever growing pool, as if by bump-pointer.
Instrumentation for Order File
Provide access to the Option info table.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Error errorCodeToError(std::error_code EC)
Helper for converting an std::error_code to a Error.
std::error_code getError() const
static void doList(opt::InputArgList &Args)
Expected< std::string > getBitcodeTargetTriple(MemoryBufferRef Buffer)
Read the header of the specified bitcode buffer and extract just the triple information.
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
int libDriverMain(ArrayRef< const char *> ARgs)
std::pair< typename base::iterator, bool > insert(StringRef Key)
uint16_t getMachine() const
Triple - Helper class for working with autoconf configuration names.
Arg * getLastArg(OptSpecifiers ...Ids) const
Return the last argument matching Id, or null.
static const char *const Magic
void handleAllErrors(Error E, HandlerTs &&... Handlers)
Behaves the same as handleErrors, except that by contract all errors must be handled by the given han...
static ErrorSuccess success()
Create a success value.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
void replace_extension(SmallVectorImpl< char > &path, const Twine &extension, Style style=Style::native)
Replace the file extension of path with extension.
LLVM_NODISCARD std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
reference get()
Returns a reference to the stored T value.
static COFF::MachineTypes getBitcodeFileMachine(MemoryBufferRef MB)
StringRef save(const char *S)
Defines the llvm::Arg class for parsed arguments.
StringRef getBufferIdentifier() const
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...
iterator_range< child_iterator > children(Error &Err, bool SkipInternal=true) const
Saves strings in the provided stable storage and returns a StringRef with a stable character pointer...
Provides a library for accessing information about this process and other processes on the operating ...
Expected< std::string > computeArchiveRelativePath(StringRef From, StringRef To)
static std::string getOutputPath(opt::InputArgList *Args, const NewArchiveMember &FirstMember)
StringRef getName() const
Return a constant reference to the value's name.
Entry for a single option instance in the option data table.
bool is_relative(const Twine &path, Style style=Style::native)
Is path relative?
static void appendFile(std::vector< NewArchiveMember > &Members, COFF::MachineTypes &LibMachine, std::string &LibMachineSource, MemoryBufferRef MB)
COFF::MachineTypes getMachineType(StringRef S)
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFile(const Twine &Filename, int64_t FileSize=-1, bool RequiresNullTerminator=true, bool IsVolatile=false)
Open the specified file as a MemoryBuffer, returning a new MemoryBuffer if successful, otherwise returning null.
Lightweight error class with error context and mandatory checking.
StringSet - A wrapper for StringMap that provides set-like functionality.
StringRef - Represent a constant reference to a string, i.e.
std::unique_ptr< MemoryBuffer > Buf
bool exists(const basic_file_status &status)
Does file exist?
static Optional< std::string > GetEnv(StringRef name)
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
file_magic - An "enum class" enumeration of file types based on magic (the first N bytes of the file)...