LLVM API Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Typedefs | Enumerations | Functions | Variables
llvm::cl Namespace Reference

Classes

class  OptionCategory
 
class  Option
 
struct  desc
 
struct  value_desc
 
struct  initializer
 
struct  LocationClass
 
struct  cat
 
struct  GenericOptionValue
 
struct  OptionValue
 
struct  OptionValueBase
 
class  OptionValueCopy
 
struct  OptionValueBase< DataType, false >
 
struct  OptionValue< cl::boolOrDefault >
 
struct  OptionValue< std::string >
 
class  ValuesClass
 
class  generic_parser_base
 
class  parser
 
class  basic_parser_impl
 
class  basic_parser
 
class  parser< bool >
 
class  parser< boolOrDefault >
 
class  parser< int >
 
class  parser< unsigned >
 
class  parser< unsigned long long >
 
class  parser< double >
 
class  parser< float >
 
class  parser< std::string >
 
class  parser< char >
 
struct  OptionDiffPrinter
 
struct  OptionDiffPrinter< DT, DT >
 
struct  applicator
 
struct  applicator< char[n]>
 
struct  applicator< const char[n]>
 
struct  applicator< const char * >
 
struct  applicator< NumOccurrencesFlag >
 
struct  applicator< ValueExpected >
 
struct  applicator< OptionHidden >
 
struct  applicator< FormattingFlags >
 
struct  applicator< MiscFlags >
 
class  opt_storage
 
class  opt_storage< DataType, false, true >
 
class  opt_storage< DataType, false, false >
 
class  opt
 
class  list_storage
 
class  list_storage< DataType, bool >
 
class  list
 
struct  multi_val
 
class  bits_storage
 
class  bits_storage< DataType, bool >
 
class  bits
 
class  alias
 
struct  aliasopt
 
struct  extrahelp
 
class  StringSaver
 Saves strings in the inheritor's stable storage and returns a stable raw character pointer. More...
 

Typedefs

typedef void(* TokenizerCallback )(StringRef Source, StringSaver &Saver, SmallVectorImpl< const char * > &NewArgv)
 String tokenization function type. Should be compatible with either Windows or Unix command line tokenizers. More...
 

Enumerations

enum  NumOccurrencesFlag {
  Optional = 0x00, ZeroOrMore = 0x01, Required = 0x02, OneOrMore = 0x03,
  ConsumeAfter = 0x04
}
 
enum  ValueExpected { ValueOptional = 0x01, ValueRequired = 0x02, ValueDisallowed = 0x03 }
 
enum  OptionHidden { NotHidden = 0x00, Hidden = 0x01, ReallyHidden = 0x02 }
 
enum  FormattingFlags { NormalFormatting = 0x00, Positional = 0x01, Prefix = 0x02, Grouping = 0x03 }
 
enum  MiscFlags { CommaSeparated = 0x01, PositionalEatsArgs = 0x02, Sink = 0x04 }
 
enum  boolOrDefault { BOU_UNSET, BOU_TRUE, BOU_FALSE }
 

Functions

void ParseCommandLineOptions (int argc, const char *const *argv, const char *Overview=0)
 
void ParseEnvironmentOptions (const char *progName, const char *envvar, const char *Overview=0)
 
void SetVersionPrinter (void(*func)())
 
void AddExtraVersionPrinter (void(*func)())
 
void PrintOptionValues ()
 
void MarkOptionsChanged ()
 
template<class Ty >
initializer< Ty > init (const Ty &Val)
 
template<class Ty >
LocationClass< Ty > location (Ty &L)
 
