class Arg

Declaration

class Arg { /* full declaration omitted */ };

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.

Declared at: llvm/include/llvm/Option/Arg.h:34

Member Variables

private const llvm::opt::Option Opt
The option this argument is an instance of.
private const llvm::opt::Arg* BaseArg
The argument this argument was derived from (during tool chain argument translation), if any.
private llvm::StringRef Spelling
How this instance of the option was spelled.
private unsigned int Index
The index at which this argument appears in the containing ArgList.
private unsigned int Claimed
This is used for generating "argument unused" diagnostics.
private unsigned int OwnsValues
Does this argument own its values?
private SmallVector<const char*, 2> Values
The argument values, as C strings.
private std::unique_ptr<Arg> Alias
If this arg was created through an alias, this is the original alias arg. For example, *this might be "-finput-charset=utf-8" and Alias might point to an arg representing "/source-charset:utf-8".

Method Overview

  • public Arg(const llvm::opt::Option Opt, llvm::StringRef Spelling, unsigned int Index, const char * Value0, const llvm::opt::Arg * BaseArg = nullptr)
  • public Arg(const llvm::opt::Option Opt, llvm::StringRef Spelling, unsigned int Index, const char * Value0, const char * Value1, const llvm::opt::Arg * BaseArg = nullptr)
  • public Arg(const llvm::opt::Arg &)
  • public Arg(const llvm::opt::Option Opt, llvm::StringRef Spelling, unsigned int Index, const llvm::opt::Arg * BaseArg = nullptr)
  • public void claim() const
  • public bool containsValue(llvm::StringRef Value) const
  • public void dump() const
  • public const llvm::opt::Arg * getAlias() const
  • public std::string getAsString(const llvm::opt::ArgList & Args) const
  • public const llvm::opt::Arg & getBaseArg() const
  • public unsigned int getIndex() const
  • public unsigned int getNumValues() const
  • public const llvm::opt::Option & getOption() const
  • public bool getOwnsValues() const
  • public llvm::StringRef getSpelling() const
  • public const char * getValue(unsigned int N = 0) const
  • public SmallVectorImpl<const char *> & getValues()
  • public const SmallVectorImpl<const char *> & getValues() const
  • public bool isClaimed() const
  • public void print(llvm::raw_ostream & O) const
  • public void render(const llvm::opt::ArgList & Args, llvm::opt::ArgStringList & Output) const
  • public void renderAsInput(const llvm::opt::ArgList & Args, llvm::opt::ArgStringList & Output) const
  • public void setAlias(std::unique_ptr<Arg> Alias)
  • public void setBaseArg(const llvm::opt::Arg * BaseArg)
  • public void setOwnsValues(bool Value) const
  • public ~Arg()

Methods

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

Declared at: llvm/include/llvm/Option/Arg.h:69

Parameters

const llvm::opt::Option Opt
llvm::StringRef Spelling
unsigned int Index
const char* Value0
const llvm::opt::Arg* BaseArg = nullptr

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

Declared at: llvm/include/llvm/Option/Arg.h:71

Parameters

const llvm::opt::Option Opt
llvm::StringRef Spelling
unsigned int Index
const char* Value0
const char* Value1
const llvm::opt::Arg* BaseArg = nullptr

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

Declared at: llvm/include/llvm/Option/Arg.h:73

Parameters

const llvm::opt::Arg&

Arg(const llvm::opt::Option Opt,
    llvm::StringRef Spelling,
    unsigned int Index,
    const llvm::opt::Arg* BaseArg = nullptr)

Declared at: llvm/include/llvm/Option/Arg.h:67

Parameters

const llvm::opt::Option Opt
llvm::StringRef Spelling
unsigned int Index
const llvm::opt::Arg* BaseArg = nullptr

void claim() const

Description

Set the Arg claimed bit.

Declared at: llvm/include/llvm/Option/Arg.h:109

bool containsValue(llvm::StringRef Value) const

Declared at: llvm/include/llvm/Option/Arg.h:120

Parameters

llvm::StringRef Value

void dump() const

Declared at: llvm/include/llvm/Option/Arg.h:135

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

Description

Args are converted to their unaliased form. For args that originally came from an alias, this returns the alias the arg was produced from.

Declared at: llvm/include/llvm/Option/Arg.h:100

std::string getAsString(
    const llvm::opt::ArgList& Args) const

Description

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.

Declared at: llvm/include/llvm/Option/Arg.h:141

Parameters

const llvm::opt::ArgList& Args

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

Description

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.

Declared at: llvm/include/llvm/Option/Arg.h:93

unsigned int getIndex() const

Declared at: llvm/include/llvm/Option/Arg.h:87

unsigned int getNumValues() const

Declared at: llvm/include/llvm/Option/Arg.h:111

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

Declared at: llvm/include/llvm/Option/Arg.h:77

bool getOwnsValues() const

Declared at: llvm/include/llvm/Option/Arg.h:103

llvm::StringRef getSpelling() const

Description

Returns the used prefix and name of the option: For `--foo=bar`, returns `--foo=`. This is often the wrong function to call: * Use `getValue()` to get `bar`. * Use `getAsString()` to get a string suitable for printing an Arg in a diagnostic.

Declared at: llvm/include/llvm/Option/Arg.h:85

const char* getValue(unsigned int N = 0) const

Declared at: llvm/include/llvm/Option/Arg.h:113

Parameters

unsigned int N = 0

SmallVectorImpl<const char*>& getValues()

Declared at: llvm/include/llvm/Option/Arg.h:117

const SmallVectorImpl<const char*>& getValues()
    const

Declared at: llvm/include/llvm/Option/Arg.h:118

bool isClaimed() const

Declared at: llvm/include/llvm/Option/Arg.h:106

void print(llvm::raw_ostream& O) const

Declared at: llvm/include/llvm/Option/Arg.h:134

Parameters

llvm::raw_ostream& O

void render(
    const llvm::opt::ArgList& Args,
    llvm::opt::ArgStringList& Output) const

Description

Append the argument onto the given array as strings.

Declared at: llvm/include/llvm/Option/Arg.h:125

Parameters

const llvm::opt::ArgList& Args
llvm::opt::ArgStringList& Output

void renderAsInput(
    const llvm::opt::ArgList& Args,
    llvm::opt::ArgStringList& Output) const

Description

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

Declared at: llvm/include/llvm/Option/Arg.h:132

Parameters

const llvm::opt::ArgList& Args
llvm::opt::ArgStringList& Output

void setAlias(std::unique_ptr<Arg> Alias)

Declared at: llvm/include/llvm/Option/Arg.h:101

Parameters

std::unique_ptr<Arg> Alias

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

Declared at: llvm/include/llvm/Option/Arg.h:96

Parameters

const llvm::opt::Arg* BaseArg

void setOwnsValues(bool Value) const

Declared at: llvm/include/llvm/Option/Arg.h:104

Parameters

bool Value

~Arg()

Declared at: llvm/include/llvm/Option/Arg.h:75