LLVM 18.0.0git
ArgList.h
Go to the documentation of this file.
1//===- ArgList.h - Argument List Management ---------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_OPTION_ARGLIST_H
10#define LLVM_OPTION_ARGLIST_H
11
12#include "llvm/ADT/ArrayRef.h"
13#include "llvm/ADT/DenseMap.h"
17#include "llvm/ADT/StringRef.h"
18#include "llvm/ADT/Twine.h"
19#include "llvm/Option/Arg.h"
21#include "llvm/Option/Option.h"
22#include <algorithm>
23#include <cstddef>
24#include <initializer_list>
25#include <iterator>
26#include <list>
27#include <memory>
28#include <string>
29#include <utility>
30#include <vector>
31
32namespace llvm {
33
34class raw_ostream;
35
36namespace opt {
37
38/// arg_iterator - Iterates through arguments stored inside an ArgList.
39template<typename BaseIter, unsigned NumOptSpecifiers = 0>
41 /// The current argument and the end of the sequence we're iterating.
42 BaseIter Current, End;
43
44 /// Optional filters on the arguments which will be match. To avoid a
45 /// zero-sized array, we store one specifier even if we're asked for none.
46 OptSpecifier Ids[NumOptSpecifiers ? NumOptSpecifiers : 1];
47
48 void SkipToNextArg() {
49 for (; Current != End; ++Current) {
50 // Skip erased elements.
51 if (!*Current)
52 continue;
53
54 // Done if there are no filters.
55 if (!NumOptSpecifiers)
56 return;
57
58 // Otherwise require a match.
59 const Option &O = (*Current)->getOption();
60 for (auto Id : Ids) {
61 if (!Id.isValid())
62 break;
63 if (O.matches(Id))
64 return;
65 }
66 }
67 }
68
69 using Traits = std::iterator_traits<BaseIter>;
70
71public:
72 using value_type = typename Traits::value_type;
73 using reference = typename Traits::reference;
74 using pointer = typename Traits::pointer;
75 using iterator_category = std::forward_iterator_tag;
76 using difference_type = std::ptrdiff_t;
77
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];
84 SkipToNextArg();
85 }
86
87 reference operator*() const { return *Current; }
88 pointer operator->() const { return Current; }
89
91 ++Current;
92 SkipToNextArg();
93 return *this;
94 }
95
97 arg_iterator tmp(*this);
98 ++(*this);
99 return tmp;
100 }
101
103 return LHS.Current == RHS.Current;
104 }
106 return !(LHS == RHS);
107 }
108};
109
110/// ArgList - Ordered collection of driver arguments.
111///
112/// The ArgList class manages a list of Arg instances as well as
113/// auxiliary data and convenience methods to allow Tools to quickly
114/// check for the presence of Arg instances for a particular Option
115/// and to iterate over groups of arguments.
116class ArgList {
117public:
124
125 template<unsigned N> using filtered_iterator =
127 template<unsigned N> using filtered_reverse_iterator =
129
130private:
131 /// The internal list of arguments.
132 arglist_type Args;
133
134 using OptRange = std::pair<unsigned, unsigned>;
135 static OptRange emptyRange() { return {-1u, 0u}; }
136
137 /// The first and last index of each different OptSpecifier ID.
139
140 /// Get the range of indexes in which options with the specified IDs might
141 /// reside, or (0, 0) if there are no such options.
142 OptRange getRange(std::initializer_list<OptSpecifier> Ids) const;
143
144protected:
145 // Make the default special members protected so they won't be used to slice
146 // derived objects, but can still be used by derived objects to implement
147 // their own special members.
148 ArgList() = default;
149
150 // Explicit move operations to ensure the container is cleared post-move
151 // otherwise it could lead to a double-delete in the case of moving of an
152 // InputArgList which deletes the contents of the container. If we could fix
153 // up the ownership here (delegate storage/ownership to the derived class so
154 // it can be a container of unique_ptr) this would be simpler.
156 : Args(std::move(RHS.Args)), OptRanges(std::move(RHS.OptRanges)) {
157 RHS.Args.clear();
158 RHS.OptRanges.clear();
159 }
160
162 Args = std::move(RHS.Args);
163 RHS.Args.clear();
164 OptRanges = std::move(RHS.OptRanges);
165 RHS.OptRanges.clear();
166 return *this;
167 }
168
169 // Protect the dtor to ensure this type is never destroyed polymorphically.
170 ~ArgList() = default;
171
172 // Implicitly convert a value to an OptSpecifier. Used to work around a bug
173 // in MSVC's implementation of narrowing conversion checking.
175
176public:
177 /// @name Arg Access
178 /// @{
179
180 /// append - Append \p A to the arg list.
181 void append(Arg *A);
182
183 const arglist_type &getArgs() const { return Args; }
184
185 unsigned size() const { return Args.size(); }
186
187 /// @}
188 /// @name Arg Iteration
189 /// @{
190
191 iterator begin() { return {Args.begin(), Args.end()}; }
192 iterator end() { return {Args.end(), Args.end()}; }
193
194 reverse_iterator rbegin() { return {Args.rbegin(), Args.rend()}; }
195 reverse_iterator rend() { return {Args.rend(), Args.rend()}; }
196
197 const_iterator begin() const { return {Args.begin(), Args.end()}; }
198 const_iterator end() const { return {Args.end(), Args.end()}; }
199
200 const_reverse_iterator rbegin() const { return {Args.rbegin(), Args.rend()}; }
201 const_reverse_iterator rend() const { return {Args.rend(), Args.rend()}; }
202
203 template<typename ...OptSpecifiers>
204 iterator_range<filtered_iterator<sizeof...(OptSpecifiers)>>
205 filtered(OptSpecifiers ...Ids) const {
206 OptRange Range = getRange({toOptSpecifier(Ids)...});
207 auto B = Args.begin() + Range.first;
208 auto E = Args.begin() + Range.second;
209 using Iterator = filtered_iterator<sizeof...(OptSpecifiers)>;
210 return make_range(Iterator(B, E, {toOptSpecifier(Ids)...}),
211 Iterator(E, E, {toOptSpecifier(Ids)...}));
212 }
213
214 template<typename ...OptSpecifiers>
215 iterator_range<filtered_reverse_iterator<sizeof...(OptSpecifiers)>>
216 filtered_reverse(OptSpecifiers ...Ids) const {
217 OptRange Range = getRange({toOptSpecifier(Ids)...});
218 auto B = Args.rend() - Range.second;
219 auto E = Args.rend() - Range.first;
220 using Iterator = filtered_reverse_iterator<sizeof...(OptSpecifiers)>;
221 return make_range(Iterator(B, E, {toOptSpecifier(Ids)...}),
222 Iterator(E, E, {toOptSpecifier(Ids)...}));
223 }
224
225 /// @}
226 /// @name Arg Removal
227 /// @{
228
229 /// eraseArg - Remove any option matching \p Id.
230 void eraseArg(OptSpecifier Id);
231
232 /// @}
233 /// @name Arg Access
234 /// @{
235
236 /// hasArg - Does the arg list contain any option matching \p Id.
237 ///
238 /// \p Claim Whether the argument should be claimed, if it exists.
239 template<typename ...OptSpecifiers>
240 bool hasArgNoClaim(OptSpecifiers ...Ids) const {
241 return getLastArgNoClaim(Ids...) != nullptr;
242 }
243 template<typename ...OptSpecifiers>
244 bool hasArg(OptSpecifiers ...Ids) const {
245 return getLastArg(Ids...) != nullptr;
246 }
247
248 /// Return true if the arg list contains multiple arguments matching \p Id.
250 auto Args = filtered(Id);
251 return (Args.begin() != Args.end()) && (++Args.begin()) != Args.end();
252 }
253
254 /// Return the last argument matching \p Id, or null.
255 template<typename ...OptSpecifiers>
256 Arg *getLastArg(OptSpecifiers ...Ids) const {
257 Arg *Res = nullptr;
258 for (Arg *A : filtered(Ids...)) {
259 Res = A;
260 Res->claim();
261 }
262 return Res;
263 }
264
265 /// Return the last argument matching \p Id, or null. Do not "claim" the
266 /// option (don't mark it as having been used).
267 template<typename ...OptSpecifiers>
268 Arg *getLastArgNoClaim(OptSpecifiers ...Ids) const {
269 for (Arg *A : filtered_reverse(Ids...))
270 return A;
271 return nullptr;
272 }
273
274 /// getArgString - Return the input argument string at \p Index.
275 virtual const char *getArgString(unsigned Index) const = 0;
276
277 /// getNumInputArgStrings - Return the number of original argument strings,
278 /// which are guaranteed to be the first strings in the argument string
279 /// list.
280 virtual unsigned getNumInputArgStrings() const = 0;
281
282 /// @}
283 /// @name Argument Lookup Utilities
284 /// @{
285
286 /// getLastArgValue - Return the value of the last argument, or a default.
288
289 /// getAllArgValues - Get the values of all instances of the given argument
290 /// as strings.
291 std::vector<std::string> getAllArgValues(OptSpecifier Id) const;
292
293 /// @}
294 /// @name Translation Utilities
295 /// @{
296
297 /// hasFlag - Given an option \p Pos and its negative form \p Neg, return
298 /// true if the option is present, false if the negation is present, and
299 /// \p Default if neither option is given. If both the option and its
300 /// negation are present, the last one wins.
301 bool hasFlag(OptSpecifier Pos, OptSpecifier Neg, bool Default) const;
302 bool hasFlagNoClaim(OptSpecifier Pos, OptSpecifier Neg, bool Default) const;
303
304 /// hasFlag - Given an option \p Pos, an alias \p PosAlias and its negative
305 /// form \p Neg, return true if the option or its alias is present, false if
306 /// the negation is present, and \p Default if none of the options are
307 /// given. If multiple options are present, the last one wins.
308 bool hasFlag(OptSpecifier Pos, OptSpecifier PosAlias, OptSpecifier Neg,
309 bool Default) const;
310
311 /// Given an option Pos and its negative form Neg, render the option if Pos is
312 /// present.
313 void addOptInFlag(ArgStringList &Output, OptSpecifier Pos,
314 OptSpecifier Neg) const;
315 /// Render the option if Neg is present.
317 OptSpecifier Neg) const {
318 addOptInFlag(Output, Neg, Pos);
319 }
320
321 /// Render only the last argument match \p Id0, if present.
322 template<typename ...OptSpecifiers>
323 void AddLastArg(ArgStringList &Output, OptSpecifiers ...Ids) const {
324 if (Arg *A = getLastArg(Ids...)) // Calls claim() on all Ids's Args.
325 A->render(*this, Output);
326 }
327
328 /// AddAllArgsExcept - Render all arguments matching any of the given ids
329 /// and not matching any of the excluded ids.
331 ArrayRef<OptSpecifier> ExcludeIds) const;
332 /// AddAllArgs - Render all arguments matching any of the given ids.
333 void AddAllArgs(ArgStringList &Output, ArrayRef<OptSpecifier> Ids) const;
334
335 /// AddAllArgs - Render all arguments matching the given ids.
336 void AddAllArgs(ArgStringList &Output, OptSpecifier Id0,
337 OptSpecifier Id1 = 0U, OptSpecifier Id2 = 0U) const;
338
339 /// AddAllArgValues - Render the argument values of all arguments
340 /// matching the given ids.
342 OptSpecifier Id1 = 0U, OptSpecifier Id2 = 0U) const;
343
344 /// AddAllArgsTranslated - Render all the arguments matching the
345 /// given ids, but forced to separate args and using the provided
346 /// name instead of the first option value.
347 ///
348 /// \param Joined - If true, render the argument as joined with
349 /// the option specifier.
351 const char *Translation,
352 bool Joined = false) const;
353
354 /// ClaimAllArgs - Claim all arguments which match the given
355 /// option id.
356 void ClaimAllArgs(OptSpecifier Id0) const;
357
358 template <typename... OptSpecifiers>
359 void claimAllArgs(OptSpecifiers... Ids) const {
360 for (Arg *A : filtered(Ids...))
361 A->claim();
362 }
363
364 /// ClaimAllArgs - Claim all arguments.
365 ///
366 void ClaimAllArgs() const;
367 /// @}
368 /// @name Arg Synthesis
369 /// @{
370
371 /// Construct a constant string pointer whose
372 /// lifetime will match that of the ArgList.
373 virtual const char *MakeArgStringRef(StringRef Str) const = 0;
374 const char *MakeArgString(const Twine &Str) const {
376 return MakeArgStringRef(Str.toStringRef(Buf));
377 }
378
379 /// Create an arg string for (\p LHS + \p RHS), reusing the
380 /// string at \p Index if possible.
381 const char *GetOrMakeJoinedArgString(unsigned Index, StringRef LHS,
382 StringRef RHS) const;
383
384 void print(raw_ostream &O) const;
385 void dump() const;
386
387 /// @}
388};
389
390class InputArgList final : public ArgList {
391private:
392 /// List of argument strings used by the contained Args.
393 ///
394 /// This is mutable since we treat the ArgList as being the list
395 /// of Args, and allow routines to add new strings (to have a
396 /// convenient place to store the memory) via MakeIndex.
397 mutable ArgStringList ArgStrings;
398
399 /// Strings for synthesized arguments.
400 ///
401 /// This is mutable since we treat the ArgList as being the list
402 /// of Args, and allow routines to add new strings (to have a
403 /// convenient place to store the memory) via MakeIndex.
404 mutable std::list<std::string> SynthesizedStrings;
405
406 /// The number of original input argument strings.
407 unsigned NumInputArgStrings;
408
409 /// Release allocated arguments.
410 void releaseMemory();
411
412public:
413 InputArgList() : NumInputArgStrings(0) {}
414
415 InputArgList(const char* const *ArgBegin, const char* const *ArgEnd);
416
418 : ArgList(std::move(RHS)), ArgStrings(std::move(RHS.ArgStrings)),
419 SynthesizedStrings(std::move(RHS.SynthesizedStrings)),
420 NumInputArgStrings(RHS.NumInputArgStrings) {}
421
423 if (this == &RHS)
424 return *this;
425 releaseMemory();
426 ArgList::operator=(std::move(RHS));
427 ArgStrings = std::move(RHS.ArgStrings);
428 SynthesizedStrings = std::move(RHS.SynthesizedStrings);
429 NumInputArgStrings = RHS.NumInputArgStrings;
430 return *this;
431 }
432
433 ~InputArgList() { releaseMemory(); }
434
435 const char *getArgString(unsigned Index) const override {
436 return ArgStrings[Index];
437 }
438
439 void replaceArgString(unsigned Index, const Twine &S) {
440 ArgStrings[Index] = MakeArgString(S);
441 }
442
443 unsigned getNumInputArgStrings() const override {
444 return NumInputArgStrings;
445 }
446
447 /// @name Arg Synthesis
448 /// @{
449
450public:
451 /// MakeIndex - Get an index for the given string(s).
452 unsigned MakeIndex(StringRef String0) const;
453 unsigned MakeIndex(StringRef String0, StringRef String1) const;
454
456 const char *MakeArgStringRef(StringRef Str) const override;
457
458 /// @}
459};
460
461/// DerivedArgList - An ordered collection of driver arguments,
462/// whose storage may be in another argument list.
463class DerivedArgList final : public ArgList {
464 const InputArgList &BaseArgs;
465
466 /// The list of arguments we synthesized.
467 mutable SmallVector<std::unique_ptr<Arg>, 16> SynthesizedArgs;
468
469public:
470 /// Construct a new derived arg list from \p BaseArgs.
471 DerivedArgList(const InputArgList &BaseArgs);
472
473 const char *getArgString(unsigned Index) const override {
474 return BaseArgs.getArgString(Index);
475 }
476
477 unsigned getNumInputArgStrings() const override {
478 return BaseArgs.getNumInputArgStrings();
479 }
480
481 const InputArgList &getBaseArgs() const {
482 return BaseArgs;
483 }
484
485 /// @name Arg Synthesis
486 /// @{
487
488 /// AddSynthesizedArg - Add a argument to the list of synthesized arguments
489 /// (to be freed).
490 void AddSynthesizedArg(Arg *A);
491
493 const char *MakeArgStringRef(StringRef Str) const override;
494
495 /// AddFlagArg - Construct a new FlagArg for the given option \p Id and
496 /// append it to the argument list.
497 void AddFlagArg(const Arg *BaseArg, const Option Opt) {
498 append(MakeFlagArg(BaseArg, Opt));
499 }
500
501 /// AddPositionalArg - Construct a new Positional arg for the given option
502 /// \p Id, with the provided \p Value and append it to the argument
503 /// list.
504 void AddPositionalArg(const Arg *BaseArg, const Option Opt,
506 append(MakePositionalArg(BaseArg, Opt, Value));
507 }
508
509 /// AddSeparateArg - Construct a new Positional arg for the given option
510 /// \p Id, with the provided \p Value and append it to the argument
511 /// list.
512 void AddSeparateArg(const Arg *BaseArg, const Option Opt,
514 append(MakeSeparateArg(BaseArg, Opt, Value));
515 }
516
517 /// AddJoinedArg - Construct a new Positional arg for the given option
518 /// \p Id, with the provided \p Value and append it to the argument list.
519 void AddJoinedArg(const Arg *BaseArg, const Option Opt,
521 append(MakeJoinedArg(BaseArg, Opt, Value));
522 }
523
524 /// MakeFlagArg - Construct a new FlagArg for the given option \p Id.
525 Arg *MakeFlagArg(const Arg *BaseArg, const Option Opt) const;
526
527 /// MakePositionalArg - Construct a new Positional arg for the
528 /// given option \p Id, with the provided \p Value.
529 Arg *MakePositionalArg(const Arg *BaseArg, const Option Opt,
530 StringRef Value) const;
531
532 /// MakeSeparateArg - Construct a new Positional arg for the
533 /// given option \p Id, with the provided \p Value.
534 Arg *MakeSeparateArg(const Arg *BaseArg, const Option Opt,
535 StringRef Value) const;
536
537 /// MakeJoinedArg - Construct a new Positional arg for the
538 /// given option \p Id, with the provided \p Value.
539 Arg *MakeJoinedArg(const Arg *BaseArg, const Option Opt,
540 StringRef Value) const;
541
542 /// @}
543};
544
545} // end namespace opt
546
547} // end namespace llvm
548
549#endif // LLVM_OPTION_ARGLIST_H
arm prera ldst opt
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.
bool End
Definition: ELF_riscv.cpp:469
#define I(x, y, z)
Definition: MD5.cpp:58
This file defines the SmallString class.
This file defines the SmallVector class.
Value * RHS
Value * LHS
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Definition: SmallString.h:26
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
LLVM Value Representation.
Definition: Value.h:74
A range adaptor for a pair of iterators.
ArgList - Ordered collection of driver arguments.
Definition: ArgList.h:116
void eraseArg(OptSpecifier Id)
eraseArg - Remove any option matching Id.
Definition: ArgList.cpp:45
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.
Definition: ArgList.cpp:151
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.
Definition: ArgList.h:268
void print(raw_ostream &O) const
Definition: ArgList.cpp:198
const char * GetOrMakeJoinedArgString(unsigned Index, StringRef LHS, StringRef RHS) const
Create an arg string for (LHS + RHS), reusing the string at Index if possible.
Definition: ArgList.cpp:187
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.
Definition: ArgList.cpp:104
arg_iterator< arglist_type::const_iterator, N > filtered_iterator
Definition: ArgList.h:126
bool hasFlagNoClaim(OptSpecifier Pos, OptSpecifier Neg, bool Default) const
Definition: ArgList.cpp:78
unsigned size() const
Definition: ArgList.h:185
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...
Definition: ArgList.cpp:160
static OptSpecifier toOptSpecifier(OptSpecifier S)
Definition: ArgList.h:174
const_iterator end() const
Definition: ArgList.h:198
iterator_range< filtered_reverse_iterator< sizeof...(OptSpecifiers)> > filtered_reverse(OptSpecifiers ...Ids) const
Definition: ArgList.h:216
bool hasMultipleArgs(OptSpecifier Id) const
Return true if the arg list contains multiple arguments matching Id.
Definition: ArgList.h:249
const char * MakeArgString(const Twine &Str) const
Definition: ArgList.h:374
const_reverse_iterator rend() const
Definition: ArgList.h:201
bool hasArgNoClaim(OptSpecifiers ...Ids) const
hasArg - Does the arg list contain any option matching Id.
Definition: ArgList.h:240
iterator begin()
Definition: ArgList.h:191
void append(Arg *A)
append - Append A to the arg list.
Definition: ArgList.cpp:32
const arglist_type & getArgs() const
Definition: ArgList.h:183
void ClaimAllArgs() const
ClaimAllArgs - Claim all arguments.
Definition: ArgList.cpp:181
const_iterator begin() const
Definition: ArgList.h:197
const_reverse_iterator rbegin() const
Definition: ArgList.h:200
arg_iterator< arglist_type::const_reverse_iterator, N > filtered_reverse_iterator
Definition: ArgList.h:128
reverse_iterator rbegin()
Definition: ArgList.h:194
Arg * getLastArg(OptSpecifiers ...Ids) const
Return the last argument matching Id, or null.
Definition: ArgList.h:256
void claimAllArgs(OptSpecifiers... Ids) const
Definition: ArgList.h:359
void dump() const
Definition: ArgList.cpp:206
reverse_iterator rend()
Definition: ArgList.h:195
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...
Definition: ArgList.cpp:111
void AddLastArg(ArgStringList &Output, OptSpecifiers ...Ids) const
Render only the last argument match Id0, if present.
Definition: ArgList.h:323
std::vector< std::string > getAllArgValues(OptSpecifier Id) const
getAllArgValues - Get the values of all instances of the given argument as strings.
Definition: ArgList.cpp:98
void addOptOutFlag(ArgStringList &Output, OptSpecifier Pos, OptSpecifier Neg) const
Render the option if Neg is present.
Definition: ArgList.h:316
bool hasArg(OptSpecifiers ...Ids) const
Definition: ArgList.h:244
StringRef getLastArgValue(OptSpecifier Id, StringRef Default="") const
getLastArgValue - Return the value of the last argument, or a default.
Definition: ArgList.cpp:92
iterator end()
Definition: ArgList.h:192
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
Definition: ArgList.h:205
void AddAllArgs(ArgStringList &Output, ArrayRef< OptSpecifier > Ids) const
AddAllArgs - Render all arguments matching any of the given ids.
Definition: ArgList.cpp:135
ArgList & operator=(ArgList &&RHS)
Definition: ArgList.h:161
ArgList(ArgList &&RHS)
Definition: ArgList.h:155
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,...
Definition: ArgList.cpp:72
A concrete instance of a particular driver option.
Definition: Arg.h:34
void claim() const
Definition: Arg.h:114
DerivedArgList - An ordered collection of driver arguments, whose storage may be in another argument ...
Definition: ArgList.h:463
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...
Definition: ArgList.h:519
const char * MakeArgStringRef(StringRef Str) const override
Construct a constant string pointer whose lifetime will match that of the ArgList.
Definition: ArgList.cpp:247
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.
Definition: ArgList.cpp:271
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.
Definition: ArgList.h:497
void AddSynthesizedArg(Arg *A)
AddSynthesizedArg - Add a argument to the list of synthesized arguments (to be freed).
Definition: ArgList.cpp:251
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.
Definition: ArgList.cpp:280
unsigned getNumInputArgStrings() const override
getNumInputArgStrings - Return the number of original argument strings, which are guaranteed to be th...
Definition: ArgList.h:477
const InputArgList & getBaseArgs() const
Definition: ArgList.h:481
const char * getArgString(unsigned Index) const override
getArgString - Return the input argument string at Index.
Definition: ArgList.h:473
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.
Definition: ArgList.cpp:262
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...
Definition: ArgList.h:504
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 ...
Definition: ArgList.h:512
Arg * MakeFlagArg(const Arg *BaseArg, const Option Opt) const
MakeFlagArg - Construct a new FlagArg for the given option Id.
Definition: ArgList.cpp:255
InputArgList(InputArgList &&RHS)
Definition: ArgList.h:417
InputArgList & operator=(InputArgList &&RHS)
Definition: ArgList.h:422
const char * getArgString(unsigned Index) const override
getArgString - Return the input argument string at Index.
Definition: ArgList.h:435
const char * MakeArgString(const Twine &Str) const
Definition: ArgList.h:374
unsigned MakeIndex(StringRef String0) const
MakeIndex - Get an index for the given string(s).
Definition: ArgList.cpp:221
void replaceArgString(unsigned Index, const Twine &S)
Definition: ArgList.h:439
unsigned getNumInputArgStrings() const override
getNumInputArgStrings - Return the number of original argument strings, which are guaranteed to be th...
Definition: ArgList.h:443
const char * MakeArgStringRef(StringRef Str) const override
Construct a constant string pointer whose lifetime will match that of the ArgList.
Definition: ArgList.cpp:240
OptSpecifier - Wrapper class for abstracting references to option IDs.
Definition: OptSpecifier.h:18
Option - Abstract representation for a single form of driver argument.
Definition: Option.h:55
arg_iterator - Iterates through arguments stored inside an ArgList.
Definition: ArgList.h:40
friend bool operator==(arg_iterator LHS, arg_iterator RHS)
Definition: ArgList.h:102
arg_iterator(BaseIter Current, BaseIter End, const OptSpecifier(&Ids)[NumOptSpecifiers ? NumOptSpecifiers :1]={})
Definition: ArgList.h:78
std::ptrdiff_t difference_type
Definition: ArgList.h:76
reference operator*() const
Definition: ArgList.h:87
typename Traits::value_type value_type
Definition: ArgList.h:72
arg_iterator & operator++()
Definition: ArgList.h:90
typename Traits::pointer pointer
Definition: ArgList.h:74
std::forward_iterator_tag iterator_category
Definition: ArgList.h:75
pointer operator->() const
Definition: ArgList.h:88
arg_iterator operator++(int)
Definition: ArgList.h:96
friend bool operator!=(arg_iterator LHS, arg_iterator RHS)
Definition: ArgList.h:105
typename Traits::reference reference
Definition: ArgList.h:73
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
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.
Definition: AddressRanges.h:18
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.
Definition: STLExtras.h:1854
@ 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.
Definition: BitVector.h:858