template<class DataType >
ValuesClass< DataType >
END_WITH_NULL 
values (const char *Arg, DataType Val, const char *Desc,...)
 
 EXTERN_TEMPLATE_INSTANTIATION (class basic_parser< bool >)
 
 EXTERN_TEMPLATE_INSTANTIATION (class basic_parser< boolOrDefault >)
 
 EXTERN_TEMPLATE_INSTANTIATION (class basic_parser< int >)
 
 EXTERN_TEMPLATE_INSTANTIATION (class basic_parser< unsigned >)
 
 EXTERN_TEMPLATE_INSTANTIATION (class basic_parser< unsigned long long >)
 
 EXTERN_TEMPLATE_INSTANTIATION (class basic_parser< double >)
 
 EXTERN_TEMPLATE_INSTANTIATION (class basic_parser< float >)
 
 EXTERN_TEMPLATE_INSTANTIATION (class basic_parser< std::string >)
 
 EXTERN_TEMPLATE_INSTANTIATION (class basic_parser< char >)
 
template<class ParserClass , class DT >
void printOptionDiff (const Option &O, const generic_parser_base &P, const DT &V, const OptionValue< DT > &Default, size_t GlobalWidth)
 
template<class ParserClass , class ValDT >
void printOptionDiff (const Option &O, const basic_parser< typename ParserClass::parser_data_type > &P, const ValDT &V, const OptionValue< ValDT > &Default, size_t GlobalWidth)
 
template<class Mod , class Opt >
void apply (const Mod &M, Opt *O)
 
 EXTERN_TEMPLATE_INSTANTIATION (class opt< unsigned >)
 
 EXTERN_TEMPLATE_INSTANTIATION (class opt< int >)
 
 EXTERN_TEMPLATE_INSTANTIATION (class opt< std::string >)
 
 EXTERN_TEMPLATE_INSTANTIATION (class opt< char >)
 
 EXTERN_TEMPLATE_INSTANTIATION (class opt< bool >)
 
void PrintVersionMessage ()
 Utility function for printing version number. More...
 
void PrintHelpMessage (bool Hidden=false, bool Categorized=false)
 
void getRegisteredOptions (StringMap< Option * > &Map)
 Use this to get a StringMap to all registered named options (e.g. -help). Note Map Should be an empty StringMap. More...
 
void TokenizeGNUCommandLine (StringRef Source, StringSaver &Saver, SmallVectorImpl< const char * > &NewArgv)
 Tokenizes a command line that can contain escapes and quotes. More...
 
void TokenizeWindowsCommandLine (StringRef Source, StringSaver &Saver, SmallVectorImpl< const char * > &NewArgv)
 Tokenizes a Windows command line which may contain quotes and escaped quotes. More...
 
bool ExpandResponseFiles (StringSaver &Saver, TokenizerCallback Tokenizer, SmallVectorImpl< const char * > &Argv)
 Expand response files on a command line recursively using the given StringSaver and tokenization strategy. Argv should contain the command line before expansion and will be modified in place. More...
 
 TEMPLATE_INSTANTIATION (class basic_parser< bool >)
 
 TEMPLATE_INSTANTIATION (class basic_parser< boolOrDefault >)
 
 TEMPLATE_INSTANTIATION (class basic_parser< int >)
 
 TEMPLATE_INSTANTIATION (class basic_parser< unsigned >)
 
 TEMPLATE_INSTANTIATION (class basic_parser< unsigned long long >)
 
 TEMPLATE_INSTANTIATION (class basic_parser< double >)
 
 TEMPLATE_INSTANTIATION (class basic_parser< float >)
 
 TEMPLATE_INSTANTIATION (class basic_parser< std::string >)
 
 TEMPLATE_INSTANTIATION (class basic_parser< char >)
 
 TEMPLATE_INSTANTIATION (class opt< unsigned >)
 
 TEMPLATE_INSTANTIATION (class opt< int >)
 
 TEMPLATE_INSTANTIATION (class opt< std::string >)
 
 TEMPLATE_INSTANTIATION (class opt< char >)
 
 TEMPLATE_INSTANTIATION (class opt< bool >)
 

Variables

OptionCategory GeneralCategory
 

Detailed Description

cl Namespace - This namespace contains all of the command line option processing machinery. It is intentionally a short name to make qualified usage concise.

Typedef Documentation

