LLVM  14.0.0git
Public Types | Public Member Functions | Protected Attributes | List of all members
llvm::opt::Option Class Reference

Option - Abstract representation for a single form of driver argument. More...

#include "llvm/Option/Option.h"

Collaboration diagram for llvm::opt::Option:
Collaboration graph
[legend]

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. More...
 
const Option getGroup () const
 
const Option getAlias () const
 
const char * getAliasArgs () const
 Get the alias arguments as a \0 separated list. More...
 
StringRef getPrefix () const
 Get the default prefix for this option. More...
 
std::string getPrefixedName () const
 Get the name of this option with the default prefix. More...
 
StringRef getHelpText () const
 Get the help text for this option. More...
 
StringRef getMetaVar () const
 Get the meta-variable list for this option. More...
 
unsigned getNumArgs () const
 
bool hasNoOptAsInput () const
 
RenderStyleKind getRenderStyle () const
 
bool hasFlag (unsigned Val) const
 Test if this option has the flag Val. More...
 
const Option getUnaliasedOption () const
 getUnaliasedOption - Return the final option this option aliases (itself, if the option has no alias). More...
 
StringRef getRenderName () const
 getRenderName - Return the name to use when rendering this option. More...
 
bool matches (OptSpecifier ID) const
 matches - Predicate for whether this option is part of the given option (which may be a group). More...
 
std::unique_ptr< Argaccept (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). More...
 
void print (raw_ostream &O) const
 
void dump () const
 

Protected Attributes

const OptTable::InfoInfo
 
const OptTableOwner
 

Detailed Description

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.

Definition at line 51 of file Option.h.

Member Enumeration Documentation

◆ OptionClass

Enumerator
GroupClass 
InputClass 
UnknownClass 
FlagClass 
JoinedClass 
ValuesClass 
SeparateClass 
RemainingArgsClass 
RemainingArgsJoinedClass 
CommaJoinedClass 
MultiArgClass 
JoinedOrSeparateClass 
JoinedAndSeparateClass 

Definition at line 53 of file Option.h.

◆ RenderStyleKind

Enumerator
RenderCommaJoinedStyle 
RenderJoinedStyle 
RenderSeparateStyle 
RenderValuesStyle 

Definition at line 69 of file Option.h.

Constructor & Destructor Documentation

◆ Option()

Option::Option ( const OptTable::Info Info,
const OptTable Owner 
)

Definition at line 26 of file Option.cpp.

References assert(), FlagClass, getAlias(), getAliasArgs(), getKind(), Info, and isValid().

Member Function Documentation

◆ accept()

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 236 of file Option.cpp.

References llvm::AMDGPU::HSAMD::Kernel::Key::Args, FlagClass, getAliasArgs(), getID(), getKind(), getName(), llvm::opt::Arg::getOwnsValues(), getPrefix(), getUnaliasedOption(), llvm::opt::Arg::getValues(), Index, JoinedClass, move, and llvm::opt::Arg::setOwnsValues().

◆ dump()

LLVM_DUMP_METHOD void Option::dump ( ) const

Definition at line 90 of file Option.cpp.

References llvm::dbgs(), and print().

Referenced by llvm::opt::OptTable::OptTable().

◆ getAlias()

const Option llvm::opt::Option::getAlias ( ) const
inline

◆ getAliasArgs()

const char* llvm::opt::Option::getAliasArgs ( ) const
inline

Get the alias arguments as a \0 separated list.

E.g. ["foo", "bar"] would be returned as "foo\0bar\0".

Definition at line 117 of file Option.h.

References llvm::opt::OptTable::Info::AliasArgs, assert(), and Info.

Referenced by accept(), and Option().

◆ getGroup()

const Option llvm::opt::Option::getGroup ( ) const
inline

Definition at line 103 of file Option.h.

References assert(), llvm::opt::OptTable::getOption(), llvm::opt::OptTable::Info::GroupID, Info, and Owner.

Referenced by matches(), and print().

◆ getHelpText()

StringRef llvm::opt::Option::getHelpText ( ) const
inline

Get the help text for this option.

Definition at line 139 of file Option.h.

References assert(), llvm::opt::OptTable::Info::HelpText, and Info.

◆ getID()

unsigned llvm::opt::Option::getID ( ) const
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().

◆ getKind()

OptionClass llvm::opt::Option::getKind ( ) const
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().

◆ getMetaVar()

StringRef llvm::opt::Option::getMetaVar ( ) const
inline

Get the meta-variable list for this option.

Definition at line 145 of file Option.h.

References assert(), Info, and llvm::opt::OptTable::Info::MetaVar.

◆ getName()

StringRef llvm::opt::Option::getName ( ) const
inline

◆ getNumArgs()

unsigned llvm::opt::Option::getNumArgs ( ) const
inline

Definition at line 150 of file Option.h.

References Info, and llvm::opt::OptTable::Info::Param.

Referenced by print().

◆ getPrefix()

StringRef llvm::opt::Option::getPrefix ( ) const
inline

◆ getPrefixedName()

std::string llvm::opt::Option::getPrefixedName ( ) const
inline

Get the name of this option with the default prefix.

Definition at line 132 of file Option.h.

References getName(), getPrefix(), and llvm::MipsISD::Ret.

◆ getRenderName()

StringRef llvm::opt::Option::getRenderName ( ) const
inline

getRenderName - Return the name to use when rendering this option.

Definition at line 196 of file Option.h.

References getName(), and getUnaliasedOption().

◆ getRenderStyle()

RenderStyleKind llvm::opt::Option::getRenderStyle ( ) const
inline

◆ getUnaliasedOption()

const Option llvm::opt::Option::getUnaliasedOption ( ) const
inline

getUnaliasedOption - Return the final option this option aliases (itself, if the option has no alias).

Definition at line 188 of file Option.h.

References getAlias(), getUnaliasedOption(), and isValid().

Referenced by accept(), getRenderName(), and getUnaliasedOption().

◆ hasFlag()

bool llvm::opt::Option::hasFlag ( unsigned  Val) const
inline

Test if this option has the flag Val.

Definition at line 182 of file Option.h.

References llvm::opt::OptTable::Info::Flags, and Info.

◆ hasNoOptAsInput()

bool llvm::opt::Option::hasNoOptAsInput ( ) const
inline

Definition at line 152 of file Option.h.

References llvm::opt::OptTable::Info::Flags, Info, and llvm::opt::RenderAsInput.

◆ isValid()

bool llvm::opt::Option::isValid ( ) const
inline

Definition at line 83 of file Option.h.

References Info.

Referenced by getUnaliasedOption(), matches(), Option(), print(), and llvm::opt::OptTable::printHelp().

◆ matches()

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 93 of file Option.cpp.

References getAlias(), getGroup(), llvm::opt::OptSpecifier::getID(), getID(), isValid(), and matches().

Referenced by llvm::opt::ArgList::AddAllArgsExcept(), and matches().

◆ print()

void Option::print ( raw_ostream O) const

Member Data Documentation

◆ Info

const OptTable::Info* llvm::opt::Option::Info
protected

◆ Owner

const OptTable* llvm::opt::Option::Owner
protected

Definition at line 78 of file Option.h.

Referenced by getAlias(), and getGroup().


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