LLVM API Documentation

Classes | Public Member Functions | Protected Member Functions
llvm::opt::OptTable Class Reference

Provide access to the Option info table. More...

#include <OptTable.h>

List of all members.

Classes

struct  Info
 Entry for a single option instance in the option data table. More...

Public Member Functions

 ~OptTable ()
unsigned getNumOptions () const
 Return the total number of option classes.
const Option getOption (OptSpecifier Opt) const
 Get the given Opt's Option instance, lazily creating it if necessary.
const char * getOptionName (OptSpecifier id) const
 Lookup the name of the given option.
unsigned getOptionKind (OptSpecifier id) const
 Get the kind of the given option.
unsigned getOptionGroupID (OptSpecifier id) const
 Get the group id for the given option.
const char * getOptionHelpText (OptSpecifier id) const
 Get the help text to use to describe this option.
const char * getOptionMetaVar (OptSpecifier id) const
 Get the meta-variable name to use when describing this options values in the help text.
ArgParseOneArg (const ArgList &Args, unsigned &Index, unsigned FlagsToInclude=0, unsigned FlagsToExclude=0) const
 Parse a single argument; returning the new argument and updating Index.
InputArgListParseArgs (const char *const *ArgBegin, const char *const *ArgEnd, unsigned &MissingArgIndex, unsigned &MissingArgCount, unsigned FlagsToInclude=0, unsigned FlagsToExclude=0) const
 Parse an list of arguments into an InputArgList.
void PrintHelp (raw_ostream &OS, const char *Name, const char *Title, unsigned FlagsToInclude, unsigned FlagsToExclude) const
 Render the help text for an option table.
void PrintHelp (raw_ostream &OS, const char *Name, const char *Title, bool ShowHidden=false) const

Protected Member Functions

 OptTable (const Info *_OptionInfos, unsigned _NumOptionInfos, bool _IgnoreCase=false)

Detailed Description

Provide access to the Option info table.

The OptTable class provides a layer of indirection which allows Option instance to be created lazily. In the common case, only a few options will be needed at runtime; the OptTable class maintains enough information to parse command lines without instantiating Options, while letting other parts of the driver still use Option instances where convenient.

Definition at line 31 of file OptTable.h.


Constructor & Destructor Documentation

OptTable::OptTable ( const Info _OptionInfos,
unsigned  _NumOptionInfos,
bool  _IgnoreCase = false 
) [protected]

Definition at line 157 of file OptTable.cpp.


Member Function Documentation

Return the total number of option classes.

Definition at line 82 of file OptTable.h.

Referenced by getOption(), OptTable(), ParseOneArg(), and PrintHelp().

Get the given Opt's Option instance, lazily creating it if necessary.

Returns:
The option, or null for the INVALID option id.

Definition at line 160 of file OptTable.cpp.

References llvm::opt::OptSpecifier::getID(), and getNumOptions().

Referenced by llvm::opt::Option::getAlias(), llvm::opt::Option::getGroup(), getOptionHelpName(), OptTable(), and ParseOneArg().

Get the group id for the given option.

Definition at line 101 of file OptTable.h.

References llvm::opt::OptTable::Info::GroupID.

Referenced by getOptionHelpGroup().

Get the help text to use to describe this option.

Definition at line 106 of file OptTable.h.

References llvm::opt::OptTable::Info::HelpText.

Referenced by getOptionHelpGroup(), and PrintHelp().

Get the kind of the given option.

Definition at line 96 of file OptTable.h.

References llvm::opt::OptTable::Info::Kind.

Referenced by PrintHelp().

Get the meta-variable name to use when describing this options values in the help text.

Definition at line 112 of file OptTable.h.

References llvm::opt::OptTable::Info::MetaVar.

Referenced by getOptionHelpName().

Lookup the name of the given option.

Definition at line 91 of file OptTable.h.

References llvm::opt::OptTable::Info::Name.

InputArgList * OptTable::ParseArgs ( const char *const ArgBegin,
const char *const ArgEnd,
unsigned MissingArgIndex,
unsigned MissingArgCount,
unsigned  FlagsToInclude = 0,
unsigned  FlagsToExclude = 0 
) const

Parse an list of arguments into an InputArgList.

The resulting InputArgList will reference the strings in [ArgBegin, ArgEnd), and their lifetime should extend past that of the returned InputArgList.

The only error that can occur in this routine is if an argument is missing values; in this case MissingArgCount will be non-zero.

Parameters:
ArgBegin- The beginning of the argument vector.
ArgEnd- The end of the argument vector.
MissingArgIndex- On error, the index of the option which could not be parsed.
MissingArgCount- On error, the number of missing options.
FlagsToInclude- Only parse options with any of these flags. Zero is the default which includes all flags.
FlagsToExclude- Don't parse options with this flag. Zero is the default and means exclude nothing.
Returns:
An InputArgList; on error this will contain all the options which could be parsed.

Definition at line 254 of file OptTable.cpp.

References llvm::ARM_PROC::A, llvm::opt::ArgList::append(), llvm::opt::InputArgList::getArgString(), and ParseOneArg().

Arg * OptTable::ParseOneArg ( const ArgList Args,
unsigned Index,
unsigned  FlagsToInclude = 0,
unsigned  FlagsToExclude = 0 
) const

Parse a single argument; returning the new argument and updating Index.

Parameters:
[in,out]Index- The current parsing position in the argument string list; on return this will be the index of the next argument string to parse.
[in]FlagsToInclude- Only parse options with any of these flags. Zero is the default which includes all flags.
[in]FlagsToExclude- Don't parse options with this flag. Zero is the default and means exclude nothing.
Returns:
The parsed argument, or 0 if the argument is missing values (in which case Index still points at the conceptual next argument string to parse).

Definition at line 195 of file OptTable.cpp.

References llvm::ARM_PROC::A, llvm::opt::Option::accept(), llvm::StringRef::data(), llvm::opt::ArgList::getArgString(), getNumOptions(), getOption(), llvm::opt::Option::hasFlag(), isInput(), llvm::StringRef::ltrim(), matchOption(), and Name.

Referenced by ParseArgs().

void OptTable::PrintHelp ( raw_ostream OS,
const char *  Name,
const char *  Title,
unsigned  FlagsToInclude,
unsigned  FlagsToExclude 
) const

Render the help text for an option table.

Parameters:
OS- The stream to write the help text to.
Name- The name to use in the usage line.
Title- The title to use in the usage line.
FlagsToInclude- If non-zero, only include options with any of these flags set.
FlagsToExclude- Exclude options with any of these flags set.

Definition at line 398 of file OptTable.cpp.

References llvm::sys::path::begin(), llvm::sys::path::const_iterator::end, llvm::opt::OptTable::Info::Flags, llvm::raw_ostream::flush(), getNumOptions(), getOptionHelpGroup(), getOptionHelpName(), getOptionHelpText(), getOptionKind(), llvm::opt::Option::GroupClass, llvm::tgtok::Id, and PrintHelpOptionList().

Referenced by PrintHelp().

void OptTable::PrintHelp ( raw_ostream OS,
const char *  Name,
const char *  Title,
bool  ShowHidden = false 
) const

Definition at line 391 of file OptTable.cpp.

References llvm::opt::HelpHidden, and PrintHelp().


The documentation for this class was generated from the following files: