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