Skip to content

Commit

Permalink
[Support] Use range-based for loops (NFC) (#97657)
Browse files Browse the repository at this point in the history
  • Loading branch information
kazutakahirata authored Jul 4, 2024
1 parent e975ff0 commit c1a5f1e
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions llvm/lib/Support/CommandLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1733,9 +1733,9 @@ bool CommandLineParser::ParseCommandLineOptions(int argc,
} else if (!ConsumeAfterOpt) {
// Positional args have already been handled if ConsumeAfter is specified.
unsigned ValNo = 0, NumVals = static_cast<unsigned>(PositionalVals.size());
for (size_t i = 0, e = PositionalOpts.size(); i != e; ++i) {
if (RequiresValue(PositionalOpts[i])) {
ProvidePositionalOption(PositionalOpts[i], PositionalVals[ValNo].first,
for (Option *Opt : PositionalOpts) {
if (RequiresValue(Opt)) {
ProvidePositionalOption(Opt, PositionalVals[ValNo].first,
PositionalVals[ValNo].second);
ValNo++;
--NumPositionalRequired; // We fulfilled our duty...
Expand All @@ -1745,16 +1745,15 @@ bool CommandLineParser::ParseCommandLineOptions(int argc,
// do not give it values that others need. 'Done' controls whether the
// option even _WANTS_ any more.
//
bool Done = PositionalOpts[i]->getNumOccurrencesFlag() == cl::Required;
bool Done = Opt->getNumOccurrencesFlag() == cl::Required;
while (NumVals - ValNo > NumPositionalRequired && !Done) {
switch (PositionalOpts[i]->getNumOccurrencesFlag()) {
switch (Opt->getNumOccurrencesFlag()) {
case cl::Optional:
Done = true; // Optional arguments want _at most_ one value
[[fallthrough]];
case cl::ZeroOrMore: // Zero or more will take all they can get...
case cl::OneOrMore: // One or more will take all they can get...
ProvidePositionalOption(PositionalOpts[i],
PositionalVals[ValNo].first,
ProvidePositionalOption(Opt, PositionalVals[ValNo].first,
PositionalVals[ValNo].second);
ValNo++;
break;
Expand All @@ -1767,11 +1766,10 @@ bool CommandLineParser::ParseCommandLineOptions(int argc,
} else {
assert(ConsumeAfterOpt && NumPositionalRequired <= PositionalVals.size());
unsigned ValNo = 0;
for (size_t J = 0, E = PositionalOpts.size(); J != E; ++J)
if (RequiresValue(PositionalOpts[J])) {
ErrorParsing |= ProvidePositionalOption(PositionalOpts[J],
PositionalVals[ValNo].first,
PositionalVals[ValNo].second);
for (Option *Opt : PositionalOpts)
if (RequiresValue(Opt)) {
ErrorParsing |= ProvidePositionalOption(
Opt, PositionalVals[ValNo].first, PositionalVals[ValNo].second);
ValNo++;
}

Expand Down

0 comments on commit c1a5f1e

Please sign in to comment.