llvm::cl::opt

A scalar command-line option storing a single parsed value of type DataType.

Synopsis

Declared in <llvm/Support/CommandLine.h>

template<
    class DataType,
    bool ExternalStorage = false,
    class ParserClass = parser<DataType>>
class opt
    : public Option
    , public opt_storage<DataType, ExternalStorage, std::is_class_v<DataType>>

Base Classes

NameDescription
OptionAbstract base for a registered command-line option.
opt_storage<DataType, ExternalStorage, std::is_class_v<DataType>>External-storage helper for cl::opt; stores the value via cl::location.

Member Functions

NameDescription
opt [constructor]Constructors
operator= Assignment operators
addArgument Register this argument with the command-line system.
addCategory Add this option to help category C.
addOccurrence [virtual]Record an occurrence, enforcing occurrence flags; return true on error.
addSubCommand Add this option to subcommand S.
error Print the option name followed by Message to Errs.
getDefault Return the default value recorded for this option.
getExtraOptionNames [virtual]Append any additional option names this parser recognizes to OptionNames.
getFormattingFlag Return how this option expects its value to be formatted on the command line (normal, positional, prefix, or always-prefix).
getMiscFlags Return the miscellaneous parsing flags for this option.
getNumAdditionalVals Return how many additional values a multi-valued option consumes.
getNumOccurrences Return how many times this option has been specified so far.
getNumOccurrencesFlag Return how many times this option may appear.
getOptionHiddenFlag Return the help-visibility flag for this option.
getOptionWidth [virtual]Return the width of the option tag for help formatting.
getParser Return the parser used to interpret this option's argument text.
getPosition Return the argv position of the last occurrence of this option.
getValue getValue overloads
getValueExpectedFlag Return whether this option expects a separate value argument on the command line.
hasArgStr Return true if this option has a non-empty argument string.
isConsumeAfter Return true if this is a ConsumeAfter option.
isDefaultOption Return true if this option is marked as a default option.
isPositional Return true if this option is parsed positionally.
isSink Return true if this option sinks unrecognized arguments.
printOptionInfo [virtual]Print help information about this option using GlobalWidth.
printOptionValue [virtual]Print this option's current value, honoring GlobalWidth formatting.
removeArgument Unregisters this option from the CommandLine system.
reset Reset occurrence counts and related parsing state for this option.
setArgStr Set the argument string used to match this option on the command line.
setCallback Register CB to run whenever this option receives a new parsed value.
setDefault [virtual]Restore this option to its default value and occurrence state.
setDescription Set the help description text shown for this option.
setFormattingFlag Set how the option name and value are formatted.
setHiddenFlag Set the help-visibility flag for this option.
setInitialValue Set the initial default value used by the cl::init modifier.
setLocation Point storage for this option at L; reports an error if already set.
setMiscFlag OR additional miscellaneous parsing flags onto this option.
setNumOccurrencesFlag Set how many times this option may appear.
setPosition Record the argv position of an occurrence.
setValue Assign V into external storage; when initial, also record default.
setValueExpectedFlag Set whether a separate value argument is expected.
setValueStr Set the value placeholder string shown in -help output.
operator DataType Implicitly convert to the stored data type.

Static Member Functions

NameDescription
printEnumValHelpStr Print multi-line help text for an enum value.
printHelpStr Print multi-line help text for an option, preserving Indent and accounting for FirstLineIndentedBy characters already printed.

Data Members

NameDescription
ArgStr The argument string itself (for example "help" or "o").
Callback Optional function invoked whenever this option receives a new value.
Categories Categories this option belongs to for categorized help.
HelpStr Descriptive text printed next to this option by -help and -help-hidden.
Subs Subcommands this option belongs to.
ValueStr Placeholder text describing the option's value in -help output.

Protected Member Functions

NameDescription
setNumAdditionalVals Set how many additional values a multi-valued option consumes.

Non-Member Functions

NameDescription
AddLiteralOptionAdds a new option for parsing and provides the option it refers to.
ProvidePositionalOptionParse positional argument Arg with option handler Handler.
printOptionDiffPrint a value diff for a generic (mapping) parser.
printOptionDiffPrint how the parsed value V differs from Default for option O, dispatching to the appropriate OptionDiffPrinter specialization.