LLVM 20.0.0git
Public Member Functions | List of all members
llvm::opt::Arg Class Reference

A concrete instance of a particular driver option. More...

#include "llvm/Option/Arg.h"

Public Member Functions

 Arg (const Option Opt, StringRef Spelling, unsigned Index, const Arg *BaseArg=nullptr)
 
 Arg (const Option Opt, StringRef Spelling, unsigned Index, const char *Value0, const Arg *BaseArg=nullptr)
 
 Arg (const Option Opt, StringRef Spelling, unsigned Index, const char *Value0, const char *Value1, const Arg *BaseArg=nullptr)
 
 Arg (const Arg &)=delete
 
Argoperator= (const Arg &)=delete
 
 ~Arg ()
 
const OptiongetOption () const
 
StringRef getSpelling () const
 Returns the used prefix and name of the option: For --foo=bar, returns --foo=.
 
unsigned getIndex () const
 
const ArggetBaseArg () const
 Return the base argument which generated this arg.
 
ArggetBaseArg ()
 
void setBaseArg (const Arg *BaseArg)
 
const ArggetAlias () const
 Args are converted to their unaliased form.
 
void setAlias (std::unique_ptr< Arg > Alias)
 
bool getOwnsValues () const
 
void setOwnsValues (bool Value) const
 
bool isClaimed () const
 
void claim () const
 
bool isIgnoredTargetSpecific () const
 
void ignoreTargetSpecific ()
 
unsigned getNumValues () const
 
const chargetValue (unsigned N=0) const
 
SmallVectorImpl< const char * > & getValues ()
 
const SmallVectorImpl< const char * > & getValues () const
 
bool containsValue (StringRef Value) const
 
void render (const ArgList &Args, ArgStringList &Output) const
 Append the argument onto the given array as strings.
 
void renderAsInput (const ArgList &Args, ArgStringList &Output) const
 Append the argument, render as an input, onto the given array as strings.
 
void print (raw_ostream &O) const
 
void dump () const
 
std::string getAsString (const ArgList &Args) const
 Return a formatted version of the argument and its values, for diagnostics.
 

Detailed Description

A concrete instance of a particular driver option.

The Arg class encodes just enough information to be able to derive the argument values efficiently.

Definition at line 34 of file Arg.h.

Constructor & Destructor Documentation

◆ Arg() [1/4]

Arg::Arg ( const Option  Opt,
StringRef  Spelling,
unsigned  Index,
const Arg BaseArg = nullptr 
)

Definition at line 21 of file Arg.cpp.

◆ Arg() [2/4]

Arg::Arg ( const Option  Opt,
StringRef  Spelling,
unsigned  Index,
const char Value0,
const Arg BaseArg = nullptr 
)

Definition at line 25 of file Arg.cpp.

References llvm::SmallVectorTemplateBase< T, bool >::push_back().

◆ Arg() [3/4]

Arg::Arg ( const Option  Opt,
StringRef  Spelling,
unsigned  Index,
const char Value0,
const char Value1,
const Arg BaseArg = nullptr 
)

Definition at line 32 of file Arg.cpp.

References llvm::SmallVectorTemplateBase< T, bool >::push_back().

◆ Arg() [4/4]

llvm::opt::Arg::Arg ( const Arg )
delete

◆ ~Arg()

Arg::~Arg ( )

Definition at line 40 of file Arg.cpp.

References llvm::SmallVectorBase< Size_T >::size().

Member Function Documentation

◆ claim()

void llvm::opt::Arg::claim ( ) const
inline

◆ containsValue()

bool llvm::opt::Arg::containsValue ( StringRef  Value) const
inline

Definition at line 132 of file Arg.h.

References llvm::is_contained().

◆ dump()

LLVM_DUMP_METHOD void Arg::dump ( ) const

Definition at line 63 of file Arg.cpp.

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

◆ getAlias()

const Arg * llvm::opt::Arg::getAlias ( ) const
inline

Args are converted to their unaliased form.

For args that originally came from an alias, this returns the alias the arg was produced from.

Definition at line 107 of file Arg.h.

◆ getAsString()

std::string Arg::getAsString ( const ArgList Args) const

Return a formatted version of the argument and its values, for diagnostics.