typedef void(* llvm::cl::TokenizerCallback)(StringRef Source, StringSaver &Saver, SmallVectorImpl< const char * > &NewArgv)

String tokenization function type. Should be compatible with either Windows or Unix command line tokenizers.

Definition at line 1791 of file CommandLine.h.

Enumeration Type Documentation

Enumerator
BOU_UNSET 
BOU_TRUE 
BOU_FALSE 

Definition at line 432 of file CommandLine.h.

Enumerator
NormalFormatting 
Positional 
Prefix 
Grouping 

Definition at line 128 of file CommandLine.h.

Enumerator
CommaSeparated 
PositionalEatsArgs 
Sink 

Definition at line 135 of file CommandLine.h.

Enumerator
Optional 
ZeroOrMore 
Required 
OneOrMore 
ConsumeAfter 

Definition at line 84 of file CommandLine.h.

Enumerator
NotHidden 
Hidden 
ReallyHidden 

Definition at line 107 of file CommandLine.h.

Enumerator
ValueOptional 
ValueRequired 
ValueDisallowed 

Definition at line 100 of file CommandLine.h.

Function Documentation

void llvm::cl::AddExtraVersionPrinter ( void(*)()  func)

===------------------------------------------------------------------—===// AddExtraVersionPrinter - Add an extra printer to use in addition to the default one. This can be called multiple times, and each time it adds a new function to the list which will be called after the basic LLVM version printing is complete. Each can then add additional information specific to the tool.

Definition at line 1769 of file CommandLine.cpp.

References ExtraVersionPrinters.

template<class Mod , class Opt >
void llvm::cl::apply ( const Mod &  M,
Opt *  O 
)
bool llvm::cl::ExpandResponseFiles ( StringSaver Saver,
TokenizerCallback  Tokenizer,
SmallVectorImpl< const char * > &  Argv 
)

Expand response files on a command line recursively using the given StringSaver and tokenization strategy. Argv should contain the command line before expansion and will be modified in place.

Expand response files on a command line recursively using the given StringSaver and tokenization strategy.

Parameters
[in]SaverDelegates back to the caller for saving parsed strings.
[in]TokenizerTokenization strategy. Typically Unix or Windows.
[in,out]ArgvCommand line into which to expand response files.
Returns
true if all were expanded successfully or there were none.

Definition at line 634 of file CommandLine.cpp.

References llvm::SmallVectorTemplateCommon< T, typename >::begin(), llvm::SmallVectorTemplateCommon< T >::begin(), llvm::SmallVectorTemplateCommon< T >::end(), llvm::SmallVectorImpl< T >::erase(), ExpandResponseFile(), I, llvm::SmallVectorImpl< T >::insert(), and llvm::SmallVectorTemplateCommon< T, typename >::size().

Referenced by ParseCommandLineOptions().

llvm::cl::EXTERN_TEMPLATE_INSTANTIATION ( class basic_parser< bool )
llvm::cl::EXTERN_TEMPLATE_INSTANTIATION ( class basic_parser< boolOrDefault )
llvm::cl::EXTERN_TEMPLATE_INSTANTIATION ( class basic_parser< int >  )
llvm::cl::EXTERN_TEMPLATE_INSTANTIATION ( class basic_parser< unsigned )
llvm::cl::EXTERN_TEMPLATE_INSTANTIATION ( class basic_parser< unsigned long long >  )
llvm::cl::EXTERN_TEMPLATE_INSTANTIATION ( class basic_parser< double >  )
llvm::cl::EXTERN_TEMPLATE_INSTANTIATION ( class basic_parser< float >  )
llvm::cl::EXTERN_TEMPLATE_INSTANTIATION ( class basic_parser< std::string >  )
llvm::cl::EXTERN_TEMPLATE_INSTANTIATION ( class basic_parser< char >  )
llvm::cl::EXTERN_TEMPLATE_INSTANTIATION ( class opt< unsigned )
llvm::cl::EXTERN_TEMPLATE_INSTANTIATION ( class opt< int >  )
llvm::cl::EXTERN_TEMPLATE_INSTANTIATION ( class opt< std::string >  )
llvm::cl::EXTERN_TEMPLATE_INSTANTIATION ( class opt< char >  )
llvm::cl::EXTERN_TEMPLATE_INSTANTIATION ( class opt< bool )
void llvm::cl::getRegisteredOptions ( StringMap< Option * > &  Map)

