LLVM 22.0.0git
llvm::opt::ArgList Class Referenceabstract

ArgList - Ordered collection of driver arguments. More...

#include "llvm/Option/ArgList.h"

Inheritance diagram for llvm::opt::ArgList:
[legend]

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_typegetArgs () 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>
ArggetLastArg (OptSpecifiers ...Ids) const
 Return the last argument matching Id, or null.
template<typename ... OptSpecifiers>
ArggetLastArgNoClaim (OptSpecifiers ...Ids) const
 Return the last argument matching Id, or null.
virtual const chargetArgString (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.
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 charMakeArgStringRef (StringRef Str) const =0
 Construct a constant string pointer whose lifetime will match that of the ArgList.
const charMakeArgString (const Twine &Str) const
LLVM_ABI const charGetOrMakeJoinedArgString (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)
ArgListoperator= (ArgList &&RHS)
 ~ArgList ()=default

Static Protected Member Functions

static OptSpecifier toOptSpecifier (OptSpecifier S)

Detailed Description

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.

Definition at line 117 of file ArgList.h.

Member Typedef Documentation

◆ arglist_type

Definition at line 119 of file ArgList.h.

◆ const_iterator

◆ const_reverse_iterator

Initial value:
arg_iterator - Iterates through arguments stored inside an ArgList.
Definition ArgList.h:41

Definition at line 123 of file ArgList.h.

◆ filtered_iterator

◆ filtered_reverse_iterator

◆ iterator

◆ reverse_iterator

Constructor & Destructor Documentation

◆ ArgList() [1/2]

llvm::opt::ArgList::ArgList ( )
protecteddefault

◆ ArgList() [2/2]

llvm::opt::ArgList::ArgList ( ArgList && RHS)
inlineprotected

Definition at line 156 of file ArgList.h.

References ArgList(), llvm::move(), and RHS.

◆ ~ArgList()

llvm::opt::ArgList::~ArgList ( )
protecteddefault

Member Function Documentation

◆ AddAllArgs()

void ArgList::AddAllArgs ( ArgStringList & Output,
OptSpecifier Id0 ) const

AddAllArgs - Render all arguments matching the given ids.

Definition at line 140 of file ArgList.cpp.

References llvm::opt::Arg::claim(), filtered(), and llvm::opt::Arg::render().

◆ addAllArgs()

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 134 of file ArgList.cpp.

References AddAllArgsExcept().

◆ 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 110 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().

◆ AddAllArgsTranslated()

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.

Parameters
Joined- If true, render the argument as joined with the option specifier.

Definition at line 156 of file ArgList.cpp.

References llvm::opt::Arg::claim(), filtered(), llvm::opt::Arg::getValue(), MakeArgString(), and llvm::SmallVectorTemplateBase< T, bool >::push_back().

◆ AddAllArgValues()

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 147 of file ArgList.cpp.

References llvm::SmallVectorImpl< T >::append(), llvm::opt::Arg::claim(), filtered(), and llvm::opt::Arg::getValues().

Referenced by getAllArgValues().

◆ AddLastArg()

template<typename... OptSpecifiers>
void llvm::opt::ArgList::AddLastArg ( ArgStringList & Output,
OptSpecifiers... Ids ) const
inline

Definition at line 331 of file ArgList.h.

References addLastArg().

◆ addLastArg()

template<typename... OptSpecifiers>
void llvm::opt::ArgList::addLastArg ( ArgStringList & Output,
OptSpecifiers... Ids ) const
inline

Render only the last argument match Id0, if present.

Definition at line 326 of file ArgList.h.

References A(), and getLastArg().

Referenced by AddLastArg().

◆ addOptInFlag()

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 103 of file ArgList.cpp.

References A(), and getLastArg().

Referenced by addOptOutFlag().

◆ addOptOutFlag()

void llvm::opt::ArgList::addOptOutFlag ( ArgStringList & Output,
OptSpecifier Pos,
OptSpecifier Neg ) const
inline

Render the option if Neg is present.

Definition at line 319 of file ArgList.h.

References addOptInFlag().

◆ append()

void ArgList::append ( Arg * A)

◆ begin() [1/2]

iterator llvm::opt::ArgList::begin ( )
inline

Definition at line 192 of file ArgList.h.

◆ begin() [2/2]

const_iterator llvm::opt::ArgList::begin ( ) const
inline

Definition at line 198 of file ArgList.h.

◆ ClaimAllArgs() [1/2]

void ArgList::ClaimAllArgs ( ) const

ClaimAllArgs - Claim all arguments.

Definition at line 177 of file ArgList.cpp.

References llvm::opt::Arg::claim(), and llvm::opt::Arg::isClaimed().

◆ ClaimAllArgs() [2/2]

void ArgList::ClaimAllArgs ( OptSpecifier Id0) const

ClaimAllArgs - Claim all arguments which match the given option id.

Definition at line 172 of file ArgList.cpp.

References llvm::opt::Arg::claim(), and filtered().

◆ claimAllArgs()

template<typename... OptSpecifiers>
void llvm::opt::ArgList::claimAllArgs ( OptSpecifiers... Ids) const
inline

Definition at line 368 of file ArgList.h.

References A(), and filtered().

◆ dump()

LLVM_DUMP_METHOD void ArgList::dump ( ) const

Definition at line 202 of file ArgList.cpp.

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

◆ end() [1/2]

iterator llvm::opt::ArgList::end ( )
inline

Definition at line 193 of file ArgList.h.

◆ end() [2/2]

const_iterator llvm::opt::ArgList::end ( ) const
inline

Definition at line 199 of file ArgList.h.

◆ eraseArg()

void ArgList::eraseArg ( OptSpecifier Id)

eraseArg - Remove any option matching Id.

Definition at line 44 of file ArgList.cpp.

References A(), and filtered().

◆ filtered()

template<typename ... OptSpecifiers>
iterator_range< filtered_iterator< sizeof...(OptSpecifiers)> > llvm::opt::ArgList::filtered ( OptSpecifiers ... Ids) const
inline

◆ filtered_reverse()

template<typename ... OptSpecifiers>
iterator_range< filtered_reverse_iterator< sizeof...(OptSpecifiers)> > llvm::opt::ArgList::filtered_reverse ( OptSpecifiers ... Ids) const
inline

Definition at line 217 of file ArgList.h.

References B(), E(), llvm::make_range(), Range, and toOptSpecifier().

Referenced by getLastArgNoClaim().

◆ getAllArgValues()

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 97 of file ArgList.cpp.

References AddAllArgValues(), llvm::SmallVectorTemplateCommon< T, typename >::begin(), and llvm::SmallVectorTemplateCommon< T, typename >::end().

◆ getArgs()

const arglist_type & llvm::opt::ArgList::getArgs ( ) const
inline

Definition at line 184 of file ArgList.h.

◆ getArgString()

virtual const char * llvm::opt::ArgList::getArgString ( unsigned Index) const
pure virtual

getArgString - Return the input argument string at Index.

Implemented in llvm::opt::DerivedArgList, and llvm::opt::InputArgList.

Referenced by GetOrMakeJoinedArgString().

◆ getLastArg()

template<typename ... OptSpecifiers>
Arg * llvm::opt::ArgList::getLastArg ( OptSpecifiers ... Ids) const
inline

Return the last argument matching Id, or null.

Definition at line 257 of file ArgList.h.

References A(), llvm::opt::Arg::claim(), and filtered().

Referenced by addLastArg(), addOptInFlag(), getLastArgValue(), hasArg(), hasFlag(), and hasFlag().

◆ getLastArgNoClaim()

template<typename ... OptSpecifiers>
Arg * llvm::opt::ArgList::getLastArgNoClaim ( OptSpecifiers ... Ids) const
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 269 of file ArgList.h.

References A(), and filtered_reverse().

Referenced by hasArgNoClaim(), and hasFlagNoClaim().

◆ getLastArgValue()

StringRef ArgList::getLastArgValue ( OptSpecifier Id,
StringRef Default = "" ) const

getLastArgValue - Return the value of the last argument, or a default.

Definition at line 91 of file ArgList.cpp.

References A(), llvm::Default, and getLastArg().

◆ getNumInputArgStrings()

virtual unsigned llvm::opt::ArgList::getNumInputArgStrings ( ) const
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 llvm::Default, and LLVM_ABI.

◆ GetOrMakeJoinedArgString()

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 183 of file ArgList.cpp.

References llvm::StringRef::data(), llvm::StringRef::ends_with(), getArgString(), MakeArgString(), llvm::StringRef::size(), and llvm::StringRef::starts_with().

◆ hasArg()

template<typename ... OptSpecifiers>
bool llvm::opt::ArgList::hasArg ( OptSpecifiers ... Ids) const
inline

Definition at line 245 of file ArgList.h.

References getLastArg().

◆ hasArgNoClaim()

template<typename ... OptSpecifiers>
bool llvm::opt::ArgList::hasArgNoClaim ( OptSpecifiers ... Ids) const
inline

hasArg - Does the arg list contain any option matching Id.

Claim Whether the argument should be claimed, if it exists.

Definition at line 241 of file ArgList.h.

References getLastArgNoClaim().

◆ hasFlag() [1/2]

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 71 of file ArgList.cpp.

References A(), llvm::Default, and getLastArg().

◆ hasFlag() [2/2]

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 84 of file ArgList.cpp.

References A(), llvm::Default, and getLastArg().

◆ hasFlagNoClaim()

bool ArgList::hasFlagNoClaim ( OptSpecifier Pos,
OptSpecifier Neg,
bool Default ) const

Definition at line 77 of file ArgList.cpp.

References A(), llvm::Default, and getLastArgNoClaim().

◆ hasMultipleArgs()

bool llvm::opt::ArgList::hasMultipleArgs ( OptSpecifier Id) const
inline

Return true if the arg list contains multiple arguments matching Id.

Definition at line 250 of file ArgList.h.

References filtered().

◆ MakeArgString()

const char * llvm::opt::ArgList::MakeArgString ( const Twine & Str) const
inline

Definition at line 383 of file ArgList.h.

References MakeArgStringRef().

Referenced by AddAllArgsTranslated(), and GetOrMakeJoinedArgString().

◆ MakeArgStringRef()

virtual const char * llvm::opt::ArgList::MakeArgStringRef ( StringRef Str) const
pure virtual

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().

◆ operator=()

ArgList & llvm::opt::ArgList::operator= ( ArgList && RHS)
inlineprotected

Definition at line 162 of file ArgList.h.

References ArgList(), and RHS.

Referenced by llvm::opt::InputArgList::operator=().

◆ print()

void ArgList::print ( raw_ostream & O) const

Definition at line 194 of file ArgList.cpp.

References A().

Referenced by dump().

◆ rbegin() [1/2]

reverse_iterator llvm::opt::ArgList::rbegin ( )
inline

Definition at line 195 of file ArgList.h.

◆ rbegin() [2/2]

const_reverse_iterator llvm::opt::ArgList::rbegin ( ) const
inline

Definition at line 201 of file ArgList.h.

◆ rend() [1/2]

reverse_iterator llvm::opt::ArgList::rend ( )
inline

Definition at line 196 of file ArgList.h.

◆ rend() [2/2]

const_reverse_iterator llvm::opt::ArgList::rend ( ) const
inline

Definition at line 202 of file ArgList.h.

◆ size()

unsigned llvm::opt::ArgList::size ( ) const
inline

Definition at line 186 of file ArgList.h.

◆ toOptSpecifier()

OptSpecifier llvm::opt::ArgList::toOptSpecifier ( OptSpecifier S)
inlinestaticprotected

Definition at line 175 of file ArgList.h.

Referenced by filtered(), and filtered_reverse().


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