19#ifndef LLVM_SUPPORT_COMMANDLINE_H
20#define LLVM_SUPPORT_COMMANDLINE_H
38#include <initializer_list>
70 StringRef Overview =
"",
71 raw_ostream *Errs =
nullptr,
72 vfs::FileSystem *VFS =
nullptr,
73 const char *EnvVar =
nullptr);
78 ArrayRef<const char *> Args,
79 StringRef Overview =
"",
80 raw_ostream *Errs =
nullptr,
81 vfs::FileSystem *VFS =
nullptr,
82 const char *EnvVar =
nullptr);
193 : Name(Name), Description(Description) {
217 : Name(Name), Description(Description) {
260 virtual bool handleOccurrence(
unsigned pos,
StringRef ArgName,
263 virtual enum ValueExpected getValueExpectedFlagDefault()
const {
268 virtual void anchor();
296 return Value ? ((
enum ValueExpected)Value) : getValueExpectedFlagDefault();
368 size_t FirstLineIndentedBy);
376 size_t FirstLineIndentedBy);
424 template <
class Opt>
void apply(Opt &O)
const { O.setInitialValue(
Init); }
431 template <
class Opt>
void apply(Opt &O)
const { O.setInitialValues(
Inits); }
451 template <
class Opt>
void apply(Opt &O)
const { O.setLocation(O,
Loc); }
475 template <
class Opt>
void apply(Opt &O)
const {
477 O.addSubCommand(*
Sub);
480 O.addSubCommand(*SC);
486template <
typename R,
typename Ty>
struct cb {
487 std::function<R(Ty)>
CB;
491 template <
typename Opt>
void apply(Opt &O)
const { O.setCallback(
CB); }
498template <
typename R,
typename C,
typename... Args>
501 using arg_type = std::tuple_element_t<0, std::tuple<Args...>>;
502 static_assert(
sizeof...(Args) == 1,
"callback function must have one and only one parameter");
503 static_assert(std::is_same_v<result_type, void>,
504 "callback return type must be void");
505 static_assert(std::is_lvalue_reference_v<arg_type> &&
506 std::is_const_v<std::remove_reference_t<arg_type>>,
507 "callback arg_type must be a const lvalue reference");
533 virtual void anchor();
540template <
class DataType,
bool isClass>
553 bool compare(
const DataType & )
const {
return false; }
579 assert(Valid &&
"invalid option value");
589 bool compare(
const DataType &V)
const {
return Valid && (Value == V); }
601template <
class DataType>
613template <
class DataType>
644 void anchor()
override;
661 void anchor()
override;
675#define clEnumVal(ENUMVAL, DESC) \
676 llvm::cl::OptionEnumValue { #ENUMVAL, int(ENUMVAL), DESC }
677#define clEnumValN(ENUMVAL, FLAGNAME, DESC) \
678 llvm::cl::OptionEnumValue { FLAGNAME, int(ENUMVAL), DESC }
693 template <
class Opt>
void apply(Opt &O)
const {
694 for (
const auto &
Value : Values)
757 size_t GlobalWidth)
const;
763 template <
class AnyOptionValue>
766 size_t GlobalWidth)
const {
776 if (!
Owner.hasArgStr())
793 if (
Owner.hasArgStr())
845 if (
Owner.hasArgStr())
850 for (
size_t i = 0, e =
Values.size(); i != e; ++i)
851 if (
Values[i].Name == ArgVal) {
852 V =
Values[i].V.getValue();
856 return O.error(
"Cannot find option named '" + ArgVal +
"'!");
867 OptionInfo X(Name,
static_cast<DataType
>(V), HelpStr);
900 size_t getOptionWidth(
const Option &O)
const;
905 void printOptionInfo(
const Option &O,
size_t GlobalWidth)
const;
908 void printOptionNoValue(
const Option &O,
size_t GlobalWidth)
const;
914 virtual void anchor();
918 void printOptionName(
const Option &O,
size_t GlobalWidth)
const;
953 size_t GlobalWidth)
const;
979 size_t GlobalWidth)
const;
1000 size_t GlobalWidth)
const;
1021 size_t GlobalWidth)
const;
1042 size_t GlobalWidth)
const;
1063 size_t GlobalWidth)
const;
1086 size_t GlobalWidth)
const;
1104 unsigned long long &Val);
1110 size_t GlobalWidth)
const;
1131 size_t GlobalWidth)
const;
1152 size_t GlobalWidth)
const;
1177 size_t GlobalWidth)
const;
1193 std::optional<std::string> &
Value) {
1226 size_t GlobalWidth)
const;
1248 size_t GlobalWidth)
const;
1259template <
class ParserClass,
class DT>
1263 P.printOptionDiff(O, OV,
Default, GlobalWidth);
1271 P.printOptionNoValue(O, GlobalWidth);
1280 P.printOptionDiff(O, V,
Default, GlobalWidth);
1286template <
class ParserClass,
class ValDT>
1304 template <
class Opt>
static void opt(
const Mod &M, Opt &O) { M.apply(O); }
1326 O.setNumOccurrencesFlag(
N);
1347template <
class Opt,
class Mod,
class... Mods>
1353template <
class Opt,
class Mod>
void apply(Opt *O,
const Mod &M) {
1362template <
class DataType,
bool ExternalStorage,
bool isClass>
1364 DataType *Location =
nullptr;
1367 void check_location()
const {
1368 assert(Location &&
"cl::location(...) not specified for a command "
1369 "line option with external storage, "
1370 "or cl::init specified before cl::location()!!");
1378 return O.error(
"cl::location(x) specified more than once!");
1384 template <
class T>
void setValue(
const T &V,
bool initial =
false) {
1409template <
class DataType>
1414 template <
class T>
void setValue(
const T &V,
bool initial =
false) {
1415 DataType::operator=(V);
1439 template <
class T>
void setValue(
const T &V,
bool initial =
false) {
1458template <
class DataType,
bool ExternalStorage =
false,
1459 class ParserClass = parser<DataType>>
1462 public opt_storage<DataType, ExternalStorage, std::is_class_v<DataType>> {
1465 bool handleOccurrence(
unsigned pos,
StringRef ArgName,
1467 typename ParserClass::parser_data_type Val =
1468 typename ParserClass::parser_data_type();
1469 if (Parser.parse(*
this, ArgName, Arg, Val))
1478 enum ValueExpected getValueExpectedFlagDefault()
const override {
1479 return Parser.getValueExpectedFlagDefault();
1483 return Parser.getExtraOptionNames(OptionNames);
1488 return Parser.getOptionWidth(*
this);
1491 void printOptionInfo(
size_t GlobalWidth)
const override {
1492 Parser.printOptionInfo(*
this, GlobalWidth);
1495 void printOptionValue(
size_t GlobalWidth,
bool Force)
const override {
1503 if constexpr (std::is_assignable_v<DataType &, DataType>) {
1514 Parser.initialize();
1535 this->
getValue() = std::forward<T>(Val);
1541 template <
class... Mods>
1542 explicit opt(
const Mods &... Ms)
1549 std::function<
void(
const typename ParserClass::parser_data_type &)> CB) {
1553 std::function<void(
const typename ParserClass::parser_data_type &)>
Callback;
1556#if !(defined(LLVM_ENABLE_LLVM_EXPORT_ANNOTATIONS) && defined(_MSC_VER))
1576 std::vector<OptionValue<DataType>> Default =
1577 std::vector<OptionValue<DataType>>();
1578 bool DefaultAssigned =
false;
1587 return O.error(
"cl::location(x) specified more than once!");
1592 template <
class T>
void addValue(
const T &V,
bool initial =
false) {
1593 assert(Location !=
nullptr &&
1594 "cl::location(...) not specified for a command "
1595 "line option with external storage!");
1596 Location->push_back(V);
1598 Default.push_back(V);
1619 std::vector<DataType> Storage;
1620 std::vector<OptionValue<DataType>> Default;
1621 bool DefaultAssigned =
false;
1624 using iterator =
typename std::vector<DataType>::iterator;
1634 using size_type =
typename std::vector<DataType>::size_type;
1638 bool empty()
const {
return Storage.empty(); }
1640 void push_back(
const DataType &value) { Storage.push_back(value); }
1641 void push_back(DataType &&value) { Storage.push_back(value); }
1643 using reference =
typename std::vector<DataType>::reference;
1655 return Storage.erase(first, last);
1660 return Storage.erase(first, last);
1664 return Storage.insert(pos, value);
1667 return Storage.insert(pos, value);
1671 return Storage.insert(pos, value);
1674 return Storage.insert(pos, value);
1680 operator std::vector<DataType> &() {
return Storage; }
1683 const std::vector<DataType> *
operator&()
const {
return &Storage; }
1685 template <
class T>
void addValue(
const T &V,
bool initial =
false) {
1686 Storage.push_back(V);
1704 class ParserClass = parser<DataType>>
1706 std::vector<unsigned> Positions;
1709 enum ValueExpected getValueExpectedFlagDefault()
const override {
1710 return Parser.getValueExpectedFlagDefault();
1714 return Parser.getExtraOptionNames(OptionNames);
1717 bool handleOccurrence(
unsigned pos,
StringRef ArgName,
1719 typename ParserClass::parser_data_type Val =
1720 typename ParserClass::parser_data_type();
1725 if (Parser.parse(*
this, ArgName, Arg, Val))
1729 Positions.push_back(pos);
1737 return Parser.getOptionWidth(*
this);
1740 void printOptionInfo(
size_t GlobalWidth)
const override {
1741 Parser.printOptionInfo(*
this, GlobalWidth);
1745 void printOptionValue(
size_t ,
bool )
const override {
1757 Parser.initialize();
1768 assert(optnum < this->
size() &&
"Invalid option index");
1769 return Positions[optnum];
1780 "Cannot have two default values");
1782 for (
auto &Val : Vs)
1786 template <
class... Mods>
1794 std::function<
void(
const typename ParserClass::parser_data_type &)> CB) {
1798 std::function<void(
const typename ParserClass::parser_data_type &)>
Callback;
1808 bool handleOccurrence(
unsigned pos,
StringRef ,
1810 return AliasFor->handleOccurrence(pos, AliasFor->ArgStr, Arg);
1813 bool addOccurrence(
unsigned pos,
StringRef ,
1815 return AliasFor->addOccurrence(pos, AliasFor->ArgStr, Value);
1819 size_t getOptionWidth()
const override;
1820 void printOptionInfo(
size_t GlobalWidth)
const override;
1823 void printOptionValue(
size_t ,
bool )
const override {
1826 void setDefault()
override { AliasFor->setDefault(); }
1828 ValueExpected getValueExpectedFlagDefault()
const override {
1829 return AliasFor->getValueExpectedFlag();
1834 error(
"cl::alias must have argument name specified!");
1836 error(
"cl::alias must have an cl::aliasopt(option) specified!");
1838 error(
"cl::alias must not have cl::sub(), aliased option's cl::sub() will be used!");
1839 Subs = AliasFor->Subs;
1851 error(
"cl::alias must only have one cl::aliasopt(...) specified!");
1855 template <
class... Mods>
1975 bool MarkEOLs =
false);
1993 bool MarkEOLs =
false);
2019 bool MarkEOLs =
false);
2038 bool MarkEOLs =
false);
2060 bool RelativeNames =
false;
2064 bool MarkEOLs =
false;
2067 bool InConfigFile =
false;
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
#define LLVM_TEMPLATE_ABI
static void Help(StringTable CPUNames, ArrayRef< SubtargetFeatureKV > FeatTable)
Display help for feature and mcpu choices.
This file defines the SmallPtrSet class.
This file defines the SmallVector class.
Contains the forward declaration for vfs::FileSystem, as well as the IntrusiveRefCntPtrInfo specializ...
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Lightweight error class with error context and mandatory checking.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
std::string str() const
Get the contents as an std::string.
Saves strings in the provided stable storage and returns a StringRef with a stable character pointer.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
LLVM Value Representation.
LLVM_ABI Value(Type *Ty, unsigned scid)
ExpansionContext & setCurrentDir(StringRef X)
LLVM_ABI ExpansionContext(BumpPtrAllocator &A, TokenizerCallback T, vfs::FileSystem *FS=nullptr)
ExpansionContext & setVFS(vfs::FileSystem *X)
ExpansionContext & setMarkEOLs(bool X)
ExpansionContext & setSearchDirs(ArrayRef< StringRef > X)
ExpansionContext & setRelativeNames(bool X)
LLVM_ABI bool findConfigFile(StringRef FileName, SmallVectorImpl< char > &FilePath)
Looks for the specified configuration file.
LLVM_ABI Error expandResponseFiles(SmallVectorImpl< const char * > &Argv)
Expands constructs "@file" in the provided array of arguments recursively.
LLVM_ABI Error readConfigFile(StringRef CfgFile, SmallVectorImpl< const char * > &Argv)
Reads command line options from the given configuration file.
The options of a library that declares them in TableGen rather than as cl::opt (see llvm/Option/Libra...
~LibraryOptions()=default
virtual void forEachOption(function_ref< void(StringRef Spelling, StringRef MetaVar, StringRef Help)> Fn) const =0
Calls Fn with the spelling of each option without its prefix (e.g.
virtual void reset()=0
Restores the default values.
LibraryOptions(bool PerContext=false)
virtual const void * getDefault() const =0
Returns the default values.
virtual void * copyDefault(BumpPtrAllocator &Alloc) const =0
Returns a copy of getDefault() allocated from Alloc.
virtual Error parse(void *Opts, ArrayRef< const char * > Args, unsigned &Consumed, BumpPtrAllocator &Alloc)=0
Parses the option spelled by Args[0], which may take Args[1] as its value, into Opts,...
virtual void * global()=0
Returns the values that ParseCommandLineOptions sets.
bool isPerContext() const
Whether every reader of the options goes through a context's LibraryOptionsContext,...
OptionCategory(StringRef const Name, StringRef const Description="")
StringRef getDescription() const
StringRef getName() const
OptionValueCopy & operator=(const OptionValueCopy &)=default
OptionValueCopy()=default
bool compare(const GenericOptionValue &V) const override
void setValue(const DataType &V)
~OptionValueCopy()=default
const DataType & getValue() const
OptionValueCopy(const OptionValueCopy &)=default
bool compare(const DataType &V) const
bool isPositional() const
virtual void getExtraOptionNames(SmallVectorImpl< StringRef > &)
void setValueExpectedFlag(enum ValueExpected Val)
void setPosition(unsigned pos)
bool isConsumeAfter() const
SmallPtrSet< SubCommand *, 1 > Subs
int getNumOccurrences() const
enum ValueExpected getValueExpectedFlag() const
void setValueStr(StringRef S)
void setNumOccurrencesFlag(enum NumOccurrencesFlag Val)
void setDescription(StringRef S)
void setFormattingFlag(enum FormattingFlags V)
void setHiddenFlag(enum OptionHidden Val)
void setMiscFlag(enum MiscFlags M)
enum FormattingFlags getFormattingFlag() const
virtual void printOptionInfo(size_t GlobalWidth) const =0
enum NumOccurrencesFlag getNumOccurrencesFlag() const
SmallVector< OptionCategory *, 1 > Categories
void addSubCommand(SubCommand &S)
unsigned getMiscFlags() const
virtual void setDefault()=0
virtual void printOptionValue(size_t GlobalWidth, bool Force) const =0
virtual ~Option()=default
static void printEnumValHelpStr(StringRef HelpStr, size_t Indent, size_t FirstLineIndentedBy)
void removeArgument()
Unregisters this option from the CommandLine system.
enum OptionHidden getOptionHiddenFlag() const
bool error(const Twine &Message, raw_ostream &Errs)
static void printHelpStr(StringRef HelpStr, size_t Indent, size_t FirstLineIndentedBy)
virtual size_t getOptionWidth() const =0
Option(enum NumOccurrencesFlag OccurrencesFlag, enum OptionHidden Hidden)
unsigned getPosition() const
SubCommandGroup(std::initializer_list< SubCommand * > IL)
ArrayRef< SubCommand * > getSubCommands() const
StringRef getName() const
SubCommand(StringRef Name, StringRef Description="")
static LLVM_ABI SubCommand & getTopLevel()
LLVM_ABI void unregisterSubCommand()
static LLVM_ABI SubCommand & getAll()
DenseMap< StringRef, Option * > OptionsMap
LLVM_ABI void registerSubCommand()
SmallVector< Option *, 4 > PositionalOpts
StringRef getDescription() const
ValuesClass(std::initializer_list< OptionEnumValue > Options)
alias(const alias &)=delete
void setAliasFor(Option &O)
alias & operator=(const alias &)=delete
alias(const Mods &... Ms)
enum ValueExpected getValueExpectedFlagDefault() const
void getExtraOptionNames(SmallVectorImpl< StringRef > &)
virtual StringRef getValueName() const
virtual ~basic_parser_impl()=default
basic_parser_impl(Option &)
OptionValue< DataType > OptVal
DataType parser_data_type
GenericOptionInfo(StringRef name, StringRef helpStr)
virtual size_t getOptionWidth(const Option &O) const
generic_parser_base(Option &O)
virtual StringRef getDescription(unsigned N) const =0
virtual const GenericOptionValue & getOptionValue(unsigned N) const =0
virtual unsigned getNumOptions() const =0
virtual StringRef getOption(unsigned N) const =0
void printOptionDiff(const Option &O, const AnyOptionValue &V, const AnyOptionValue &Default, size_t GlobalWidth) const
void printGenericOptionDiff(const Option &O, const GenericOptionValue &V, const GenericOptionValue &Default, size_t GlobalWidth) const
virtual void printOptionInfo(const Option &O, size_t GlobalWidth) const
unsigned findOption(StringRef Name)
virtual ~generic_parser_base()=default
void getExtraOptionNames(SmallVectorImpl< StringRef > &OptionNames)
enum ValueExpected getValueExpectedFlagDefault() const
void push_back(DataType &&value)
typename std::vector< DataType >::const_iterator const_iterator
typename std::vector< DataType >::const_reference const_reference
const_iterator begin() const
iterator erase(const_iterator first, const_iterator last)
iterator insert(const_iterator pos, const DataType &value)
iterator erase(iterator first, iterator last)
const_reference operator[](size_type pos) const
void addValue(const T &V, bool initial=false)
void push_back(const DataType &value)
typename std::vector< DataType >::reference reference
reference operator[](size_type pos)
const std::vector< DataType > * operator&() const
iterator insert(iterator pos, const DataType &value)
typename std::vector< DataType >::size_type size_type
const_reference front() const
const_iterator end() const
iterator insert(const_iterator pos, DataType &&value)
iterator erase(iterator pos)
std::vector< DataType > * operator&()
const std::vector< OptionValue< DataType > > & getDefault() const
iterator erase(const_iterator pos)
iterator insert(iterator pos, DataType &&value)
typename std::vector< DataType >::iterator iterator
const std::vector< OptionValue< DataType > > & getDefault() const
void addValue(const T &V, bool initial=false)
bool setLocation(Option &O, StorageClass &L)
void setCallback(std::function< void(const typename ParserClass::parser_data_type &)> CB)
list(const list &)=delete
void setInitialValues(ArrayRef< DataType > Vs)
std::function< void(const typename ParserClass::parser_data_type &)> Callback
list & operator=(const list &)=delete
ParserClass & getParser()
unsigned getPosition(unsigned optnum) const
OptionValue< DataType > Default
DataType operator->() const
const OptionValue< DataType > & getDefault() const
void setValue(const T &V, bool initial=false)
DataType getValue() const
void setValue(const T &V, bool initial=false)
OptionValue< DataType > Default
const DataType & getValue() const
const OptionValue< DataType > & getDefault() const
const DataType & getValue() const
bool setLocation(Option &O, DataType &L)
void setValue(const T &V, bool initial=false)
const OptionValue< DataType > & getDefault() const
ParserClass & getParser()
opt & operator=(const opt &)=delete
void setInitialValue(const DataType &V)
void setCallback(std::function< void(const typename ParserClass::parser_data_type &)> CB)
DataType & operator=(const T &Val)
DataType & operator=(T &&Val)
std::function< void(const typename ParserClass::parser_data_type &)> Callback
OptionInfo(StringRef name, DataType v, StringRef helpStr)
OptionValue< DataType > V
StringRef getValueName() const override
void printOptionDiff(const Option &O, ElementCount V, OptVal Default, size_t GlobalWidth) const
bool parse(Option &O, StringRef ArgName, StringRef Arg, ElementCount &Value)
bool parse(Option &O, StringRef ArgName, StringRef Arg, boolOrDefault &Val)
void printOptionDiff(const Option &O, boolOrDefault V, OptVal Default, size_t GlobalWidth) const
StringRef getValueName() const override
enum ValueExpected getValueExpectedFlagDefault() const
enum ValueExpected getValueExpectedFlagDefault() const
void printOptionDiff(const Option &O, bool V, OptVal Default, size_t GlobalWidth) const
bool parse(Option &O, StringRef ArgName, StringRef Arg, bool &Val)
StringRef getValueName() const override
bool parse(Option &, StringRef, StringRef Arg, char &Value)
void printOptionDiff(const Option &O, char V, OptVal Default, size_t GlobalWidth) const
StringRef getValueName() const override
void printOptionDiff(const Option &O, double V, OptVal Default, size_t GlobalWidth) const
StringRef getValueName() const override
bool parse(Option &O, StringRef ArgName, StringRef Arg, double &Val)
bool parse(Option &O, StringRef ArgName, StringRef Arg, float &Val)
StringRef getValueName() const override
void printOptionDiff(const Option &O, float V, OptVal Default, size_t GlobalWidth) const
StringRef getValueName() const override
void printOptionDiff(const Option &O, int V, OptVal Default, size_t GlobalWidth) const
bool parse(Option &O, StringRef ArgName, StringRef Arg, int &Val)
StringRef getValueName() const override
bool parse(Option &O, StringRef ArgName, StringRef Arg, long &Val)
void printOptionDiff(const Option &O, long V, OptVal Default, size_t GlobalWidth) const
bool parse(Option &O, StringRef ArgName, StringRef Arg, long long &Val)
StringRef getValueName() const override
void printOptionDiff(const Option &O, long long V, OptVal Default, size_t GlobalWidth) const
void printOptionDiff(const Option &O, std::optional< StringRef > V, const OptVal &Default, size_t GlobalWidth) const
bool parse(Option &, StringRef, StringRef Arg, std::optional< std::string > &Value)
StringRef getValueName() const override
StringRef getValueName() const override
void printOptionDiff(const Option &O, StringRef V, const OptVal &Default, size_t GlobalWidth) const
bool parse(Option &, StringRef, StringRef Arg, std::string &Value)
bool parse(Option &O, StringRef ArgName, StringRef Arg, unsigned &Val)
void printOptionDiff(const Option &O, unsigned V, OptVal Default, size_t GlobalWidth) const
StringRef getValueName() const override
StringRef getValueName() const override
void printOptionDiff(const Option &O, unsigned long V, OptVal Default, size_t GlobalWidth) const
bool parse(Option &O, StringRef ArgName, StringRef Arg, unsigned long &Val)
StringRef getValueName() const override
void printOptionDiff(const Option &O, unsigned long long V, OptVal Default, size_t GlobalWidth) const
bool parse(Option &O, StringRef ArgName, StringRef Arg, unsigned long long &Val)
DataType parser_data_type
SmallVector< OptionInfo, 8 > Values
void removeLiteralOption(StringRef Name)
Remove the specified option.
StringRef getDescription(unsigned N) const override
void addLiteralOption(StringRef Name, const DT &V, StringRef HelpStr)
Add an entry to the mapping table.
const GenericOptionValue & getOptionValue(unsigned N) const override
StringRef getOption(unsigned N) const override
bool parse(Option &O, StringRef ArgName, StringRef Arg, DataType &V)
unsigned getNumOptions() const override
An efficient, type-erasing, non-owning reference to a callable.
A range adaptor for a pair of iterators.
This class implements an extremely fast bulk output stream that can only output to a stream.
The virtual file system interface.
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This namespace contains all of the command line option processing machinery.
LLVM_ABI iterator_range< SmallPtrSet< SubCommand *, 4 >::iterator > getRegisteredSubcommands()
Use this to get all registered SubCommands from the provided parser.
LLVM_ABI void PrintVersionMessage()
Utility function for printing version number.
LLVM_ABI bool ExpandResponseFiles(StringSaver &Saver, TokenizerCallback Tokenizer, SmallVectorImpl< const char * > &Argv)
A convenience helper which supports the typical use case of expansion function call.
LLVM_ABI LibraryOptionsContext & getCAPILibraryOptions()
LLVM_ABI void TokenizeWindowsCommandLine(StringRef Source, StringSaver &Saver, SmallVectorImpl< const char * > &NewArgv, bool MarkEOLs=false)
Tokenizes a string of Windows command line arguments, which may contain quotes and escaped quotes.
list_initializer< Ty > list_init(ArrayRef< Ty > Vals)
LLVM_ABI OptionCategory & getGeneralCategory()
LLVM_ABI void addLibraryOptions(LibraryOptions &L)
Makes ParseCommandLineOptions recognize L's options.
LLVM_ABI void ResetAllOptionOccurrences()
Reset all command line options to a state that looks as if they have never appeared on the command li...
LLVM_ABI void SetVersionPrinter(VersionPrinterTy func)
===------------------------------------------------------------------—===// Override the default (LLV...
LLVM_ABI void tokenizeConfigFile(StringRef Source, StringSaver &Saver, SmallVectorImpl< const char * > &NewArgv, bool MarkEOLs=false)
Tokenizes content of configuration file.
LLVM_ABI DenseMap< StringRef, Option * > & getRegisteredOptions(SubCommand &Sub=SubCommand::getTopLevel())
Use this to get a map of all registered named options (e.g.
LLVM_ABI bool expandResponseFiles(int Argc, const char *const *Argv, const char *EnvVar, StringSaver &Saver, SmallVectorImpl< const char * > &NewArgv)
A convenience helper which concatenates the options specified by the environment variable EnvVar and ...
LLVM_ABI void ResetCommandLineParser()
Reset the command line parser back to its initial state.
LLVM_ABI void PrintOptionValues()
void apply(Opt *O, const Mod &M, const Mods &... Ms)
LLVM_ABI void AddLiteralOption(Option &O, StringRef Name)
Adds a new option for parsing and provides the option it refers to.
void printOptionDiff(const Option &O, const generic_parser_base &P, const DT &V, const OptionValue< DT > &Default, size_t GlobalWidth)
LLVM_ABI void TokenizeWindowsCommandLineNoCopy(StringRef Source, StringSaver &Saver, SmallVectorImpl< StringRef > &NewArgv)
Tokenizes a Windows command line while attempting to avoid copies.
ValuesClass values(OptsTy... Options)
Helper to build a ValuesClass by forwarding a variable number of arguments as an initializer list to ...
template class LLVM_TEMPLATE_ABI basic_parser< bool >
LLVM_ABI void printBuildConfig(raw_ostream &OS)
Prints the compiler build configuration.
void(*)(StringRef Source, StringSaver &Saver, SmallVectorImpl< const char * > &NewArgv, bool MarkEOLs) TokenizerCallback
String tokenization function type.
LLVM_ABI bool ProvidePositionalOption(Option *Handler, StringRef Arg, int i)
Parses Arg into the option handler Handler.
initializer< Ty > init(const Ty &Val)
std::function< void(raw_ostream &)> VersionPrinterTy
LLVM_ABI bool parseCommandLineOptions(LibraryOptionsContext &Context, ArrayRef< const char * > Args, StringRef Overview="", raw_ostream *Errs=nullptr, vfs::FileSystem *VFS=nullptr, const char *EnvVar=nullptr)
LLVM_ABI ArrayRef< StringRef > getCompilerBuildConfig()
An array of optional enabled settings in the LLVM build configuration, which may be of interest to co...
LocationClass< Ty > location(Ty &L)
LLVM_ABI bool ParseCommandLineOptions(int argc, const char *const *argv, StringRef Overview="", raw_ostream *Errs=nullptr, vfs::FileSystem *VFS=nullptr, const char *EnvVar=nullptr)
cb< typename detail::callback_traits< F >::result_type, typename detail::callback_traits< F >::arg_type > callback(F CB)
LLVM_ABI void HideUnrelatedOptions(cl::OptionCategory &Category, SubCommand &Sub=SubCommand::getTopLevel())
Mark all options not part of this category as cl::ReallyHidden.
LLVM_ABI void AddExtraVersionPrinter(VersionPrinterTy func)
===------------------------------------------------------------------—===// Add an extra printer to u...
LLVM_ABI void PrintHelpMessage(bool Hidden=false, bool Categorized=false)
This function just prints the help message, exactly the same way as if the -help or -help-hidden opti...
LLVM_ABI void TokenizeWindowsCommandLineFull(StringRef Source, StringSaver &Saver, SmallVectorImpl< const char * > &NewArgv, bool MarkEOLs=false)
Tokenizes a Windows full command line, including command name at the start.
LLVM_ABI void TokenizeGNUCommandLine(StringRef Source, StringSaver &Saver, SmallVectorImpl< const char * > &NewArgv, bool MarkEOLs=false)
Tokenizes a command line that can contain escapes and quotes.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
LLVM_ABI raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
@ Mod
The access may modify the value stored in memory.
@ Sub
Subtraction of integers.
ArrayRef(const T &OneElt) -> ArrayRef< T >
BumpPtrAllocatorImpl<> BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
Implement std::hash so that hash_code can be used in STL containers.
GenericOptionValue()=default
GenericOptionValue(const GenericOptionValue &)=default
GenericOptionValue & operator=(const GenericOptionValue &)=default
~GenericOptionValue()=default
virtual bool compare(const GenericOptionValue &V) const =0
void print(const Option &O, const parser< DT > &P, const DT &V, const OptionValue< DT > &Default, size_t GlobalWidth)
void print(const Option &O, const parser< ParserDT > &P, const ValDT &, const OptionValue< ValDT > &, size_t GlobalWidth)
~OptionValueBase()=default
OptionValueBase & operator=(const OptionValueBase &)=default
OptionValueBase(const OptionValueBase &)=default
OptionValueBase()=default
bool compare(const DataType &) const
const DataType & getValue() const
~OptionValueBase()=default
bool compare(const GenericOptionValue &) const override
OptionValue< DataType > WrapperType
void setValue(const DT &)
OptionValue< cl::boolOrDefault > & operator=(const cl::boolOrDefault &V)
OptionValue(const cl::boolOrDefault &V)
cl::boolOrDefault WrapperType
OptionValue< std::string > & operator=(const std::string &V)
OptionValue(const std::string &V)
OptionValue(const DataType &V)
OptionValue< DataType > & operator=(const DT &V)
void apply(alias &A) const
static void opt(MiscFlags MF, Option &O)
static void opt(NumOccurrencesFlag N, Option &O)
static void opt(OptionHidden OH, Option &O)
static void opt(StringRef Str, Opt &O)
static void opt(ValueExpected VE, Option &O)
static void opt(StringRef Str, Opt &O)
static void opt(StringRef Str, Opt &O)
static void opt(const Mod &M, Opt &O)
OptionCategory & Category
cb(std::function< R(Ty)> CB)
void apply(Option &O) const
std::tuple_element_t< 0, std::tuple< Args... > > arg_type
initializer(const Ty &Val)
list_initializer(ArrayRef< Ty > Vals)
void apply(Option &O) const
value_desc(StringRef Str)