llvm.org GIT mirror llvm / 7fba8d7
Generic: add range-adapter for option parsing. I want to use it in lld, but while I'm here I'll update LLVM uses. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212615 91177308-0d34-0410-b5e6-96231b3b80d8 Tim Northover 6 years ago
2 changed file(s) with 20 addition(s) and 17 deletion(s). Raw diff Collapse all Expand all
147147 }
148148 arg_iterator filtered_end() const {
149149 return arg_iterator(Args.end(), *this);
150 }
151
152 iterator_range filtered(OptSpecifier Id0 = 0U,
153 OptSpecifier Id1 = 0U,
154 OptSpecifier Id2 = 0U) const {
155 return iterator_range(filtered_begin(Id0, Id1, Id2),
156 filtered_end());
150157 }
151158
152159 /// @}
233233
234234 void ArgList::AddAllArgs(ArgStringList &Output, OptSpecifier Id0,
235235 OptSpecifier Id1, OptSpecifier Id2) const {
236 for (arg_iterator it = filtered_begin(Id0, Id1, Id2),
237 ie = filtered_end(); it != ie; ++it) {
238 (*it)->claim();
239 (*it)->render(*this, Output);
236 for (auto Arg: filtered(Id0, Id1, Id2)) {
237 Arg->claim();
238 Arg->render(*this, Output);
240239 }
241240 }
242241
243242 void ArgList::AddAllArgValues(ArgStringList &Output, OptSpecifier Id0,
244243 OptSpecifier Id1, OptSpecifier Id2) const {
245 for (arg_iterator it = filtered_begin(Id0, Id1, Id2),
246 ie = filtered_end(); it != ie; ++it) {
247 (*it)->claim();
248 for (unsigned i = 0, e = (*it)->getNumValues(); i != e; ++i)
249 Output.push_back((*it)->getValue(i));
244 for (auto Arg : filtered(Id0, Id1, Id2)) {
245 Arg->claim();
246 for (unsigned i = 0, e = Arg->getNumValues(); i != e; ++i)
247 Output.push_back(Arg->getValue(i));
250248 }
251249 }
252250
253251 void ArgList::AddAllArgsTranslated(ArgStringList &Output, OptSpecifier Id0,
254252 const char *Translation,
255253 bool Joined) const {
256 for (arg_iterator it = filtered_begin(Id0),
257 ie = filtered_end(); it != ie; ++it) {
258 (*it)->claim();
254 for (auto Arg: filtered(Id0)) {
255 Arg->claim();
259256
260257 if (Joined) {
261258 Output.push_back(MakeArgString(StringRef(Translation) +
262 (*it)->getValue(0)));
259 Arg->getValue(0)));
263260 } else {
264261 Output.push_back(Translation);
265 Output.push_back((*it)->getValue(0));
262 Output.push_back(Arg->getValue(0));
266263 }
267264 }
268265 }
269266
270267 void ArgList::ClaimAllArgs(OptSpecifier Id0) const {
271 for (arg_iterator it = filtered_begin(Id0),
272 ie = filtered_end(); it != ie; ++it)
273 (*it)->claim();
268 for (auto Arg : filtered(Id0))
269 Arg->claim();
274270 }
275271
276272 void ArgList::ClaimAllArgs() const {