Skip to content

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

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
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions llvm/include/llvm/Support/Allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,9 @@ class BumpPtrAllocatorImpl

// Use negative index to denote custom sized slabs.
int64_t InCustomSizedSlabIdx = -1;
for (size_t Idx = 0, E = CustomSizedSlabs.size(); Idx < E; Idx++) {
const char *S = static_cast<const char *>(CustomSizedSlabs[Idx].first);
size_t Size = CustomSizedSlabs[Idx].second;
for (const auto &Slab : CustomSizedSlabs) {
const char *S = static_cast<const char *>(Slab.first);
size_t Size = Slab.second;
if (P >= S && P < S + Size)
return InCustomSizedSlabIdx - static_cast<int64_t>(P - S);
InCustomSizedSlabIdx -= static_cast<int64_t>(Size);
Expand Down
26 changes: 13 additions & 13 deletions llvm/lib/Support/CommandLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2313,8 +2313,8 @@ class HelpPrinter {
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) {
Expand Down Expand Up @@ -2384,8 +2384,8 @@ class HelpPrinter {
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";
Expand All @@ -2400,8 +2400,8 @@ class HelpPrinter {

// 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);
Expand Down Expand Up @@ -2447,9 +2447,9 @@ class CategorizedHelpPrinter : public HelpPrinter {
// 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);
Expand Down Expand Up @@ -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.
Expand Down
Loading