Skip to content

[Support] Use range-based for loops (NFC) #97657

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading