LLVM 22.0.0git
|
ArgList - Ordered collection of driver arguments. More...
#include "llvm/Option/ArgList.h"
Public Types | |
using | arglist_type = SmallVector<Arg *, 16> |
using | iterator = arg_iterator<arglist_type::iterator> |
using | const_iterator = arg_iterator<arglist_type::const_iterator> |
using | reverse_iterator = arg_iterator<arglist_type::reverse_iterator> |
using | const_reverse_iterator |
template<unsigned N> | |
using | filtered_iterator |
template<unsigned N> | |
using | filtered_reverse_iterator |
Public Member Functions | |
Arg Access | |
LLVM_ABI void | append (Arg *A) |
append - Append A to the arg list. | |
const arglist_type & | getArgs () const |
unsigned | size () const |
template<typename ... OptSpecifiers> | |
bool | hasArgNoClaim (OptSpecifiers ...Ids) const |
hasArg - Does the arg list contain any option matching Id . | |
template<typename ... OptSpecifiers> | |
bool | hasArg (OptSpecifiers ...Ids) const |
bool | hasMultipleArgs (OptSpecifier Id) const |
Return true if the arg list contains multiple arguments matching Id . | |
template<typename... OptSpecifiers> | |
LLVM_ATTRIBUTE_NOINLINE Arg * | getLastArg (OptSpecifiers... Ids) const |
Return the last argument matching Id , or null. | |
template<typename... OptSpecifiers> | |
LLVM_ATTRIBUTE_NOINLINE Arg * | getLastArgNoClaim (OptSpecifiers... Ids) const |
Return the last argument matching Id , or null. | |
virtual const char * | getArgString (unsigned Index) const =0 |
getArgString - Return the input argument string at Index . | |
virtual unsigned | getNumInputArgStrings () const =0 |
getNumInputArgStrings - Return the number of original argument strings, which are guaranteed to be the first strings in the argument string list. | |
StringRef | getSubCommand (ArrayRef< OptTable::SubCommand > AllSubCommands, std::function< void(ArrayRef< StringRef >)> HandleMultipleSubcommands, std::function< void(ArrayRef< StringRef >)> HandleOtherPositionals) const |
getSubCommand - Find subcommand from the arguments if the usage is valid. | |
Arg Iteration | |
iterator | begin () |
iterator | end () |
reverse_iterator | rbegin () |
reverse_iterator | rend () |
const_iterator | begin () const |
const_iterator | end () const |
const_reverse_iterator | rbegin () const |
const_reverse_iterator | rend () const |
template<typename ... OptSpecifiers> | |
iterator_range< filtered_iterator< sizeof...(OptSpecifiers)> > | filtered (OptSpecifiers ...Ids) const |
template<typename ... OptSpecifiers> | |
iterator_range< filtered_reverse_iterator< sizeof...(OptSpecifiers)> > | filtered_reverse (OptSpecifiers ...Ids) const |
Arg Removal | |
LLVM_ABI void | eraseArg (OptSpecifier Id) |
eraseArg - Remove any option matching Id . | |
Argument Lookup Utilities | |
LLVM_ABI StringRef | getLastArgValue (OptSpecifier Id, StringRef Default="") const |
getLastArgValue - Return the value of the last argument, or a default. | |
LLVM_ABI std::vector< std::string > | getAllArgValues (OptSpecifier Id) const |
getAllArgValues - Get the values of all instances of the given argument as strings. | |
Translation Utilities | |
LLVM_ABI bool | hasFlag (OptSpecifier Pos, OptSpecifier Neg, bool Default) const |
hasFlag - Given an option Pos and its negative form Neg , return true if the option is present, false if the negation is present, and Default if neither option is given. | |
LLVM_ABI bool | hasFlagNoClaim (OptSpecifier Pos, OptSpecifier Neg, bool Default) const |
LLVM_ABI bool | hasFlag (OptSpecifier Pos, OptSpecifier PosAlias, OptSpecifier Neg, bool Default) const |
hasFlag - Given an option Pos , an alias PosAlias and its negative form Neg , return true if the option or its alias is present, false if the negation is present, and Default if none of the options are given. | |
LLVM_ABI void | addOptInFlag (ArgStringList &Output, OptSpecifier Pos, OptSpecifier Neg) const |
Given an option Pos and its negative form Neg, render the option if Pos is present. | |
void | addOptOutFlag (ArgStringList &Output, OptSpecifier Pos, OptSpecifier Neg) const |
Render the option if Neg is present. | |
template<typename... OptSpecifiers> | |
void | addLastArg (ArgStringList &Output, OptSpecifiers... Ids) const |
Render only the last argument match Id0 , if present. | |
template<typename... OptSpecifiers> | |
void | AddLastArg (ArgStringList &Output, OptSpecifiers... Ids) const |
LLVM_ABI void | AddAllArgsExcept (ArgStringList &Output, ArrayRef< OptSpecifier > Ids, ArrayRef< OptSpecifier > ExcludeIds) const |
AddAllArgsExcept - Render all arguments matching any of the given ids and not matching any of the excluded ids. | |
LLVM_ABI void | addAllArgs (ArgStringList &Output, ArrayRef< OptSpecifier > Ids) const |
Render all arguments matching any of the given ids. | |
LLVM_ABI void | AddAllArgs (ArgStringList &Output, OptSpecifier Id0) const |
AddAllArgs - Render all arguments matching the given ids. | |
LLVM_ABI void | AddAllArgValues (ArgStringList &Output, OptSpecifier Id0, OptSpecifier Id1=0U, OptSpecifier Id2=0U) const |
AddAllArgValues - Render the argument values of all arguments matching the given ids. | |
LLVM_ABI void | AddAllArgsTranslated (ArgStringList &Output, OptSpecifier Id0, const char *Translation, bool Joined=false) const |
AddAllArgsTranslated - Render all the arguments matching the given ids, but forced to separate args and using the provided name instead of the first option value. | |
LLVM_ABI void | ClaimAllArgs (OptSpecifier Id0) const |
ClaimAllArgs - Claim all arguments which match the given option id. | |
template<typename... OptSpecifiers> | |
void | claimAllArgs (OptSpecifiers... Ids) const |
LLVM_ABI void | ClaimAllArgs () const |
ClaimAllArgs - Claim all arguments. | |
Arg Synthesis | |
virtual const char * | MakeArgStringRef (StringRef Str) const =0 |
Construct a constant string pointer whose lifetime will match that of the ArgList. | |
const char * | MakeArgString (const Twine &Str) const |
LLVM_ABI const char * | GetOrMakeJoinedArgString (unsigned Index, StringRef LHS, StringRef RHS) const |
Create an arg string for (LHS + RHS ), reusing the string at Index if possible. | |
LLVM_ABI void | print (raw_ostream &O) const |
LLVM_ABI void | dump () const |
Protected Member Functions | |
ArgList ()=default | |
ArgList (ArgList &&RHS) | |
ArgList & | operator= (ArgList &&RHS) |
~ArgList ()=default |
Static Protected Member Functions | |
static OptSpecifier | toOptSpecifier (OptSpecifier S) |
ArgList - Ordered collection of driver arguments.
The ArgList class manages a list of Arg instances as well as auxiliary data and convenience methods to allow Tools to quickly check for the presence of Arg instances for a particular Option and to iterate over groups of arguments.
using llvm::opt::ArgList::arglist_type = SmallVector<Arg *, 16> |
using llvm::opt::ArgList::filtered_iterator |
using llvm::opt::ArgList::filtered_reverse_iterator |
|
protecteddefault |
Referenced by ArgList(), llvm::opt::InputArgList::InputArgList(), and operator=().
|
inlineprotected |
Definition at line 157 of file ArgList.h.
References ArgList(), llvm::move(), and RHS.
|
protecteddefault |
void ArgList::AddAllArgs | ( | ArgStringList & | Output, |
OptSpecifier | Id0 ) const |
AddAllArgs - Render all arguments matching the given ids.
Definition at line 142 of file ArgList.cpp.
References llvm::opt::Arg::claim(), filtered(), and llvm::opt::Arg::render().
void ArgList::addAllArgs | ( | ArgStringList & | Output, |
ArrayRef< OptSpecifier > | Ids ) const |
Render all arguments matching any of the given ids.
This is a nicer interface when you don't have a list of Ids to exclude.
Definition at line 136 of file ArgList.cpp.
References AddAllArgsExcept().
void ArgList::AddAllArgsExcept | ( | ArgStringList & | Output, |
ArrayRef< OptSpecifier > | Ids, | ||
ArrayRef< OptSpecifier > | ExcludeIds ) const |
AddAllArgsExcept - Render all arguments matching any of the given ids and not matching any of the excluded ids.
Definition at line 112 of file ArgList.cpp.
References llvm::opt::Arg::claim(), llvm::opt::Arg::getOption(), llvm::opt::Option::matches(), and llvm::opt::Arg::render().
Referenced by addAllArgs().
void ArgList::AddAllArgsTranslated | ( | ArgStringList & | Output, |
OptSpecifier | Id0, | ||
const char * | Translation, | ||
bool | Joined = false ) const |
AddAllArgsTranslated - Render all the arguments matching the given ids, but forced to separate args and using the provided name instead of the first option value.
Joined | - If true, render the argument as joined with the option specifier. |
Definition at line 158 of file ArgList.cpp.
References llvm::opt::Arg::claim(), filtered(), llvm::opt::Arg::getValue(), MakeArgString(), and llvm::SmallVectorTemplateBase< T, bool >::push_back().
void ArgList::AddAllArgValues | ( | ArgStringList & | Output, |
OptSpecifier | Id0, | ||
OptSpecifier | Id1 = 0U, | ||
OptSpecifier | Id2 = 0U ) const |
AddAllArgValues - Render the argument values of all arguments matching the given ids.
Definition at line 149 of file ArgList.cpp.
References llvm::SmallVectorImpl< T >::append(), llvm::opt::Arg::claim(), filtered(), and llvm::opt::Arg::getValues().
Referenced by getAllArgValues().
|
inline |
Definition at line 348 of file ArgList.h.
References addLastArg().
|
inline |
Render only the last argument match Id0
, if present.
Definition at line 343 of file ArgList.h.
References A(), and getLastArg().
Referenced by AddLastArg().
void ArgList::addOptInFlag | ( | ArgStringList & | Output, |
OptSpecifier | Pos, | ||
OptSpecifier | Neg ) const |
Given an option Pos and its negative form Neg, render the option if Pos is present.
Definition at line 105 of file ArgList.cpp.
References A(), and getLastArg().
Referenced by addOptOutFlag().
|
inline |
Render the option if Neg is present.
Definition at line 336 of file ArgList.h.
References addOptInFlag().
void ArgList::append | ( | Arg * | A | ) |
append - Append A
to the arg list.
Definition at line 33 of file ArgList.cpp.
References A().
Referenced by llvm::opt::DerivedArgList::AddFlagArg(), llvm::opt::DerivedArgList::AddJoinedArg(), llvm::opt::DerivedArgList::AddPositionalArg(), and llvm::opt::DerivedArgList::AddSeparateArg().
|
inline |
void ArgList::ClaimAllArgs | ( | ) | const |
ClaimAllArgs - Claim all arguments.
Definition at line 179 of file ArgList.cpp.
References llvm::opt::Arg::claim(), and llvm::opt::Arg::isClaimed().
void ArgList::ClaimAllArgs | ( | OptSpecifier | Id0 | ) | const |
ClaimAllArgs - Claim all arguments which match the given option id.
Definition at line 174 of file ArgList.cpp.
References llvm::opt::Arg::claim(), and filtered().
|
inline |
Definition at line 385 of file ArgList.h.
References A(), and filtered().
LLVM_DUMP_METHOD void ArgList::dump | ( | ) | const |
Definition at line 204 of file ArgList.cpp.
References llvm::dbgs(), LLVM_DUMP_METHOD, and print().
|
inline |
void ArgList::eraseArg | ( | OptSpecifier | Id | ) |
eraseArg - Remove any option matching Id
.
Definition at line 46 of file ArgList.cpp.
References A(), and filtered().
|
inline |
Definition at line 207 of file ArgList.h.
References B(), E(), llvm::make_range(), Range, and toOptSpecifier().
Referenced by AddAllArgs(), AddAllArgsTranslated(), AddAllArgValues(), ClaimAllArgs(), claimAllArgs(), eraseArg(), getLastArg(), and hasMultipleArgs().
|
inline |
Definition at line 218 of file ArgList.h.
References B(), E(), llvm::make_range(), Range, and toOptSpecifier().
Referenced by getLastArgNoClaim().
std::vector< std::string > ArgList::getAllArgValues | ( | OptSpecifier | Id | ) | const |
getAllArgValues - Get the values of all instances of the given argument as strings.
Definition at line 99 of file ArgList.cpp.
References AddAllArgValues(), llvm::SmallVectorTemplateCommon< T, typename >::begin(), and llvm::SmallVectorTemplateCommon< T, typename >::end().
|
inline |
getArgString - Return the input argument string at Index
.
Implemented in llvm::opt::DerivedArgList, and llvm::opt::InputArgList.
Referenced by GetOrMakeJoinedArgString().
|
inline |
Return the last argument matching Id
, or null.
Definition at line 258 of file ArgList.h.
References A(), llvm::opt::Arg::claim(), filtered(), and LLVM_ATTRIBUTE_NOINLINE.
Referenced by addLastArg(), addOptInFlag(), getLastArgValue(), hasArg(), hasFlag(), and hasFlag().
|
inline |
Return the last argument matching Id
, or null.
Do not "claim" the option (don't mark it as having been used).
Definition at line 270 of file ArgList.h.
References A(), filtered_reverse(), and LLVM_ATTRIBUTE_NOINLINE.
Referenced by hasArgNoClaim(), and hasFlagNoClaim().
StringRef ArgList::getLastArgValue | ( | OptSpecifier | Id, |
StringRef | Default = "" ) const |
getLastArgValue - Return the value of the last argument, or a default.
Definition at line 93 of file ArgList.cpp.
References A(), llvm::Default, and getLastArg().
|
pure virtual |
getNumInputArgStrings - Return the number of original argument strings, which are guaranteed to be the first strings in the argument string list.
Implemented in llvm::opt::DerivedArgList, and llvm::opt::InputArgList.
References AllSubCommands, llvm::Default, and LLVM_ABI.
const char * ArgList::GetOrMakeJoinedArgString | ( | unsigned | Index, |
StringRef | LHS, | ||
StringRef | RHS ) const |
Create an arg string for (LHS
+ RHS
), reusing the string at Index
if possible.
Definition at line 185 of file ArgList.cpp.
References llvm::StringRef::data(), llvm::StringRef::ends_with(), getArgString(), MakeArgString(), llvm::StringRef::size(), and llvm::StringRef::starts_with().
StringRef ArgList::getSubCommand | ( | ArrayRef< OptTable::SubCommand > | AllSubCommands, |
std::function< void(ArrayRef< StringRef >)> | HandleMultipleSubcommands, | ||
std::function< void(ArrayRef< StringRef >)> | HandleOtherPositionals ) const |
getSubCommand - Find subcommand from the arguments if the usage is valid.
AllSubCommands | - A list of all valid subcommands. |
HandleMultipleSubcommands | - A callback for the case where multiple subcommands are present in the arguments. It gets a list of all found subcommands. |
HandleOtherPositionals | - A callback for the case where positional arguments that are not subcommands are present. |
Definition at line 207 of file ArgList.cpp.
References A(), AllSubCommands, llvm::SmallVectorTemplateCommon< T, typename >::empty(), llvm::SmallVectorTemplateCommon< T, typename >::front(), llvm::opt::Option::InputClass, llvm::SmallVectorTemplateBase< T, bool >::push_back(), and llvm::SmallVectorTemplateCommon< T, typename >::size().
|
inline |
Definition at line 246 of file ArgList.h.
References getLastArg().
|
inline |
hasArg - Does the arg list contain any option matching Id
.
Claim
Whether the argument should be claimed, if it exists.
Definition at line 242 of file ArgList.h.
References getLastArgNoClaim().
bool ArgList::hasFlag | ( | OptSpecifier | Pos, |
OptSpecifier | Neg, | ||
bool | Default ) const |
hasFlag - Given an option Pos
and its negative form Neg
, return true if the option is present, false if the negation is present, and Default
if neither option is given.
If both the option and its negation are present, the last one wins.
Definition at line 73 of file ArgList.cpp.
References A(), llvm::Default, and getLastArg().
bool ArgList::hasFlag | ( | OptSpecifier | Pos, |
OptSpecifier | PosAlias, | ||
OptSpecifier | Neg, | ||
bool | Default ) const |
hasFlag - Given an option Pos
, an alias PosAlias
and its negative form Neg
, return true if the option or its alias is present, false if the negation is present, and Default
if none of the options are given.
If multiple options are present, the last one wins.
Definition at line 86 of file ArgList.cpp.
References A(), llvm::Default, and getLastArg().
bool ArgList::hasFlagNoClaim | ( | OptSpecifier | Pos, |
OptSpecifier | Neg, | ||
bool | Default ) const |
Definition at line 79 of file ArgList.cpp.
References A(), llvm::Default, and getLastArgNoClaim().
|
inline |
Return true if the arg list contains multiple arguments matching Id
.
Definition at line 251 of file ArgList.h.
References filtered().
Definition at line 400 of file ArgList.h.
References MakeArgStringRef().
Referenced by AddAllArgsTranslated(), and GetOrMakeJoinedArgString().
Construct a constant string pointer whose lifetime will match that of the ArgList.
Implemented in llvm::opt::DerivedArgList, and llvm::opt::InputArgList.
Referenced by MakeArgString().
Definition at line 163 of file ArgList.h.
References ArgList(), and RHS.
Referenced by llvm::opt::InputArgList::operator=().
void ArgList::print | ( | raw_ostream & | O | ) | const |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlinestaticprotected |
Definition at line 176 of file ArgList.h.
Referenced by filtered(), and filtered_reverse().