LLVM 17.0.0git
|
Option - Abstract representation for a single form of driver argument. More...
#include "llvm/Option/Option.h"
Public Types | |
enum | OptionClass { GroupClass = 0 , InputClass , UnknownClass , FlagClass , JoinedClass , ValuesClass , SeparateClass , RemainingArgsClass , RemainingArgsJoinedClass , CommaJoinedClass , MultiArgClass , JoinedOrSeparateClass , JoinedAndSeparateClass } |
enum | RenderStyleKind { RenderCommaJoinedStyle , RenderJoinedStyle , RenderSeparateStyle , RenderValuesStyle } |
Public Member Functions | |
Option (const OptTable::Info *Info, const OptTable *Owner) | |
bool | isValid () const |
unsigned | getID () const |
OptionClass | getKind () const |
StringRef | getName () const |
Get the name of this option without any prefix. | |
const Option | getGroup () const |
const Option | getAlias () const |
const char * | getAliasArgs () const |
Get the alias arguments as a \0 separated list. | |
StringRef | getPrefix () const |
Get the default prefix for this option. | |
std::string | getPrefixedName () const |
Get the name of this option with the default prefix. | |
StringRef | getHelpText () const |
Get the help text for this option. | |
StringRef | getMetaVar () const |
Get the meta-variable list for this option. | |
unsigned | getNumArgs () const |
bool | hasNoOptAsInput () const |
RenderStyleKind | getRenderStyle () const |
bool | hasFlag (unsigned Val) const |
Test if this option has the flag Val. | |
const Option | getUnaliasedOption () const |
getUnaliasedOption - Return the final option this option aliases (itself, if the option has no alias). | |
StringRef | getRenderName () const |
getRenderName - Return the name to use when rendering this option. | |
bool | matches (OptSpecifier ID) const |
matches - Predicate for whether this option is part of the given option (which may be a group). | |
std::unique_ptr< Arg > | accept (const ArgList &Args, StringRef CurArg, bool GroupedShortOption, unsigned &Index) const |
Potentially accept the current argument, returning a new Arg instance, or 0 if the option does not accept this argument (or the argument is missing values). | |
void | print (raw_ostream &O) const |
void | dump () const |
Protected Attributes | |
const OptTable::Info * | Info |
const OptTable * | Owner |
Option - Abstract representation for a single form of driver argument.
An Option class represents a form of option that the driver takes, for example how many arguments the option has and how they can be provided. Individual option instances store additional information about what group the option is a member of (if any), if the option is an alias, and a number of flags. At runtime the driver parses the command line into concrete Arg instances, each of which corresponds to a particular Option instance.
Option::Option | ( | const OptTable::Info * | Info, |
const OptTable * | Owner | ||
) |
Definition at line 26 of file Option.cpp.
References assert(), FlagClass, getAlias(), getAliasArgs(), getKind(), Info, Info, and isValid().
std::unique_ptr< Arg > Option::accept | ( | const ArgList & | Args, |
StringRef | CurArg, | ||
bool | GroupedShortOption, | ||
unsigned & | Index | ||
) | const |
Potentially accept the current argument, returning a new Arg instance, or 0 if the option does not accept this argument (or the argument is missing values).
If the option accepts the current argument, accept() sets Index to the position where argument parsing should resume (even if the argument is missing values).
CurArg
The argument to be matched. It may be shorter than the underlying storage to represent a Joined argument. GroupedShortOption
If true, we are handling the fallback case of parsing a prefix of the current argument as a short option.
Definition at line 232 of file Option.cpp.
References A, FlagClass, getAliasArgs(), getID(), getKind(), getName(), llvm::opt::Arg::getOwnsValues(), getPrefix(), getUnaliasedOption(), llvm::opt::Arg::getValues(), JoinedClass, and llvm::opt::Arg::setOwnsValues().
Referenced by llvm::opt::OptTable::ParseOneArg().
LLVM_DUMP_METHOD void Option::dump | ( | ) | const |
Definition at line 89 of file Option.cpp.
References llvm::dbgs(), and print().
Referenced by llvm::opt::OptTable::OptTable().
Definition at line 109 of file Option.h.
References llvm::opt::OptTable::Info::AliasID, assert(), llvm::opt::OptTable::getOption(), Info, and Owner.
Referenced by getUnaliasedOption(), matches(), Option(), print(), and llvm::opt::OptTable::printHelp().
Definition at line 103 of file Option.h.
References assert(), llvm::opt::OptTable::getOption(), llvm::opt::OptTable::Info::GroupID, Info, and Owner.
|
inline |
Get the help text for this option.
Definition at line 140 of file Option.h.
References assert(), llvm::opt::OptTable::Info::HelpText, and Info.
|
inline |
Definition at line 87 of file Option.h.
References assert(), llvm::opt::OptTable::Info::ID, and Info.
Referenced by accept(), matches(), and llvm::opt::OptTable::printHelp().
|
inline |
Definition at line 92 of file Option.h.
References assert(), Info, and llvm::opt::OptTable::Info::Kind.
Referenced by accept(), getRenderStyle(), Option(), and print().
|
inline |
Get the meta-variable list for this option.
Definition at line 146 of file Option.h.
References assert(), Info, and llvm::opt::OptTable::Info::MetaVar.
|
inline |
Get the name of this option without any prefix.
Definition at line 98 of file Option.h.
References assert(), Info, and llvm::opt::OptTable::Info::Name.
Referenced by accept(), getPrefixedName(), getRenderName(), llvm::opt::DerivedArgList::MakeFlagArg(), llvm::opt::DerivedArgList::MakeJoinedArg(), llvm::opt::DerivedArgList::MakePositionalArg(), llvm::opt::DerivedArgList::MakeSeparateArg(), and print().
|
inline |
Definition at line 151 of file Option.h.
References Info, and llvm::opt::OptTable::Info::Param.
Referenced by print().
|
inline |
Get the default prefix for this option.
Definition at line 126 of file Option.h.
References Info, and llvm::opt::OptTable::Info::Prefixes.
Referenced by accept(), getPrefixedName(), llvm::opt::DerivedArgList::MakeFlagArg(), llvm::opt::DerivedArgList::MakeJoinedArg(), llvm::opt::DerivedArgList::MakePositionalArg(), and llvm::opt::DerivedArgList::MakeSeparateArg().
|
inline |
Get the name of this option with the default prefix.
Definition at line 133 of file Option.h.
References getName(), and getPrefix().
|
inline |
getRenderName - Return the name to use when rendering this option.
Definition at line 197 of file Option.h.
References getName(), and getUnaliasedOption().
|
inline |
Definition at line 155 of file Option.h.
References CommaJoinedClass, FlagClass, llvm::opt::OptTable::Info::Flags, getKind(), GroupClass, Info, InputClass, JoinedAndSeparateClass, JoinedClass, JoinedOrSeparateClass, llvm_unreachable, MultiArgClass, RemainingArgsClass, RemainingArgsJoinedClass, RenderCommaJoinedStyle, llvm::opt::RenderJoined, RenderJoinedStyle, llvm::opt::RenderSeparate, RenderSeparateStyle, RenderValuesStyle, SeparateClass, UnknownClass, and ValuesClass.
getUnaliasedOption - Return the final option this option aliases (itself, if the option has no alias).
Definition at line 189 of file Option.h.
References getAlias(), getUnaliasedOption(), and isValid().
Referenced by accept(), getRenderName(), and getUnaliasedOption().
Test if this option has the flag Val.
Definition at line 183 of file Option.h.
References llvm::opt::OptTable::Info::Flags, and Info.
Referenced by llvm::opt::OptTable::ParseOneArg().
|
inline |
Definition at line 153 of file Option.h.
References llvm::opt::OptTable::Info::Flags, Info, and llvm::opt::RenderAsInput.
|
inline |
Definition at line 83 of file Option.h.
References Info.
Referenced by getUnaliasedOption(), matches(), Option(), print(), and llvm::opt::OptTable::printHelp().
bool Option::matches | ( | OptSpecifier | ID | ) | const |
matches - Predicate for whether this option is part of the given option (which may be a group).
Note that matches against options which are an alias should never be done – aliases do not participate in matching and so such a query will always be false.
Definition at line 92 of file Option.cpp.
References getAlias(), getGroup(), getID(), llvm::opt::OptSpecifier::getID(), isValid(), and matches().
Referenced by llvm::opt::ArgList::AddAllArgsExcept(), and matches().
void Option::print | ( | raw_ostream & | O | ) | const |
Definition at line 41 of file Option.cpp.
References CommaJoinedClass, FlagClass, getAlias(), getGroup(), getKind(), getName(), getNumArgs(), GroupClass, I, Info, InputClass, isValid(), JoinedAndSeparateClass, JoinedClass, JoinedOrSeparateClass, MultiArgClass, N, P, llvm::opt::OptTable::Info::Prefixes, print(), RemainingArgsClass, RemainingArgsJoinedClass, SeparateClass, UnknownClass, and ValuesClass.
Referenced by dump(), llvm::opt::Arg::print(), and print().
|
protected |
Definition at line 77 of file Option.h.
Referenced by getAlias(), getAliasArgs(), getGroup(), getHelpText(), getID(), getKind(), getMetaVar(), getName(), getNumArgs(), getPrefix(), getRenderStyle(), hasFlag(), hasNoOptAsInput(), isValid(), Option(), and print().
Definition at line 78 of file Option.h.
Referenced by getAlias(), and getGroup().