LLVM: lib/Support/CommandLine.cpp File Reference (original) (raw)

Go to the source code of this file.

Namespaces
namespace llvm
This is an optimization pass for GlobalISel generic memory operations.
namespace 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)
template<typename T , T TrueVal, T FalseVal>
static bool parseBool (Option &O, StringRef ArgName, StringRef Arg, T &Value)
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.
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.
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()).
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.
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.
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 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.
Variables
static const size_t DefaultPad = 2
static StringRef ArgPrefix = "-"
static StringRef ArgPrefixLong = "--"
static StringRef ArgHelpPrefix = " - "
static ManagedStatic< CommandLineParser > GlobalParser
static LLVM_REQUIRE_CONSTANT_INITIALIZATION ManagedStatic< SubCommand > TopLevelSubCommand
static ManagedStatic< SubCommand > AllSubCommands
static StringRef EqValue = "="
static StringRef EmptyOption = ""
static StringRef OptionPrefix = " ="
static const size_t MaxOptWidth = 8
static ManagedStatic< CommandLineCommonOptions > CommonOptions

DEBUG_TYPE

#define DEBUG_TYPE "commandline"

LLVM_IS_DEBUG_BUILD

#define LLVM_IS_DEBUG_BUILD 0

PRINT_OPT_DIFF

| #define PRINT_OPT_DIFF | ( | | T | ) | | ------------------------ | - | | ---------------- | - |

Value:

size_t GlobalWidth) const { \

printOptionName(O, GlobalWidth); \

std::string Str; \

{ \

SS << V; \

} \

outs() << "= " << Str; \

size_t NumSpaces = \

outs().indent(NumSpaces) << " (default: "; \

if (D.hasValue()) \

outs() << D.getValue(); \

else \

outs() << "*no default*"; \

outs() << ")\n"; \

}

static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")

static const size_t MaxOptWidth

A raw_ostream that writes to an std::string.

Definition at line 2198 of file CommandLine.cpp.

argPlusPrefixesSize()

argPrefix()

CommaSeparateAndAddOccurrence()

EatsUnboundedNumberOfValues()

ExpandBasePaths()

Definition at line 1119 of file CommandLine.cpp.

References llvm::sys::path::append(), llvm::SmallString< InternalLen >::append(), assert(), llvm::StringRef::data(), llvm::SmallVectorBase< Size_T >::empty(), llvm::StringRef::empty(), llvm::StringRef::find(), llvm::sys::path::is_absolute(), LHS, llvm::StringRef::npos, llvm::StringSaver::save(), llvm::StringRef::size(), llvm::SmallString< InternalLen >::str(), and llvm::StringRef::substr().

getOptionPred()

getOptionPrefixesSize()

static size_t getOptionPrefixesSize ( ) static

getValueStr()

HandlePrefixedOrGroupedOption()

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 747 of file CommandLine.cpp.

References llvm:🆑:AlwaysPrefix, assert(), llvm::StringMap< ValueTy, AllocatorTy >::count(), llvm::StringRef::empty(), llvm:🆑:Option::error(), llvm::StringMap< ValueTy, AllocatorTy >::find(), llvm:🆑:Option::getFormattingFlag(), getOptionPred(), llvm:🆑:Option::getValueExpectedFlag(), isGrouping(), isPrefixedOrGrouping(), llvm::Length, llvm:🆑:Prefix, ProvideOption(), llvm::StringRef::size(), llvm::StringRef::substr(), and llvm:🆑:ValueRequired.

hasUTF8ByteOrderMark()

initCommonOptions()

static void initCommonOptions ( ) static

Definition at line 2649 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:🆑:getRegisteredOptions(), llvm:🆑:HideUnrelatedOptions(), and llvm:🆑:ParseCommandLineOptions().

isGrouping()

isPrefixedOrGrouping()

isQuote()

isWhitespace()

static bool isWhitespace ( char C) static

isWhitespaceOrNull()

static bool isWhitespaceOrNull ( char C) static

isWindowsSpecialChar()

static bool isWindowsSpecialChar ( char C) static

isWindowsSpecialCharInCommandName()

static bool isWindowsSpecialCharInCommandName ( char C) static

LookupNearestOption()

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 570 of file CommandLine.cpp.

References llvm::StringMap< ValueTy, AllocatorTy >::begin(), llvm::StringRef::edit_distance(), llvm::StringRef::empty(), llvm::StringMap< ValueTy, AllocatorTy >::end(), LHS, Name, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm:🆑:ReallyHidden, RHS, llvm::StringRef::split(), and llvm:🆑:ValueDisallowed.

OptNameCompare()

parseBackslash()

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 899 of file CommandLine.cpp.

References llvm::SmallString< InternalLen >::append(), I, and llvm::SmallVectorTemplateBase< T, bool >::push_back().

Referenced by tokenizeWindowsCommandLineImpl().

parseBool()

template<typename T , T TrueVal, T FalseVal>

parseDouble()

ProvideOption()

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 647 of file CommandLine.cpp.

References llvm:🆑:AlwaysPrefix, assert(), CommaSeparateAndAddOccurrence(), llvm:🆑:Option::error(), llvm:🆑:Option::getFormattingFlag(), llvm:🆑:Option::getNumAdditionalVals(), llvm:🆑:Option::getValueExpectedFlag(), llvm:🆑:ValueDisallowed, llvm:🆑:ValueOptional, and llvm:🆑:ValueRequired.

Referenced by HandlePrefixedOrGroupedOption(), and llvm:🆑:ProvidePositionalOption().

RequiresValue()

shouldPrintOption()

sortOpts()

sortSubCommands()

SubNameCompare()

tokenizeWindowsCommandLineImpl()

Definition at line 932 of file CommandLine.cpp.

References assert(), llvm::SmallVectorImpl< T >::clear(), llvm::SmallVectorBase< Size_T >::empty(), I, INIT, isWhitespaceOrNull(), isWindowsSpecialChar(), isWindowsSpecialCharInCommandName(), llvm_unreachable, parseBackslash(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::StringSaver::save(), and llvm::SmallString< InternalLen >::str().

Referenced by llvm:🆑:TokenizeWindowsCommandLine(), llvm:🆑:TokenizeWindowsCommandLineFull(), and llvm:🆑:TokenizeWindowsCommandLineNoCopy().

AllSubCommands

ArgHelpPrefix

ArgPrefix

ArgPrefixLong

CommonOptions

DefaultPad

const size_t DefaultPad = 2 static

EmptyOption

EqValue

GlobalParser

Definition at line 405 of file CommandLine.cpp.

Referenced by llvm:🆑:Option::addArgument(), llvm:🆑:AddLiteralOption(), llvm:🆑:Option::error(), llvm:🆑:extrahelp::extrahelp(), llvm:🆑:getRegisteredOptions(), llvm:🆑:getRegisteredSubcommands(), llvm:🆑:SubCommand::operator bool(), llvm:🆑:ParseCommandLineOptions(), llvm:🆑:PrintOptionValues(), llvm:🆑:SubCommand::registerSubCommand(), llvm:🆑:Option::removeArgument(), llvm:🆑:ResetCommandLineParser(), llvm:🆑:Option::setArgStr(), and llvm:🆑:SubCommand::unregisterSubCommand().

MaxOptWidth

const size_t MaxOptWidth = 8 static

OptionPrefix

TopLevelSubCommand