Use this to get a StringMap to all registered named options (e.g. -help). Note Map Should be an empty StringMap.

Parameters
[out]Mapwill be filled with mappings where the key is the Option argument string (e.g. "help") and value is the corresponding Option*.

Access to unnamed arguments (i.e. positional) are not provided because it is expected that the client already has access to these.

Typical usage:

main(int argc,char* argv[]) {
StringMap<llvm::cl::Option*> opts;
assert(opts.count("help") == 1)
opts["help"]->setDescription("Show alphabetical help information")
// More code
llvm::cl::ParseCommandLineOptions(argc,argv);
//More code
}

This interface is useful for modifying options in libraries that are out of the control of the client. The options should be modified before calling llvm::cl::ParseCommandLineOptions().

Definition at line 1776 of file CommandLine.cpp.

References GetOptionInfo(), and llvm::StringMapImpl::size().

template<class Ty >
initializer<Ty> llvm::cl::init ( const Ty &  Val)
template<class Ty >
LocationClass<Ty> llvm::cl::location ( Ty &  L)

Definition at line 333 of file CommandLine.h.

Referenced by setPrefixPresent().

void llvm::cl::MarkOptionsChanged ( )
void llvm::cl::ParseCommandLineOptions ( int  argc,
const char *const *  argv,
const char *  Overview = 0 
)
void llvm::cl::ParseEnvironmentOptions ( const char *  progName,
const char *  envVar,
const char *  Overview = 0 
)

ParseEnvironmentOptions - An alternative entry point to the CommandLine library, which allows you to read the program's name from the caller (as PROGNAME) and its command-line arguments from an environment variable (whose name is given in ENVVAR).

Definition at line 691 of file CommandLine.cpp.

References llvm::LibFunc::getenv, ParseCommandLineOptions(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), llvm::SmallVectorTemplateCommon< T >::size(), and TokenizeGNUCommandLine().

void llvm::cl::PrintHelpMessage ( bool  Hidden = false,
bool  Categorized = false 
)

This function just prints the help message, exactly the same way as if the -help or -help-hidden option had been given on the command line.

NOTE: THIS FUNCTION TERMINATES THE PROGRAM!

Parameters
Hiddenif true will print hidden options
Categorizedif true print options in categories

Definition at line 1742 of file CommandLine.cpp.

References CategorizedHiddenPrinter(), CategorizedNormalPrinter(), UncategorizedHiddenPrinter(), and UncategorizedNormalPrinter().

template<class ParserClass , class DT >
void llvm::cl::printOptionDiff ( const Option &  O,
const generic_parser_base &  P,
const DT &  V,
const OptionValue< DT > &  Default,
size_t  GlobalWidth 
)

Definition at line 957 of file CommandLine.h.

References llvm::cl::generic_parser_base::printOptionDiff().

template<class ParserClass , class ValDT >
void llvm::cl::printOptionDiff ( const Option &  O,
const basic_parser< typename ParserClass::parser_data_type > &  P,
const ValDT &  V,
const OptionValue< ValDT > &  Default,
size_t  GlobalWidth 
)
void llvm::cl::PrintOptionValues ( )
void llvm::cl::PrintVersionMessage ( )

Utility function for printing version number.

Definition at line 1761 of file CommandLine.cpp.

References VersionPrinterInstance.

void llvm::cl::SetVersionPrinter ( void(*)()  func)

===------------------------------------------------------------------—===// SetVersionPrinter - Override the default (LLVM specific) version printer used to print out the version when –version is given on the command line. This allows other systems using the CommandLine utilities to print their own version string.

