10 #ifndef LLVM_OPTION_ARGLIST_H
11 #define LLVM_OPTION_ARGLIST_H
25 #include <initializer_list>
40 template<
typename BaseIter,
unsigned NumOptSpecifiers = 0>
43 BaseIter Current, End;
47 OptSpecifier Ids[NumOptSpecifiers ? NumOptSpecifiers : 1];
49 void SkipToNextArg() {
50 for (; Current != End; ++Current) {
56 if (!NumOptSpecifiers)
60 const Option &O = (*Current)->getOption();
70 using Traits = std::iterator_traits<BaseIter>;
80 BaseIter Current, BaseIter End,
81 const OptSpecifier (&Ids)[NumOptSpecifiers ? NumOptSpecifiers : 1] = {})
82 : Current(Current), End(End) {
83 for (
unsigned I = 0;
I != NumOptSpecifiers; ++
I)
84 this->Ids[
I] = Ids[
I];
89 operator const Arg*() {
return *Current; }
107 return LHS.Current == RHS.Current;
110 return !(LHS == RHS);
138 using OptRange = std::pair<unsigned, unsigned>;
139 static OptRange emptyRange() {
return {-1u, 0u}; }
146 OptRange getRange(std::initializer_list<OptSpecifier> Ids)
const;
160 : Args(std::move(RHS.Args)), OptRanges(std::move(RHS.OptRanges)) {
162 RHS.OptRanges.clear();
166 Args = std::move(RHS.Args);
168 OptRanges = std::move(RHS.OptRanges);
169 RHS.OptRanges.clear();
207 template<
typename ...OptSpecifiers>
211 auto B = Args.
begin() + Range.first;
212 auto E = Args.
begin() + Range.second;
218 template<
typename ...OptSpecifiers>
222 auto B = Args.
rend() - Range.second;
223 auto E = Args.
rend() - Range.first;
243 template<
typename ...OptSpecifiers>
247 template<
typename ...OptSpecifiers>
248 bool hasArg(OptSpecifiers ...Ids)
const {
253 template<
typename ...OptSpecifiers>
265 template<
typename ...OptSpecifiers>
273 virtual const char *
getArgString(
unsigned Index)
const = 0;
306 bool Default =
true)
const;
336 const char *Translation,
337 bool Joined =
false)
const;
384 mutable std::list<std::string> SynthesizedStrings;
387 unsigned NumInputArgStrings;
390 void releaseMemory();
393 InputArgList(
const char*
const *ArgBegin,
const char*
const *ArgEnd);
396 :
ArgList(std::move(RHS)), ArgStrings(std::move(RHS.ArgStrings)),
397 SynthesizedStrings(std::move(RHS.SynthesizedStrings)),
398 NumInputArgStrings(RHS.NumInputArgStrings) {}
403 ArgStrings = std::move(RHS.ArgStrings);
404 SynthesizedStrings = std::move(RHS.SynthesizedStrings);
405 NumInputArgStrings = RHS.NumInputArgStrings;
412 return ArgStrings[Index];
416 return NumInputArgStrings;
521 #endif // LLVM_OPTION_ARGLIST_H
const_reverse_iterator rend() const
bool matches(OptSpecifier ID) const
matches - Predicate for whether this option is part of the given option (which may be a group)...
pointer operator->() const
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 ...
virtual const char * MakeArgStringRef(StringRef Str) const =0
Construct a constant string pointer whose lifetime will match that of the ArgList.
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...
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
Arg * getLastArgNoClaim(OptSpecifiers...Ids) const
Return the last argument matching Id, or null.
Arg * MakeFlagArg(const Arg *BaseArg, const Option Opt) const
MakeFlagArg - Construct a new FlagArg for the given option Id.
const InputArgList & getBaseArgs() const
arg_iterator< arglist_type::const_reverse_iterator, N > filtered_reverse_iterator
void eraseArg(OptSpecifier Id)
eraseArg - Remove any option matching Id.
reverse_iterator rbegin()
const char * getArgString(unsigned Index) const override
getArgString - Return the input argument string at Index.
unsigned getNumInputArgStrings() const override
getNumInputArgStrings - Return the number of original argument strings, which are guaranteed to be th...
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...
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
arg_iterator - Iterates through arguments stored inside an ArgList.
arg_iterator(BaseIter Current, BaseIter End, const OptSpecifier(&Ids)[NumOptSpecifiers?NumOptSpecifiers:1]={})
virtual unsigned getNumInputArgStrings() const =0
getNumInputArgStrings - Return the number of original argument strings, which are guaranteed to be th...
iterator_range< filtered_reverse_iterator< sizeof...(OptSpecifiers)> > filtered_reverse(OptSpecifiers...Ids) const
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
arg_iterator operator++(int)
std::ptrdiff_t difference_type
void AddAllArgs(ArgStringList &Output, ArrayRef< OptSpecifier > Ids) const
AddAllArgs - Render all arguments matching any of the given ids.
void AddSynthesizedArg(Arg *A)
AddSynthesizedArg - Add a argument to the list of synthesized arguments (to be freed).
void print(raw_ostream &O) const
const char * MakeArgStringRef(StringRef Str) const override
Construct a constant string pointer whose lifetime will match that of the ArgList.
Option - Abstract representation for a single form of driver argument.
A concrete instance of a particular driver option.
DerivedArgList(const InputArgList &BaseArgs)
Construct a new derived arg list from BaseArgs.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
const arglist_type & getArgs() const
arg_iterator & operator++()
iterator_range< filtered_iterator< sizeof...(OptSpecifiers)> > filtered(OptSpecifiers...Ids) const
arg_iterator< arglist_type::const_iterator, N > filtered_iterator
void claim() const
Set the Arg claimed bit.
const char * GetOrMakeJoinedArgString(unsigned Index, StringRef LHS, StringRef RHS) const
Create an arg string for (LHS + RHS), reusing the string at Index if possible.
bool hasFlag(OptSpecifier Pos, OptSpecifier Neg, bool Default=true) const
hasFlag - Given an option Pos and its negative form Neg, return true if the option is present...
const char * MakeArgString(const Twine &Str) const
void AddLastArg(ArgStringList &Output, OptSpecifier Id0) const
AddLastArg - Render only the last argument match Id0, if present.
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.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
typename Traits::pointer pointer
ArgList & operator=(ArgList &&RHS)
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...
virtual const char * getArgString(unsigned Index) const =0
getArgString - Return the input argument string at Index.
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...
StringRef toStringRef(SmallVectorImpl< char > &Out) const
This returns the twine as a single StringRef if it can be represented as such.
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...
bool hasArgNoClaim(OptSpecifiers...Ids) const
hasArg - Does the arg list contain any option matching Id.
Arg * getLastArg(OptSpecifiers...Ids) const
Return the last argument matching Id, or null.
A range adaptor for a pair of iterators.
Defines the llvm::Arg class for parsed arguments.
friend bool operator!=(arg_iterator LHS, arg_iterator RHS)
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...
friend bool operator==(arg_iterator LHS, arg_iterator RHS)
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...
const_iterator end() const
void ClaimAllArgs() const
ClaimAllArgs - Claim all arguments.
void append(Arg *A)
append - Append A to the arg list.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
OptSpecifier - Wrapper class for abstracting references to option IDs.
static OptSpecifier toOptSpecifier(OptSpecifier S)
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
typename Traits::value_type value_type
reference operator*() const
std::forward_iterator_tag iterator_category
reverse_iterator rbegin()
std::vector< std::string > getAllArgValues(OptSpecifier Id) const
getAllArgValues - Get the values of all instances of the given argument as strings.
LLVM Value Representation.
const_iterator begin() const
This class implements an extremely fast bulk output stream that can only output to a stream...
DerivedArgList - An ordered collection of driver arguments, whose storage may be in another argument ...
StringRef - Represent a constant reference to a string, i.e.
ArgList - Ordered collection of driver arguments.
StringRef getLastArgValue(OptSpecifier Id, StringRef Default="") const
getLastArgValue - Return the value of the last argument, or a default.
const_reverse_iterator rbegin() const
bool hasArg(OptSpecifiers...Ids) const
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...
typename Traits::reference reference