[llvm] [Support] Use range-based for loops (NFC) (PR #169001)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 21 09:07:43 PST 2025
https://github.com/kazutakahirata updated https://github.com/llvm/llvm-project/pull/169001
>From 2016389ce54ef69931a5cb22885ba531d393acb9 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Thu, 20 Nov 2025 09:37:47 -0800
Subject: [PATCH 1/3] [Support] Use range-based for loops (NFC)
Identified with modernize-loop-convert.
---
llvm/lib/Support/CommandLine.cpp | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp
index dab8beeff7ca5..26e14dec228e1 100644
--- a/llvm/lib/Support/CommandLine.cpp
+++ b/llvm/lib/Support/CommandLine.cpp
@@ -602,10 +602,8 @@ static Option *LookupNearestOption(StringRef Arg,
// Find the closest match.
Option *Best = nullptr;
unsigned BestDistance = 0;
- for (StringMap<Option *>::const_iterator it = OptionsMap.begin(),
- ie = OptionsMap.end();
- it != ie; ++it) {
- Option *O = it->second;
+ for (const auto &Opt : OptionsMap) {
+ Option *O = Opt.second;
// Do not suggest really hidden options (not shown in any help).
if (O->getOptionHiddenFlag() == ReallyHidden)
continue;
>From f772444f42c007647bc8eda035eb9b029818e789 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Fri, 21 Nov 2025 08:03:57 -0800
Subject: [PATCH 2/3] Address a comment.
---
llvm/lib/Support/CommandLine.cpp | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp
index 26e14dec228e1..ac5bf9a8a3177 100644
--- a/llvm/lib/Support/CommandLine.cpp
+++ b/llvm/lib/Support/CommandLine.cpp
@@ -602,8 +602,7 @@ static Option *LookupNearestOption(StringRef Arg,
// Find the closest match.
Option *Best = nullptr;
unsigned BestDistance = 0;
- for (const auto &Opt : OptionsMap) {
- Option *O = Opt.second;
+ for (const auto &[Key, O] : OptionsMap) {
// Do not suggest really hidden options (not shown in any help).
if (O->getOptionHiddenFlag() == ReallyHidden)
continue;
>From 96bc09e8190c69dcaf9f53d94d5b10d9d3cabd4a Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Fri, 21 Nov 2025 09:04:06 -0800
Subject: [PATCH 3/3] Use _.
---
llvm/lib/Support/CommandLine.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp
index ac5bf9a8a3177..5095b298fd42d 100644
--- a/llvm/lib/Support/CommandLine.cpp
+++ b/llvm/lib/Support/CommandLine.cpp
@@ -602,7 +602,7 @@ static Option *LookupNearestOption(StringRef Arg,
// Find the closest match.
Option *Best = nullptr;
unsigned BestDistance = 0;
- for (const auto &[Key, O] : OptionsMap) {
+ for (const auto &[_, O] : OptionsMap) {
// Do not suggest really hidden options (not shown in any help).
if (O->getOptionHiddenFlag() == ReallyHidden)
continue;
More information about the llvm-commits
mailing list