LLVM  14.0.0git
Namespaces | Macros | Functions | Variables
CommandLine.cpp File Reference
#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/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>
Include dependency graph for CommandLine.cpp:

Go to the source code of this file.

Namespaces

 llvm
 This is an optimization pass for GlobalISel generic memory operations.
 
 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 OptionLookupNearestOption (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 OptiongetOptionPred (StringRef Name, size_t &Length, bool(*Pred)(const Option *), const StringMap< Option * > &OptionsMap)
 
static OptionHandlePrefixedOrGroupedOption (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 void tokenizeWindowsCommandLineImpl (StringRef Src, StringSaver &Saver, function_ref< void(StringRef)> AddToken, bool AlwaysCopy, function_ref< void()> MarkEOL)
 
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 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
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "commandline"

Definition at line 53 of file CommandLine.cpp.

◆ LLVM_IS_DEBUG_BUILD

#define LLVM_IS_DEBUG_BUILD   0

Definition at line 2408 of file CommandLine.cpp.

◆ PRINT_OPT_DIFF

#define PRINT_OPT_DIFF (   T)
Value:
size_t GlobalWidth) const { \
printOptionName(O, GlobalWidth); \
std::string Str; \
{ \
raw_string_ostream SS(Str); \
SS << V; \
} \
outs() << "= " << Str; \
size_t NumSpaces = \
MaxOptWidth > Str.size() ? MaxOptWidth - Str.size() : 0; \
outs().indent(NumSpaces) << " (default: "; \
if (D.hasValue()) \
outs() << D.getValue(); \
outs() << "*no default*"; \
outs() << ")\n"; \
}

Definition at line 2066 of file CommandLine.cpp.

Function Documentation

◆ argPlusPrefixesSize()

static size_t argPlusPrefixesSize ( StringRef  ArgName,
size_t  Pad = DefaultPad 
)
static

◆ argPrefix()

static SmallString<8> argPrefix ( StringRef  ArgName,
size_t  Pad = DefaultPad 
)
static

Definition at line 115 of file CommandLine.cpp.

References ArgPrefix, ArgPrefixLong, I, llvm::cl::Prefix, and llvm::StringRef::size().

◆ CommaSeparateAndAddOccurrence()

static bool CommaSeparateAndAddOccurrence ( Option Handler,
unsigned  pos,
StringRef  ArgName,
StringRef  Value,
bool  MultiArg = false 
)
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().

◆ EatsUnboundedNumberOfValues()

static bool EatsUnboundedNumberOfValues ( const Option O)
static

◆ ExpandResponseFile()

static llvm::Error ExpandResponseFile ( StringRef  FName,
StringSaver Saver,
TokenizerCallback  Tokenizer,
SmallVectorImpl< const char * > &  NewArgv,
bool  MarkEOLs,
bool  RelativeNames,
llvm::vfs::FileSystem FS 
)
static

◆ getOptionPred()

static Option* getOptionPred ( StringRef  Name,
size_t &  Length,
bool(*)(const Option *)  Pred,
const StringMap< Option * > &  OptionsMap 
)
static

◆ getOptionPrefixesSize()

static size_t getOptionPrefixesSize ( )
static

◆ getValueStr()

static StringRef getValueStr ( const Option O,
StringRef  DefaultMsg 
)
static

◆ HandlePrefixedOrGroupedOption()

static Option* HandlePrefixedOrGroupedOption ( StringRef Arg,
StringRef Value,
bool &  ErrorParsing,
const StringMap< Option * > &  OptionsMap 
)
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, 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.

◆ hasUTF8ByteOrderMark()

static bool hasUTF8ByteOrderMark ( ArrayRef< char >  S)
static

Definition at line 1077 of file CommandLine.cpp.

References S.

Referenced by ExpandResponseFile().

◆ initCommonOptions()

static void initCommonOptions ( )
static

◆ isGrouping()

static bool isGrouping ( const Option O)
inlinestatic

◆ isPrefixedOrGrouping()

static bool isPrefixedOrGrouping ( const Option O)
inlinestatic

◆ isQuote()

static bool isQuote ( char  C)
static

Definition at line 821 of file CommandLine.cpp.

Referenced by llvm::cl::TokenizeGNUCommandLine().

◆ isWhitespace()

static bool isWhitespace ( char  C)
static

◆ isWhitespaceOrNull()

static bool isWhitespaceOrNull ( char  C)
static

Definition at line 817 of file CommandLine.cpp.

References isWhitespace().

Referenced by isWindowsSpecialChar(), and tokenizeWindowsCommandLineImpl().

◆ isWindowsSpecialChar()

static bool isWindowsSpecialChar ( char  C)
static

Definition at line 923 of file CommandLine.cpp.

References isWhitespaceOrNull().

◆ LookupNearestOption()

static Option* LookupNearestOption ( StringRef  Arg,
const StringMap< Option * > &  OptionsMap,
std::string &  NearestString 
)
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 572 of file CommandLine.cpp.

References Arg, llvm::StringMap< ValueTy, AllocatorTy >::begin(), llvm::StringRef::edit_distance(), llvm::StringRef::empty(), llvm::StringMap< ValueTy, AllocatorTy >::end(), it, llvm::RISCVFenceField::O, llvm::cl::ReallyHidden, and llvm::cl::ValueDisallowed.

◆ OptNameCompare()

static int OptNameCompare ( const std::pair< const char *, Option * > *  LHS,
const std::pair< const char *, Option * > *  RHS 
)
static

Definition at line 2123 of file CommandLine.cpp.

Referenced by sortOpts().

◆ parseBackslash()

static size_t parseBackslash ( StringRef  Src,
size_t  I,
SmallString< 128 > &  Token 
)
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.

  • If an even number of backslashes is followed by a double quote, one backslash is output for every pair of backslashes, and the last double quote remains unconsumed. The double quote will later be interpreted as the start or end of a quoted string in the main loop outside of this function.
  • If an odd number of backslashes is followed by a double quote, one backslash is output for every pair of backslashes, and a double quote is output for the last pair of backslash-double quote. The double quote is consumed in this case.
  • Otherwise, backslashes are interpreted literally.

Definition at line 901 of file CommandLine.cpp.

References llvm::SmallString< InternalLen >::append(), E, and I.

◆ parseDouble()

static bool parseDouble ( Option O,
StringRef  Arg,
double Value 
)
static

Definition at line 1911 of file CommandLine.cpp.

References Arg, and llvm::RISCVFenceField::O.

◆ ProvideOption()

static bool ProvideOption ( Option Handler,
StringRef  ArgName,
StringRef  Value,
int  argc,
const char *const argv,
int i 
)
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::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().

◆ RequiresValue()

static bool RequiresValue ( const Option O)
static

◆ shouldPrintOption()

static bool shouldPrintOption ( StringRef  Name,
StringRef  Description,
const Option O 
)
static

◆ sortOpts()

static void sortOpts ( StringMap< Option * > &  OptMap,
SmallVectorImpl< std::pair< const char *, Option * >> &  Opts,
bool  ShowHidden 
)
static

◆ sortSubCommands()

static void sortSubCommands ( const SmallPtrSetImpl< SubCommand * > &  SubMap,
SmallVectorImpl< std::pair< const char *, SubCommand * >> &  Subs 
)
static

Definition at line 2162 of file CommandLine.cpp.

References llvm::array_pod_sort(), S, and SubNameCompare().

◆ SubNameCompare()

static int SubNameCompare ( const std::pair< const char *, SubCommand * > *  LHS,
const std::pair< const char *, SubCommand * > *  RHS 
)
static

Definition at line 2128 of file CommandLine.cpp.

Referenced by sortSubCommands().

◆ tokenizeWindowsCommandLineImpl()

static void tokenizeWindowsCommandLineImpl ( StringRef  Src,
StringSaver Saver,
function_ref< void(StringRef)>  AddToken,
bool  AlwaysCopy,
function_ref< void()>  MarkEOL 
)
inlinestatic

Variable Documentation

◆ ArgHelpPrefix

StringRef ArgHelpPrefix = " - "
static

◆ ArgPrefix

StringRef ArgPrefix = "-"
static

Definition at line 104 of file CommandLine.cpp.

Referenced by argPlusPrefixesSize(), and argPrefix().

◆ ArgPrefixLong

StringRef ArgPrefixLong = "--"
static

Definition at line 105 of file CommandLine.cpp.

Referenced by argPlusPrefixesSize(), and argPrefix().

◆ CommonOptions

ManagedStatic<CommandLineCommonOptions> CommonOptions
static

◆ DefaultPad

const static size_t DefaultPad = 2
static

Definition at line 102 of file CommandLine.cpp.

◆ EmptyOption

StringRef EmptyOption = "<empty>"
static

◆ EqValue

StringRef EqValue = "=<value>"
static

◆ GlobalParser

ManagedStatic<CommandLineParser> GlobalParser
static

◆ MaxOptWidth

const size_t MaxOptWidth = 8
static

◆ OptionPrefix

StringRef OptionPrefix = " ="
static
T
llvm::cl::printOptionDiff
void printOptionDiff(const Option &O, const generic_parser_base &P, const DT &V, const OptionValue< DT > &Default, size_t GlobalWidth)
Definition: CommandLine.h:1226
MaxOptWidth
static const size_t MaxOptWidth
Definition: CommandLine.cpp:2032
llvm::RISCVFenceField::O
@ O
Definition: RISCVBaseInfo.h:206
llvm::cl::Option
Definition: CommandLine.h:249
D
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
llvm::X86AS::SS
@ SS
Definition: X86.h:189
outs
So we should use XX3Form_Rcr to implement instrinsic Convert DP outs ins xscvdpsp No builtin are required Round &Convert QP DP(dword[1] is set to zero) No builtin are required Round to Quad Precision because you need to assign rounding mode in instruction Provide builtin(set f128:$vT,(int_ppc_vsx_xsrqpi f128:$vB))(set f128 yields< n x< ty > >< result > yields< ty >< result > No builtin are required Load Store load store see def memrix16 in PPCInstrInfo td Load Store Vector load store outs ins lxsdx set load store with conversion from to outs ins lxsspx set load store outs ins lxsiwzx set PPClfiwzx outs
This returns a reference to a raw_fd_ostream for standard output.
Definition: README_P9.txt:537
llvm::cl::OptionValue
Definition: CommandLine.h:533