[llvm] [ADT] Use a range-based for loop instead of llvm::for_each (NFC) (PR #149542)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 18 09:12:23 PDT 2025


https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/149542

LLVM Coding Standards discourages llvm::for_each unless we already
have a callable.


>From 3df1c9ed4f8bb8f86fca2f3e749dd4edab3b2613 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Thu, 17 Jul 2025 09:54:36 -0700
Subject: [PATCH] [ADT] Use a range-based for loop instead of llvm::for_each
 (NFC)

LLVM Coding Standards discourages llvm::for_each unless we already
have a callable.
---
 llvm/include/llvm/ADT/CombinationGenerator.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/llvm/include/llvm/ADT/CombinationGenerator.h b/llvm/include/llvm/ADT/CombinationGenerator.h
index 6100aa9812293..bbdbd9bfa1be3 100644
--- a/llvm/include/llvm/ADT/CombinationGenerator.h
+++ b/llvm/include/llvm/ADT/CombinationGenerator.h
@@ -118,10 +118,9 @@ class CombinationGenerator {
       : VariablesChoices(VariablesChoices_) {
 #ifndef NDEBUG
     assert(!VariablesChoices.empty() && "There should be some variables.");
-    llvm::for_each(VariablesChoices, [](ArrayRef<choice_type> VariableChoices) {
+    for (ArrayRef<choice_type> VariableChoices : VariablesChoices)
       assert(!VariableChoices.empty() &&
              "There must always be some choice, at least a placeholder one.");
-    });
 #endif
   }
 



More information about the llvm-commits mailing list