Since this is for diagnostics, if this Arg was produced through an alias, this returns the string representation of the alias that the user wrote.

Definition at line 66 of file Arg.cpp.

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

Referenced by llvm::dlltoolDriverMain(), and llvm::libDriverMain().

◆ getBaseArg() [1/2]

Arg & llvm::opt::Arg::getBaseArg ( )
inline

Definition at line 102 of file Arg.h.

◆ getBaseArg() [2/2]

const Arg & llvm::opt::Arg::getBaseArg ( ) const
inline

Return the base argument which generated this arg.

This is either the argument itself or the argument it was derived from during tool chain specific argument translation.

Definition at line 99 of file Arg.h.

Referenced by claim(), ignoreTargetSpecific(), isClaimed(), and isIgnoredTargetSpecific().

◆ getIndex()

unsigned llvm::opt::Arg::getIndex ( ) const
inline

Definition at line 93 of file Arg.h.

Referenced by render().

◆ getNumValues()

unsigned llvm::opt::Arg::getNumValues ( ) const
inline

Definition at line 123 of file Arg.h.

References llvm::SmallVectorBase< Size_T >::size().

Referenced by render().

◆ getOption()

const Option & llvm::opt::Arg::getOption ( ) const
inline

Definition at line 83 of file Arg.h.

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

◆ getOwnsValues()

bool llvm::opt::Arg::getOwnsValues ( ) const
inline

Definition at line 110 of file Arg.h.

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

◆ getSpelling()

StringRef llvm::opt::Arg::getSpelling ( ) const
inline

Returns the used prefix and name of the option: For --foo=bar, returns --foo=.

This is often the wrong function to call:

Definition at line 91 of file Arg.h.

Referenced by render().

◆ getValue()

const char * llvm::opt::Arg::getValue ( unsigned  N = 0) const
inline

◆ getValues() [1/2]

SmallVectorImpl< const char * > & llvm::opt::Arg::getValues ( )
inline

Definition at line 129 of file Arg.h.

Referenced by llvm::opt::Option::accept(), and llvm::opt::ArgList::AddAllArgValues().

◆ getValues() [2/2]

const SmallVectorImpl< const char * > & llvm::opt::Arg::getValues ( ) const
inline

Definition at line 130 of file Arg.h.

◆ ignoreTargetSpecific()

void llvm::opt::Arg::ignoreTargetSpecific ( )
inline

Definition at line 119 of file Arg.h.

References getBaseArg().

◆ isClaimed()

bool llvm::opt::Arg::isClaimed ( ) const
inline

Definition at line 113 of file Arg.h.

References getBaseArg().

Referenced by llvm::opt::ArgList::ClaimAllArgs().

◆ isIgnoredTargetSpecific()

bool llvm::opt::Arg::isIgnoredTargetSpecific ( ) const
inline

Definition at line 116 of file Arg.h.

References getBaseArg().

◆ operator=()

Arg & llvm::opt::Arg::operator= ( const Arg )
delete

◆ print()

void Arg::print ( raw_ostream O) const

Definition at line 47 of file Arg.cpp.

References llvm::opt::Option::print(), and llvm::SmallVectorBase< Size_T >::size().

Referenced by dump().

◆ render()

void Arg::render ( const ArgList Args,
ArgStringList Output 
) const

◆ renderAsInput()

void Arg::renderAsInput ( const ArgList Args,
ArgStringList Output 
) const

Append the argument, render as an input, onto the given array as strings.

The distinction is that some options only render their values when rendered as a input (e.g., Xlinker).

Definition at line 85 of file Arg.cpp.

References llvm::SmallVectorImpl< T >::append(), llvm::SmallVectorTemplateCommon< T, typename >::begin(), llvm::SmallVectorTemplateCommon< T, typename >::end(), getOption(), and render().

◆ setAlias()

void llvm::opt::Arg::setAlias ( std::unique_ptr< Arg Alias)
inline

Definition at line 108 of file Arg.h.

◆ setBaseArg()

void llvm::opt::Arg::setBaseArg ( const Arg BaseArg)
inline

Definition at line 103 of file Arg.h.

◆ setOwnsValues()

void llvm::opt::Arg::setOwnsValues ( bool  Value) const
inline

Definition at line 111 of file Arg.h.

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


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