From c1a5f1ea363560961f52a62335658b445c51b491 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Fri, 5 Jul 2024 05:47:00 +0900 Subject: [PATCH] [Support] Use range-based for loops (NFC) (#97657) --- llvm/lib/Support/CommandLine.cpp | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp index 6dc0c86cea8946..ecc487a17cccae 100644 --- a/llvm/lib/Support/CommandLine.cpp +++ b/llvm/lib/Support/CommandLine.cpp @@ -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(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... @@ -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; @@ -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++; }