LLVM  6.0.0svn
Public Types | Protected Member Functions | Static Protected Member Functions | List of all members
llvm::opt::ArgList Class Referenceabstract

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

#include "llvm/Option/ArgList.h"

Inheritance diagram for llvm::opt::ArgList:
Inheritance graph
[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 = arg_iterator< arglist_type::const_reverse_iterator >
 
template<unsigned N>
using filtered_iterator = arg_iterator< arglist_type::const_iterator, N >
 
template<unsigned N>
using filtered_reverse_iterator = arg_iterator< arglist_type::const_reverse_iterator, N >
 

Public Member Functions

Arg Access
void append (Arg *A)
 append - Append A to the arg list. More...
 
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. More...
 
template<typename ... OptSpecifiers>
bool hasArg (OptSpecifiers ...Ids) const
 
template<typename ... OptSpecifiers>
ArggetLastArg (OptSpecifiers ...Ids) const
 Return the last argument matching Id, or null. More...
 
template<typename ... OptSpecifiers>
ArggetLastArgNoClaim (OptSpecifiers ...Ids) const
 Return the last argument matching Id, or null. More...
 
virtual const chargetArgString (unsigned Index) const =0
 getArgString - Return the input argument string at Index. More...
 
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. More...
 
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
void eraseArg (OptSpecifier Id)
 eraseArg - Remove any option matching Id. More...
 
Argument Lookup Utilities
StringRef getLastArgValue (OptSpecifier Id, StringRef Default="") const
 getLastArgValue - Return the value of the last argument, or a default. More...
 
std::vector< std::string > getAllArgValues (OptSpecifier Id) const
 getAllArgValues - Get the values of all instances of the given argument as strings. More...
 
Translation Utilities
bool hasFlag (OptSpecifier Pos, OptSpecifier Neg, bool Default=true) 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. More...
 
bool hasFlag (OptSpecifier Pos, OptSpecifier PosAlias, OptSpecifier Neg, bool Default=true) 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. More...
 
void AddLastArg (ArgStringList &Output, OptSpecifier Id0) const
 AddLastArg - Render only the last argument match Id0, if present. More...
 
void AddLastArg (ArgStringList &Output, OptSpecifier Id0, OptSpecifier Id1) const
 
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. More...
 
void AddAllArgs (ArgStringList &Output, ArrayRef< OptSpecifier > Ids) const
 AddAllArgs - Render all arguments matching any of the given ids. More...
 
void AddAllArgs (ArgStringList &Output, OptSpecifier Id0, OptSpecifier Id1=0U, OptSpecifier Id2=0U) const
 AddAllArgs - Render all arguments matching the given ids. More...
 
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. More...
 
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. More...
 
void ClaimAllArgs (OptSpecifier Id0) const
 ClaimAllArgs - Claim all arguments which match the given option id. More...
 
void ClaimAllArgs () const
 ClaimAllArgs - Claim all arguments. More...
 
Arg Synthesis
virtual const charMakeArgStringRef (StringRef Str) const =0
 Construct a constant string pointer whose lifetime will match that of the ArgList. More...
 
const charMakeArgString (const Twine &Str) const
 
const charGetOrMakeJoinedArgString (unsigned Index, StringRef LHS, StringRef RHS) const
 Create an arg string for (LHS + RHS), reusing the string at Index if possible. More...
 
void print (raw_ostream &O) const
 
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 120 of file ArgList.h.

Member Typedef Documentation

◆ arglist_type

Definition at line 122 of file ArgList.h.

◆ const_iterator

Definition at line 124 of file ArgList.h.

◆ const_reverse_iterator

Definition at line 127 of file ArgList.h.

◆ filtered_iterator

Definition at line 130 of file ArgList.h.

◆ filtered_reverse_iterator

Definition at line 132 of file ArgList.h.

◆ iterator

Definition at line 123 of file ArgList.h.

◆ reverse_iterator

Definition at line 125 of file ArgList.h.

Constructor & Destructor Documentation

◆ ArgList() [1/2]

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

◆ ArgList() [2/2]

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

◆ ~ArgList()

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

Member Function Documentation

◆ AddAllArgs() [1/2]

void ArgList::AddAllArgs ( ArgStringList Output,
ArrayRef< OptSpecifier Ids 
) const

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

References AddAllArgsExcept(), and llvm::None.

◆ AddAllArgs() [2/2]

void ArgList::AddAllArgs ( ArgStringList Output,
OptSpecifier  Id0,
OptSpecifier  Id1 = 0U,
OptSpecifier  Id2 = 0U 
) const

AddAllArgs - Render all arguments matching the given ids.

This 3-opt variant of AddAllArgs could be eliminated in favor of one that accepts a single specifier, given the above which accepts any number.

Definition at line 145 of file ArgList.cpp.

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

◆ 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 113 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 162 of file ArgList.cpp.

References llvm::opt::Arg::claim(), filtered(), llvm::opt::Arg::getValue(), MakeArgString(), and llvm::SmallVectorTemplateBase< T, isPodLike >::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 153 of file ArgList.cpp.

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

Referenced by getAllArgValues().

◆ AddLastArg() [1/2]

void ArgList::AddLastArg ( ArgStringList Output,
OptSpecifier  Id0 
) const

AddLastArg - Render only the last argument match Id0, if present.

Definition at line 98 of file ArgList.cpp.

References getLastArg().

◆ AddLastArg() [2/2]

void ArgList::AddLastArg ( ArgStringList Output,
OptSpecifier  Id0,
OptSpecifier  Id1 
) const

Definition at line 105 of file ArgList.cpp.

References getLastArg().

◆ append()

void ArgList::append ( Arg A)

◆ begin() [1/2]

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

◆ begin() [2/2]

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

◆ ClaimAllArgs() [1/2]

void ArgList::ClaimAllArgs ( OptSpecifier  Id0) const

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

Definition at line 178 of file ArgList.cpp.

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

◆ ClaimAllArgs() [2/2]

void ArgList::ClaimAllArgs ( ) const

ClaimAllArgs - Claim all arguments.

Definition at line 183 of file ArgList.cpp.

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

◆ dump()

LLVM_DUMP_METHOD void ArgList::dump ( ) const

Definition at line 208 of file ArgList.cpp.

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

◆ end() [1/2]

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

Definition at line 196 of file ArgList.h.

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

◆ end() [2/2]

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

Definition at line 202 of file ArgList.h.

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

◆ eraseArg()

void ArgList::eraseArg ( OptSpecifier  Id)

◆ 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

◆ 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 92 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 187 of file ArgList.h.

References llvm::AMDGPU::HSAMD::Kernel::Key::Args.

◆ 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 llvm::opt::Option::accept(), GetOrMakeJoinedArgString(), and llvm::opt::OptTable::ParseOneArg().

◆ getLastArg()

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

Return the last argument matching Id, or null.

Definition at line 254 of file ArgList.h.

References llvm::opt::Arg::claim().

Referenced by AddLastArg(), llvm::dlltoolDriverMain(), getLastArgValue(), getOutputPath(), 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 266 of file ArgList.h.

References hasFlag().

◆ getLastArgValue()

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

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

Definition at line 86 of file ArgList.cpp.

References getLastArg().

Referenced by llvm::dlltoolDriverMain().

◆ 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.

Referenced by llvm::opt::Option::accept().

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

References llvm::StringRef::data(), llvm::StringRef::endswith(), getArgString(), MakeArgString(), llvm::StringRef::size(), and llvm::StringRef::startswith().

Referenced by llvm::opt::Arg::render().

◆ hasArg()

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

Definition at line 248 of file ArgList.h.

Referenced by llvm::dlltoolDriverMain().

◆ 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 244 of file ArgList.h.

Referenced by llvm::dlltoolDriverMain().

◆ hasFlag() [1/2]

bool ArgList::hasFlag ( OptSpecifier  Pos,
OptSpecifier  Neg,
bool  Default = true 
) 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 getLastArg().

◆ hasFlag() [2/2]

bool ArgList::hasFlag ( OptSpecifier  Pos,
OptSpecifier  PosAlias,
OptSpecifier  Neg,
bool  Default = true 
) 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 79 of file ArgList.cpp.

References getLastArg().

◆ MakeArgString()

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

◆ 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.

◆ operator=()

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

Definition at line 165 of file ArgList.h.

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

◆ print()

void ArgList::print ( raw_ostream O) const

Definition at line 200 of file ArgList.cpp.

References llvm::opt::Arg::print().

Referenced by dump().

◆ rbegin() [1/2]

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

◆ rbegin() [2/2]

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

◆ rend() [1/2]

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

Definition at line 199 of file ArgList.h.

References llvm::SmallVectorTemplateCommon< T, typename >::rend().

◆ rend() [2/2]

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

Definition at line 205 of file ArgList.h.

References llvm::SmallVectorTemplateCommon< T, typename >::rend().

◆ size()

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

Definition at line 189 of file ArgList.h.

References llvm::SmallVectorTemplateCommon< T, typename >::size().

◆ toOptSpecifier()

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

Definition at line 178 of file ArgList.h.

References llvm::sys::path::append().


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