LLVM
15.0.0git
|
#include "llvm/Support/CommandLine.h"
#include "DebugOptions.h"
#include "llvm-c/Support.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/STLFunctionalExtras.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Triple.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Config/config.h"
#include "llvm/Support/ConvertUTF.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Host.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/Process.h"
#include "llvm/Support/StringSaver.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "llvm/Support/raw_ostream.h"
#include <cstdlib>
#include <string>
Go to the source code of this file.
Namespaces | |
llvm | |
This is an optimization pass for GlobalISel generic memory operations. | |
llvm::cl | |
This namespace contains all of the command line option processing machinery. | |
Macros | |
#define | DEBUG_TYPE "commandline" |
#define | PRINT_OPT_DIFF(T) |
#define | LLVM_IS_DEBUG_BUILD 0 |
Functions | |
static size_t | argPlusPrefixesSize (StringRef ArgName, size_t Pad=DefaultPad) |
static SmallString< 8 > | argPrefix (StringRef ArgName, size_t Pad=DefaultPad) |
static bool | isGrouping (const Option *O) |
static bool | isPrefixedOrGrouping (const Option *O) |
static Option * | LookupNearestOption (StringRef Arg, const StringMap< Option * > &OptionsMap, std::string &NearestString) |
LookupNearestOption - Lookup the closest match to the option specified by the specified option on the command line. More... | |
static bool | CommaSeparateAndAddOccurrence (Option *Handler, unsigned pos, StringRef ArgName, StringRef Value, bool MultiArg=false) |
CommaSeparateAndAddOccurrence - A wrapper around Handler->addOccurrence() that does special handling of cl::CommaSeparated options. More... | |
static bool | ProvideOption (Option *Handler, StringRef ArgName, StringRef Value, int argc, const char *const *argv, int &i) |
ProvideOption - For Value, this differentiates between an empty value ("") and a null value (StringRef()). More... | |
static Option * | getOptionPred (StringRef Name, size_t &Length, bool(*Pred)(const Option *), const StringMap< Option * > &OptionsMap) |
static Option * | HandlePrefixedOrGroupedOption (StringRef &Arg, StringRef &Value, bool &ErrorParsing, const StringMap< Option * > &OptionsMap) |
HandlePrefixedOrGroupedOption - The specified argument string (which started with at least one '-') does not fully match an available option. More... | |
static bool | RequiresValue (const Option *O) |
static bool | EatsUnboundedNumberOfValues (const Option *O) |
static bool | isWhitespace (char C) |
static bool | isWhitespaceOrNull (char C) |
static bool | isQuote (char C) |
static size_t | parseBackslash (StringRef Src, size_t I, SmallString< 128 > &Token) |
Backslashes are interpreted in a rather complicated way in the Windows-style command line, because backslashes are used both to separate path and to escape double quote. More... | |
static bool | isWindowsSpecialChar (char C) |
static bool | isWindowsSpecialCharInCommandName (char C) |
static void | tokenizeWindowsCommandLineImpl (StringRef Src, StringSaver &Saver, function_ref< void(StringRef)> AddToken, bool AlwaysCopy, function_ref< void()> MarkEOL, bool InitialCommandName) |
static bool | hasUTF8ByteOrderMark (ArrayRef< char > S) |
static void | ExpandBasePaths (StringRef BasePath, StringSaver &Saver, const char *&Arg) |
static llvm::Error | ExpandResponseFile (StringRef FName, StringSaver &Saver, TokenizerCallback Tokenizer, SmallVectorImpl< const char * > &NewArgv, bool MarkEOLs, bool RelativeNames, bool ExpandBasePath, llvm::vfs::FileSystem &FS) |
static void | initCommonOptions () |
static StringRef | getValueStr (const Option &O, StringRef DefaultMsg) |
static bool | parseDouble (Option &O, StringRef Arg, double &Value) |
static size_t | getOptionPrefixesSize () |
static bool | shouldPrintOption (StringRef Name, StringRef Description, const Option &O) |
static int | OptNameCompare (const std::pair< const char *, Option * > *LHS, const std::pair< const char *, Option * > *RHS) |
static int | SubNameCompare (const std::pair< const char *, SubCommand * > *LHS, const std::pair< const char *, SubCommand * > *RHS) |
static void | sortOpts (StringMap< Option * > &OptMap, SmallVectorImpl< std::pair< const char *, Option * >> &Opts, bool ShowHidden) |
static void | sortSubCommands (const SmallPtrSetImpl< SubCommand * > &SubMap, SmallVectorImpl< std::pair< const char *, SubCommand * >> &Subs) |
void | LLVMParseCommandLineOptions (int argc, const char *const *argv, const char *Overview) |
This function parses the given arguments using the LLVM command line parser. More... | |
Variables | |
const static size_t | DefaultPad = 2 |
static StringRef | ArgPrefix = "-" |
static StringRef | ArgPrefixLong = "--" |
static StringRef | ArgHelpPrefix = " - " |
static ManagedStatic< CommandLineParser > | GlobalParser |
static StringRef | EqValue = "=<value>" |
static StringRef | EmptyOption = "<empty>" |
static StringRef | OptionPrefix = " =" |
static const size_t | MaxOptWidth = 8 |
static ManagedStatic< CommandLineCommonOptions > | CommonOptions |
#define DEBUG_TYPE "commandline" |
Definition at line 52 of file CommandLine.cpp.
#define LLVM_IS_DEBUG_BUILD 0 |
Definition at line 2458 of file CommandLine.cpp.
#define PRINT_OPT_DIFF | ( | T | ) |
Definition at line 2129 of file CommandLine.cpp.
|
static |
Definition at line 107 of file CommandLine.cpp.
References ArgHelpPrefix, ArgPrefix, ArgPrefixLong, and llvm::StringRef::size().
Referenced by llvm::cl::generic_parser_base::getOptionWidth(), llvm::cl::basic_parser_impl::getOptionWidth(), and llvm::cl::generic_parser_base::printOptionInfo().
|
static |
Definition at line 114 of file CommandLine.cpp.
References ArgPrefix, ArgPrefixLong, I, llvm::cl::Prefix, and llvm::StringRef::size().
|
static |
CommaSeparateAndAddOccurrence - A wrapper around Handler->addOccurrence() that does special handling of cl::CommaSeparated options.
Definition at line 620 of file CommandLine.cpp.
References llvm::cl::Option::addOccurrence(), llvm::cl::CommaSeparated, llvm::StringRef::find(), llvm::cl::Option::getMiscFlags(), llvm::StringRef::npos, and llvm::StringRef::substr().
Referenced by ProvideOption().
Definition at line 807 of file CommandLine.cpp.
References llvm::RISCVFenceField::O, llvm::cl::OneOrMore, and llvm::cl::ZeroOrMore.
|
static |
Definition at line 1120 of file CommandLine.cpp.
References llvm::SmallString< InternalLen >::append(), llvm::sys::path::append(), Arg, assert(), llvm::StringRef::data(), llvm::StringRef::empty(), llvm::StringRef::find(), llvm::sys::path::is_absolute(), LHS, llvm::StringRef::npos, llvm::StringSaver::save(), llvm::SmallString< InternalLen >::str(), and llvm::StringRef::substr().
Referenced by ExpandResponseFile().
|
static |
Definition at line 1152 of file CommandLine.cpp.
References llvm::SmallString< InternalLen >::append(), llvm::sys::path::append(), Arg, assert(), llvm::convertUTF16ToUTF8String(), llvm::createStringError(), llvm::StringRef::data(), llvm::ArrayRef< T >::data(), llvm::errorCodeToError(), ExpandBasePaths(), llvm::X86AS::FS, llvm::ErrorOr< T >::get(), llvm::MemoryBuffer::getBufferEnd(), llvm::MemoryBuffer::getBufferSize(), llvm::MemoryBuffer::getBufferStart(), llvm::ErrorOr< T >::getError(), llvm::hasUTF16ByteOrderMark(), hasUTF8ByteOrderMark(), llvm::sys::path::is_absolute(), llvm::sys::path::is_relative(), llvm::sys::path::parent_path(), llvm::StringSaver::save(), llvm::ArrayRef< T >::size(), llvm::SmallString< InternalLen >::str(), and llvm::Error::success().
|
static |
Definition at line 719 of file CommandLine.cpp.
References llvm::StringMap< ValueTy, AllocatorTy >::end(), and llvm::StringMap< ValueTy, AllocatorTy >::find().
Referenced by HandlePrefixedOrGroupedOption().
|
static |
Definition at line 2013 of file CommandLine.cpp.
References ArgHelpPrefix, OptionPrefix, and llvm::StringRef::size().
Referenced by llvm::cl::generic_parser_base::getOptionWidth(), and llvm::cl::generic_parser_base::printOptionInfo().
Definition at line 1785 of file CommandLine.cpp.
References llvm::RISCVFenceField::O.
Referenced by llvm::cl::basic_parser_impl::getOptionWidth(), and llvm::cl::basic_parser_impl::printOptionInfo().
|
static |
HandlePrefixedOrGroupedOption - The specified argument string (which started with at least one '-') does not fully match an available option.
Check to see if this is a prefix or grouped option. If so, split arg into output an Arg/Value pair and return the Option to parse it with.
Definition at line 748 of file CommandLine.cpp.
References llvm::cl::AlwaysPrefix, Arg, assert(), llvm::StringMap< ValueTy, AllocatorTy >::count(), llvm::NVPTXISD::Dummy, llvm::StringRef::empty(), llvm::cl::Option::error(), llvm::StringMap< ValueTy, AllocatorTy >::find(), llvm::cl::Option::getFormattingFlag(), getOptionPred(), llvm::cl::Option::getValueExpectedFlag(), isGrouping(), isPrefixedOrGrouping(), llvm::cl::Prefix, ProvideOption(), llvm::StringRef::substr(), and llvm::cl::ValueRequired.
|
static |
|
static |
Definition at line 2592 of file CommandLine.cpp.
References CommonOptions, llvm::initDebugCounterOptions(), llvm::initDebugOptions(), llvm::initGraphWriterOptions(), llvm::initRandomSeedOptions(), llvm::initSignalsOptions(), llvm::initStatisticOptions(), llvm::initTimerOptions(), llvm::initTypeSizeOptions(), and llvm::initWithColorOptions().
Referenced by llvm::cl::getRegisteredOptions(), llvm::cl::HideUnrelatedOptions(), and llvm::cl::ParseCommandLineOptions().
Definition at line 124 of file CommandLine.cpp.
References llvm::cl::Grouping, and llvm::RISCVFenceField::O.
Referenced by HandlePrefixedOrGroupedOption(), and isPrefixedOrGrouping().
Definition at line 127 of file CommandLine.cpp.
References llvm::cl::AlwaysPrefix, isGrouping(), llvm::RISCVFenceField::O, and llvm::cl::Prefix.
Referenced by HandlePrefixedOrGroupedOption().
|
static |
Definition at line 820 of file CommandLine.cpp.
Referenced by llvm::cl::TokenizeGNUCommandLine().
|
static |
Definition at line 812 of file CommandLine.cpp.
Referenced by isWhitespaceOrNull(), llvm::cl::tokenizeConfigFile(), and llvm::cl::TokenizeGNUCommandLine().
|
static |
Definition at line 816 of file CommandLine.cpp.
References isWhitespace().
Referenced by isWindowsSpecialChar(), isWindowsSpecialCharInCommandName(), and tokenizeWindowsCommandLineImpl().
|
static |
Definition at line 924 of file CommandLine.cpp.
References isWhitespaceOrNull().
Referenced by tokenizeWindowsCommandLineImpl().
|
static |
Definition at line 927 of file CommandLine.cpp.
References isWhitespaceOrNull().
Referenced by tokenizeWindowsCommandLineImpl().
|
static |
LookupNearestOption - Lookup the closest match to the option specified by the specified option on the command line.
If there is a value specified (after an equal sign) return that as well. This assumes that leading dashes have already been stripped.
Definition at line 571 of file CommandLine.cpp.
References Arg, llvm::StringMap< ValueTy, AllocatorTy >::begin(), llvm::StringRef::edit_distance(), llvm::StringMap< ValueTy, AllocatorTy >::end(), it, LHS, llvm::RISCVFenceField::O, llvm::cl::ReallyHidden, RHS, and llvm::cl::ValueDisallowed.
|
static |
Backslashes are interpreted in a rather complicated way in the Windows-style command line, because backslashes are used both to separate path and to escape double quote.
This method consumes runs of backslashes as well as the following double quote if it's escaped.
Definition at line 900 of file CommandLine.cpp.
References llvm::SmallString< InternalLen >::append(), E, and I.
Referenced by tokenizeWindowsCommandLineImpl().
Definition at line 1974 of file CommandLine.cpp.
References Arg, and llvm::RISCVFenceField::O.
|
inlinestatic |
ProvideOption - For Value, this differentiates between an empty value ("") and a null value (StringRef()).
The later is accepted for arguments that don't allow a value (-foo) the former is rejected (-foo=).
Definition at line 648 of file CommandLine.cpp.
References llvm::cl::AlwaysPrefix, assert(), CommaSeparateAndAddOccurrence(), llvm::cl::Option::error(), llvm::cl::Option::getFormattingFlag(), llvm::cl::Option::getNumAdditionalVals(), llvm::cl::Option::getValueExpectedFlag(), i, llvm::cl::ValueDisallowed, llvm::cl::ValueOptional, and llvm::cl::ValueRequired.
Referenced by HandlePrefixedOrGroupedOption(), and llvm::cl::ProvidePositionalOption().
Definition at line 802 of file CommandLine.cpp.
References llvm::RISCVFenceField::O, llvm::cl::OneOrMore, and llvm::cl::Required.
Definition at line 2017 of file CommandLine.cpp.
References llvm::StringRef::empty(), llvm::RISCVFenceField::O, and llvm::cl::ValueOptional.
Referenced by llvm::cl::generic_parser_base::getOptionWidth(), and llvm::cl::generic_parser_base::printOptionInfo().
|
static |
Definition at line 2197 of file CommandLine.cpp.
References llvm::array_pod_sort(), llvm::StringMap< ValueTy, AllocatorTy >::begin(), E, llvm::StringMap< ValueTy, AllocatorTy >::end(), llvm::cl::Hidden, I, llvm::SmallPtrSetImpl< PtrType >::insert(), OptNameCompare(), and llvm::cl::ReallyHidden.
|
static |
Definition at line 2225 of file CommandLine.cpp.
References llvm::array_pod_sort(), S, and SubNameCompare().
|
static |
Definition at line 2191 of file CommandLine.cpp.
Referenced by sortSubCommands().
|
inlinestatic |
Definition at line 933 of file CommandLine.cpp.
References assert(), llvm::SmallVectorImpl< T >::clear(), E, I, INIT, isWhitespaceOrNull(), isWindowsSpecialChar(), isWindowsSpecialCharInCommandName(), llvm_unreachable, parseBackslash(), llvm::StringSaver::save(), and llvm::SmallString< InternalLen >::str().
Referenced by llvm::cl::TokenizeWindowsCommandLine(), llvm::cl::TokenizeWindowsCommandLineFull(), and llvm::cl::TokenizeWindowsCommandLineNoCopy().
|
static |
Definition at line 105 of file CommandLine.cpp.
Referenced by argPlusPrefixesSize(), getOptionPrefixesSize(), llvm::cl::Option::printEnumValHelpStr(), and llvm::cl::Option::printHelpStr().
|
static |
Definition at line 103 of file CommandLine.cpp.
Referenced by argPlusPrefixesSize(), and argPrefix().
|
static |
Definition at line 104 of file CommandLine.cpp.
Referenced by argPlusPrefixesSize(), and argPrefix().
|
static |
Definition at line 2590 of file CommandLine.cpp.
Referenced by llvm::cl::AddExtraVersionPrinter(), llvm::cl::HideUnrelatedOptions(), initCommonOptions(), llvm::cl::PrintHelpMessage(), llvm::cl::PrintVersionMessage(), and llvm::cl::SetVersionPrinter().
|
static |
Definition at line 101 of file CommandLine.cpp.
|
static |
Definition at line 2011 of file CommandLine.cpp.
Referenced by llvm::cl::generic_parser_base::getOptionWidth(), and llvm::cl::generic_parser_base::printOptionInfo().
|
static |
Definition at line 2010 of file CommandLine.cpp.
Referenced by llvm::cl::generic_parser_base::getOptionWidth(), and llvm::cl::generic_parser_base::printOptionInfo().
|
static |
Definition at line 436 of file CommandLine.cpp.
Referenced by llvm::cl::Option::addArgument(), llvm::cl::AddLiteralOption(), llvm::cl::Option::error(), llvm::cl::extrahelp::extrahelp(), llvm::cl::getRegisteredOptions(), llvm::cl::getRegisteredSubcommands(), llvm::cl::SubCommand::operator bool(), llvm::cl::ParseCommandLineOptions(), llvm::cl::PrintOptionValues(), llvm::cl::SubCommand::registerSubCommand(), llvm::cl::Option::removeArgument(), llvm::cl::ResetCommandLineParser(), llvm::cl::Option::setArgStr(), and llvm::cl::SubCommand::unregisterSubCommand().
|
static |
Definition at line 2095 of file CommandLine.cpp.
Referenced by llvm::cl::generic_parser_base::printGenericOptionDiff().
|
static |
Definition at line 2012 of file CommandLine.cpp.
Referenced by getOptionPrefixesSize(), and llvm::cl::generic_parser_base::printOptionInfo().