|
LLVM
10.0.0
|
#include "llvm/Support/CommandLine.h"#include "llvm-c/Support.h"#include "llvm/ADT/ArrayRef.h"#include "llvm/ADT/Optional.h"#include "llvm/ADT/STLExtras.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 <map>#include <string>Go to the source code of this file.
Namespaces | |
| llvm | |
| This class represents lattice values for constants. | |
| llvm::cl | |
| cl Namespace - 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 | hasUTF8ByteOrderMark (ArrayRef< char > S) |
| static llvm::Error | ExpandResponseFile (StringRef FName, StringSaver &Saver, TokenizerCallback Tokenizer, SmallVectorImpl< const char *> &NewArgv, bool MarkEOLs, bool RelativeNames, llvm::vfs::FileSystem &FS) |
| static StringRef | getValueStr (const Option &O, StringRef DefaultMsg) |
| static bool | parseDouble (Option &O, StringRef Arg, double &Value) |
| 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) |
| static HelpPrinter | UncategorizedNormalPrinter (false) |
| static HelpPrinter | UncategorizedHiddenPrinter (true) |
| static CategorizedHelpPrinter | CategorizedNormalPrinter (false) |
| static CategorizedHelpPrinter | CategorizedHiddenPrinter (true) |
| static HelpPrinterWrapper | WrappedNormalPrinter (UncategorizedNormalPrinter, CategorizedNormalPrinter) |
| static HelpPrinterWrapper | WrappedHiddenPrinter (UncategorizedHiddenPrinter, CategorizedHiddenPrinter) |
| 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 | |
| static const 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 size_t | OptionPrefixesSize = OptionPrefix.size() + ArgHelpPrefix.size() |
| static const size_t | MaxOptWidth = 8 |
| static cl::OptionCategory | GenericCategory ("Generic Options") |
| static cl::opt< HelpPrinter, true, parser< bool > > | HLOp ("help-list", cl::desc("Display list of available options (--help-list-hidden for more)"), cl::location(UncategorizedNormalPrinter), cl::Hidden, cl::ValueDisallowed, cl::cat(GenericCategory), cl::sub(*AllSubCommands)) |
| static cl::opt< HelpPrinter, true, parser< bool > > | HLHOp ("help-list-hidden", cl::desc("Display list of all available options"), cl::location(UncategorizedHiddenPrinter), cl::Hidden, cl::ValueDisallowed, cl::cat(GenericCategory), cl::sub(*AllSubCommands)) |
| static cl::opt< HelpPrinterWrapper, true, parser< bool > > | HOp ("help", cl::desc("Display available options (--help-hidden for more)"), cl::location(WrappedNormalPrinter), cl::ValueDisallowed, cl::cat(GenericCategory), cl::sub(*AllSubCommands)) |
| static cl::alias | HOpA ("h", cl::desc("Alias for --help"), cl::aliasopt(HOp), cl::DefaultOption) |
| static cl::opt< HelpPrinterWrapper, true, parser< bool > > | HHOp ("help-hidden", cl::desc("Display all available options"), cl::location(WrappedHiddenPrinter), cl::Hidden, cl::ValueDisallowed, cl::cat(GenericCategory), cl::sub(*AllSubCommands)) |
| static cl::opt< bool > | PrintOptions ("print-options", cl::desc("Print non-default options after command line parsing"), cl::Hidden, cl::init(false), cl::cat(GenericCategory), cl::sub(*AllSubCommands)) |
| static cl::opt< bool > | PrintAllOptions ("print-all-options", cl::desc("Print all option values after command line parsing"), cl::Hidden, cl::init(false), cl::cat(GenericCategory), cl::sub(*AllSubCommands)) |
| static VersionPrinterTy | OverrideVersionPrinter = nullptr |
| static std::vector< VersionPrinterTy > * | ExtraVersionPrinters = nullptr |
| static VersionPrinter | VersionPrinterInstance |
| static cl::opt< VersionPrinter, true, parser< bool > > | VersOp ("version", cl::desc("Display the version of this program"), cl::location(VersionPrinterInstance), cl::ValueDisallowed, cl::cat(GenericCategory)) |
| #define DEBUG_TYPE "commandline" |
Definition at line 50 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 2017 of file CommandLine.cpp.
|
static |
Definition at line 105 of file CommandLine.cpp.
References llvm::StringRef::size().
Referenced by llvm::cl::generic_parser_base::getOptionWidth(), llvm::cl::basic_parser_impl::getOptionWidth(), getValueStr(), llvm::cl::Option::printHelpStr(), and llvm::cl::generic_parser_base::printOptionInfo().
|
static |
Definition at line 112 of file CommandLine.cpp.
References llvm::SmallString< InternalLen >::append(), ArgPrefix, ArgPrefixLong, I, llvm::cl::Prefix, llvm::SmallVectorTemplateBase< T, bool >::push_back(), and llvm::StringRef::size().
Referenced by isPrefixedOrGrouping().
|
static |
Referenced by sortSubCommands().
|
static |
Referenced by sortSubCommands().
|
static |
CommaSeparateAndAddOccurrence - A wrapper around Handler->addOccurrence() that does special handling of cl::CommaSeparated options.
Definition at line 621 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 808 of file CommandLine.cpp.
References llvm::cl::Option::getNumOccurrencesFlag(), llvm::cl::OneOrMore, and llvm::cl::ZeroOrMore.
Referenced by llvm::cl::ResetAllOptionOccurrences().
|
static |
Definition at line 1055 of file CommandLine.cpp.
References llvm::SmallString< InternalLen >::append(), llvm::sys::path::append(), assert(), llvm::SmallString< InternalLen >::c_str(), llvm::convertUTF16ToUTF8String(), llvm::createStringError(), llvm::errorCodeToError(), llvm::ErrorOr< T >::get(), llvm::vfs::FileSystem::getBufferForFile(), llvm::ErrorOr< T >::getError(), llvm::hasUTF16ByteOrderMark(), hasUTF8ByteOrderMark(), llvm::sys::path::is_absolute(), llvm::sys::path::is_relative(), llvm::sys::path::parent_path(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::StringSaver::save(), and llvm::Error::success().
|
static |
Definition at line 720 of file CommandLine.cpp.
References llvm::StringMap< ValueTy, AllocatorTy >::end(), llvm::StringMap< ValueTy, AllocatorTy >::find(), llvm::StringRef::size(), and llvm::StringRef::substr().
Referenced by HandlePrefixedOrGroupedOption().
Definition at line 1689 of file CommandLine.cpp.
References argPlusPrefixesSize(), llvm::StringRef::empty(), and llvm::cl::Option::ValueStr.
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 749 of file CommandLine.cpp.
References llvm::cl::AlwaysPrefix, 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::size(), llvm::StringRef::substr(), and llvm::cl::ValueRequired.
Referenced by llvm::cl::ResetAllOptionOccurrences().
Definition at line 1050 of file CommandLine.cpp.
References llvm::ArrayRef< T >::size().
Referenced by ExpandResponseFile().
Definition at line 122 of file CommandLine.cpp.
References llvm::cl::Option::getMiscFlags(), and llvm::cl::Grouping.
Referenced by HandlePrefixedOrGroupedOption(), and isPrefixedOrGrouping().
Definition at line 125 of file CommandLine.cpp.
References llvm::cl::AllSubCommands, llvm::cl::AlwaysPrefix, Arg, argPrefix(), llvm::cl::Option::ArgStr, llvm::cl::ConsumeAfter, llvm::cl::SubCommand::ConsumeAfterOpt, DefaultPad, llvm::cl::Option::error(), llvm::errs(), llvm::cl::Option::getExtraOptionNames(), llvm::cl::Option::getFormattingFlag(), llvm::cl::Option::getMiscFlags(), llvm::cl::Option::getNumOccurrencesFlag(), llvm::cl::Option::hasArgStr(), llvm::cl::Option::isDefaultOption(), isGrouping(), Name, llvm::RISCVFenceField::O, llvm::operator<<(), llvm::cl::SubCommand::OptionsMap, llvm::cl::ParseCommandLineOptions(), llvm::cl::Positional, llvm::cl::SubCommand::PositionalOpts, llvm::cl::Prefix, llvm::SmallVectorTemplateBase< T >::push_back(), llvm::report_fatal_error(), llvm::cl::ResetAllOptionOccurrences(), llvm::PPCISD::SC, llvm::cl::Sink, llvm::cl::SubCommand::SinkOpts, llvm::cl::Option::Subs, and llvm::cl::TopLevelSubCommand.
Referenced by HandlePrefixedOrGroupedOption().
Definition at line 821 of file CommandLine.cpp.
Referenced by llvm::cl::TokenizeGNUCommandLine().
Definition at line 813 of file CommandLine.cpp.
Referenced by isWhitespaceOrNull(), llvm::cl::tokenizeConfigFile(), and llvm::cl::TokenizeGNUCommandLine().
Definition at line 817 of file CommandLine.cpp.
References isWhitespace().
Referenced by llvm::cl::TokenizeWindowsCommandLine().
This function parses the given arguments using the LLVM command line parser.
Note that the only stable thing about this function is its signature; you cannot rely on any particular set of command line arguments being interpreted the same way across LLVM versions.
Definition at line 2586 of file CommandLine.cpp.
References llvm::nulls(), and llvm::cl::ParseCommandLineOptions().
|
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 576 of file CommandLine.cpp.
References Arg, llvm::cl::Option::ArgStr, llvm::StringMap< ValueTy, AllocatorTy >::begin(), llvm::StringRef::edit_distance(), llvm::StringRef::empty(), llvm::StringMap< ValueTy, AllocatorTy >::end(), llvm::cl::Option::getExtraOptionNames(), llvm::cl::Option::getValueExpectedFlag(), llvm::cl::Option::hasArgStr(), llvm::RISCVFenceField::O, llvm::SmallVectorTemplateBase< T >::push_back(), llvm::StringRef::split(), and llvm::cl::ValueDisallowed.
Referenced by llvm::cl::ResetAllOptionOccurrences().
|
static |
Definition at line 2074 of file CommandLine.cpp.
Referenced by sortOpts().
|
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 901 of file CommandLine.cpp.
References llvm::SmallString< InternalLen >::append(), E, I, llvm::SmallVectorTemplateBase< T, bool >::push_back(), and llvm::StringRef::size().
Referenced by llvm::cl::TokenizeWindowsCommandLine().
Definition at line 1864 of file CommandLine.cpp.
References llvm::cl::Option::error(), llvm::cl::parser< DataType >::parse(), and llvm::to_float().
|
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 649 of file CommandLine.cpp.
References llvm::cl::AlwaysPrefix, assert(), CommaSeparateAndAddOccurrence(), llvm::StringRef::data(), llvm::cl::Option::error(), llvm::cl::Option::getFormattingFlag(), llvm::cl::Option::getNumAdditionalVals(), llvm::cl::Option::getValueExpectedFlag(), llvm::cl::ValueDisallowed, llvm::cl::ValueOptional, and llvm::cl::ValueRequired.
Referenced by HandlePrefixedOrGroupedOption(), llvm::cl::ProvidePositionalOption(), and llvm::cl::ResetAllOptionOccurrences().
Definition at line 803 of file CommandLine.cpp.
References llvm::cl::Option::getNumOccurrencesFlag(), llvm::cl::OneOrMore, and llvm::cl::Required.
Referenced by llvm::cl::ResetAllOptionOccurrences().
Definition at line 1905 of file CommandLine.cpp.
References llvm::StringRef::empty(), llvm::cl::Option::getValueExpectedFlag(), and llvm::cl::ValueOptional.
Referenced by llvm::cl::generic_parser_base::getOptionWidth(), and llvm::cl::generic_parser_base::printOptionInfo().
|
static |
Definition at line 2085 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.
Referenced by llvm::cl::PrintOptionValues(), and sortSubCommands().
|
static |
Definition at line 2113 of file CommandLine.cpp.
References llvm::cl::AllSubCommands, llvm::array_pod_sort(), assert(), B, llvm::cl::Option::Categories, CategorizedHiddenPrinter(), CategorizedNormalPrinter(), llvm::cl::SubCommand::ConsumeAfterOpt, llvm::cl::DefaultOption, llvm::numbers::e, E, llvm::StringRef::empty(), first, GenericCategory, llvm::cl::SubCommand::getDescription(), llvm::cl::SubCommand::getName(), HHOp, llvm::cl::Hidden, HLHOp, HLOp, HOp, HOpA, I, llvm::raw_ostream::indent(), llvm::cl::init(), llvm::cl::location(), llvm::max(), llvm::cl::NotHidden, llvm::cl::SubCommand::OptionsMap, llvm::outs(), llvm::cl::SubCommand::PositionalOpts, PrintAllOptions, PrintOptions, second, llvm::cl::Option::setHiddenFlag(), sortOpts(), SubNameCompare(), llvm::cl::TopLevelSubCommand, UncategorizedHiddenPrinter(), UncategorizedNormalPrinter(), llvm::cl::ValueDisallowed, WrappedHiddenPrinter(), and WrappedNormalPrinter().
|
static |
Definition at line 2079 of file CommandLine.cpp.
Referenced by sortSubCommands().
|
static |
Referenced by sortSubCommands().
|
static |
Referenced by sortSubCommands().
|
static |
Referenced by sortSubCommands().
|
static |
Referenced by sortSubCommands().
|
static |
Definition at line 103 of file CommandLine.cpp.
|
static |
Definition at line 101 of file CommandLine.cpp.
Referenced by argPrefix().
|
static |
Definition at line 102 of file CommandLine.cpp.
Referenced by argPrefix().
|
static |
Definition at line 99 of file CommandLine.cpp.
Referenced by isPrefixedOrGrouping().
|
static |
Definition at line 1901 of file CommandLine.cpp.
Referenced by llvm::cl::generic_parser_base::printOptionInfo().
|
static |
Definition at line 1900 of file CommandLine.cpp.
Referenced by llvm::cl::generic_parser_base::printOptionInfo().
|
static |
Definition at line 2437 of file CommandLine.cpp.
|
static |
Referenced by llvm::cl::HideUnrelatedOptions(), and sortSubCommands().
|
static |
Definition at line 434 of file CommandLine.cpp.
|
static |
Referenced by sortSubCommands().
|
static |
Referenced by sortSubCommands().
|
static |
Referenced by sortSubCommands().
|
static |
Referenced by foldShuffleOfHorizOp(), lowerAddSubToHorizontalOp(), and sortSubCommands().
Referenced by sortSubCommands().
|
static |
Definition at line 1983 of file CommandLine.cpp.
|
static |
Definition at line 1902 of file CommandLine.cpp.
|
static |
Definition at line 1903 of file CommandLine.cpp.
Referenced by llvm::cl::generic_parser_base::printOptionInfo().
|
static |
Definition at line 2435 of file CommandLine.cpp.
|
static |
Referenced by sortSubCommands().
|
static |
Referenced by sortSubCommands().
|
static |
Definition at line 2518 of file CommandLine.cpp.
|
static |
1.8.13