Definition at line 1765 of file CommandLine.cpp.

References OverrideVersionPrinter.

llvm::cl::TEMPLATE_INSTANTIATION ( class basic_parser< bool )
llvm::cl::TEMPLATE_INSTANTIATION ( class basic_parser< boolOrDefault )
llvm::cl::TEMPLATE_INSTANTIATION ( class basic_parser< int >  )
llvm::cl::TEMPLATE_INSTANTIATION ( class basic_parser< unsigned )
llvm::cl::TEMPLATE_INSTANTIATION ( class basic_parser< unsigned long long >  )
llvm::cl::TEMPLATE_INSTANTIATION ( class basic_parser< double >  )
llvm::cl::TEMPLATE_INSTANTIATION ( class basic_parser< float >  )
llvm::cl::TEMPLATE_INSTANTIATION ( class basic_parser< std::string >  )
llvm::cl::TEMPLATE_INSTANTIATION ( class basic_parser< char >  )
llvm::cl::TEMPLATE_INSTANTIATION ( class opt< unsigned )
llvm::cl::TEMPLATE_INSTANTIATION ( class opt< int >  )
llvm::cl::TEMPLATE_INSTANTIATION ( class opt< std::string >  )
llvm::cl::TEMPLATE_INSTANTIATION ( class opt< char >  )
llvm::cl::TEMPLATE_INSTANTIATION ( class opt< bool )
void llvm::cl::TokenizeGNUCommandLine ( StringRef  Source,
StringSaver Saver,
SmallVectorImpl< const char * > &  NewArgv 
)

Tokenizes a command line that can contain escapes and quotes.

The quoting rules match those used by GCC and other tools that use libiberty's buildargv() or expandargv() utilities, and do not match bash. They differ from buildargv() on treatment of backslashes that do not escape a special character to make it possible to accept most Windows file paths.

Parameters
[in]SourceThe string to be split on whitespace with quotes.
[in]SaverDelegates back to the caller for saving parsed strings.
[out]NewArgvAll parsed strings are appended to NewArgv.

Definition at line 454 of file CommandLine.cpp.

References llvm::SmallString< InternalLen >::c_str(), llvm::SmallVectorImpl< T >::clear(), llvm::SmallVectorBase::empty(), I, isGNUSpecial(), isQuote(), isWhitespace(), llvm::SmallVectorTemplateBase< T, isPodLike >::push_back(), llvm::cl::StringSaver::SaveString(), and llvm::StringRef::size().

Referenced by ParseCommandLineOptions(), and ParseEnvironmentOptions().

void llvm::cl::TokenizeWindowsCommandLine ( StringRef  Source,
StringSaver Saver,
SmallVectorImpl< const char * > &  NewArgv 
)

Tokenizes a Windows command line which may contain quotes and escaped quotes.

See MSDN docs for CommandLineToArgvW for information on the quoting rules. http://msdn.microsoft.com/en-us/library/windows/desktop/17w5ykft(v=vs.85).aspx

Parameters
[in]SourceThe string to be split on whitespace with quotes.
[in]SaverDelegates back to the caller for saving parsed strings.
[out]NewArgvAll parsed strings are appended to NewArgv.

Definition at line 542 of file CommandLine.cpp.

References llvm::SmallString< InternalLen >::c_str(), llvm::SmallVectorImpl< T >::clear(), llvm::SmallVectorBase::empty(), I, INIT, isWhitespace(), parseBackslash(), llvm::SmallVectorTemplateBase< T, isPodLike >::push_back(), llvm::cl::StringSaver::SaveString(), and llvm::StringRef::size().

template<class DataType >
ValuesClass<DataType> END_WITH_NULL llvm::cl::values ( const char *  Arg,
DataType  Val,
const char *  Desc,
  ... 
)

Definition at line 510 of file CommandLine.h.

Variable Documentation

OptionCategory llvm::cl::GeneralCategory