9#ifndef LLVM_OPTION_ARGLIST_H
10#define LLVM_OPTION_ARGLIST_H
24#include <initializer_list>
39template<
typename BaseIter,
unsigned NumOptSpecifiers = 0>
42 BaseIter Current, End;
46 OptSpecifier Ids[NumOptSpecifiers ? NumOptSpecifiers : 1];
48 void SkipToNextArg() {
49 for (; Current !=
End; ++Current) {
55 if (!NumOptSpecifiers)
59 const Option &O = (*Current)->getOption();
69 using Traits = std::iterator_traits<BaseIter>;
79 BaseIter Current, BaseIter End,
80 const OptSpecifier (&Ids)[NumOptSpecifiers ? NumOptSpecifiers : 1] = {})
81 : Current(Current),
End(End) {
82 for (
unsigned I = 0;
I != NumOptSpecifiers; ++
I)
83 this->Ids[
I] = Ids[
I];
103 return LHS.Current ==
RHS.Current;
134 using OptRange = std::pair<unsigned, unsigned>;
135 static OptRange emptyRange() {
return {-1u, 0u}; }
142 OptRange getRange(std::initializer_list<OptSpecifier> Ids)
const;
158 RHS.OptRanges.clear();
162 Args = std::move(
RHS.Args);
164 OptRanges = std::move(
RHS.OptRanges);
165 RHS.OptRanges.clear();
185 unsigned size()
const {
return Args.size(); }
203 template<
typename ...OptSpecifiers>
207 auto B = Args.begin() +
Range.first;
208 auto E = Args.begin() +
Range.second;
214 template<
typename ...OptSpecifiers>
218 auto B = Args.rend() -
Range.second;
219 auto E = Args.rend() -
Range.first;
239 template<
typename ...OptSpecifiers>
243 template<
typename ...OptSpecifiers>
244 bool hasArg(OptSpecifiers ...Ids)
const {
251 return (Args.begin() != Args.end()) && (++Args.begin()) != Args.end();
255 template<
typename ...OptSpecifiers>
267 template<
typename ...OptSpecifiers>
322 template <
typename... OptSpecifiers>
325 A->render(*
this, Output);
327 template <
typename... OptSpecifiers>
354 const char *Translation,
355 bool Joined =
false)
const;
361 template <
typename... OptSpecifiers>
407 mutable std::list<std::string> SynthesizedStrings;
410 unsigned NumInputArgStrings;
413 void releaseMemory();
418 InputArgList(
const char*
const *ArgBegin,
const char*
const *ArgEnd);
422 SynthesizedStrings(
std::
move(
RHS.SynthesizedStrings)),
423 NumInputArgStrings(
RHS.NumInputArgStrings) {}
430 ArgStrings = std::move(
RHS.ArgStrings);
431 SynthesizedStrings = std::move(
RHS.SynthesizedStrings);
432 NumInputArgStrings =
RHS.NumInputArgStrings;
439 return ArgStrings[
Index];
447 return NumInputArgStrings;
477 return BaseArgs.getArgString(
Index);
481 return BaseArgs.getNumInputArgStrings();
Defines the llvm::Arg class for parsed arguments.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file defines the DenseMap class.
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
This file defines the SmallString class.
This file defines the SmallVector class.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
StringRef - Represent a constant reference to a string, i.e.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
LLVM Value Representation.
A range adaptor for a pair of iterators.
ArgList - Ordered collection of driver arguments.
void eraseArg(OptSpecifier Id)
eraseArg - Remove any option matching Id.
virtual const char * getArgString(unsigned Index) const =0
getArgString - Return the input argument string at Index.
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.
virtual unsigned getNumInputArgStrings() const =0
getNumInputArgStrings - Return the number of original argument strings, which are guaranteed to be th...
Arg * getLastArgNoClaim(OptSpecifiers ...Ids) const
Return the last argument matching Id, or null.
void print(raw_ostream &O) const
const char * GetOrMakeJoinedArgString(unsigned Index, StringRef LHS, StringRef RHS) const
Create an arg string for (LHS + RHS), reusing the string at Index if possible.
void addOptInFlag(ArgStringList &Output, OptSpecifier Pos, OptSpecifier Neg) const
Given an option Pos and its negative form Neg, render the option if Pos is present.
arg_iterator< arglist_type::const_iterator, N > filtered_iterator
bool hasFlagNoClaim(OptSpecifier Pos, OptSpecifier Neg, bool Default) const
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 a...
static OptSpecifier toOptSpecifier(OptSpecifier S)
const_iterator end() const
iterator_range< filtered_reverse_iterator< sizeof...(OptSpecifiers)> > filtered_reverse(OptSpecifiers ...Ids) const
bool hasMultipleArgs(OptSpecifier Id) const
Return true if the arg list contains multiple arguments matching Id.
void AddAllArgs(ArgStringList &Output, OptSpecifier Id0) const
AddAllArgs - Render all arguments matching the given ids.
const char * MakeArgString(const Twine &Str) const
const_reverse_iterator rend() const
bool hasArgNoClaim(OptSpecifiers ...Ids) const
hasArg - Does the arg list contain any option matching Id.
void AddLastArg(ArgStringList &Output, OptSpecifiers... Ids) const
void append(Arg *A)
append - Append A to the arg list.
void addLastArg(ArgStringList &Output, OptSpecifiers... Ids) const
Render only the last argument match Id0, if present.
const arglist_type & getArgs() const
void addAllArgs(ArgStringList &Output, ArrayRef< OptSpecifier > Ids) const
Render all arguments matching any of the given ids.
void ClaimAllArgs() const
ClaimAllArgs - Claim all arguments.
const_iterator begin() const
const_reverse_iterator rbegin() const
arg_iterator< arglist_type::const_reverse_iterator, N > filtered_reverse_iterator
reverse_iterator rbegin()
Arg * getLastArg(OptSpecifiers ...Ids) const
Return the last argument matching Id, or null.
void claimAllArgs(OptSpecifiers... Ids) 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 exc...
std::vector< std::string > getAllArgValues(OptSpecifier Id) const
getAllArgValues - Get the values of all instances of the given argument as strings.
void addOptOutFlag(ArgStringList &Output, OptSpecifier Pos, OptSpecifier Neg) const
Render the option if Neg is present.
bool hasArg(OptSpecifiers ...Ids) const
StringRef getLastArgValue(OptSpecifier Id, StringRef Default="") const
getLastArgValue - Return the value of the last argument, or a default.
virtual const char * MakeArgStringRef(StringRef Str) const =0
Construct a constant string pointer whose lifetime will match that of the ArgList.
iterator_range< filtered_iterator< sizeof...(OptSpecifiers)> > filtered(OptSpecifiers ...Ids) const
ArgList & operator=(ArgList &&RHS)
bool hasFlag(OptSpecifier Pos, OptSpecifier Neg, bool Default) const
hasFlag - Given an option Pos and its negative form Neg, return true if the option is present,...
A concrete instance of a particular driver option.
DerivedArgList - An ordered collection of driver arguments, whose storage may be in another argument ...
void AddJoinedArg(const Arg *BaseArg, const Option Opt, StringRef Value)
AddJoinedArg - Construct a new Positional arg for the given option Id, with the provided Value and ap...
const char * MakeArgStringRef(StringRef Str) const override
Construct a constant string pointer whose lifetime will match that of the ArgList.
Arg * MakeSeparateArg(const Arg *BaseArg, const Option Opt, StringRef Value) const
MakeSeparateArg - Construct a new Positional arg for the given option Id, with the provided Value.
void AddFlagArg(const Arg *BaseArg, const Option Opt)
AddFlagArg - Construct a new FlagArg for the given option Id and append it to the argument list.
void AddSynthesizedArg(Arg *A)
AddSynthesizedArg - Add a argument to the list of synthesized arguments (to be freed).
Arg * MakeJoinedArg(const Arg *BaseArg, const Option Opt, StringRef Value) const
MakeJoinedArg - Construct a new Positional arg for the given option Id, with the provided Value.
unsigned getNumInputArgStrings() const override
getNumInputArgStrings - Return the number of original argument strings, which are guaranteed to be th...
const InputArgList & getBaseArgs() const
const char * getArgString(unsigned Index) const override
getArgString - Return the input argument string at Index.
Arg * MakePositionalArg(const Arg *BaseArg, const Option Opt, StringRef Value) const
MakePositionalArg - Construct a new Positional arg for the given option Id, with the provided Value.
void AddPositionalArg(const Arg *BaseArg, const Option Opt, StringRef Value)
AddPositionalArg - Construct a new Positional arg for the given option Id, with the provided Value an...
void AddSeparateArg(const Arg *BaseArg, const Option Opt, StringRef Value)
AddSeparateArg - Construct a new Positional arg for the given option Id, with the provided Value and ...
Arg * MakeFlagArg(const Arg *BaseArg, const Option Opt) const
MakeFlagArg - Construct a new FlagArg for the given option Id.
OptSpecifier - Wrapper class for abstracting references to option IDs.
Option - Abstract representation for a single form of driver argument.
arg_iterator - Iterates through arguments stored inside an ArgList.
friend bool operator==(arg_iterator LHS, arg_iterator RHS)
arg_iterator(BaseIter Current, BaseIter End, const OptSpecifier(&Ids)[NumOptSpecifiers ? NumOptSpecifiers :1]={})
std::ptrdiff_t difference_type
reference operator*() const
typename Traits::value_type value_type
arg_iterator & operator++()
typename Traits::pointer pointer
std::forward_iterator_tag iterator_category
pointer operator->() const
arg_iterator operator++(int)
friend bool operator!=(arg_iterator LHS, arg_iterator RHS)
typename Traits::reference reference
This class implements an extremely fast bulk output stream that can only output to a stream.
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
This is an optimization pass for GlobalISel generic memory operations.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
@ Default
The result values are uniform if and only if all operands are uniform.
Implement std::hash so that hash_code can be used in STL containers.