LLVM: lib/Option/ArgList.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

14#include "llvm/Config/llvm-config.h"

22#include

23#include

24#include

25#include

26#include

27#include

28

29using namespace llvm;

31

34

35

36 for (Option O = A->getOption().getUnaliasedOption(); O.isValid();

37 O = O.getGroup()) {

38 auto &R =

39 OptRanges.insert(std::make_pair(O.getID(), emptyRange())).first->second;

40 R.first = std::min(R.first, Args.size() - 1);

41 R.second = Args.size();

42 }

43}

44

46

47

49

50 Arg **ArgsBegin = Args.data();

51 ArgsBegin[&A - ArgsBegin] = nullptr;

52 }

53 OptRanges.erase(Id.getID());

54}

55

56ArgList::OptRange

57ArgList::getRange(std::initializer_list Ids) const {

58 OptRange R = emptyRange();

59 for (auto Id : Ids) {

60 auto I = OptRanges.find(Id.getID());

61 if (I != OptRanges.end()) {

62 R.first = std::min(R.first, I->second.first);

63 R.second = std::max(R.second, I->second.second);

64 }

65 }

66

67 if (R.first == -1u)

68 R.first = 0;

69 return R;

70}

71

74 return A->getOption().matches(Pos);

76}

77

81 return A->getOption().matches(Pos);

83}

84

88 return A->getOption().matches(Pos) || A->getOption().matches(PosAlias);

90}

91

94 return A->getValue();

96}

97

101 return std::vectorstd::string(Values.begin(), Values.end());

102}

103

107 if (A->getOption().matches(Pos))

108 A->render(*this, Output);

109}

110

114 for (const Arg *Arg : *this) {

115 bool Excluded = false;

118 Excluded = true;

119 break;

120 }

121 }

122 if (!Excluded) {

127 break;

128 }

129 }

130 }

131 }

132}

133

134

139}

140

145 }

146}

147

150 for (auto *Arg : filtered(Id0, Id1, Id2)) {

153 Output.append(Values.begin(), Values.end());

154 }

155}

156

158 const char *Translation,

159 bool Joined) const {

162

163 if (Joined) {

166 } else {

169 }

170 }

171}

172

176}

177

179 for (auto *Arg : *this)

182}

183

190 return Cur.data();

191

193}

194

196 for (Arg *A : *this) {

197 O << "* ";

198 A->print(O);

199 }

200}

201

202#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)

204#endif

205

206void InputArgList::releaseMemory() {

207

208 for (Arg *A : *this)

209 delete A;

210}

211

213 const char* const *ArgEnd)

214 : NumInputArgStrings(ArgEnd - ArgBegin) {

215 ArgStrings.append(ArgBegin, ArgEnd);

216}

217

219 unsigned Index = ArgStrings.size();

220

221

222 SynthesizedStrings.push_back(std::string(String0));

223 ArgStrings.push_back(SynthesizedStrings.back().c_str());

224

225 return Index;

226}

227

230 unsigned Index0 = MakeIndex(String0);

231 unsigned Index1 = MakeIndex(String1);

232 assert(Index0 + 1 == Index1 && "Unexpected non-consecutive indices!");

233 (void) Index1;

234 return Index0;

235}

236

239}

240

242 : BaseArgs(BaseArgs) {}

243

246}

247

249 SynthesizedArgs.push_back(std::unique_ptr(A));

250}

251

253 SynthesizedArgs.push_back(

256 return SynthesizedArgs.back().get();

257}

258

262 SynthesizedArgs.push_back(

264 Index, BaseArgs.getArgString(Index), BaseArg));

265 return SynthesizedArgs.back().get();

266}

267

271 SynthesizedArgs.push_back(

273 Index, BaseArgs.getArgString(Index + 1), BaseArg));

274 return SynthesizedArgs.back().get();

275}

276

280 SynthesizedArgs.push_back(std::make_unique(

283 return SynthesizedArgs.back().get();

284}

Defines the llvm::Arg class for parsed arguments.

static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")

#define LLVM_DUMP_METHOD

Mark debug helper function definitions like dump() that should not be stripped from debug builds.

assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())

This file defines the SmallVector class.

ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...

iterator find(const_arg_type_t< KeyT > Val)

bool erase(const KeyT &Val)

std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)

void append(ItTy in_start, ItTy in_end)

Add the specified range to the end of the SmallVector.

void push_back(const T &Elt)

pointer data()

Return a pointer to the vector's buffer, even if empty().

This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.

StringRef - Represent a constant reference to a string, i.e.

bool starts_with(StringRef Prefix) const

Check if this string starts with the given Prefix.

constexpr size_t size() const

size - Get the string size.

constexpr const char * data() const

data - Get a pointer to the start of the string (which may not be null terminated).

bool ends_with(StringRef Suffix) const

Check if this string ends with the given Suffix.

LLVM Value Representation.

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.

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.

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...

void AddAllArgs(ArgStringList &Output, OptSpecifier Id0) const

AddAllArgs - Render all arguments matching the given ids.

const char * MakeArgString(const Twine &Str) const

void append(Arg *A)

append - Append A to the arg list.

void addAllArgs(ArgStringList &Output, ArrayRef< OptSpecifier > Ids) const

Render all arguments matching any of the given ids.

void ClaimAllArgs() const

ClaimAllArgs - Claim all arguments.

Arg * getLastArg(OptSpecifiers ...Ids) const

Return the last argument matching Id, or null.

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.

StringRef getLastArgValue(OptSpecifier Id, StringRef Default="") const

getLastArgValue - Return the value of the last argument, or a default.

iterator_range< filtered_iterator< sizeof...(OptSpecifiers)> > filtered(OptSpecifiers ...Ids) const

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.

void render(const ArgList &Args, ArgStringList &Output) const

Append the argument onto the given array as strings.

SmallVectorImpl< const char * > & getValues()

const Option & getOption() const

const char * getValue(unsigned N=0) const

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 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.

DerivedArgList(const InputArgList &BaseArgs)

Construct a new derived arg list from BaseArgs.

const char * MakeArgString(const Twine &Str) const

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.

Arg * MakeFlagArg(const Arg *BaseArg, const Option Opt) const

MakeFlagArg - Construct a new FlagArg for the given option Id.

const char * getArgString(unsigned Index) const override

getArgString - Return the input argument string at Index.

const char * MakeArgString(const Twine &Str) const

unsigned MakeIndex(StringRef String0) const

MakeIndex - Get an index for the given string(s).

const char * MakeArgStringRef(StringRef Str) const override

Construct a constant string pointer whose lifetime will match that of the ArgList.

OptSpecifier - Wrapper class for abstracting references to option IDs.

Option - Abstract representation for a single form of driver argument.

bool matches(OptSpecifier ID) const

matches - Predicate for whether this option is part of the given option (which may be a group).

StringRef getPrefix() const

Get the default prefix for this option.

StringRef getName() const

Get the name of this option without any prefix.

This class implements an extremely fast bulk output stream that can only output to a stream.

This is an optimization pass for GlobalISel generic memory operations.

raw_ostream & dbgs()

dbgs() - This returns a reference to a raw_ostream for debugging messages.

@ Default

The result values are uniform if and only if all operands are uniform.