aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Support/CommandLine.cpp
diff options
context:
space:
mode:
authorKazu Hirata <kazu@google.com>2025-05-17 17:01:05 -0700
committerGitHub <noreply@github.com>2025-05-17 17:01:05 -0700
commitbc6107a8d23d7a1d14f801f8f4ec84188d942f2f (patch)
tree33e1a503975ae405f9fcaf38c56d9c508e3dcc7f /llvm/lib/Support/CommandLine.cpp
parentc0ca030782f9c572a5df5f3506652e81aeecad0d (diff)
downloadllvm-bc6107a8d23d7a1d14f801f8f4ec84188d942f2f.zip
llvm-bc6107a8d23d7a1d14f801f8f4ec84188d942f2f.tar.gz
llvm-bc6107a8d23d7a1d14f801f8f4ec84188d942f2f.tar.bz2
[Support] Use range-based for loops (NFC) (#140401)
Diffstat (limited to 'llvm/lib/Support/CommandLine.cpp')
-rw-r--r--llvm/lib/Support/CommandLine.cpp26
1 files changed, 13 insertions, 13 deletions
diff --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp
index 49cefb1..ced7e7b 100644
--- a/llvm/lib/Support/CommandLine.cpp
+++ b/llvm/lib/Support/CommandLine.cpp
@@ -2313,8 +2313,8 @@ protected:
StrSubCommandPairVector;
// Print the options. Opts is assumed to be alphabetically sorted.
virtual void printOptions(StrOptionPairVector &Opts, size_t MaxArgLen) {
- for (size_t i = 0, e = Opts.size(); i != e; ++i)
- Opts[i].second->printOptionInfo(MaxArgLen);
+ for (const auto &Opt : Opts)
+ Opt.second->printOptionInfo(MaxArgLen);
}
void printSubCommands(StrSubCommandPairVector &Subs, size_t MaxSubLen) {
@@ -2384,8 +2384,8 @@ public:
if (Sub == &SubCommand::getTopLevel() && !Subs.empty()) {
// Compute the maximum subcommand length...
size_t MaxSubLen = 0;
- for (size_t i = 0, e = Subs.size(); i != e; ++i)
- MaxSubLen = std::max(MaxSubLen, strlen(Subs[i].first));
+ for (const auto &Sub : Subs)
+ MaxSubLen = std::max(MaxSubLen, strlen(Sub.first));
outs() << "\n\n";
outs() << "SUBCOMMANDS:\n\n";
@@ -2400,8 +2400,8 @@ public:
// Compute the maximum argument length...
size_t MaxArgLen = 0;
- for (size_t i = 0, e = Opts.size(); i != e; ++i)
- MaxArgLen = std::max(MaxArgLen, Opts[i].second->getOptionWidth());
+ for (const auto &Opt : Opts)
+ MaxArgLen = std::max(MaxArgLen, Opt.second->getOptionWidth());
outs() << "OPTIONS:\n";
printOptions(Opts, MaxArgLen);
@@ -2447,9 +2447,9 @@ protected:
// Walk through pre-sorted options and assign into categories.
// Because the options are already alphabetically sorted the
// options within categories will also be alphabetically sorted.
- for (size_t I = 0, E = Opts.size(); I != E; ++I) {
- Option *Opt = Opts[I].second;
- for (auto &Cat : Opt->Categories) {
+ for (const auto &I : Opts) {
+ Option *Opt = I.second;
+ for (OptionCategory *Cat : Opt->Categories) {
assert(llvm::is_contained(SortedCategories, Cat) &&
"Option has an unregistered category");
CategorizedOptions[Cat].push_back(Opt);
@@ -2708,11 +2708,11 @@ void CommandLineParser::printOptionValues() {
// Compute the maximum argument length...
size_t MaxArgLen = 0;
- for (size_t i = 0, e = Opts.size(); i != e; ++i)
- MaxArgLen = std::max(MaxArgLen, Opts[i].second->getOptionWidth());
+ for (const auto &Opt : Opts)
+ MaxArgLen = std::max(MaxArgLen, Opt.second->getOptionWidth());
- for (size_t i = 0, e = Opts.size(); i != e; ++i)
- Opts[i].second->printOptionValue(MaxArgLen, CommonOptions->PrintAllOptions);
+ for (const auto &Opt : Opts)
+ Opt.second->printOptionValue(MaxArgLen, CommonOptions->PrintAllOptions);
}
// Utility function for printing the help message.